Giter VIP home page Giter VIP logo

laravel-oci8's Introduction

Oracle DB driver for Laravel 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 6.x
7.x 7.x
8.x 8.x
9.x 9.x
10.x 10.x
11.x 11.x

Quick Installation

composer require yajra/laravel-oci8:^11

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', ''),
    'service_name'   => env('DB_SERVICE_NAME', ''),
    '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'),
    'server_version' => env('DB_SERVER_VERSION', '11g'),
    'load_balance'   => env('DB_LOAD_BALANCE', 'yes'),
    'dynamic'        => [],
],

Then, you can set connection data in your .env files:

DB_CONNECTION=oracle
DB_HOST=oracle.host
DB_PORT=1521
DB_SERVICE_NAME=orcl
DB_DATABASE=xe
DB_USERNAME=hr
DB_PASSWORD=hr

If you want to connect to a cluster containing multiple hosts, you can either set tns manually or set host as a comma-separated array and configure other fields as you wish:

DB_CONNECTION=oracle
DB_HOST=oracle1.host, oracle2.host
DB_PORT=1521
DB_SERVICE_NAME=orcl
DB_LOAD_BALANCE=no
DB_DATABASE=xe
DB_USERNAME=hr
DB_PASSWORD=hr

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' => '',
]

In some cases you may wish to set the connection parameters dynamically in your app. For instance, you may access more than one database, or your users may already have their own accounts on the Oracle database:

'oracle' => [
    'driver' => 'oracle',
    'host' => 'oracle.host',
    'port' => '1521',
    'service_name' => 'sid_alias',
    'prefix' => 'schemaowner',
    'dynamic' => [App\Models\Oracle\Config::class, 'dynamicConfig'],
]

The callback function in your app must be static and accept a reference to the $config[] array (which will already be populated with values set in the config file):

namespace App\Models\Oracle;

class Config {

    public static function dynamicConfig(&$config) {

        if (Illuminate\Support\Facades\Auth::check()) {
            $config['username'] = App\Oracle\Config::getOraUser();
            $config['password'] = App\Oracle\Config::getOraPass();
        }

    }
}

Then run your laravel installation...

Oracle Max Name Length

By default, DB object name are limited to 30 characters. To increase the limit, you can set the ORA_MAX_NAME_LEN=128 in your .env file.

Note: this config requires Oracle 12c02 or higher.

