Skip to content

Commit

Permalink
Merge pull request #61 from efcor/9.x
Browse files Browse the repository at this point in the history
update for Laravel 9
  • Loading branch information
jfelder authored Nov 29, 2022
2 parents 38f8278 + 1a99528 commit c805c0e
Show file tree
Hide file tree
Showing 23 changed files with 1,185 additions and 505 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 2
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
language: php

php:
- 7.3
- 7.4
- 8.1

env:
global:
Expand Down
19 changes: 12 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "jfelder/oracledb",
"description": "Oracle DB driver for Laravel",
"keywords": ["oracle", "laravel", "laravel 8", "pdo_oci", "oci8"],
"keywords": ["oracle", "laravel", "laravel 9", "pdo_oci", "oci8"],
"license": "MIT",
"authors": [
{
Expand All @@ -10,20 +10,25 @@
}
],
"require": {
"php": "^7.3.0",
"illuminate/support": "^8.0",
"illuminate/database": "^8.24.0",
"illuminate/pagination": "^8.0"
"php": "^8.1.0",
"illuminate/support": "^9.0",
"illuminate/database": "^9.0",
"illuminate/pagination": "^9.0"
},
"require-dev": {
"mockery/mockery": "^1.4.2",
"phpunit/phpunit": "^9.3.3"
"mockery/mockery": "^1.4.4",
"phpunit/phpunit": "^9.5.8"
},
"autoload": {
"psr-4": {
"Jfelder\\": "src/Jfelder"
}
},
"autoload-dev": {
"psr-4": {
"Jfelder\\OracleDB\\Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"providers": [
Expand Down
18 changes: 11 additions & 7 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
## Laravel Oracle Database Package

### OracleDB (updated for Laravel 8.x)
### OracleDB (updated for Laravel 9)

[![Latest Stable Version](https://poser.pugx.org/jfelder/oracledb/v/stable.png)](https://packagist.org/packages/jfelder/oracledb) [![Total Downloads](https://poser.pugx.org/jfelder/oracledb/downloads.png)](https://packagist.org/packages/jfelder/oracledb) [![Build Status](https://travis-ci.org/jfelder/Laravel-OracleDB.png)](https://travis-ci.org/jfelder/Laravel-OracleDB)


OracleDB is an Oracle Database Driver package for [Laravel Framework](https://laravel.com) - thanks [@taylorotwell](https://github.com/taylorotwell). OracleDB is an extension of [Illuminate/Database](https://github.com/illuminate/database) that uses either the [PDO_OCI](https://www.php.net/manual/en/ref.pdo-oci.php) extension or the [OCI8 Functions](https://www.php.net/manual/en/ref.oci8.php) wrapped into the PDO namespace.

_NOTE: This package has not been tested in PHP 8._
> **Note:** This package is designed to run in PHP 8.1, and has not been tested in PHP 8.0
**Please report any bugs you may find.**

Expand Down Expand Up @@ -55,7 +55,10 @@ connection into the "Default Database Connection Name" section in `config/databa

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

_NOTE: OCI8 is the default driver. If you want to use the PDO_OCI driver, change the `driver` value to `'pdo'` in the `config/oracledb.php` file for whichever connections you wish to have utilize PDO_OCI. Setting the driver to `'pdo'` will make OracleDB use the [PDO_OCI](https://www.php.net/manual/en/ref.pdo-oci.php) extension. Given any other `driver` value, OracleDB will use the [OCI8 Functions](https://www.php.net/manual/en/ref.oci8.php)._
> **Note:** The default driver, `'oci8'`, makes OracleDB use the
[OCI8 Functions](https://www.php.net/manual/en/ref.oci8.php) under the hood. If you want to use
[PDO_OCI](https://www.php.net/manual/en/ref.pdo-oci.php) instead, change the `driver` value to `'pdo'` in the
`config/oracledb.php` file.

```php
$results = DB::select('select * from users where id = ?', [1]);
Expand All @@ -74,15 +77,15 @@ in config/oracledb.php file.
#### Inserting Records Into A Table With An Auto-Incrementing ID

```php
$id = DB::connection('oracle')->table('users')->insertGetId(
['email' => 'john@example.com', 'votes' => 0], 'userid'
);
$id = DB::connection('oracle')->table('users')->insertGetId(
['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 Database Basic Docs](https://laravel.com/docs/8.x/database) for more information.
See [Laravel Database Basic Docs](https://laravel.com/docs/9.x/database) for more information.

### Unimplemented Features

Expand All @@ -98,6 +101,7 @@ features not already listed.
- deleting with a join `DB::from('users')->join('contacts', 'users.id', '=', 'contacts.id')->where('users.email', '=', 'foo')->delete();`
- deleting with a limit `DB::from('users')->where('email', '=', 'foo')->orderBy('id')->take(1)->delete();`
- json operations `DB::from('users')->where('items->sku', '=', 'foo-bar')->get();`
- whereFulltext `DB::table('users')->whereFulltext('description', 'Hello World');`

#### Schema Builder

Expand Down
8 changes: 6 additions & 2 deletions src/Jfelder/OracleDB/Connectors/OracleConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Jfelder\OracleDB\Connectors;

use InvalidArgumentException;
use Illuminate\Database\Connectors\Connector as Connector;
use Illuminate\Database\Connectors\ConnectorInterface as ConnectorInterface;
use Jfelder\OracleDB\OCI_PDO\OCI as OCI;
Expand All @@ -26,14 +27,17 @@ class OracleConnector extends Connector implements ConnectorInterface
* @param array $config
* @param array $options
* @return PDO
* @throws InvalidArgumentException
*/
public function createConnection($dsn, array $config, array $options)
{
if ($config['driver'] == 'pdo') {
if ($config['driver'] === 'pdo') {
return parent::createConnection($dsn, $config, $options);
} else {
} elseif ($config['driver'] === 'oci8') {
return new OCI($dsn, $config['username'], $config['password'], $options, $config['charset']);
}

throw new InvalidArgumentException('Unsupported driver ['.$config['driver'].'].');
}

/**
Expand Down
Loading

0 comments on commit c805c0e

Please sign in to comment.