Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize package #13

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
vendor/
composer.lock
vendor/
90 changes: 44 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,56 +1,32 @@
l4-odbc-driver
==============
# Laravel 4 ODBC [![Build Status](https://travis-ci.org/wajatimur/odbc-driver.svg?branch=master)](https://travis-ci.org/wajatimur/odbc-driver)

Laravel 4 ODBC
An ODBC driver implementation, currently its support Laravel Framework only.

Installation
============
## Requirements
- PHP 5.3+
- Laravel 4.1.*

To Install this in your Laravel 4.1 app add
## Installation
L4ODBC can be install using composer by adding below line into your existing `composer.json` under require section and executing `composer update` in your Laravel project root folder.

```json
require {
"ccovey/odbc-driver-l4": "1.1.x"
}
"wajatimur/odbc-driver": "dev-master"
```

And then run

`composer install`

This will download the required package from Packagist.org

Then in your app/config directory open app.php and find
Then you need to bootstrap the driver by declaring the service provider registration in you `app.php` file under `app\config` path from Laravel project root folder.

`'Illuminate\Database\DatabaseServiceProvider',`

And replace it with

`'Ccovey\ODBCDriver\ODBCDriverServiceProvider',`
```php
'Foundation\Database\Driver\ODBCDriverServiceProvider',
```

## Configuration
Finally be sure to add the odbc driver with connection information to the `config/database.php` file like so:

```php
'default' => 'mysql',
'connections' => array(
'mysql' => array(
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'database',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
'sqlsrv' => array(
'driver' => 'sqlsrv',
'host' => 'localhost',
'database' => 'database',
'username' => 'root',
'password' => '',
'prefix' => '',
),

// .. Existing config here ..

'odbc' => array(
'driver' => 'odbc',
'dsn' => 'Driver={iSeries Access ODBC Driver};System=my_system_name;',
Expand All @@ -62,23 +38,45 @@ Finally be sure to add the odbc driver with connection information to the `confi
),
```

Note that database is a required value in the array.
## Extending
To create a custom grammar just add your file to `Grammars` folder within the package. Below is the basic template to create a custom grammar.

Notes
==========
```php
namespace Foundation\Database\Driver\Grammars;

To add a custom grammar add your file to ODBCDriver/Grammars with the name you would like to use (currently there is a DB2 grammar file if you would like a reference). Then in your odbc config array add the class name to the grammar key. If you would like to submit a grammar for use in the package please submit a pull request and I will get it in asap.
use Illuminate\Database\Query\Grammars\Grammar;

If you would like to use a Laravel provided file just add that instead. For example if you want to use SQL Server Gramamr instead you can add like so:
class MyCustomGrammar extends {
// .. Add your override method here ..
}

```

### Using Custom Grammar
To use the custom grammar, jusct change the grammar key in you database config base on you grammar file name. If you have a custom grammar with file name `MyCustomGrammar.php`, the grammar key should be as below.

```php
'odbc' => array(
'driver' => 'odbc',
'dsn' => 'some driver',
'grammar' => 'SqlServerGrammar',
'grammar' => 'MyCustomGrammar',
'username' => 'foo',
'password' => 'bar',
'database' => '',
),
```

If you would like to use a Laravel provided grammar file just add that instead. For example if you want to use SQL Server Gramamr, you can use the `SqlServerGrammar` as key in your database config. Others grammar provided by Laravel listed below.

- MySqlGrammar
- SqlServerGrammar
- SQLiteGrammar
- PostgresGrammar

If you would like to submit a grammar for use in the package please submit a pull request and I will get it in asap.






26 changes: 12 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
{
"name": "ccovey/odbc-driver",
"description": "",
"name": "wajatimur/odbc-driver",
"type": "library",
"description": "ODBC Driver for Laravel",
"keywords": ["odbc","laravel"],
"authors": [
{
"name": "Cody Covey",
"email": "ccovey14@gmail.com"
"name": "Azri Jamil",
"email": "azri@nematix.com",
"homepage": "http://wajatimur.wordpress.com"
}
],
"license": "MIT",
"require": {
"php": ">=5.3.0",
"illuminate/support": "4.1.x",
"illuminate/database": "4.1.x"
},
"require-dev": {
"mockery/mockery": "dev-master"
"illuminate/support": "~4.1",
"illuminate/database": "~4.1"
},
"autoload": {
"classmap": [
"src/migrations"
],
"psr-0": {
"Ccovey\\ODBCDriver": "src/"
"Foundation\\Database\\Driver\\ODBCDriver": "src/"
}
},
"minimum-stability": "dev"
}
}
Empty file removed public/.gitkeep
Empty file.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php namespace Ccovey\ODBCDriver\Grammars;
<?php namespace Foundation\Database\Driver\Grammars;

use Illuminate\Database\Query\Grammars\Grammar;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php namespace Ccovey\ODBCDriver;
<?php namespace Foundation\Database\Driver;

use Illuminate\Database\Connection;
use Illuminate\Database\Query\Grammars\Grammar;
use Illuminate\Database\Schema\Grammars\Grammar;


class ODBCDriverConnection extends Connection
{
/**
Expand All @@ -14,7 +14,7 @@ protected function getDefaultQueryGrammar()
$grammarConfig = $this->getGrammarConfig();

if ($grammarConfig) {
$packageGrammar = "Ccovey\\ODBCDriver\\Grammars\\" . $grammarConfig;
$packageGrammar = "Foundation\\Database\\Driver\\Grammars\\" . $grammarConfig;
if (class_exists($packageGrammar)) {
return $this->withTablePrefix(new $packageGrammar);
}
Expand All @@ -34,7 +34,7 @@ protected function getDefaultQueryGrammar()
*/
protected function getDefaultSchemaGrammar()
{
return $this->withTablePrefix(new Schema\Grammars\Grammar);
return $this->withTablePrefix(new Grammar);
}

protected function getGrammarConfig()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?php

namespace Ccovey\ODBCDriver;
<?php namespace Foundation\Database\Driver;

use Illuminate\Database\Connectors\ConnectionFactory;
use Illuminate\Database\Connectors\MySqlConnector;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?php

namespace Ccovey\ODBCDriver;
<?php namespace Foundation\Database\Driver;

use Illuminate\Database\Connectors\Connector;
use Illuminate\Database\Connectors\ConnectorInterface;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?php

namespace Ccovey\ODBCDriver;
<?php namespace Foundation\Database\Driver;

use Illuminate\Database\DatabaseManager;
use Illuminate\Database\Eloquent\Model;
Expand Down
Empty file removed src/config/.gitkeep
Empty file.
Empty file removed src/lang/.gitkeep
Empty file.
Empty file removed src/migrations/.gitkeep
Empty file.
Empty file removed src/views/.gitkeep
Empty file.