CakeDC / cakephp-oracle-driver

CakePHP 3 Driver for Oracle Database
Other
40 stars 24 forks source link

Read from oracle table #11

Closed alex712 closed 7 years ago

alex712 commented 8 years ago

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

alex712 commented 8 years ago

Hello guys,

I got the data from oracle in this way in my controller's action:

$connection = ConnectionManager::get('default'); $results = $connection->execute('SELECT * FROM mytable')->fetchAll('assoc'); $query = $connection->newQuery();

Or another way:

$query->select(['field1', 'field2']) ->from('mytable') ->where(['id =' => 1]);

which works fine. But is not same as I am trying with a model:

$this->MyModel->find('all'); This way is giving me an error "ORA-00907: missing right parenthesis ". Can you help me with a suggestion please?

spout commented 8 years ago

@alex712 I have experienced the same issue, https://github.com/CakeDC/cakephp-oracle-driver/commit/739de49357809e809d8e974d715796b3b6931979 fixes it. But now I got another errors with constraints: Columns used in constraints must be added to the Table schema first.

alex712 commented 8 years ago

@spout thanks, that fixed my error. After I modified the file worked fine. Regarding your issue, I'm thinking because you're using constraints on columns. Have you tried to test with a table without constrains?

spout commented 8 years ago

@alex712 : it's simple constraints like foreign keys, cannot live without this. And I don't know how to bypass this kind of problem.

skie commented 7 years ago

hotfix merged. issue not reproduced anymore