row

(/rs/public/functions.mysql.php)

row -- Multiple columns from one row in a database table.

Description

array row ($query, $return = MYSQL_NUM)

This function executes a SELECT statement on a databaes table and returns all selected values in one row in a MySQL table. The values are returned in an integer-indexed array starting with key 0. This makes it possible to use list() to access the values in the array.

You can use the 2nd parameter to change the type of array returned. If you would like an associative ray returned, use MYSQL_ASSOC. If you would like an array containing both integer and associative indices, use MYSQL_BOTH. The default value is MYSQL_NUM, which returns an array with integer indices.

$query is a valid MySQL SELECT statement without the word "SELECT". The function prepends $query with the word "SELECT" and a space.

This function returns false on failure.

Examples

row ("* FROM table") /* Returns an array containing all columns in order from the first row in table. If there are no rows in table, returns false. */

row ("A, B FROM table WHERE C = D") /* Returns an array containing (0 => A, 1 => B) from the first row which satisfies the WHERE clause C = D. If no rows satisfy the WHERE clause, returns false. */

row ("SELECT * FROM table") /* Returns false. Do not use SELECT in $query. */

list ($a, $b) = row ("A, B FROM table") /* Recommended use. $a and $b contain the values in columns A and B in the first row in table. */

Related Functions

cell, entry

Dependencies

data, entry

Function Index