LaravelDatabaseConnection

Summary

No private methods found
No private properties found
N/A
File
databaseconnection.php
Package
Default
Class hierarchy
LaravelDatabaseConnection

Tags

None found

Properties

$pdo

$pdo : \PDO

The raw PDO connection instance.

Type

PDO

Tags

None found

$config

$config : array

The connection configuration array.

Type

array

Tags

None found

$queries

$queries : array

All of the queries that have been executed on all connections.

Type

array

Tags

None found

$grammar

$grammar : \Laravel\Database\Query\Grammars\Grammar

The query grammar instance for the connection.

Type

LaravelDatabaseQueryGrammarsGrammar

Tags

None found

Methods

__construct()

__construct(\PDO  $pdo, array  $config) : void

Create a new database connection instance.

Parameters

PDO $pdo
array $config

Tags

None found

table()

table(string  $table) : \Laravel\Database\Query

Begin a fluent query against a table.

// Start a fluent query against the "users" table $query = DB::connection()->table('users');

// Start a fluent query against the "users" table and get all the users
$users = DB::connection()->table('users')->get();

Parameters

string $table

Returns

LaravelDatabaseQuery

Tags

None found

transaction()

transaction(callback  $callback) : boolean

Execute a callback wrapped in a database transaction.

Parameters

callback $callback

Returns

boolean

Tags

None found

only()

only(string  $sql, array  $bindings = array()) : mixed

Execute a SQL query against the connection and return a single column result.

// Get the total number of rows on a table $count = DB::connection()->only('select count(*) from users');

// Get the sum of payment amounts from a table
$sum = DB::connection()->only('select sum(amount) from payments')

Parameters

string $sql
array $bindings

Returns

mixed

Tags

None found

first()

first(string  $sql, array  $bindings = array()) : object

Execute a SQL query against the connection and return the first result.

// Execute a query against the database connection $user = DB::connection()->first('select * from users');

// Execute a query with bound parameters
$user = DB::connection()->first('select * from users where id = ?', array($id));

Parameters

string $sql
array $bindings

Returns

object

Tags

None found

query()

query(string  $sql, array  $bindings = array()) : array

Execute a SQL query and return an array of StdClass objects.

Parameters

string $sql
array $bindings

Returns

array

Tags

None found

driver()

driver() : string

Get the driver name for the database connection.

Returns

string

Tags

None found

__call()

__call(  $method,   $parameters) 

Magic Method for dynamically beginning queries on database tables.

Parameters

$method
$parameters

Tags

None found

grammar()

grammar() : \Laravel\Database\Query\Grammars\Grammar

Create a new query grammar for the connection.

Returns

LaravelDatabaseQueryGrammarsGrammar

Tags

None found

execute()

execute(string  $sql, array  $bindings = array()) : array

Execute a SQL query against the connection.

The PDO statement and boolean result will be returned in an array.

Parameters

string $sql
array $bindings

Returns

array

Tags

None found

fetch()

fetch(\PDOStatement  $statement, integer  $style) : array

Fetch all of the rows for a given statement.

Parameters

PDOStatement $statement
integer $style

Returns

array

Tags

None found

log()

log(string  $sql, array  $bindings, integer  $start) : void

Log the query and fire the core query event.

Parameters

string $sql
array $bindings
integer $start

Tags

None found