DatabaseService::ExecuteTemplate (since version 2.0)
Syntax
mixed ExecuteTemplate ( string $templateKey [, array $fields = null [, array $values = null ]] )
Parameters
templateKey
The templateKey to use the SQL attached to.
fields
The fields to replace on template. Fields could be table or other fields that dont need to be binded as parameters to the statement.
values
The values to replace on the template. The values are quotes and binded as parameters to the statement.
Return
mixed Returns the result of the SQL template exectued.
See also
Examples
<?php
$template = '
<SQLTEMPLATE>
<SQL key="user_fetch">
<![CDATA[ SELECT { fields } FROM { table } WHERE { matches } ]]>
</SQL>
</SQLTEMPLATE>
';
// add template to database service
DatabaseService::AddTemplate($template);
?>
$template = '
<SQLTEMPLATE>
<SQL key="user_fetch">
<![CDATA[ SELECT { fields } FROM { table } WHERE { matches } ]]>
</SQL>
</SQLTEMPLATE>
';
// add template to database service
DatabaseService::AddTemplate($template);
?>
<?php
// select the database profile
DatabaseService::Begin('database_localhost');
// execute template with some parameters
$results = DatabaseService::ExecuteTemplate('user_fetch', array('table' =>'user', 'fields' => 'id,username'), 'matches' => array('age' => 50));
// release the activated profile
DatabaseService:End();
?>
// select the database profile
DatabaseService::Begin('database_localhost');
// execute template with some parameters
$results = DatabaseService::ExecuteTemplate('user_fetch', array('table' =>'user', 'fields' => 'id,username'), 'matches' => array('age' => 50));
// release the activated profile
DatabaseService:End();
?>
Last change 10/16/2009