Code Monkey home page Code Monkey logo

cakephp-oracle-driver's Introduction

CakePHP 4 Driver for Oracle Database

Downloads Latest Version

Versions and branches

CakePHP CakeDC Oracle Driver Plugin Tag Notes
4.0 5.x 5.0.0 stable
^3.8 <4.0 4.x 4.0.0 stable
^3.7 3.x 3.0.0 stable

Installation

You can install this plugin into your CakePHP application using Composer.

The recommended way to install Composer packages is:

composer require cakedc/cakephp-oracle-driver

Ensure the Oracle Plugin is loaded in your src/Application.php file

    /**
     * {@inheritdoc}
     */
    public function bootstrap()
    {
        parent::bootstrap();

        $this->addPlugin(\CakeDC\OracleDriver\Plugin::class, ['bootstrap' => true]);
    }

Requirements

  • CakePHP 4.0+
  • an Oracle PHP extension
    • OCI8 (PHP extension built with PHP)
    • PDO_OCI (PHP extension built with PHP)

Notes on extensions

For full support, it is recommended to run the OCI8 extension if possible.

While PDO_OCI might be simpler to set up, there are some limitations (e.g. it doesn't support the stored code layer, so only the SQL layer will be available.)

Datasource configuration

Here is an example datasource configuration:

        <?php
return [
    'Datasources' => [
        'default' => [
            'className' => 'CakeDC\OracleDriver\Database\OracleConnection',
            'driver' => 'CakeDC\OracleDriver\Database\Driver\OracleOCI', # For OCI8
            #'driver' => 'CakeDC\\OracleDriver\\Database\\Driver\\OraclePDO', # For PDO_OCI
            'persistent' => true,           // Database persistent connection between http requests
            'host' => 'oracle11g',          // Database host name or IP address
            //'port' => 'nonstandard_port', // Database port number (default: 1521)
            'username' => 'blogs',          // Database username
            'password' => 'password',       // Database password
            'database' => 'XE',             // Database name (maps to Oracle's `SERVICE_NAME`)
            'sid' => '',                    // Database System ID (maps to Oracle's `SID`)
            'instance' => '',               // Database instance name (maps to Oracle's `INSTANCE_NAME`)
            'pooled' => '',                 // Database pooling (maps to Oracle's `SERVER=POOLED`)
            'flags' => [],                  // Database low level parameters for OCI or PDO connection. Auto-generated by default
            'encoding' => '',               // Database charset (default same as database charset)
            'init' => [],                   // Array of queries executed at connection
            'cacheMetadata' => true,        // Enable cakephp schema caching
            'server_version' => 12,        // Oracle server numeric version ex.: 11,12,19
            'autoincrement' => true,        // Enable autoincrement insteadof custom triggers in case of oracle 12+
        ]
    ]
];

For oracle 12g should be used config settings server_version with value 12. If version is greater or equals to 12 the plugin uses new oracle pagination features.

Additional if autoincrement is set to true, then for primary keys in fixtures used new orale autoincreament feature.

As you can see, the className and driver need switched to Oracle-specific classes. The driver will depend on whether you want to use PDO or not. The database name "XE" in this case, is defined as the SERVICE_NAME in Oracle's system-wide tnsnames.ora file.

The above array format is translated into Oracle's Easy Connection Naming. You can find the logic for this in \CakeDC\OracleDriver\Database\Driver\OracleBase::getDSN().

Documentation

For documentation, as well as tutorials, see the docs directory of this repository.

Roadmap

  • Provide full compatibility with Phinx based migrations
  • Provide compatibility with Oracle database version 12
  • Transform data types into native PHP types when returned form the database @todo copy todos to the roadmap

Support

For bugs and feature requests, please use the issues section of this repository.

Commercial support is also available, contact us for more information.

Contributing

This repository follows the CakeDC Plugin Standard. If you'd like to contribute new features, enhancements or bug fixes to the plugin, please read our Contribution Guidelines for detailed instructions.

License

Copyright 2016 - 2020 Cake Development Corporation (CakeDC). All rights reserved.

Licensed under the MIT License. Redistributions of the source code included in this repository must retain the copyright notice found in each file.

cakephp-oracle-driver's People

Contributors

alphp avatar dependabot[bot] avatar ivasse avatar skie avatar steinkel avatar tyl13 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cakephp-oracle-driver's Issues

Tests can't be executed.

I run phpunit, but error.

[vagrant@localhost public]$ vendor/bin/phpunit 
PHPUnit 5.2.9 by Sebastian Bergmann and contributors.

PHP Warning:  Fixture creation for "comments" failed "ORA-00904: : invalid identifier" in /home/dev/public/vendor/cakephp/cakephp/src/TestSuite/Fixture/TestFixture.php on line 303

Warning: Fixture creation for "comments" failed "ORA-00904: : invalid identifier" in /home/dev/public/vendor/cakephp/cakephp/src/TestSuite/Fixture/TestFixture.php on line 303
PHP Fatal error:  Uncaught exception 'CakeDC\OracleDriver\Database\OCI8\OCI8Exception' with message 'ORA-01747: invalid user.table.column, table.column, or column specification' in /home/dev/public/src/Database/OCI8/OCI8Exception.php:26
Stack trace:
#0 /home/dev/public/src/Database/OCI8/OCI8Statement.php(251): CakeDC\OracleDriver\Database\OCI8\OCI8Exception::fromErrorInfo(Array)
#1 /home/dev/public/vendor/cakephp/cakephp/src/Database/Statement/StatementDecorator.php(171): CakeDC\OracleDriver\Database\OCI8\OCI8Statement->execute(NULL)
#2 /home/dev/public/src/Database/Statement/OracleStatement.php(43): Cake\Database\Statement\StatementDecorator->execute(NULL)
#3 /home/dev/public/vendor/cakephp/cakephp/src/Database/Connection.php(270): CakeDC\OracleDriver\Database\Statement\OracleStatement->execute()
#4 /home/dev/public/vendor/cakephp/cakephp/src/Database/Query.php(188): Cake\Database\Connection->run(Object(Cake\Database\Query))
#5 /home/dev/public/vendor/cakephp/cakephp/src/TestSuite/Fixture/TestFixture.php(347): Cake\Database\Q in /home/dev/public/src/Database/OCI8/OCI8Exception.php on line 26

Fatal error: Uncaught exception 'CakeDC\OracleDriver\Database\OCI8\OCI8Exception' with message 'ORA-01747: invalid user.table.column, table.column, or column specification' in /home/dev/public/src/Database/OCI8/OCI8Exception.php:26
Stack trace:
#0 /home/dev/public/src/Database/OCI8/OCI8Statement.php(251): CakeDC\OracleDriver\Database\OCI8\OCI8Exception::fromErrorInfo(Array)
#1 /home/dev/public/vendor/cakephp/cakephp/src/Database/Statement/StatementDecorator.php(171): CakeDC\OracleDriver\Database\OCI8\OCI8Statement->execute(NULL)
#2 /home/dev/public/src/Database/Statement/OracleStatement.php(43): Cake\Database\Statement\StatementDecorator->execute(NULL)
#3 /home/dev/public/vendor/cakephp/cakephp/src/Database/Connection.php(270): CakeDC\OracleDriver\Database\Statement\OracleStatement->execute()
#4 /home/dev/public/vendor/cakephp/cakephp/src/Database/Query.php(188): Cake\Database\Connection->run(Object(Cake\Database\Query))
#5 /home/dev/public/vendor/cakephp/cakephp/src/TestSuite/Fixture/TestFixture.php(347): Cake\Database\Q in /home/dev/public/src/Database/OCI8/OCI8Exception.php on line 26

I think this driver can't use CakePHP's CommentsFixture.
How do you run tests?

Persistence ?

Does it have a persistance parameter ? I would like to leave the connection to the database opened.

info : cakePHP 3.7+ some deprecated messages (16384) for OracleOCI::connection()

For information:

Deprecated (16384): CakeDC\OracleDriver\Database\Driver\OracleOCI::connection() is deprecated. Use setConnection()/getConnection() instead. - ...cakedc\cakephp-oracle-driver\src\Database\Driver\OracleOCI.php, line: 34

Deprecated (16384): CakeDC\OracleDriver\Database\Driver\OracleOCI::connection() is deprecated. Use setConnection()/getConnection() instead. - ...cakedc\cakephp-oracle-driver\src\Database\Driver\OracleBase.php, line: 74

corrected on my local version.

OracleOCI extension php

Hello,

to connect to oracle database from my project cakephp, Im using CakeDC, it's working perfectly on windows, but not with centos

Database driver CakeDC\OracleDriver\Database\Driver\OracleOCI cannot be used due to a missing PHP extension or unmet dependency

php -i |grep oci

/etc/php.d/oci8.ini,
/etc/php.d/pdo_oci.ini
oci8
oci8.connection_class => no value => no value
oci8.default_prefetch => 100 => 100
oci8.events => Off => Off
oci8.max_persistent => -1 => -1
oci8.old_oci_close_semantics => Off => Off
oci8.persistent_timeout => -1 => -1
oci8.ping_interval => 60 => 60
oci8.privileged_connect => Off => Off
oci8.statement_cache_size => 20 => 20
PDO drivers => pgsql, sqlite, sqlsrv, oci

can you help me please, I'm blocked since 2 days

Triple quote on default value

I have a table with some default value, when I generated DDL with sql developer i get this:

CREATE TABLE "CLA"."SOL_BANDO"
( "ID_BANDO" NUMBER,
"COD_TIPO_BANDO" VARCHAR2(20 BYTE),
"DESCRIZIONE" VARCHAR2(500 BYTE),
"NOTE" VARCHAR2(4000 BYTE),
"DATA_APERTURA" DATE,
"DATA_CHIUSURA" DATE,
"ANNO" NUMBER,
"LINK_BANDO" VARCHAR2(500 BYTE),
"FLAG_SOSPESO" CHAR(1 BYTE) DEFAULT 'N',

The driver with createSql write

CREATE TABLE SOL_BANDO (
id_bando NUMBER NOT NULL,
cod_tipo_bando VARCHAR2(20) DEFAULT NULL,
descrizione VARCHAR2(500) DEFAULT NULL,
note VARCHAR2(4000) DEFAULT NULL,
data_apertura TIMESTAMP DEFAULT NULL,
data_chiusura TIMESTAMP DEFAULT NULL,
anno NUMBER DEFAULT NULL,
link_bando VARCHAR2(500) DEFAULT NULL,
flag_sospeso VARCHAR2(1) DEFAULT '''N''',

Look at default value generated

Above
"FLAG_SOSPESO" CHAR(1 BYTE) DEFAULT 'N',
Bottom
flag_sospeso VARCHAR2(1) DEFAULT '''N''',

when this code is excute i get an oracle error

Report error - Errore SQL: ORA-01401: valore inserito troppo grande per la colonna 01401. 00000 - "inserted value too large for column" *Cause: The value inserted was too large for the given column. *Action: Do not insert a value greater than what the column can hold.

There is a way to overdue this? About the number of single quote generated around default value,
maybe with some configuration parameters?

Thanks in advance

Sorry for my poor English

5.x Always quote SELECT identifier for Oracle

Oracle auto converts unquoted identifiers to upper case.
Unquoted select aliases brake the cakePHP camelCase table Alias.

cakePHP commit cakephp/cakephp@4949b72 "Quote SELECT identifiers only if autoquoting is enabled."

The postgres driver is modified to always apply select aliases cakephp/cakephp@49608e9#diff-e71e42d8a65ac8e52edc9657223c9f8c Always quote SELECT identifier for Postgres.

The Oracle driver need the same modification as the postgres driver

Does not generate relationships in the Model Table file

I have two simple tables, the second is made with a foreign key to the first.
When I use "bake" to generate code in the "initialize" function, SecondTable file, I don't get, for example: $this->belongsTo('Firsts', [
'foreignKey' => 'first_id'.
joinType' => 'INNER'
])
Cakephp: 3.5
The connection is ok, but no relationship is ever generated.
Can you suggest something to me?

CalcCodeFixture don't create Oracle Package.

I run tests/TestCase/ORM/MethodTest.php , an error have occurred.

[vagrant@localhost public]$ vendor/bin/phpunit --bootstrap ./tests/bootstrap.php tests/TestCase/ORM/MethodTest.php 
PHPUnit 5.2.9 by Sebastian Bergmann and contributors.

E                                                                   1 / 1 (100%)

Time: 2.02 seconds, Memory: 5.75Mb

There was 1 error:

1) CakeDC\OracleDriver\Test\TestCase\ORM\MethodTest::testMethodCall
Cake\Database\Exception: Cannot describe CALC.SUM. Method not found.

