All Projects → jamierumbelow → Codeigniter Schema

jamierumbelow / Codeigniter Schema

⛔️DEPRECATED Expressive table definitions

Projects that are alternatives of or similar to Codeigniter Schema

Aawindow
[Deprecated] · UIWindow subclass to enable behavior like adaptive round-corners & detecting when Control Center is opened.
Stars: ✭ 486 (+458.62%)
Mutual labels:  deprecated, archived, obsolete
Mern Starter
⛔️ DEPRECATED - Boilerplate for getting started with MERN stack
Stars: ✭ 5,175 (+5848.28%)
Mutual labels:  deprecated, archived, obsolete
VRTK.Tutorials.OculusIntegration
Prefabs and code for use with the Oculus Integration Unity Package
Stars: ✭ 26 (-70.11%)
Mutual labels:  deprecated, archived, obsolete
Docker Cleanup
DEPRECATED Automatic Docker image, container and volume cleanup
Stars: ✭ 582 (+568.97%)
Mutual labels:  deprecated, archived, obsolete
react-native-apple-sign-in
Apple Signin for your React Native applications
Stars: ✭ 16 (-81.61%)
Mutual labels:  deprecated, archived, obsolete
Tinx
⛔️ Laravel Tinx is archived and no longer maintained.
Stars: ✭ 437 (+402.3%)
Mutual labels:  deprecated, archived, obsolete
Mern Cli
⛔️ DEPRECATED - A cli tool for getting started with MERN
Stars: ✭ 575 (+560.92%)
Mutual labels:  deprecated, archived, obsolete
ionic-3D-card-carousel
DEPRECATED Sample project that shows an experimental 3D card carousel in Ionic.
Stars: ✭ 29 (-66.67%)
Mutual labels:  deprecated, archived, obsolete
Sphero Mac Sdk
🚫 DEPRECATED: Sphero SDK for the Mac platform.
Stars: ✭ 70 (-19.54%)
Mutual labels:  deprecated, archived, obsolete
AASecondaryScreen
[Deprecated] · Approachable implementation of iOS AirPlay-Mirroring using Swift.
Stars: ✭ 40 (-54.02%)
Mutual labels:  deprecated, archived, obsolete
Piranha
[DEPRECATED] This is the legacy version of Piranha CMS for .NET 4.5, MVC 5.2 & WebPages 3.2.
Stars: ✭ 418 (+380.46%)
Mutual labels:  deprecated, archived, obsolete
Codeigniter Base Model
⛔️DEPRECATED CodeIgniter base CRUD model to remove repetition and increase productivity
Stars: ✭ 1,052 (+1109.2%)
Mutual labels:  deprecated, archived, obsolete
Sphero.js
🚫 DEPRECATED: The Sphero JavaScript SDK to control Sphero robots.
Stars: ✭ 346 (+297.7%)
Mutual labels:  deprecated, archived, obsolete
Pygeoip
DEPRECATED: Pure Python API for Maxmind's binary GeoIP databases
Stars: ✭ 483 (+455.17%)
Mutual labels:  deprecated, archived, obsolete
Azure-AppServices-Diagnostics
Azure App Service Diagnostics provides developers ability to write various diagnostics features which helps customers to diagnose and troubleshoot their applications hosted on app services.
Stars: ✭ 42 (-51.72%)
Mutual labels:  deprecated, archived, obsolete
QR
DEPRECATED The bookmarklet and extensions generate QRCode of the current URL for viewing on mobile devices (Google Chrome/Mozilla Firefox/Opera/Safari)
Stars: ✭ 20 (-77.01%)
Mutual labels:  deprecated, archived, obsolete
Sphero-Win-SDK
🚫 DEPRECATED: Sphero SDK for Win 8.1+ using RFCOMM
Stars: ✭ 36 (-58.62%)
Mutual labels:  deprecated, archived, obsolete
jest-badges-readme
Creates a group of coverage badges from Jest into your README
Stars: ✭ 30 (-65.52%)
Mutual labels:  deprecated, archived, obsolete
Sphero-AR-SDK
🚫 DEPRECATED: Sphero's augmented reality SDK
Stars: ✭ 46 (-47.13%)
Mutual labels:  deprecated, archived, obsolete
VRTK.Prefabs
*Deprecated* - A collection of productive prefabs for rapidly building spatial computing solutions in the Unity software.
Stars: ✭ 61 (-29.89%)
Mutual labels:  deprecated, archived, obsolete

