2017 © Pedro Peláez
 

library schema-builder

Fork of illuminate/database to use the schema builder alone.

image

robclancy/schema-builder

Fork of illuminate/database to use the schema builder alone.

  • Saturday, April 13, 2013
  • by Robbo
  • Repository
  • 2 Watchers
  • 2 Stars
  • 131 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 382 Forks
  • 0 Open issues
  • 1 Versions
  • 2 % Grown

The README.md

Schema Builder

This is a port of http://github.com/illuminate/database to provide the schema builder without all the extra features., (*1)

Build Status, (*2)

The idea behind this is allowing the scheme builder to be used in projects that already have a database layer that uses PDO., (*3)

All you need to use this is a PDO instance. If you create it manually you might want to consider using http://github.com/robclancy/db-connector which is another fork of http://github.com/illuminate/database but to just connect to the database. With your PDO instance you create a Robbo\SchemaBuilder\Connection instance and then call ->getSchemaBuilder() to get started. Then you use the builder as described in the [http://four.laravel.com/docs/schema](Laravel docs) however substitute your instance for Schema::., (*4)

Installation

Add the following to the "require" section of your composer.json file:, (*5)

    "robclancy/schema-builder": "1.0.x"

Native example

Following example will assume you have a PDO instance stored in $pdo., (*6)


// Create the connection $connection = new Robbo\SchemaBuilder\Connection\MySqlConnection($pdo, 'database_name', 'tableprefix_'); // Alternatively you can use a factory method to create an instance depending on the driver // Drivers supported: mysql, pgsql, sqlite and sqlsrv $connection = Robbo\SchemaBuilder\Connection::create('mysql', $pdo, 'database_name', 'tableprefix_') $builder = $connection->getSchemaBuilder(); // Now you can use it like in the laravel docs... $builder->create('users', function($table) { $table->increments('id'); });

Support for a dry run is also supported using the functionality from illuminate/database. Use it like so..., (*7)


// $builder and $connection is the same from above $queries = $connection->pretend(function($connection) use ($builder) { // Could use $connection->getSchemaBuilder() here in place of $builder $builder->create('users', function($table) { $table->increments('id'); }); }); // Now $queries will contain all queries that were created

The Versions

13/04 2013

dev-master

9999999-dev

Fork of illuminate/database to use the schema builder alone.

  Sources   Download

The Requires

  • php >=5.3.0

 

The Development Requires

by Avatar Robbo

database sql schema