PEAR Handbuch | ||
---|---|---|
Zurück | Nach vorne |
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:
Beispiel 1. "mytable"
|
Beispiel 2. returned array - version 1
|
Beispiel 3. returned array - version 2
|
Parameter
$query - the SQL query
$force_array - used only when the query returns exactly two columns. If true, the values of the returned array will be one-element arrays instead of scalars.
$params - if supplied, prepare/execute will be used with this array as execute parameters
Returns
array - associative array with results from the query.
Anmerkung: Keep in mind that database functions in PHP usually return string values for results regardless of the database's internal type.
Zurück | Zum Anfang | Nach vorne |
DB::getCol() | Nach oben | DB::getAll() |