Oracle DB driver for Laravel 4|5|6|7|8 via OCI8

Overview

Oracle DB driver for Laravel 4|5|6|7|8 via OCI8

Build Status Total Downloads Latest Stable Version License

Laravel-OCI8

Laravel-OCI8 is an Oracle Database Driver package for Laravel. Laravel-OCI8 is an extension of Illuminate/Database that uses OCI8 extension to communicate with Oracle. Thanks to @taylorotwell.

Documentations

Laravel Version Compatibility

Laravel Package
5.1.x 5.1.x
5.2.x 5.2.x
5.3.x 5.3.x
5.4.x 5.4.x
5.5.x 5.5.x
5.6.x 5.6.x
5.7.x 5.7.x
5.8.x 5.8.x
6.x.x 6.x.x
7.x.x 7.x.x
8.x.x 8.x.x

Quick Installation

composer require yajra/laravel-oci8:^8

Service Provider (Optional on Laravel 5.5+)

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

Yajra\Oci8\Oci8ServiceProvider::class,

Configuration (OPTIONAL)

Finally you can optionally publish a configuration file by running the following Artisan command. If config file is not publish, the package will automatically use what is declared on your .env file database configuration.

php artisan vendor:publish --tag=oracle

This will copy the configuration file to config/oracle.php.

Note: For Laravel Lumen configuration, make sure you have a config/database.php file on your project and append the configuration below:

'oracle' => [
    'driver'        => 'oracle',
    'tns'           => env('DB_TNS', ''),
    'host'          => env('DB_HOST', ''),
    'port'          => env('DB_PORT', '1521'),
    'database'      => env('DB_DATABASE', ''),
    'username'      => env('DB_USERNAME', ''),
    'password'      => env('DB_PASSWORD', ''),
    'charset'       => env('DB_CHARSET', 'AL32UTF8'),
    'prefix'        => env('DB_PREFIX', ''),
    'prefix_schema' => env('DB_SCHEMA_PREFIX', ''),
    'edition'       => env('DB_EDITION', 'ora$base'),
],

If you need to connect with the service name instead of tns, you can use the configuration below:

'oracle' => [
    'driver' => 'oracle',
    'host' => 'oracle.host',
    'port' => '1521',
    'database' => 'xe',
    'service_name' => 'sid_alias',
    'username' => 'hr',
    'password' => 'hr',
    'charset' => '',
    'prefix' => '',
]

And run your laravel installation...

[Laravel 5.2++] Oracle User Provider

When using oracle, we may encounter a problem on authentication because oracle queries are case sensitive by default. By using this oracle user provider, we will now be able to avoid user issues when logging in and doing a forgot password failure because of case sensitive search.

To use, just update auth.php config and set the driver to oracle

'providers' => [
    'users' => [
        'driver' => 'oracle',
        'model' => App\User::class,
    ],
]

Credits

License

The MIT License (MIT). Please see License File for more information.

