Support Joomla!

references:joomla.framework:database:jdatabase-replaceprefix

Table of Contents

replacePrefix

API Package Subpackage Class Method Reference Last reviewed Doc status
API Home Package Joomla.Framework Subpackage Database Class JDatabase Method replacePrefix Reference replacePrefix() Never Work in Progress

This function replaces a string identifier $prefix with the string held in the _table_prefix class variable.

Syntax

void replacePrefix ( $sql, $prefix )

$sql string is a string containing the SQL query.
$prefix string is a string containing the common table prefix. This parameter is optional and if omitted defaults to '#__'.

Examples

Example

$database =& JFactory::getDBO();

$sql = "SELECT * FROM #__content WHERE introtext=test";

echo $sql . '<br />';
$sql = $database->replacePrefix( $sql );
echo $sql;

might produce:

Result

SELECT * FROM #__content WHERE introtext=test
SELECT * FROM jos_content WHERE introtext=test

Discussion

Full name:
E-Mail:
 
references/joomla.framework/database/jdatabase-replaceprefix.txt (656 views) · Last modified: 2007/08/15 14:52