/home/dev/public/src/Database/Schema/MethodsCollection.php:111
/home/dev/public/src/ORM/Method.php:125
/home/dev/public/src/ORM/Request.php:49
/home/dev/public/src/ORM/Method.php:232
/home/dev/public/tests/TestCase/ORM/MethodTest.php:30

FAILURES!
Tests: 1, Assertions: 0, Errors: 1.

I run this test again after I created calc package, this test is success.

[vagrant@localhost public]$ vendor/bin/phpunit --bootstrap ./tests/bootstrap.php tests/TestCase/ORM/MethodTest.php 
PHPUnit 5.2.9 by Sebastian Bergmann and contributors.

.                                                                   1 / 1 (100%)

Time: 2.76 seconds, Memory: 6.25Mb

OK (1 test, 5 assertions)

I think CalcCodeFixture don't create Oracle Package.

OracleBufferedStatement failure after CakePHP 3.7

CakePHP 3.7 refactored BufferedStatement to use StatementInterface instead of StatementDecorator:
cakephp/cakephp@35dcf38

This removes the protected variable _statement in favor of statement:
https://github.com/cakephp/cakephp/blob/1f6fd21ca27ffc88fa88506a400b94a809e29254/src/Database/Statement/BufferedStatement.php#L43

As a result, recent calls to fetch() will fail with:

