db::column PHP Method

column() static public method

Returns all values from single column of a table
static public column ( string $table, string $column, mixed $where = null, string $order = null, integer $page = null, integer $limit = null ) : mixed
$table string The table name
$column string The name of the column
$where mixed Either a key/value array as AND connected where clause or a simple MySQL where clause string
$order string Order clause without the order keyword. ie: "added desc"
$page integer a page number
$limit integer a number for rows to return
return mixed
    static function column($table, $column, $where = null, $order = null, $page = null, $limit = null)
    {
        $result = self::select($table, $column, $where, $order, $page, $limit, false);
        $array = array();
        while ($r = self::fetch($result)) {
            array_push($array, a::get($r, $column));
        }
        return $array;
    }

Usage Example

Example #1
0
 public function testColumn()
 {
     $result = db::column('users', 'username');
     $this->assertEquals(array('john', 'paul', 'george'), $result->toArray());
 }