Db::getColumn

Usage

array Db::getColumn(string $sql, [ ... $args ])

Description

Get a one dimensional array of a single column within a database table.

Parameters

Parameter Required Type Description
$sql Yes string The SQL statement to execute, which can contain placeholders (ie. %s, %i, %b, et al). For full details, please see the Database Placeholders page of the documentation.
$args No desc=

Return Value

A one-dimensional array of the values of the first column of all rows retrieved.

Examples

Select Column

db->getColumn("SELECT name FROM products WHERE category_id = %i AND is_active = %b", $cat_id, true);

// $names is a one-dimensional array of all product names
print_r($names);

See Also