[REVIEW] database->Quote

Last reviewed: Not reviewed
phpDocumentor

database->Quote

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 ( string $text )

$text
is the raw string to be escaped and quoted.

Examples

Example:

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

might produce:

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

Please report any errors on this page to the Developer Documentation Forum.

Last Updated ( Monday, 25 December 2006 )