DB::getAssoc()

DB::getAssoc() --  Fetch the result set as an associative array using the first column as the key.

Description

array &getAssoc (string $query [, boolean $force_array [, array $params]])

Fetch the entire result set of a query and return it as an associative array using the first column as the key. If the result set contains more than two columns, the value will be an array of the values from column 2-n. If the result set contains only two columns, the returned value will be a scalar with the value of the second column (unless forced to an array with the $force_array parameter). A DB error code is returned on errors. If the result set contains fewer than two columns, a DB_ERROR_TRUNCATED error is returned.

A using example:
Then the call getAssoc('SELECT id,text FROM mytable') returns:
...while the call getAssoc('SELECT id,text,date FROM mytable') returns:

Parameter

Returns

Anmerkung: Keep in mind that database functions in PHP usually return string values for results regardless of the database's internal type.