mixed db_get_data (string tablename [, mixed id [, mixed col [, string where [, int type [, string idfield [, string orderby]]]]]])
Reads data from a table.
tablename is the name of the table that will be examined. If it is
NULL, the function uses the most recently used table (the one used in the last non-NULL
function
call).
id is a record identifier key or a set of identifiers that
may be an array or a CSV string.
col is a string with the name(s) of
the columns(s) desired. It may be an array or a CSV string.
where is
an optional "WHERE" SQL clause.
type defines the kind of data
returned. Accepted values are FETCH_BOTH
, FETCH_NUM
(the default) and FETCH_ASSOC
.
idfield is the name of identifier field (column). Default is "id".
orderby is an optional "ORDER BY" SQL clause.
Keys and columns
The table below summarizes the options for id and col.
id |
col |
Data returned |
---|---|---|
integer |
null |
Array with the whole record id |
integer |
string |
The value of column col of record id |
integer |
string array |
Array with column values in array col of record id |
integer array |
null |
Array of arrays with values from all columns of the id records |
integer array |
string |
Array with the values of column col from the id records |
integer array |
string array |
Two-dimensional array with the values of columns col from the id records |
null |
null |
Array of arrays with the whole table |
null |
string |
Array with values of the col column from the whole table |
null |
string array |
Array of arrays with the values of the columns col from the whole table |
Result
The result type specifies which type of data you want to return. There are three possible types:
FETCH_BOTH
returns an associative and numeric array.FETCH_NUM
returns a numeric array. This is the default.FETCH_ASSOC
returns an associative array.Example
|
See also