0

iam using zendFramework2.5.1 with Oracle 11g. Database connectivity/DML queries executing fine.

i need to export the column names of a table present in oracleDB. i use Zend\Db\TableGateway\TableGateway for DB connectivity. i learnt that by using Zend\Db\Metadata\Metadata column names could be retrived. Using the $tableObject (as shown below), i retrieved the existing adapter object and table name. No issues here.

$metadataObject = new Metadata($tableObject->getAdapter());
$tableName = $tableObject->getTable();

But when below code executes, exception occurs.

$metadataTable = $metadataObject->getTable($tableName); 

Exception

Zend\Db\Adapter\Exception\RuntimeException

File:
C:\wamp\www\zfc2\vendor\zendframework\zend-db\src\Adapter\Driver\Oci8\Statement.php:260
Message:
ORA-01745: invalid host/bind variable name
Stack trace:
#0 C:\wamp\www\zfc2\vendor\zendframework\zend-db\src\Metadata\Source\OracleMetadata.php(137):    Zend\Db\Adapter\Driver\Oci8\Statement->execute(Array)
#1 C:\wamp\www\zfc2\vendor\zendframework\zend-db\src\Metadata\Source\AbstractSource.php(316): Zend\Db\Metadata\Source\OracleMetadata->loadConstraintData('CSS_MILIBRIS_US...', 'LNK1DB')
#2 C:\wamp\www\zfc2\vendor\zendframework\zend-db\src\Metadata\Source\AbstractSource.php(142): Zend\Db\Metadata\Source\AbstractSource->getConstraints('CSS_MILIBRIS_US...', 'LNK1DB')
#3 C:\wamp\www\zfc2\vendor\zendframework\zend-db\src\Metadata\Metadata.php(178): Zend\Db\Metadata\Source\AbstractSource->getTable('CSS_MILIBRIS_US...', NULL)
#4 C:\wamp\www\zfc2\module\Kiosque\src\Kiosque\Controller\LandingController.php(76): Zend\Db\Metadata\Metadata->getTable('CSS_MILIBRIS_US...')
#5 C:\wamp\www\zfc2\vendor\zendframework\zend-mvc\src\Controller\AbstractActionController.php(82):

i referred the ZendDBManual Link. and tried the same. i analyzed the exception,but couldn't proceed further with what i have analyzed.
What i observed going through websites is, this has something to do with accessing restricted variables present in oracle (am not sure about it). . Any help in providing solution for this issue is much appreciated.

1 Answer 1

0

i got a solution for this. i analyzed/browsed/went through the logs. i found out that zend provides a metadata class for oracle which is

use Zend\Db\Metadata\Source\OracleMetadata;

i kindof misthought the function which could retrieve column names of a table. The correct function to retrieve the column names of table is getColumnNames

$metadata = new OracleMetadata($tableObject->getAdapter());
$myTableName = $tableObject->getTable();
$metadataTable = $metadata->getColumnNames($myTableName);  

This same logic has to work with Metadata class too i think. But i didnt verify it

use Zend\Db\Metadata\Metadata
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.