Horde_Db_Adapter_Base::selectValues PHP Method

selectValues() public method

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.
return 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