Exception: Call to a member function fetch() on null in [vendor/cakedc/cakephp-oracle-driver/src/Database/Statement/OracleBufferedStatement.php, line 36]
2019-03-06 18:24:03 Error: [Error] Call to a member function fetch() on null in vendor/cakedc/cakephp-oracle-driver/src/Database/Statement/OracleBufferedStatement.php on line 36
Stack Trace:
#0 vendor/cakedc/cakephp-oracle-driver/src/Database/Statement/OracleStatement.php(98): CakeDC\OracleDriver\Database\Statement\OracleBufferedStatement->fetch('num')
#1 vendor/cakephp/cakephp/src/Database/Schema/Collection.php(65): CakeDC\OracleDriver\Database\Statement\OracleStatement->fetch()
#2 vendor/cakephp/bake/src/Shell/Task/ModelTask.php(1093): Cake\Database\Schema\Collection->listTables()
#3 vendor/cakephp/bake/src/Shell/Task/ModelTask.php(1046): Bake\Shell\Task\ModelTask->_getAllTables()
#4 vendor/cakephp/bake/src/Shell/Task/ModelTask.php(1061): Bake\Shell\Task\ModelTask->listAll()
#5 vendor/cakephp/bake/src/Shell/BakeShell.php(258): Bake\Shell\Task\ModelTask->listUnskipped()
#6 vendor/cakephp/cakephp/src/Console/Shell.php(518): Bake\Shell\BakeShell->all()
#7 vendor/cakephp/cakephp/src/Console/ShellDispatcher.php(230): Cake\Console\Shell->runCommand(Array, true, Array)
#8 vendor/cakephp/cakephp/src/Console/ShellDispatcher.php(182): Cake\Console\ShellDispatcher->_dispatch(Array)
#9 vendor/cakephp/cakephp/src/Console/ShellDispatcher.php(128): Cake\Console\ShellDispatcher->dispatch(Array)
#10 bin/cake.php(33): Cake\Console\ShellDispatcher::run(Array)
#11 {main}