Comments
  • Use of undefined constant OCI_CRED_EXT - assumed 'OCI_CRED_EXT' (this will throw an Error in a future version of PHP)

    Use of undefined constant OCI_CRED_EXT - assumed 'OCI_CRED_EXT' (this will throw an Error in a future version of PHP)

    Summary of problem or feature request

    I'm having error when trying to select table. Anyone can help?

    Code snippet of problem

    Route::get('test-oracle-connection', function () {
        $sspd = \Illuminate\Support\Facades\DB::connection('oracle')->table('sspd')->first();
    
        dd($sspd);
    });
    

    Errors:

    Use of undefined constant OCI_CRED_EXT - assumed 'OCI_CRED_EXT' (this will throw an Error in a future version of PHP)
    

    System details

    • Operating System: macOS Mojave Version 10.14.4 (18E226)
    • PHP Version: 7.3
    • Laravel Version: 5.8.*
    • Laravel-OCI8 Version: 5.8.*
    need feedback need help OCI_CRED_EXT 
    opened by muhghazaliakbar 33
  • Relationships problem

    Relationships problem

    Summary of problem or feature request

    Relationships are outputting stranger SQL, just does not work. Why it's writting IS NULL and IS NOT NULL over the query?

    Code snippet of problem

    MAIN MODEL

    <?php
    namespace Models;
    
    use Illuminate\Database\Eloquent\Model as Eloquent;
    
    class Tgfpro extends Eloquent
    {
        protected $table = 'TGFPRO';
        protected $primaryKey = 'CODPROD';
        public $timestamps = false;
    
        public function valor()
        {
        	return $this->hasMany('Models\Tgfexc', 'CODPROD')
        		->select('VLRVENDA');
        }
    
        public function getImagemAttribute($value)
        {
        	return base64_encode($value);
        }
    }
    

    SECONDARY MODEL

    <?php
    namespace Models;
    
    use Illuminate\Database\Eloquent\Model as Eloquent;
    
    class Tgfexc extends Eloquent
    {
        protected $table = 'TGFEXC';
        public $timestamps = false;
    }
    

    CONTROLLER CALL

            $produtos = Models\Tgfpro::where('ATIVO', 'S')
            	->limit(10)
            	->orderBy('CODPROD', 'ASC')
            	->get([
            		'CODPROD',
            		'DESCRPROD',
            		'IMAGEM'
            	]);
    

    OUTPUTTED SQL

    select "VLRVENDA" from "TGFEXC" where "TGFEXC"."CODPROD" is null and "TGFEXC"."CODPROD" is not null
    

    System details

    • Windows 10
    • PHP 5.6.30
    • Using stand alone
    • Laravel-OCI8 ^5.4
    stale 
    opened by jokeronaldo 22
  • Error saving field of type CLOB

    Error saving field of type CLOB

    Boa tarde. Não estou conseguindo salvar um dado do tipo clob Estou fazendo desta forma

    $dados =  \DB::table('tabela')->where('id', $id)->updateLob(
       array('name'        =>'demo update blob'),
       array('observacao'  => 'blob content here')
    );
    

    Apresenta este erro:

    SQLSTATE[HY093]: Invalid parameter number: Columns/Parameters are 1-based

    System details

    • Windows
    • PHP Version 5.6
    • Laravel Version 5.1
    question 
    opened by luiz-andrade 21
  • Unsupported driver [pdo-via-oci8]

    Unsupported driver [pdo-via-oci8]

    I am seeing an issue where laravel is not recognizing the pdo-via-oci8 driver. I have oci8 enabled in my php install and have followed the install directions for this package. is there a step that I am missing?

    opened by warroyo 21
  • Auth::attempt + Auth::loginUsingId    not saving with OracleElequent user model

    Auth::attempt + Auth::loginUsingId not saving with OracleElequent user model

    Hello, sorry to keep bothering you.

    I am using the same user model that ships with Laravel, just added extends OracleElequent instead of model. I can create/update users, but whenever I use Auth::attempt or Auth::loginUsingId, the user is only logged in for that request, new requests the user is still a guest. I tried exact code with MySQL, working fine, also tried different session drivers, cookies/files/database. Same issue, any advice ? I found a workaround, that is using Session::put('user', Auth::user() ); //for saving in session Session::get('user'); // for retrieving

    This way I can store/retrieve current user, but it's a temporary fix. Thanks again

    opened by AminMkh 19
  • Call to undefined function yajra\Pdo\oci_connect()

    Call to undefined function yajra\Pdo\oci_connect()

    Installed exactly as README recommends, received FatalErrorException (as follows):

    Symfony \ Component \ Debug \ Exception \ FatalErrorException

    Call to undefined function yajra\Pdo\oci_connect()

    nginx/php5.5/oracle

    opened by jamieshepherd 18
  • Oci8Exception in Oci8.php line 454

    Oci8Exception in Oci8.php line 454

    Hi there! I'm trying to connect an Oracle DB (OSX using virtualBox DeveloperDaysVM2016-01-22.ova) with "laravel/framework": "5.2.*" with "yajra/laravel-oci8": "~4.0" My oracle.php config as follows:

    return [
        'oracle' => array(
    'driver' => 'oracle',
    'host' => '127.0.0.1',
    'port' => '1521',
    'database' => 'HR',
    'service_name' => 'orcl',
    'username' => 'hr',
    'password' => 'oracle',
    'charset' => '',
    'prefix' => '',
    )
    ];
    

    but I can't get connected... I always recive: Whoops, looks like something went wrong.

    1/1
    Oci8Exception in Oci8.php line 454:
    in Oci8.php line 454
    at Oci8->connect('(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521)) (CONNECT_DATA =(SERVICE_NAME = orcl)))', 'hr', 'oracle', array('2', '2', '0', 'charset' => ''), '') in Oci8.php line 66
    at Oci8->__construct('(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521)) (CONNECT_DATA =(SERVICE_NAME = orcl)))', 'hr', 'oracle', array('2', '2', '0', 'charset' => '')) in OracleConnector.php line 189
    at OracleConnector->createConnection('(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521)) (CONNECT_DATA =(SERVICE_NAME = orcl)))', array('driver' => 'oracle', 'host' => '127.0.0.1', 'port' => '1521', 'database' => 'HR', 'service_name' => 'orcl', 'username' => 'hr', 'password' => 'oracle', 'charset' => '', 'prefix' => ''), array('2', '2', '0')) in OracleConnector.php line 36
    at OracleConnector->connect(array('driver' => 'oracle', 'host' => '127.0.0.1', 'port' => '1521', 'database' => 'HR', 'service_name' => 'orcl', 'username' => 'hr', 'password' => 'oracle', 'charset' => '', 'prefix' => '')) in Oci8ServiceProvider.php line 42
    at Oci8ServiceProvider->Yajra\Oci8\{closure}(array('driver' => 'oracle', 'host' => '127.0.0.1', 'port' => '1521', 'database' => 'HR', 'service_name' => 'orcl', 'username' => 'hr', 'password' => 'oracle', 'charset' => '', 'prefix' => ''), 'oracle')
    at call_user_func(object(Closure), array('driver' => 'oracle', 'host' => '127.0.0.1', 'port' => '1521', 'database' => 'HR', 'service_name' => 'orcl', 'username' => 'hr', 'password' => 'oracle', 'charset' => '', 'prefix' => ''), 'oracle') in DatabaseManager.php line 164
    at DatabaseManager->makeConnection('oracle') in DatabaseManager.php line 68
    at DatabaseManager->connection() in DatabaseManager.php line 317
    at DatabaseManager->__call('conection', array()) in Facade.php line 215
    at DatabaseManager->conection() in Facade.php line 215
    at Facade::__callStatic('conection', array()) in routes.php line 16
    at DB::conection() in routes.php line 16
    at RouteServiceProvider->{closure}()
    at call_user_func_array(object(Closure), array()) in Route.php line 158
    at Route->runCallable(object(Request)) in Route.php line 137
    at Route->run(object(Request)) in Router.php line 703
    at Router->Illuminate\Routing\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
    at Pipeline->Illuminate\Routing\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
    at Pipeline->then(object(Closure)) in Router.php line 705
    at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 678
    at Router->dispatchToRoute(object(Request)) in Router.php line 654
    at Router->dispatch(object(Request)) in Kernel.php line 246
    at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
    at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44
    at CheckForMaintenanceMode->handle(object(Request), object(Closure))
    at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
    at Pipeline->Illuminate\Routing\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
    at Pipeline->then(object(Closure)) in Kernel.php line 132
    at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
    at Kernel->handle(object(Request)) in index.php line 54
    

    Any ideas to fix it? Many thanks in advance!

    opened by oneme 15
  • [LARAVEL5] When running migrations, I get

    [LARAVEL5] When running migrations, I get "Call to undefined function Yajra\Pdo\oci_connect()"

    Hi All, I am trying to migrate my database from mysql to Oracle, but when i try to run php artisan migrate, it simply wont run properly. I have tested the connection, and it is working fine. When i access the aplication, it tries to look for the tables, etc. I have the oci installed, under composer and on providers on app.php

    Does anyone have any idea on what's causing this?

    on /storage/logs: [2016-01-12 15:01:47] local.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Call to undefined function Yajra\Pdo\oci_connect()' in /home/programacao/projetos/gestor-codemed/vendor/yajra/laravel-pdo-via-oci8/src/Pdo/Oci8.php:449 Stack trace: #0 {main}

    opened by vitroz 15
  • PHP says: Call to undefined function yajra\\Pdo\\oci_connect() but I have OCI8 installed and enabled

    PHP says: Call to undefined function yajra\\Pdo\\oci_connect() but I have OCI8 installed and enabled

    Ok, guys, I don't know for sure if this is a bug, but I report it because this is very strange. First of wall, I got this error when I try to seed my database using the comand (only when I try to seed):

     php artisan db:seed
    

    Then I got the error:

    {"error":{"type":"Symfony\Component\Debug\Exception\FatalErrorException","message":"Call to undefined function yajra\Pdo\oci_connect()","file":"/var/www/html/po/vendor/yajra/laravel-pdo-via-oci8/src/yajra/Pdo/Oci8.php","line":81}}

    Ok, now first question: Do I have to install PDO OCI?

    I just installed OCI8 with Instant Client 12:

    sudo pecl install oci8
    

    Added: extension=oci8.so in oci8.ini at /etc/php5/fpm/conf.d. Checked the install with <?php phpinfo(); ?>and it's OK (see attached image). oci8

    Well, after all those configuration, I started install yajra/laravel-oci8. Added the configuration at composer.json. Added, yajra\Oci8\Oci8ServiceProvider' in config/app.php and I configured the database. Ok then, now I can connect successfully but I got the error when I try to seed the database.

    My environment:

    • Apache 2.4;
    • PHP 5.6;
    • Laravel 4.2;
    • PHP OCI8 2.0.8.
    • yajra/laravel: 2.1.0;
    • Oracle Instant Client 12.1;
    • Linux Mint 17.1
    opened by rgiaviti 15
  • Laravel does not delete bank record

    Laravel does not delete bank record

    Summary of problem or feature request

    The laravel does not show any error but also does not delete.

    Code snippet of problem

    Controller

     public function destroy($id)
        {
            //
            $projeto = ProjetoModel::findOrFail($id);
            return response()->json($projeto->delete());
        }
    

    Model

    class ProjetoModel extends Model
    {
        //
        use SoftDeletes;
        const  DELETED_AT = 'ST_EXCLUIDO';
        const  CREATED_AT = 'ST_CRIADO';
        const  UPDATED_AT = 'ST_ATUALIZADO';
        const NAME_TABLE = 'PROJETO';
        protected $table = 'PROJETO';
        protected $primaryKey = 'ID_PROJETO';
        protected $fillable = ['NM_PROJETO','SG_PROJETO','ID_RESPONSAVEL'];
        protected $guarded = ['ID_PROJETO','ST_EXCLUIDO','ST_CRIADO', 'ST_ATUALIZADO'];
    }
    
    

    System details

    • Operating System ubuntu 16.04.2 LTS
    • PHP Version 7.1
    • Laravel Version 5.4
    • Laravel-OCI8 Version last
    question 
    opened by danilodorgam 14
  • Laravel 5.4.19 - SQLSTATE[42S02]: Base table or view not found

    Laravel 5.4.19 - SQLSTATE[42S02]: Base table or view not found

    Summary of problem or feature request

    After upgrading Laravel to version 5.4.19, I started to receive "SQLSTATE[42S02]: Base table or view not found" errors. If I downgrade Laravel to 5.4.18, the issue goes away.

    System details

    • Operating System: Ubuntu
    • PHP Version: 7
    • Laravel Version: 5.4.19
    • Laravel-OCI8 Version: 5.4.7
    bug 
    opened by patkruk 13
  • Errors when trying to query tables with lower cased names

    Errors when trying to query tables with lower cased names

    Summary of problem or feature request

    The database I'm trying to connect to has a table named like this: "vwInt_dimProject". When I try to query this table with the query builder it auto-capitalises the table name resulting in "VWINT_DIMPROJECT" which gives me the following error:

    select * from VWINT_DIMPROJECT

    ORA-00942: table or view does not exist

    Code snippet of problem

    Simple model defined like this:

    image

    I have traced the problem down to this line here:

    https://github.com/yajra/laravel-oci8/blob/9.x/src/Oci8/Query/Grammars/OracleGrammar.php#L275

    If I comment out this Str::upper statement then everything works fine.

    Perhaps we can have a way to disable this line? Or make it respect the PDO::ATTR_CASE setting?

    System details

    • Operating System
    • PHP Version: 8.1
    • Laravel Version: 9
    • Laravel-OCI8 Version: 9.2
    enhancement need help 
    opened by BARNZ 2
  • get TNS:no listener error message for running tests

    get TNS:no listener error message for running tests

    Getting TNS:no listener error message when I run tests

    when I run test I get this error message. TNS:no listener

    commands for running tests:

    ./vendor/bin/phpunit

    opened by falahatiali 1
  • Undefined constant

    Undefined constant "Yajra\Pdo\OCI_DEFAULT" running without php -S localhost:8000 -t public but xampp

    i running lumen 9 without php -S localhost:8000 -t public i found error this Undefined constant "Yajra\Pdo\OCI_DEFAULT", running in xampp but i run with php -S localhost:8000 -t public it's work , can you help me to solved running in xampp ?

    • Operating System Windows
    • PHP Version 8
    • Lumen 9
    • Laravel-OCI8 Version ^9.0
    opened by dedisupriadi1612 1
  • Undefined constant

    Undefined constant "Yajra\Pdo\OCI_DEFAULT"

    Summary of problem or feature request

      Error 
    
      Undefined constant "Yajra\Pdo\OCI_DEFAULT"
    
       at vendor/yajra/laravel-pdo-via-oci8/src/Pdo/Oci8.php:138
    

    Why the constant can be undefined?

    private function connect(string $dsn, string $username, string $password, array $options, string $charset) 137▕ { ➜ 138▕ $sessionMode = array_key_exists('session_mode', $options) ? $options['session_mode'] : OCI_DEFAULT; 139▕ 140▕ if (array_key_exists(PDO::ATTR_PERSISTENT, $options) && $options[PDO::ATTR_PERSISTENT]) { 141▕ $this->dbh = @oci_pconnect($username, $password, $dsn, $charset, $sessionMode); 142▕ } else {

    Code snippet of problem

    System details

    • openSUSE Leap 15
    • PHP8
    • Laravel 9
    opened by julianov 4
Releases(v9.2.1)
Driver to seamlessly integrate the Backup Manager into Laravel applications.

Laravel Driver for the Database Backup Manager This package pulls in the framework agnostic Backup Manager and provides seamless integration with Lara

Backup Manager 636 Dec 30, 2022
Laravel 5.1 ODBC Driver

l5-odbc-driver Laravel 5.1 ODBC driver Installation To Install this in your Laravel 5.1 app, open composer.json and add: "require": { "garylocke/odb

Gary Locke 8 Sep 19, 2019
🔌 A Doctrine DBAL Driver implementation on top of Swoole Coroutine PostgreSQL extension

Swoole Coroutine PostgreSQL Doctrine DBAL Driver A Doctrine\DBAL\Driver implementation on top of Swoole\Coroutine\PostgreSQL. Getting started Install

Leo Cavalcante 19 Nov 25, 2022
Doctrine PHP mapping driver

WORK IN PROGRESS! Doctrine PHP mapping driver Alternative mapping driver that allows to write mappings in PHP. Documentation Associations examples TOD

Andrey Klimenko 3 Aug 15, 2021
A package for using Google Datastore as a database driver

Laravel Eloquent for Google Datastore A package for using Google Datastore as a database driver. By using this package, you can use query builder and

A1 Comms Ltd 3 Apr 26, 2022
A PHP client driver for the RethinkDB query language (ReQL).

PHP-RQL A PHP client driver for the RethinkDB query language (ReQL).

Daniel Mewes 341 Dec 30, 2022
Feather - a highly performant SQLite Cache Driver for Kirby 3

?? Kirby3 SQLite Cache-Driver Feather - a highly performant SQLite Cache Driver for Kirby 3 Commerical Usage Support open source! This plugin is free

Bruno Meilick 1 Dec 15, 2021
A Laravel package to output a specific sql to your favourite debugging tool. The supported log output is Laravel Telescope, Laravel Log, Ray, Clockwork, Laravel Debugbar and your browser.

Laravel showsql A Laravel package to output a specific sql to your favourite debugging tool, your browser or your log file. Use case You often want to

Dieter Coopman 196 Dec 28, 2022
This project is about import CSV to Laravel with Laravel Excel library.

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Abraham Víctor Zaragoza Rodríguez 1 Nov 20, 2021
[READ ONLY] Subtree split of the Illuminate Database component (see laravel/framework)

Illuminate Database The Illuminate Database component is a full database toolkit for PHP, providing an expressive query builder, ActiveRecord style OR

The Laravel Components 2.5k Dec 27, 2022
Baum is an implementation of the Nested Set pattern for Laravel's Eloquent ORM.

Baum Baum is an implementation of the Nested Set pattern for Laravel 5's Eloquent ORM. For Laravel 4.2.x compatibility, check the 1.0.x branch branch

Estanislau Trepat 2.2k Jan 3, 2023
Effective tree structures in Laravel 4-5

This is a Laravel 4-8 package for working with trees in relational databases. Laravel 5.7, 5.8, 6.0, 7.0, 8.0 is supported since v5 Laravel 5.5, 5.6 i

Alexander Kalnoy 3.3k Jan 6, 2023
Adjacency List’ed Closure Table database design pattern implementation for the Laravel framework.

ClosureTable This is a database manipulation package for the Laravel 5.4+ framework. You may want to use it when you need to store and operate hierarc

Yan Ivanov 441 Dec 11, 2022
A drop-in library for certain database functionality in Laravel, that allows for extra features that may never make it into the main project.

Eloquence Eloquence is a package to extend Laravel's base Eloquent models and functionality. It provides a number of utilities and classes to work wit

Kirk Bushell 470 Dec 8, 2022
Laravel Inverse Seed Generator

Inverse seed generator (iSeed) is a Laravel package that provides a method to generate a new seed file based on data from the existing database table.

Orange Hill Development 2.5k Dec 29, 2022
A package to backup your Laravel app

A modern backup solution for Laravel apps This Laravel package creates a backup of your application. The backup is a zip file that contains all files

Spatie 5.1k Jan 1, 2023
A drop-in Doctrine ORM 2 implementation for Laravel 5+ and Lumen

Laravel Doctrine ORM A drop-in Doctrine ORM 2 implementation for Laravel 5+ $scientist = new Scientist( 'Albert', 'Einstein' ); $scientist->a

Laravel Doctrine 777 Dec 17, 2022
A MongoDB based Eloquent model and Query builder for Laravel (Moloquent)

Laravel MongoDB This package adds functionalities to the Eloquent model and Query builder for MongoDB, using the original Laravel API. This library ex

Jens Segers 6.3k Jan 5, 2023
Laravel Migrations Generator: Automatically generate your migrations from an existing database schema.

Laravel Migrations Generator Generate Laravel Migrations from an existing database, including indexes and foreign keys! Upgrading to Laravel 5.4 Pleas

Bernhard Breytenbach 3.3k Dec 30, 2022