[READ ONLY] Subtree split of the Illuminate Database component (see laravel/framework)
PHP
Latest commit 9a091eb Feb 17, 2017 @pdscopes pdscopes committed with taylorotwell [5.5] Eloquent QueriesRelationships withCount now properly uses alias…
… (#17871)

* Eloquent QueriesRelationships withCount now properly uses alias

* Altered tests to account for changes in withCount changes

* Removed unnecessary file
Permalink
Failed to load latest commit information.
Capsule Avoid call_user_func_array in __call functions (#14791) Aug 12, 2016
Concerns [5.4] Fix throws docblocks (#17254) Jan 10, 2017
Connectors add options to build dsn with secure sql server connection (#17841) Feb 9, 2017
Console [5.4] Multiple docblocks and fixes (#17253) Jan 10, 2017
Eloquent [5.5] Eloquent QueriesRelationships withCount now properly uses alias… Feb 17, 2017
Events Fire a statement prepared event. Jan 10, 2017
Migrations fix #17546, settings the --database option in the migrate command (#1… Jan 26, 2017
Query fix conflicts Feb 15, 2017
Schema Remove unused imports. (#17421) Jan 19, 2017
Connection.php tweak method name and order Jan 12, 2017
ConnectionInterface.php slight formatting Aug 22, 2016
ConnectionResolver.php Additional cs fixes Jun 1, 2015
ConnectionResolverInterface.php Fix typehint Jul 15, 2015
DatabaseManager.php tweak database connection handling Jan 12, 2017
DatabaseServiceProvider.php [5.4] Allow configuration of Faker locale through config (#17895) Feb 12, 2017
DetectsDeadlocks.php Add option to automatically retry deadlocked transactions (#5380) Aug 22, 2016
DetectsLostConnections.php Revert #12151 & #12333: Handle InnoDB Deadlocks By Re-Attempting Tran… Aug 22, 2016
Grammar.php Apply fixes from StyleCI (#17356) Jan 16, 2017
MigrationServiceProvider.php Move all framework command registration into ArtisanServiceProvider. Dec 19, 2016
MySqlConnection.php Begin cleaning up database connection. Jan 2, 2017
PostgresConnection.php Begin cleaning up database connection. Jan 2, 2017
QueryException.php No need to set twice. (#17215) Jan 9, 2017
README.md Update laravel urls with https (#14629) Aug 5, 2016
SQLiteConnection.php Fixed docblocks Aug 26, 2015
Seeder.php Merge branch '5.3' into 5.4 Jan 13, 2017
SqlServerConnection.php Fixed sql server Aug 23, 2016
composer.json Merge branch '5.4' Jan 16, 2017

README.md

Illuminate Database

The Illuminate Database component is a full database toolkit for PHP, providing an expressive query builder, ActiveRecord style ORM, and schema builder. It currently supports MySQL, Postgres, SQL Server, and SQLite. It also serves as the database layer of the Laravel PHP framework.

Usage Instructions

First, create a new "Capsule" manager instance. Capsule aims to make configuring the library for usage outside of the Laravel framework as easy as possible.

use Illuminate\Database\Capsule\Manager as Capsule;

$capsule = new Capsule;

$capsule->addConnection([
    'driver'    => 'mysql',
    'host'      => 'localhost',
    'database'  => 'database',
    'username'  => 'root',
    'password'  => 'password',
    'charset'   => 'utf8',
    'collation' => 'utf8_unicode_ci',
    'prefix'    => '',
]);

// Set the event dispatcher used by Eloquent models... (optional)
use Illuminate\Events\Dispatcher;
use Illuminate\Container\Container;
$capsule->setEventDispatcher(new Dispatcher(new Container));

// Make this Capsule instance available globally via static methods... (optional)
$capsule->setAsGlobal();

// Setup the Eloquent ORM... (optional; unless you've used setEventDispatcher())
$capsule->bootEloquent();

composer require "illuminate/events" required when you need to use observers with Eloquent.

Once the Capsule instance has been registered. You may use it like so:

Using The Query Builder

$users = Capsule::table('users')->where('votes', '>', 100)->get();

Other core methods may be accessed directly from the Capsule in the same manner as from the DB facade:

$results = Capsule::select('select * from users where id = ?', array(1));

Using The Schema Builder

Capsule::schema()->create('users', function($table)
{
    $table->increments('id');
    $table->string('email')->unique();
    $table->timestamps();
});

Using The Eloquent ORM

class User extends Illuminate\Database\Eloquent\Model {}

$users = User::where('votes', '>', 1)->get();

For further documentation on using the various database facilities this library provides, consult the Laravel framework documentation.