Db::getField
Usage
?mixed Db::getField(string $sql, [ ... $args ])Description
Get value of a single column within the first row retrived.Parameters
Parameter | Required | Type | Description |
---|---|---|---|
$sql | Yes | string | The SQL statement to execute, which can contain placeholders (ie. %s, %i, %b, et al). For full details, please see the Database Placeholders page of the documentation. |
$args | No | desc= |
Return Value
Returns the first column from the first row retrived, or null if no rows were retrived.Examples
Get Field
$prod_id = 85;
if (!$Price = $this->db->getField("SELECT price FROM products WHERE id = %i", $prod_id)) {
die("No product found with id# $prod_id");
}
echo "Price of product is $price\n";