Horde_Db_Adapter_Base::selectValues PHP 메소드

selectValues() 공개 메소드

Returns an array of the values of the first column in a select: selectValues("SELECT id FROM companies LIMIT 3") => [1,2,3]
public selectValues ( string $sql, mixed $arg1 = null, string $arg2 = null ) : array
$sql string SQL statement.
$arg1 mixed Either an array of bound parameters or a query name.
$arg2 string If $arg1 contains bound parameters, the query name.
리턴 array
    public function selectValues($sql, $arg1 = null, $arg2 = null)
    {
        $result = $this->selectAll($sql, $arg1, $arg2);
        $values = array();
        foreach ($result as $row) {
            $values[] = next($row);
        }
        return $values;
    }

Usage Example

예제 #1
0
파일: Sql.php 프로젝트: horde/horde
 protected function _getStoryIdsByChannel($channel_id)
 {
     $sql = 'SELECT story_id as id FROM jonah_stories ' . 'WHERE channel_id = ?';
     try {
         return $this->_db->selectValues($sql, array($channel_id));
     } catch (Horde_Db_Exception $e) {
         throw new Jonah_Exception($e);
     }
 }
All Usage Examples Of Horde_Db_Adapter_Base::selectValues