Code at fault is minimally:

$record = $this->_statement->fetch($type);

and

5.x Driver config() function always returns null values

The config function of ConfigTrait returns always null values so _transformValueCase and _transformFieldCase doesn't apply the case setted in configuration.

src/Config/ConfigTrait.php

if (!$this->_configInitialized) {
    $this->_config = $this->_defaultConfig;
    $this->_configInitialized = true;
}

I think the problem is that ConfigTrait reads _defaultConfig which is never setted, instead of merge _config values with _baseConfig.

Lowercase column names

Hello,

How can i get the result sets having the column names in lowercase as i can't find in the docs?
At this point i am using an external method that uses array_map and applies array_change_key_case to the array.
Thanks!

NLS_NUMERIC_CHARACTERS problem for ptBR Database

We're having problems using the driver with our database because of our numeric character configuration. I've found a solution here but it doesn't look good to change the plugin itself.

Is there a more organized solution for that? Using PDO maybe?

Thanks for the awesome plugin.

Add cacheMetadata key to the config example in README

The example configuration en REAME does not have the cacheMetadata key, and while I know that it's something that's beyond the scope of this plugin I guess that many others (as I did), will copy it as it's and use it in its project configs.

Without that key CakePHP won't cache the schema, and it will be quering for it every time, hitting down performance.