DEPRECATED: Schema

No Maintenance Intended

Schema allows you to write your migrations (and define your database tables) in pure, beautiful PHP. No more feeding the DBForge library raw SQL fragments or dumping and loading at the command line. Schema lets you design your database in your migrations with ultimate ease.

Synopsis

Schema::create_table('users', function($table){
    
    $table->auto_increment_integer('id');
    
    $table->string('email');
    $table->string('password');
    
    $table->string('first_name');
    $table->string('last_name');
    
    $table->text('biography');
    
    $table->boolean('enabled');
    
    $table->timestamps();
});

Requirements

Schema requires at minimum PHP 5.1.2 (although 5.3 is recommended) and CodeIgniter 2.0.0.

Installation

Schema is easy to install using CodeIgniter Sparks. Simply install schema:

$ php tools/spark install schema

...and load the Spark when you want to use it:

$this->load->spark('schema');

Alternatively, you can download the repository through GitHub, extract the libraries/Schema.php and move it to the application/libraries directory. Then load it by calling $this->load->library.

Creating Tables

The Schema::create_table() function allows you to define and create a table in one fell swoop. It takes two parameters: the table name as a string, and a closure function, or 'block', (which enables the nice schema defining DSL).

This function takes a single parameter, which is an instance of Schema_Table_Definition. You can then call methods on this object to define the schema for your database tables.

Schema::create_table('users', function($table){
    // Definition goes in here
});

If you're not running PHP5.3, you can pass through FALSE (boolean) and create_table() will return the table object directly. Finish your statements with a call to $table->create_table().

$table = Schema::create_table('users', FALSE);

$table->string('name');
$table->create_table();

Data Types

Schema_Table_Definition has a bunch of methods that allow you to create data types. These are all reasonably self-explanatory:

  • integer($name) - create an INT column
  • tinyint($name) - create an TINYINT column
  • string($name, $constraint = 200) - create a VARCHAR column (with optional constraint)
  • text($name) - create a TEXT column
  • longtext($name) - create a LONGTEXT column
  • date($name) - create a DATE column
  • datetime($text) - create a DATETIME column
  • decimal($name, $constraint = '10,2') - create an DECIMAL column (with optional constraint)
  • boolean($name) - MySQL doesn't have a native boolean type, so we create a TINYINT

There are also two special methods to speed up your development.

auto_increment_integer($name) allows you to specify an auto_increment INT (with required primary keys). This is most helpful for adding an id column:

$table->auto_increment_integer('id');

timestamps() automatically generates two columns, created_at and updated_at, both DATETIME columns.

Keys

You can add keys (indexes) through two functions, primary_key($name), and key($name, $primary = FALSE). primary_key() is a small wrapper around key().

Modifying Tables

Schema also contains a series of functions that allow you to modify an existing table.

Add Columns

Schema::add_column() lets you add a column to an existing table very simply. It takes three parameters, the table name, the column name and the column data type.

Schema::add_column('users', 'rank', 'integer');

Remove Columns

Schema::remove_column() lets you remove a column from a database table.

Schema::remove_column('users', 'rank');

Rename Columns

Schema::rename_column() lets you rename a column in a database table.

Schema::rename_column('users', 'rank', 'position');

Modify Columns

Schema::modify_column() allows you to modify the type and properties of a column.

Schema::modify_column('users', 'rank', 'string', array('constraint' => 250));

Running Unit Tests

NOTE: In order to run the test suite PHP5.3 is required

Schema comes with a unit test suite to ensure that the software remains stable and refactorable. It uses the very simple and lightweight PHP testing framework Inferno. Inferno is tucked away in a submodule:

$ cd path_to_schema_repo/
$ git submodule init
$ git submodule update

Then, all it takes is a call to tests/all.php to run the entire test suite.

$ php tests/all.php

You can also specify particular files in the suite by calling that file directly:

$ php tests/Schema_test.php

Release Notes

  • 0.2.0
    • Added the ability to add a column after another
    • Added a boolean() method
  • 0.1.0
    • Initial Release
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].