Reputation: 9092
I guess that the way Zend use to build sql statement don't work with Oracle.
I'm using Oracle in my local Windows PC. My PHP works correct with Oracle already with oci8 extension, I configured following the link below:
http://www.oracle.com/technetwork/articles/technote-php-instant-084410.html
I'm trying to connect ZF2 with Oracle. I'm using the tutorial code at Zend website:
http://zf2.readthedocs.org/en/latest/index.html#userguide
This code works perfectly with mySQL. I'm changing the database configuration to use Oracle instead.
Below is my config:
< ?php
return array( 'db' => array(
'driver' => 'Oci8', 'host' => 'localhost/orcl', ), 'service_manager' => array( 'factories' => array( 'Zend\Db\Adapter\Adapter' => 'Zend\Db\Adapter\AdapterServiceFactory', ), ),
);
?>
< ?php
return array(
'db' => array( 'username' => 'test', 'password' => 'test', ),
);
After configuring, I try to browse the url, the error appear say "table or view does not exist". This is Oracle error, it means Zend connected to Oracle but something wrong in SQL statement.
After some debug, I see the sql statement is:
SELECT "album".* FROM "album"
It' error because Oracle don't want to receive double quote.
I tried some hard-code in file /Zend/Db/Adapter/Driver/Oci8/Statement.php, function setSql line 112, change to:
public function setSql($sql)
{
$this->sql = $sql;
$this->sql = "SELECT album.* FROM album";
return $this;
}
(remove double quote on query)
It's work!!!
I think there're some other configuration so make Zend work correctly.
Please help me! Thank you
Upvotes: 1
Views: 1875
Reputation: 11
Same problem was here: ZF2 IBM
Solution: quote_identifiers == false:
'db' => array(
'driver' => $dbParams['driver'],
'connection_string' => $dbParams['database'],
'username' => $dbParams['username'],
'password' => $dbParams['password'],
'character_set' => $dbParams['character_set'],
'platform_options' => array('quote_identifiers' => false)
),
Upvotes: 1