Table of Contents

Quote

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

ADODB Compatibility function. See http://phplens.com/adodb/reference.functions.quote.html for more information. Returns a quoted string with all characters that have special meaning for the database escaped. This function is the same as database→getEscaped except that the string returned is surrounded by single quotes.

Syntax

string Quote ( $text )

$text string is a string to be quoted.

Examples

Example

$database =& JFactory::getDBO();

$text = $database->Quote( "Joomla! is 'Power in Simplicity'!" );
$sql = "SELECT * FROM #__content WHERE introtext=$text";
$database->setQuery( $sql );
if (!$database->query()) {
  echo $database->stderr();
}
 
echo $database->getQuery();

might produce:

Result

SELECT * FROM jos_content WHERE introtext='Joomla! is \'Power in Simplicity\'!'