[READ ONLY] Subtree split of the Illuminate Database component (see laravel/framework)
Latest commit 53485a4 Sep 19, 2018
Permalink
Failed to load latest commit information.
Capsule Avoid call_user_func_array in __call functions (#14791) Aug 12, 2016
Concerns [5.7] Add empty line before throw parameters in doc block; (#25641) Sep 16, 2018
Connectors Modify MSSQL driver order (#25150) Aug 9, 2018
Console formatting Jul 15, 2018
Eloquent [5.7] Add empty line before throw parameters in doc block; (#25641) Sep 16, 2018
Events Fix database events phpdoc (#22420) Dec 14, 2017
Migrations [5.7] Add empty line before throw parameters in doc block; (#25641) Sep 16, 2018
Query Merge branch '5.7' Sep 19, 2018
Schema [5.7] Add empty line before throw parameters in doc block; (#25641) Sep 16, 2018
Connection.php [5.7] Add empty line before throw parameters in doc block; (#25641) Sep 16, 2018
ConnectionInterface.php Add cursor to ConnectionInterface (#23525) Mar 13, 2018
ConnectionResolver.php Additional cs fixes Jun 1, 2015
ConnectionResolverInterface.php Fix typehint Jul 15, 2015
DatabaseManager.php unify exception formatting (#23266) Feb 23, 2018
DatabaseServiceProvider.php [5.8] Register binding for schema facade (#25512) Sep 7, 2018
DetectsDeadlocks.php Detect MySQL Galera deadblocks. (#22214) Nov 26, 2017
DetectsLostConnections.php Handle AWS Connection Lost (#25295) Aug 22, 2018
Grammar.php optimize method calls (#24783) Jul 9, 2018
MigrationServiceProvider.php Move all framework command registration into ArtisanServiceProvider. Dec 19, 2016
MySqlConnection.php refactor to use Builder Mar 26, 2017
PostgresConnection.php refactor to use Builder Mar 26, 2017
QueryException.php No need to set twice. (#17215) Jan 9, 2017
README.md fix psr-2: database readme sample code (#19490) Jun 6, 2017
SQLiteConnection.php refactor to use Builder Mar 26, 2017
Seeder.php make call chainable (#22288) Dec 3, 2017
SqlServerConnection.php refactor to use Builder Mar 26, 2017
composer.json [5.8] Bumped Laravel version to 5.8 (#25057) Aug 3, 2018

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.