[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.

laravel-oci8's People

Contributors

adam2marsh avatar ardani avatar carusogabriel avatar chaospower avatar einnar82 avatar filipegar avatar forgandenny avatar franpregernik avatar gergelykralik avatar hpacleb avatar jaydons avatar jf-m avatar jfelder avatar jidago avatar joaorobertopb avatar johnrcui avatar josecl avatar masoudtajer avatar mazedlx avatar mfrancoisbbs avatar mohammadmehrabani avatar mozgovoyandrey avatar mstaack avatar omarata avatar rhernandezob avatar stylecibot avatar tylerian avatar wremonyo avatar yajra avatar zsgsdesign avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-oci8's Issues

Integer column type with length cause problem with sequences....

When I decide the length of integer column this column serve as the auto increment of the table instead the ID which I decided it before. Do you have any idea ?

For example :

Schema::create('users', function(OracleBlueprint $table)

{
$table->increments('id');
$table->integer('primary_phone', 15);
$table->timestamps();

});

the primary_phone column will serve as the sequence of the table instead of ID, do you have any idea?

Thank you.

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

Ora-02275 Foreign Key constraint executed more than once.

Hi,
There is a problem specifically with oracle driver when defining some foreign keys. I have already met this error once but I render myself helpless. Complete issue is posted on stackoverflow here. If you need more of code, feel free to ask.
Thanks.

Laravel with Oracle : PHP and DB server connection problem after SQL update or insert command on SQL Enterprise manager

Hi folks
We are developing PHP web application with Laravel framework and database is Oracle
After we input SQL update/insert/delete command from SQL Enterprise manager, problem starts that disappears DB connection between PHP program and DB server. it means it is not connection PHP programm and oracle database server. After restart Oracle server , PHP program work properly, DB connection is good. All SQL commands from PHP program are good.
What we have to do ? advice please.

Oracle :
Oracle including Dot release like 8.1.7, lunix (Oracle 11g R2 11.2.0.3)
Oracle patch (OPatch version : 11.2.0.1.7)

oh, No! The latest version can not use Eloquent " where " condition

Like this:

TagInfo::where('tag_level', $level);

Then report QueryException:

Error Code : 904 Error Message : ORA-00904: "tag_level": invalid identifier Position : 66 Statement : select "tag_code", "tag_name", "tag_level" from "D_TAGINFO" where "tag_level" = :autoparam0 order by "tag_code" asc (SQL: select "tag_code", "tag_name", "tag_level" from "D_TAGINFO" where "tag_level" = 1 order by "tag_code" asc)

You see, the sql statement:

select "tag_code", "tag_name", "tag_level" from "D_TAGINFO" where "tag_level" = 1 order by "tag_code" asc

As u see, all columns and table name has add double quotes, that 's the problem!

auto increment problem

How to remove all sequences cache from my migration classes? It's default cache size 20. But I want all sequences cache set no cache from my migration classes.

Set named parameters in prepared query

Hi,

When i try to bind my named parameters in prepared query i got this error :
In fr:

oci_bind_by_name(): ORA-01036: numรฉro/nom de variable interdit

In eng:

oci_bind_by_name(): ORA-01036: illegal variable name/number

My code looks like this:

$results = DB::select( DB::raw("SELECT * FROM some_table WHERE some_col = :somevariable"), array(
   'somevariable' => $someVariable,
 ));

My exact code is :

return DB::select(DB::raw("select * from structure WHERE STR_TYPE = :uf"), array(":uf" => 'UF'));

Can you help me to fix it ? Or maybe a bug ?

Thanks for you help

Multiple connections on rollback

Hi, thank you for your great package. I have a problem which I'm not sure if it depends on this module or Laravel's connection management. When I'm using multiple connections inside the same transaction (a read-only and a write-only) if an Exception arise it seems to rollback only if the last connection is the same as the failing query's one.

Example 1

  • [Start transaction]
  • Select [conn.1 r-o]
  • Insert [conn.2 w-o]
  • Wrong Insert [conn.2 w-o]
  • Auto-rollback with success, nothing on DB

Example 2

[Start transaction]
Insert [conn.2 w-o]
Select [conn.1 r-o]
Wrong Insert [conn.2 w-o]
Auto-rollback fails, first Insert is on DB

Call to undefined method yajra\Oci8\Oci8Connection::getDoctrineDriver()

Hi!
I'm using Laravel 4.2 with Xethron MigrationsGenerator. When I launch artisan migrate:generate --connection=oracle I get:

{
   "error":{
      "type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException",
      "message":"Call to undefined method yajra\\Oci8\\Oci8Connection::getDoctrineDriver()",
      "file":"D:\\xampp\\htdocs\\gamelife-api\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Connection.php",
      "line":797
   }
}

With a simple oci connection I have no problems. Can you help me?

Thanks.

invalid user and pass on everything

After updating to the latest version, I am getting invalid user/pass for every connection. no code has been changed on my end. I am using laravel 4.1.29

I get the 'Unsupported driver [pdo-via-oci8]' error message on Ubuntu 14.10

I configured a Windows machine with this driver and it works as expected. However I get the error 'Unsupported driver [pdo-via-oci8]' on my Ubuntu 14.10. I installed lamp-server^ package. Configured it for oci8 extension. Using oci8, I can connect to database both in plain php and laravel (i.e oci_connect). However using laravel DB::select it produces the above mentioned error. Any idea how to connect?

Laravel 5 support

Hi Arjay,
what about L5 support? Are you planning to support the coming release?

Thanks a lot for your effort.

Best regards.

Pietro

Error ORA-28547

Hi,

I have a wep app hosted in MediaTemple but using a remote oracle database connection. In development process I was connecting ok, with a remote testing database, but now I am trying to switch to production database I cannot connect, the issue is: Error ORA-28547

Any idea??

Blob Update: Not updating correctly

Using the sample blob field update provided on the laravel-oci page I came up with this code:

DB::table( 'metas' )
    ->where( 'object_id' , '=', $postId )
    ->where( 'meta_name', '=', $name )
    ->updateLob(
        array( 'meta_name'      => $name, ),
        array( 'meta_value'     => $value )
    );

But when this code executes it do this. example:

  • Old Blob Value:
    "Laravel"
  • And then update the field with this string:
    "PHP"
  • New Blob Value:
    "PHPavel"

I think it only replace a substring of the blob field depending on the length of the new value.

Thanks,

Answer

how to execute select query more faster on laravel? I have 1 millon row data! But it's not working!

Date and timestamp difference in Oci8Connection

Hello,

we got some problems in our "date" type fields in db.
the values in resultsets, that date fields seems with 00:00:00 suffix, which not existing in db actually.

based on this problem i checked out your oci8connection.php and see setDateFormat function.
this function get one parameters, and set this value to date and timestamp formats.

I think we should seperate them;.

public function setDateFormat($date_format = 'YYYY-MM-DD',$timestamp_format = 'YYYY-MM-DD HH24:MI:SS'){
        self::statement("alter session set NLS_DATE_FORMAT = '$date_format'");
        self::statement("alter session set NLS_TIMESTAMP_FORMAT = '$timestamp_format'");
}

After all, now everythink works fine..

(oci8serviceprovider)

$db->setDateFormat('YYYY-MM-DD', 'YYYY-MM-DD HH24:MI:SS');

maybe you could add this to your new release..
Thanks

Usage in standalone instance of Illuminate/Database

Hello,

While trying to use standalone Illuminate/Database with OCI8 I run into errors related to missing "oracle" driver.

At the first glance it looks like one needs to set up Laravel application to register OCI service provider etc.

Is there a way to use OCI support for standalone DB usage?

whereHas returns wrong result

Hi @yajra

Not sure how/where to fix this but I appear to be facing the exact same issue as described here:

laravel/framework#3353

A snippet of my code is below:

        $sitesPendingUserUpdates = Site::with(
            array(
                'users' => function ($query) {
                    $query->withTrashed();
                    $query->where('deletion_pending', '1');
                    $query->orWhere('password_pending', '1');
                    $query->orderBy('username');
                }
            ));
        $sitesPendingUserUpdates->whereHas(
            'users', 
            function ($query) {
                $query->withTrashed();
                $query->where('deletion_pending', '1');
                $query->orWhere('password_pending', '1');
            });
        // I HAVE TO ADD THIS LINE BELOW ::
        $sitesPendingUserUpdates->has('users', '>', DB::raw(1));
        // I HAVE TO ADD THIS LINE ABOVE ^^
        $sitesPendingUserUpdates = $sitesPendingUserUpdates->get();

I return an array with 2 sites. One site with a populated user array and one with an empty user array. The site with the empty user array should not get returned.

not connecting to DB

im already set up all, but at the time to try install migrate utility "php artisan migrate:install" i get a SqlException, i cant find wich Exception it is, the only feedback i get is :

migrate:install [--database[="..."]]

this on Git Bash terminal over Windows 7.

looking on the logs of laravel the only feedback i get is this:

[2014-06-19 21:37:33] production.ERROR: exception 'yajra\Pdo\Oci8\Exceptions\SqlException' in C:\xampp\htdocs\pruebalaravel\vendor\yajra\laravel-pdo-via-oci8\src\yajra\Pdo\Oci8.php:74
Stack trace:
#0 C:\xampp\htdocs\pruebalaravel\vendor\yajra\laravel-oci8\src\yajra\Oci8\Connectors\OracleConnector.php(42): yajra\Pdo\Oci8->__construct('(DESCRIPTION = ...', 'ADMINISTRACION', '0rg4n1z4c10n', Array)
#1 C:\xampp\htdocs\pruebalaravel\vendor\yajra\laravel-oci8\src\yajra\Oci8\Connectors\OracleConnector.php(56): yajra\Oci8\Connectors\OracleConnector->createConnection('(DESCRIPTION = ...', Array, Array)
#2 C:\xampp\htdocs\pruebalaravel\vendor\yajra\laravel-oci8\src\yajra\Oci8\Oci8ServiceProvider.php(47): yajra\Oci8\Connectors\OracleConnector->connect(Array)
#3 [internal function]: yajra\Oci8\Oci8ServiceProvider->yajra\Oci8{closure}(Array, 'oracle')
#4 C:\xampp\htdocs\pruebalaravel\bootstrap\compiled.php(7228): call_user_func(Object(Closure), Array, 'oracle')
#5 C:\xampp\htdocs\pruebalaravel\bootstrap\compiled.php(7208): Illuminate\Database\DatabaseManager->makeConnection('oracle')
#6 C:\xampp\htdocs\pruebalaravel\vendor\laravel\framework\src\Illuminate\Database\Migrations\DatabaseMigrationRepository.php(167): Illuminate\Database\DatabaseManager->connection(NULL)
#7 C:\xampp\htdocs\pruebalaravel\vendor\laravel\framework\src\Illuminate\Database\Migrations\DatabaseMigrationRepository.php(115): Illuminate\Database\Migrations\DatabaseMigrationRepository->getConnection()
#8 C:\xampp\htdocs\pruebalaravel\vendor\laravel\framework\src\Illuminate\Database\Console\Migrations\InstallCommand.php(52): Illuminate\Database\Migrations\DatabaseMigrationRepository->createRepository()
#9 C:\xampp\htdocs\pruebalaravel\vendor\laravel\framework\src\Illuminate\Console\Command.php(112): Illuminate\Database\Console\Migrations\InstallCommand->fire()
#10 C:\xampp\htdocs\pruebalaravel\vendor\symfony\console\Symfony\Component\Console\Command\Command.php(252): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 C:\xampp\htdocs\pruebalaravel\vendor\laravel\framework\src\Illuminate\Console\Command.php(100): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 C:\xampp\htdocs\pruebalaravel\vendor\symfony\console\Symfony\Component\Console\Application.php(887): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 C:\xampp\htdocs\pruebalaravel\vendor\symfony\console\Symfony\Component\Console\Application.php(193): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Database\Console\Migrations\InstallCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 C:\xampp\htdocs\pruebalaravel\vendor\symfony\console\Symfony\Component\Console\Application.php(124): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 C:\xampp\htdocs\pruebalaravel\artisan(59): Symfony\Component\Console\Application->run()
#16 {main} [] []

and my database.php configuration is this:
'oracle' => array(
'driver' => 'pdo-via-oci8',
'host' => '192.168.6.3',
'port' => '1521',
'database' => 'XXX', //i put here the schema
'service_name' => 'XXX', //i put here my SID
'username' => 'myusername',
'password' => 'mypassword',
'charset' => '',
'prefix' => '',
),

so the fact is, i have the schema DB, the SID, my server is locally(that why the ip like 192.168....). the schema and the username had the same value.
we already know that oracle uses instances and schemas, not databases, so how should i fill the database.php if i had name of instance, name of schema, ip address of server, user and password???? so that laravel dont get with an error over the database name! please help meeee :(

i assume all config and drivers are correct(php, oci8, etc), cuz i tested a solo php file to connecting to oracle and the connection is stablished giving me a resource id.
Sooo what can i do?

Booleans saved as chars rather than int

Hi,

I'm curious as to whether there was a reason that booleans were stored as chars rather than ints.

The issue this causes is that any JSON returned from the server is then a string of "0" and "1" which are both truthy values in JavaScript meaning we always have to parseInt(data.paramName) to get an appropriate boolean value.

It seems the intention here is to use ints for booleans (?) or is that just to convert the char value to "0" & "1"?

If there's no reason for them being set as chars rather than ints then I propose this is changed. As it is part of the blueprint/creation of a table this shouldn't be a breaking change and I assume would mean new tables use ints.

Unit tests failing

Unit tests failing on PHP 5.4+ maybe due to Illuminate Database changes or something.

Failing tests:

  1. Oci8QueryBuilderTest::testUpdateLobMethod
  2. Oci8QueryBuilderTest::testOrderBys

Creating a CHAR column

I had an error when I tried to create a column of the type CHAR. I solved it by adding this function to the OracleGrammar class :

/**
 * Create the column definition for a char type.
 *
 * @param  \Illuminate\Support\Fluent  $column
 * @return string
 */
protected function typeChar(Fluent $column)
{
    return "char({$column->length})";
}

I don't know if this is normal.

Class 'yajra\Oci8\Oci8ServiceProvider' not found

im having this issue,although i followed your guide,
i even tried to make an alias but it also didnt work

Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_ERROR)
Class 'yajra\Oci8\Oci8ServiceProvider' not found
Open: E:\wamp\www\ctonew - Copy\vendor\laravel\framework\src\Illuminate\Foundation\ProviderRepository.php
*
* @param \Illuminate\Foundation\Application $app
* @param string $provider
* @return \Illuminate\Support\ServiceProvider
*/
public function createProvider(Application $app, $provider)
{
return new $provider($app);
}

invalid TNS with multiple address connection

Hi,
I use multiple connection host, and got this error from oracle (10g)
ORA-12154: TNS:could not resolve the connect identifier specified

I have to remove the first identifier from CONNECT_DATA to make it work.

index 7619f25..c87ad33 100644
--- a/src/yajra/Oci8/Connectors/OracleConnector.php
+++ b/src/yajra/Oci8/Connectors/OracleConnector.php
@@ -87,7 +87,7 @@ class OracleConnector extends Connector implements ConnectorInterface
                 }

                 // create a tns with multiple address connection
