Delicious Bookmark this on Delicious Share on Facebook SlashdotSlashdot It! Digg! Digg



PHP : Function Reference : SDO Relational Data Access Service Functions : SDO_DAS_Relational::executePreparedQuery

SDO_DAS_Relational::executePreparedQuery

Executes an SQL query passed as a prepared statement, with a list of values to substitute for placeholders, and return the results as a normalised data graph. ()
SDODataObject SDO_DAS_Relational::executePreparedQuery ( PDO database_handle, PDOStatement prepared_statement, array value_list [, array column_specifier] )

Example 2204. Retrieving a data object using executePreparedQuery()

In this example a single data object is retrieved from the database - or possibly more than one if there is more than one company called 'Acme'. For each company returned, the name and id properties are echoed.

Other examples of the use of executePreparedQuery() can be found in the example code supplied in sdo/DAS/Relational/Scenarios .

<?php
require_once 'SDO/DAS/Relational.php';
require_once
'company_metadata.inc.php';

/**************************************************************
* Construct the DAS with the metadata
***************************************************************/
$das = new SDO_DAS_Relational ($database_metadata,'company',$SDO_reference_metadata);

/**************************************************************
* Get a database connection
***************************************************************/
$dbh = new PDO(PDO_DSN,DATABASE_USER,DATABASE_PASSWORD);

/**************************************************************
* Issue a query to obtain a company object - possibly more if they exist
* Use a prepared query with a placeholder.
***************************************************************/
$name = 'Acme';
$pdo_stmt = $dbh->prepare('select name, id from company where name=?');
$root = $das->executePreparedQuery(
   
$dbh,
   
$pdo_stmt,
   array(
$name),
   array(
'company.name', 'company.id'));

/**************************************************************
* Echo name and id
***************************************************************/
foreach ($root['company'] as $company) {
   echo
"Company obtained from the database has name = " .
   
$company['name'] . " and id " . $company['id'] . "\n";
}
?>

Change Language


Follow Navioo On Twitter
SDO_DAS_Relational::applyChanges
SDO_DAS_Relational::__construct
SDO_DAS_Relational::createRootDataObject
SDO_DAS_Relational::executePreparedQuery
SDO_DAS_Relational::executeQuery
eXTReMe Tracker