jfelder/oracledb

Oracle DB driver for Laravel 4

Installs: 985

Dependents: 0

Stars: 67

Watchers: 16

Forks: 38

Language: PHP

4.2.1 2014-10-09 19:02 UTC

README

OracleDB (updated for 4.2)

Latest Stable Version Total Downloads Build Status SensioLabsInsight

OracleDB is an Oracle Database Driver package for Laravel 4 - thanks @taylorotwell. OracleDB is an extension of Illuminate/Database that uses either the PDO_OCI extension or the OCI8 Functions wrapped into the PDO namespace.

Please report any bugs you may find.

Installation

Add jfelder/oracledb as a requirement to composer.json:

{
    "require": {
        "jfelder/oracledb": "*"
    }
}

And then run composer update

Once Composer has installed or updated your packages you need to register OracleDB. Open up app/config/app.php and find the providers key and add:

'Jfelder\OracleDB\OracleDBServiceProvider'

Finally you need to publish a configuration file by running the following Artisan command.

$ php artisan config:publish jfelder/oracledb

This will copy the configuration file to app/config/packages/jfelder/oracledb/database.php

Basic Usage

The configuration file for this package is located at 'app/config/packages/jfelder/oracledb/database.php'. In this file you may define all of your oracle database connections. If you want to make one of these connections the default connection, enter the name you gave the connection into the "Default Database Connection Name" section in 'app/config/database.php'.

Once you have configured the OracleDB database connection(s), you may run queries using the 'DB' class as normal.

NEW: To use the oci8 library, enter "oci8" as the driver and the code will automatically use the oci8 library instead of the pdo_oci library. Any other value will result in the pdo_oci library being used.
$results = DB::select('select * from users where id = ?', array(1));

The above statement assumes you have set the default connection to be the oracle connection you setup in OracleDB's config file and will always return an 'array' of results.

$results = DB::connection('oracle')->select('select * from users where id = ?', array(1));

Just like the built-in database drivers, you can use the connection method to access the oracle database(s) you setup in OracleDB's config file.

Inserting Records Into A Table With An Auto-Incrementing ID
    $id = DB::connection('oracle')->table('users')->insertGetId(
        array('email' => 'john@example.com', 'votes' => 0), 'userid'
    );

Note: When using the insertGetId method, you can specify the auto-incrementing column name as the second parameter in insertGetId function. It will default to "id" if not specified.

See Laravel 4 Database Basic Docs for more information.

License

Licensed under the MIT License.