-                $config['tns'] = "(DESCRIPTION = {$address} (LOAD_BALANCE = yes) (FAILOVER = on) (CONNECT_DATA = {$config['database']} (SERVER = DEDICATED) (SERVICE_NAME = {$config['database']})))
+                $config['tns'] = "(DESCRIPTION = {$address} (LOAD_BALANCE = yes) (FAILOVER = on) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = {$config['database']})))";
             }
         }

Thanks.

Answer

Is working table relation correctly? I have a problem.

First
$ php artisan migrate

Migration table created successfully.
[Illuminate\Database\QueryException]
Error Code : 955
Error Message : ORA-00955: name is already used by an existing object
Position : 13
Statement : create index form_question_get_value_value_ on form_question_get_value ( value_type ) (SQL: create index form_question_get_value_value_ on form_question_get_value ( value_type ))

[yajra\Pdo\Oci8\Exceptions\SqlException]
Error Code : 955
Error Message : ORA-00955: name is already used by an existing object
Position : 13
Statement : create index form_question_get_value_value_ on form_question_get_value ( value_type )

migrate [--bench[="..."]] [--database[="..."]] [--force] [--path[="..."]] [--package[="..."]] [--pretend] [--seed]

After
$ php artisan migrate

[Illuminate\Database\QueryException]
Error Code : 955
Error Message : ORA-00955: name is already used by an existing object
Position : 13
Statement : create table form_question_get_value ( id number(10,0) not null, question_id number(10,0) not null, caption varchar2(255) null, value number(10,0) not null, value_type number(10,0) not null, created_at timestamp default CURRENT_TIMESTAMP not null, updated_at timestamp default CURRENT_TIMESTAMP not null, constraint form_question_get_value_id_pri primary key ( id ) ) (SQL: create table form_question_get_value ( id number(10,0) not null, question_id number(10,0) not null, caption varchar2(255) null, value number(10,0) not null, value_type number(10,0) not null, created_at timestamp default CURRENT_TIMESTAMP not null, updated_at timestamp default CURRENT_TIMESTAMP not null, constraint form_question_get_value_id_pri primary key ( id ) ))

