Db::getHash

Usage

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

Description

Get an associative array of two columns 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

Returns an associative array, the keys being the first column of all rows retrieved and the values being the second column of all rows retrived.

Examples

Get Hash



$cats = $this->db->getHash("SELECT id,name FROM categories ORDER BY name"); // $cats is now an associative array, keys being id# of all categories // and values being the category names.

See Also