<?php
return [
    'Datasources' => [
        'default' => [
            'className' => 'CakeDC\OracleDriver\Database\OracleConnection',
            'driver' => 'CakeDC\OracleDriver\Database\Driver\OracleOCI', # For OCI8
            #'driver' => 'CakeDC\\OracleDriver\\Database\\Driver\\OraclePDO', # For PDO_OCI
            'host' => 'oracle11g',          # Database host name or IP address
            //'port' => 'nonstandard_port', # Database port number (default: 1521)
            'username' => 'blogs',          # Database username
            'password' => 'password',       # Database password
            'database' => 'XE',             # Database name (maps to Oracle's `SERVICE_NAME`)
            'sid' => '',                    # Database System ID (maps to Oracle's `SID`)
            'instance' => '',               # Database instance name (maps to Oracle's `INSTANCE_NAME`)
            'pooled' => '',                 # Database pooling (maps to Oracle's `SERVER=POOLED`)
            /**
             * tell cakephp to cache schema
             */
            'cacheMetadata' => true,
        ]
    ]
];

Call Oracle Procedure with Array

I wanna to passing array into my store procedure but there didnt appear to support.
Please teach me how way i can pass through array into my store procedure.
Thanks and sorry for my poor English

Pagination error

Hello.

I'm starting to use the plug-in with Cakephp 4 and this is causing the problem below when accessing the user index:

1. Notice (8): Undefined index: count [CORE\src\Database\FieldTypeConverter.php, line 127].

And this error still occurs:

1. Argument 1 passed to Cake \ ORM \ Entity :: __ construct () must be of the type array, bool given, called in C: \ Developer \ xampp \ htdocs \ sispcmi \ vendor \ cakephp \ cakephp \ src \ ORM \ ResultSet.php on line 544

Does anyone know what these problems can be and how to fix them ???

I tested with MySQL and the error does not occur.

Thanks.

insert or update in cakePHP 3.6

The commit 8d5f5c0 merged in master for adding CakePHP 3.6 compatibility added a regression.
With the commit 8d5f5c0 only select statement can be done. Insert or update statements always fails.

From 8d5f5c0

