ADOdb Library for PHP Manual
Prev GetOne Next


Adds a bind parameter in a fashion that is compatible with Microsoft SQL Server and Oracle oci8. The parameters are:

Executes the SQL and returns the first field of the first row. The recordset and remaining rows are discarded for you automatically. If an error occur, false is returned; use ErrorNo() or ErrorMsg() to get the error details. Since 4.96, we return null if no records were found.


Returns an associative array for the given query $sql with optional bind parameters in $inputarr. If the number of columns returned is greater to two, a 2-dimensional array is returned, with the first column of the recordset becomes the keys to the rest of the rows. If the columns is equal to two, a 1-dimensional array is created, where the the keys directly map to the values (unless $force_array is set to true, when an array is created for each value).


We have the following data in a recordset:

row1: Apple, Fruit, Edible
row2: Cactus, Plant, Inedible
row3: Rose, Flower, Edible

GetAssoc will generate the following 2-dimensional associative array:

Apple => array[Fruit, Edible]
Cactus => array[Plant, Inedible]
Rose => array[Flower,Edible]

If the dataset is:

row1: Apple, Fruit
row2: Cactus, Plant
row3: Rose, Flower

GetAssoc will generate the following 1-dimensional associative array (with $force_array==false):

Apple => Fruit

The function returns:

The associative array, or false if an error occurs.

CacheGetAssoc([$secs2cache,] $sql,$inputarr=false,$force_array=false,$first2cols=false)

Caching version of GetAssoc function above.

GetMedian($table, $field, $where='')

Returns the median value of $field for $table. The $where clause is optional. If used, make sure the WHERE is included, as in "WHERE name > 'A'". If an error occurs, false is returned. Since ADOdb 4.991 and ADOdb 5.06.

Very useful for statistics and parallel processing, where you want to have process A handling account 1 to median, and process B handling account median+1 to last. If you have 4 parallel processes, GetMedian() again for the two halves.

Prev Home Next
Parameter Up CacheGetOne

Sponsored by phpLens