[yajra\Pdo\Oci8\Exceptions\SqlException]
Error Code : 955
Error Message : ORA-00955: name is already used by an existing object
Position : 13
Statement : create table form_question_get_value ( id number(10,0) not null, question_id number(10,0) not null, caption varchar2(255) null, value number(10,0) not null, value_type number(10,0) not null, created_at timestamp default CURRENT_TIMESTAMP not null, updated_at timestamp default CURRENT_TIMESTAMP not null, constraint form_question_get_value_id_pri primary key ( id ) )

migrate [--bench[="..."]] [--database[="..."]] [--force] [--path[="..."]] [--package[="..."]] [--pretend] [--seed]

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

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?

Schema::drop thows "ORA-00972: identifier is too long"

Schema::drop() does not check if the column is an autoincrement before running this:

            // drop sequence for auto increment
        $this->connection->dropSequence("{$prefix}{$table}_{$col}_seq");
            // drop trigger for auto increment work around
        $this->connection->dropTrigger("{$prefix}{$table}_{$col}_trg");

Is it possible to check if it is an autoincrement column beforehand?

As a result I have a longer table name that is migrated successfully (that does not use autoincrement) however on rolling back I get the following:

  [Illuminate\Database\QueryException]
  ORA-00972: identifier is too long
  ORA-06512: at line 6 (SQL:
                        declare
                                e exception;
                                pragma exception_init(e,-4080);
                        begin
                                execute immediate 'drop trigger eventCurrentStatus_DEVICEGUID_trg';
                        exception
                        when e then
                                null;
                        end;)