-        if ($isObject && $query->bufferResults() === false || $disableBuffer) {
-            $statement->bufferResults(false);
+        if ($isObject && $query->isBufferedResultsEnabled() === false || $disableBuffer) {
+            $statement->enableBufferedResults(false);

The exepresion $query->bufferResults() should be replaced with $query->isBufferedResultsEnabled() in cakePHP 3.6

But $statement->enableBufferedResults(false) doesn't exist and $statement->bufferResults(false); should be keep in place

Stored Procedure Problem - ORA 06502, ORA 06512

Good afternoon,

I have implemented exactly the example found in https://github.com/CakeDC/cakephp-oracle-driver/blob/4.x/docs/Methods.md, however, I have got the following error:

image

PHP Code:

public function inicio() {

        $method = \CakeDC\OracleDriver\ORM\MethodRegistry::get('CalcSum', ['method' => 'PKG_COMPRAS.SOMA']);
        $request = $method->newRequest(['PRIMEIRO' => 5, 'SEGUNDO' => 10]);
        // $request->isNew() would return true at this point
        $method->execute($request);
        // $request->isNew() would return false at this point, as it's executed already
        echo $request->result(); // 15
    }

Oracle Function:

function soma(primeiro in number, segundo  in number) return number is	
	begin	
		return primeiro + segundo;	
	end;

array_combine error as a result of find()->toArray()

Hello,
The information does not come up when I try a simple query below. can you check?

$this->loadModel('ModelName');
$results = $this->{ModelName}->find()->toArray();

Undefined index: CORE\src\Database\FieldTypeConverter.php, line 127
array_combine() ->CORE\src\ORM\ResultSet.php, line 469


This way everything works perfectly:
$connection = ConnectionManager::get('oracle');
$results = $connection->execute('SELECT * FROM TABLENAME')->fetchAll('assoc');

ORA-00972: identifier is too long

Oracle has a 30-character limit for identifiers, including aliases.
Cake creates field aliases using the pattern "Tablealias__fieldname", which not infrequently results in more than 30 characters, especially in the legacy systems I deal with.
I'd be more than happy to leave my own Cake 3 Oracle driver behind as a historical relic, but I can't switch to your much more robust driver without this issue being addressed somehow.
I'm genuinely embarrassed to exhibit this code, but here's the quick-and-dirty workaround I did in my driver:
snelg/cakephp-3-oracle@e7feaa0

So that's a general idea for one solution or, more likely, an example of what to avoid at all costs :)

OCI8Connection: incomplete recognition of the configuration ?

DataSource configuration, in config\app.php, is NOT 100% recognized,
especially options like charset, persistent, etc…

Option charset is not recognized in this function :
https://github.com/CakeDC/cakephp-oracle-driver/blob/master/src/Database/OCI8/OCI8Connection.php#L55-59

because in file:
https://github.com/CakeDC/cakephp-oracle-driver/blob/master/src/Database/Driver/OracleOCI.php#L20-30

There seems to be a typo.

protected function _connect($dsn, array $config)
{
//why only config[flags] and not all config from DataSource in App.php ?
//$connection = new OCI8Connection($dsn, $config['username'], $config['password'], $config['flags']);

//SHOULD IT BE ?
$connection = new OCI8Connection($dsn, $config['username'], $config['password'], $config);

// now works fine for me and charset option is now recognized.
// Solved my problem of charset conversion.

    $this->setconnection($connection);
    return true;
}

Anyway thanks for making the plugin by the way, works great !

5x : strtolower() expects parameter 1 to be string, null given

Having several indexes on a table give error : "strtolower() expects parameter 1 to be string, null given" at line 515 in ROOT/vendor/cakedc/cakephp-oracle-driver/src/Database/Schema/OracleSchema.php

        if ( strtolower($tableIndex['is_primary']) === 'p') {

when an index in not a primary index $tableIndex['is_primary'] is null

Driver's config is broken by empty $_defaultConfig

In MySQL driver's behavior:
$this->_config is initialized by $_baseConfig.
e.g.)
https://github.com/cakephp/cakephp/blob/master/src/Database/Driver/Mysql.php#L34

In this dirver's behavior:
$this->_config is initialized by $_baseConfig,
but $this->_config is overwrite by empty $_defaultConfig.

https://github.com/CakeDC/cakephp-oracle-driver/blob/master/src/Database/Driver/OracleBase.php#L31
https://github.com/CakeDC/cakephp-oracle-driver/blob/master/src/Config/ConfigTrait.php#L80
https://github.com/CakeDC/cakephp-oracle-driver/blob/master/src/Config/ConfigTrait.php#L244

; sorry, I can speak english little...

I want to use 'case' => 'lower' option, but I can't use bacause this problem.

https://github.com/CakeDC/cakephp-oracle-driver/blob/master/src/Config/ConfigTrait.php#L80
https://github.com/CakeDC/cakephp-oracle-driver/blob/master/src/Config/ConfigTrait.php#L244

I rewrite
$this->_config = $this->_defaultConfig;
to
$this->_config = $this->_baseConfig;

Application run very well, but I can't judge this fix is good/bad..

Plugin for PHP 8

Recently install cakephp 4 over PHP 8 and this work good and faster, less the cakedc oracle plugin not working. Version PDO and OCI is different in OCI8Statement.php file.

Any option of upgrade this plugin?

Columns used in index IDX_NAME in table TBL_NAME was not found

Hi, i get this error with our application:

Columns used in index "idx_f_cognome" in table "anagrafica_0" must be added to the Table schema first. The column "sys_nc00020$" was not found

This happens because the index is not a table column but is a column expressions.

I don't know if this is a common things, but we have this kind of index in our databases.
And this is blocking for ORM and cake model generation.
We have a index with name idx_f_cognome that has a columns SYS_NC00020$ who is a column expressions SUBSTR("COGNOME",1,50).

So in the code
.... /vendor/cakedc/cakephp-oracle-driver/src/Database/Schema/OracleSchema.php at line 535

if ($isIndex) {
$table->addIndex($keyName, [
'type' => $type,
'columns' => $columns,
]);
this exception happens

Im not DBA and can't' modifiy the db structure,
Also i cant make a view of this table,
but i think it maybe be a good thing having a list of items, index, constraint etc to skip for the model generation, if it's possibile.
Bye

5.x Foreign keys not selected

When driver search for foreign keys doesn't converts the related column names in the selected case, so throw the following error:

Error: [InvalidArgumentException] Unable to load `Roles` association. 
Ensure foreign key in `Users` is selected. in /var/www/html/vendor/cakephp/cakephp/src/ORM/EagerLoader.php on line 662

"FROM DUAL" incorrectly appended when "from" at begin of line

See Database/Driver/OracleBase.php line 175:

if (strpos($statement, 'select') !== 0 || preg_match('/ from /', $statement)) {

When the "from" part of the query is at the start of a line (formatted for multiple lines), FROM DUAL is appended to the statement, causing the query to fail. I fixed the query by adding a space before from. We should be able to fix OracleBase.php by changing the regular expression to /\sfrom\s/, allowing any whitespace.

Can't use latin characters

Hi, i have spanish or latin characters store in the database such as "áéíóú" but when i make a get query word return without the accent marks "aeiou".

this is my connection

'default' => [
	'className' => 'CakeDC\OracleDriver\Database\OracleConnection',
	'driver' => 'CakeDC\OracleDriver\Database\Driver\OracleOCI',
	'persistent' => false,
	'host' => '127.0.0.1',            
	'username' => 'user',
	'password' => 'pass',
	'database' => 'orcl',
	'encoding' => 'utf8',            
	'timezone' => 'UTC',
	'flags' => ['charset' => 'AL32UTF8'],
	'cacheMetadata' => true,
	'log' => false,
	'quoteIdentifiers' => false,
	'url' => env('DATABASE_URL', null),
]

I've tried to set NLS_LANGUAGE='LATIN AMERICAN SPANISH' NLS_TERRITORY='AMERICA' in the ALTER SESSION of the OracleBase.php file too.

any help?

Bake a model when you are connected to an oracle database

Is it possible to use bake tool to bake a model when you are connected to a oracle database?
I tried to use bake model and I get this
Exception: Database driver CakeDC\OracleDriver\Database\Driver\OracleOCI cannot be used due to a missing PHP extension or unmet dependency in [/var/www/html/test/vendor/cakephp/cakephp/src/Database/Connection.php, line 169]

Oracle Field XMLTYPE

In one of my tables I have a field of type XMLTYPE. Retrieving this, throws the Exception "Unsupported File Type". As soon as I delete the field from the table everything works fine. Do you know this error, and do you know any workaround? Checked my whole System and I'm afraid the error comes from the oracle driver.

Class CakeDC\OracleDriver\Database\Type\CursorType not found

Hi,

I have installed OracleDriver in CakePHP 3 without composer because I can't use it in my work.

So when I copy package in CakePHP plugins folder i get error : Class 'CakeDC\OracleDriver\Database\Type\CursorType' not found.

I think it's a miss config in composer.json or another, I don't know !

Sorry for my bad English !

Thank you for your help !

Floats in database returns with no decimals

Hi, I have quantities store in the oracle like 17.12345 but in a "find()" instruction i get the number as 17 with no decimals.

That field in oracle is DataType: Number with Precision: 22 and Scale: 8.

This is what the query returns

\src\Controller\ConsultasController.php (line 115) [ (int) 0 => object(App\Model\Entity\Padron) { ... 'CANTIDAD' => (float) 17, <---- '[new]' => false, '[accessible]' => [ '*' => true ], '[dirty]' => [], '[original]' => [], '[virtual]' => [], '[errors]' => [], '[invalid]' => [], '[repository]' => 'Padron' } ]

Any idea??

Cake\Database\Driver and Cake\Database\Driver\PDODriverTrait define the same property ($_connection)

After update from cakephp 3.5 to 3.7.4, i have the following error

Strict (2048): Cake\Database\Driver and Cake\Database\Driver\PDODriverTrait define the same property ($_connection) in the composition of CakeDC\OracleDriver\Database\Driver\OracleBase. This might be incompatible, to improve maintainability consider using accessor methods in traits instead. Class was composed [ROOT/vendor/cakedc/cakephp-oracle-driver/src/Database/Driver/OracleBase.php, line 297]

using PHP 5.6.

The cakephp-oracle-driver can't execute query with cakephp 3.7.4

OracleOCI default configuration

For OCI configuration $config['persistent'] and $config['encoding'] setting are ingnored.

As explain in #38 persistent and encoding setting can be defined in the $config['flags']['persistent'] and $config['flags']['charset'].

The default value for $_baseConfig['encoding'] => 'utf8' is never used and the charset default value for the connection is set to the database charset.

OracleBase inccorectly assumes that the tableName does not hold the schema too.

Describe the Bug

When the driver tries to auto-increment the sequence, the table variable can hold the Schema. So,

select sequence_name from user_tab_identity_cols where table_name='$tableName' and column_name='$columnName'

comes back with no result since the table_name isn't expecting the Schema too. The other issue with the above is that it expects that the user to have a sequence for it that it may not.

To reproduce

Have a database setup that has a user with access to another Schema that is not its own. In the app_local config, set the schema to that one and the username to the user that has access to it. Make sure autoincrement is set to true and try to save a new item into a table without stating what its primary key should be set to. When it tries to do the first query in this function then it should return a result that is false.

Expected behavior

I expect the result to not be false because the sequence does exists, but it's table_name does not include the schema.

Impact on your work

The function does not work as intended and does not allow me to insert a new item into the table.

Additional context

This could probably be fixed in the lastInsertId function and just have the schema passed to the _autoincrementSequenceId function.

Read from oracle table

Hello guys,

I installed cake 3.2 and oracle driver from composer. I configured database connection. All good until I'm trying to bake a Model - I'm getting 2 errors in my console:

Warning: Warning (2): oci_bind_by_name(): ORA-01036: illegal variable name/number in [my_server\vendor\cakedc\cakephp-oracle-driver\src\Database\OCI8\OCI8Statement.php, line 184]

Exception: ORA-00907: missing right parenthesis in [my_server\vendor\cakedc\cakephp-oracle-driver\src\Database\OCI8\OCI8Exception.php, line 26]

My real problem is that I can't create a Model for my table. Can you please help me with any suggestion? Regards

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.