Methods summary
public
|
#
__construct( PDO $pdo, array $config )
Create a new database connection instance.
Create a new database connection instance.
Parameters
- $pdo
PDO
$pdo
- $config
array $config
|
public
Laravel\Database\Query
|
#
table( string $table )
Begin a fluent query against a table.
Begin a fluent query against a table.
$query = DB::connection()->table('users');
$users = DB::connection()->table('users')->get();
Parameters
Returns
|
protected
Laravel\Database\Query\Grammars\Grammar
|
#
grammar( )
Create a new query grammar for the connection.
Create a new query grammar for the connection.
Returns
|
public
boolean
|
#
transaction( callable $callback )
Execute a callback wrapped in a database transaction.
Execute a callback wrapped in a database transaction.
Parameters
- $callback
callable $callback
Returns
boolean
|
public
mixed
|
#
only( string $sql, array $bindings = array() )
Execute a SQL query against the connection and return a single column
result.
Execute a SQL query against the connection and return a single column
result.
$count = DB::connection()->only('select count(*) from users');
$sum = DB::connection()->only('select sum(amount) from payments')
Parameters
- $sql
string $sql
- $bindings
array $bindings
Returns
mixed
|
public
object
|
#
first( string $sql, array $bindings = array() )
Execute a SQL query against the connection and return the first result.
Execute a SQL query against the connection and return the first result.
$user = DB::connection()->first('select * from users');
$user = DB::connection()->first('select * from users where id = ?', array($id));
Parameters
- $sql
string $sql
- $bindings
array $bindings
Returns
object
|
public
array
|
#
query( string $sql, array $bindings = array() )
Execute a SQL query and return an array of StdClass objects.
Execute a SQL query and return an array of StdClass objects.
Parameters
- $sql
string $sql
- $bindings
array $bindings
Returns
array
|
protected
array
|
#
execute( string $sql, array $bindings = array() )
Execute a SQL query against the connection.
Execute a SQL query against the connection.
The PDO statement and boolean result will be returned in an array.
Parameters
- $sql
string $sql
- $bindings
array $bindings
Returns
array
|
protected
array
|
#
fetch( PDOStatement $statement, integer $style )
Fetch all of the rows for a given statement.
Fetch all of the rows for a given statement.
Parameters
Returns
array
|
protected
|
#
log( string $sql, array $bindings, integer $start )
Log the query and fire the core query event.
Log the query and fire the core query event.
Parameters
- $sql
string $sql
- $bindings
array $bindings
- $start
integer $start
|
public
string
|
#
driver( )
Get the driver name for the database connection.
Get the driver name for the database connection.
Returns
string
|
public
|
#
__call( mixed $method, mixed $parameters )
Magic Method for dynamically beginning queries on database tables.
Magic Method for dynamically beginning queries on database tables.
|