migrate:reset [--database[="..."]] [--pretend]

Thanks for creating this extension!

dropIfExists not working

Hi,

Im having issue using the dropIfExists. My code is this
Schema::dropIfExists( 'XAMPPLE' );

Error Code : 955 Error Message : ORA-00955: name is already used by an existing object Position

But the drop method works:
Schema::drop( 'XAMPPLE' );

Thanks

Error: ORA-12505: TNS:listener does not currently know of SID given in connect descriptor

'oracle' => array(
'driver' => 'oracle',
'host' => '192.168.152.189',//server IP
'port' => '1521',
'database' => 'orcl', //SID
'username' => 'system',
'password' => '123456',
),
I've add this code in app/config/database.php
But I couldn't connected to Oracle with Laravel, from my client PC to Server.

show this Error: ORA-12505: TNS:listener does not currently know of SID given in connect descriptor

TIMESTAMP treated as DATE

Hi,

I've noticed that creating eloquent's timestamps() and softDeletes() results in corresponding CREATED_AT, UPDATED_AT and DELETED_AT fields to be of type DATE instead of TIMESTAMP.

Thanks!

Does Laravel-OCI8 support UTF-8 ?

Hello Arjay, we tried to post Arabic data to the oracle database but we found that the data isn't in the correct Arabic language. The problem caused in the save operation (Laravel receives the data correctly).

