Commit 0f1bd8a7 authored by Taylor Otwell's avatar Taylor Otwell

added db::first method.

parent 066db38d
......@@ -33,6 +33,19 @@ class DB {
return static::$connections[$connection];
}
/**
* Execute a SQL query against the connection and return the first result.
*
* @param string $sql
* @param array $bindings
* @param string $connection
* @return object
*/
public static function first($sql, $bindings = array(), $connection = null)
{
return (count($results = static::query($sql, $bindings, $connection)) > 0) ? $results[0] : null;
}
/**
* Execute a SQL query against the connection.
*
......@@ -46,7 +59,7 @@ class DB {
* @param string $sql
* @param array $bindings
* @param string $connection
* @return mixed
* @return array
*/
public static function query($sql, $bindings = array(), $connection = null)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment