Db::::getIdRow

Usage

?array Db::getIdRow(string $table_name, string | int $id, [ string $id_col = '' ])

Description

Get a single row by value of the id / primary key column as an associative array.

Parameters

Parameter Required Type Description
$table_name Yes string The table name to retrieve record from.
$id Yes string | int The id# / value of the primary key column to search for.
$id_col No string The column to search the id# for. Defaults to the primary key column of the table.

Return Value

Returns an associative array of the individual record retrieved, or null if no record exists.

Examples

Get Row by ID#


$id = 94; if (!$row = $this->db->getIdRow('products', $id)) { die("No product exists with id# $id"); } print_r($row);

See Also