If we enter the data from navicat for oracle the data saves correctly.

what we have to change to avoid this issue ?

Thanks

Isn't ->pluck() working?

Laravel 4.1.28 + laravel-oci8 latest version.

In my model, I have a simple statement, e.g. :

$result = DB::table('ch_allegati')->where('numero_chiamata', '2014002822 ')->->where('id', 7)->pluck('estensione');

...which produces this SQL:

select t2.* from ( select rownum AS "rn", t1.* from (select estensione from ch_allegati where numero_chiamata = 2014002822 and id = 7) t1 ) t2 where t2."rn" between 1 and 1

If I run this query (from TOAD or SQL Plus), it returns one row and two columns ('rn', 'estensione'), instead of one row and one column ('estensione').

Eventually, after executing the statement, $result contains "1", which is the value of the 'rn' column, instead of the one of the column 'estensione'.

I am doing anything wrong?

Thank you.

Undefined index: driver

I just recently did a composer update on my project and now I am getting the error "ErrorException","message":"Undefined index: driver" "OracleConnector.php","line":32"

Is anyone else experiencing this? I have not changed any code...

'rn' value in response

Hi @yajra but what is this rn value? I'm getting it returned in one of my responses. Searched google for laravel "rn" and found myself at #12 .

I'm running a simple command in a controller method:

return SiteDevice::find($device_guid);

Getting the response:

{
    rn: "1",
    device_guid: "296946177",
    site_id: "4531",
    device_id: "10",
    device_num: "1",
    device_tag: "SYSTEM",
    description: "System Info"
}

query building error, need quotes around table field's name

Hello, I am using this package with Laravel 5 and Oracle 11.

The thing is, when I use the ORM, OracleElequent, and try to insert, I get Invalid Identifier around the field name itself, example:

$user = new User();
$user->name = 'Amin';
$user->save();

The query produced, and sent to Oracle is:
"Insert into user(name) values('Amin');
And Oracle returns an error, invalid identifier NAME, meaning it wants 'name' instead of name.

Writing Raw queries works fine as long as I add the quotations myself, but Query Builder isn't easy to modify.

Can you please help ?

Oracle Sequence

Hi Yajra,

When Im getting the current sequence value after insert it displays error.

ErrorException
Undefined property: stdClass::$id

public function lastInsertId($name)
{
// check if a valid name and sequence exists
if (!$name or !self::checkSequence($name))
return 0;

    $data = self::select("select {$name}.currval from dual");
    return $data[0]->id;
}

this error happens on both:
DB::lastInsertId('seq_name');
DB::currentSequenceValue('seq_name');

Thanks for this awesome driver!

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

Prefixed table trigger not using prefixed name

I have set up the 'prefix' attribute on my oracle connection to be "portal_" and have created a migration for a "categories" table. As expected, the migration created a "portal_categories" table, but it tried to create the sequence with the unprefixed name and failed.

[Illuminate\Database\QueryException]
ORA-00942: table or view does not exist (SQL:
create trigger categories_id_trg
before insert or update on categories
for each row
begin
if inserting and :new.id is null then
select categories_id_seq.nextval into :new.id from dual;
end if;
end;)

If I manually run the SQL changing "on categories" to "on portal_categories", everything else works fine.

Thanks for the great package, hope I can help.

A point i wanted to discuss

Originaly, my library was split in two, for good reasons that you didn't know about and i want to share those reasons with you.

At a base, the split was made to clearly disociate the two libraries:

  1. Provides the PDO support via userspace using OCI8 functions
  2. The other is just a wrapper to access oracle through any PDO driver, but mostly, in this case through the PDO-via-oci8

Merging the two inside the same project have benefits but also has draw backs!

Benefits

  1. Only one package to maintain
  2. Less dependencies to manage when installing through composer, more direct all in all
  3. Because of less packages, less fail points, you'd need very thorough testing to make sure each library does exactly what it has to do...

Draw backs

  1. I can no longuer substitute easily the PDO driver for something else, like a fork on PDO-via-OCI8 from someone else that could have a bug fix... I'm tributary to your whole library
  2. You are merging two libraries in one, thus giving two reasons to be to your project, if a problem arises, it will invariably hit all your users of your big library
  3. There are no standalone PDO-via-OCI8 driver anymore, if i want to slowly refactor my application to use PDO-via-OCI8 i can't do it anymore cause it doesn't exist...

Reason for drawback number 1

I'm currently developping a library that intercepts queries sent to PDO/Native libraries by acting as a proxy. This library will allow testing through expectations just like mockery does and act as a middle-man.

In the scenario where the two are split, it's easy to create a middleman for PDO that accepts another PDO inside of it or generates it on the fly based on options passed on to it.

But in your scenario it becomes impossible to do unless i create my own library that gives an additionnal connection that override's yours.

Thats why i would suggest you do back to 2 split libraries, at least, you are not coupling two different libraries together and letting people do the middle man!

Procedure

How to call and display oracle stored procedure?

oci8 for support oracle 12c AND issue of offset and limit order

first :oracle 12c support
i edited your package for support offset and limit support for pagination and other stuffs
and the way that package query for this 2 function if you wonder i will give it to you

second:
i edited the order of offset and limit in the array in order to compile the offset before limit

Laravel 5

Hi,
When you support laravel 5? thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.