PDO::quote
Quotes a string for use in a query.
&reftitle.description;
stringPDO::quote
stringstring
intparameter_type
PDO::quote places quotes around the input string (if
required) and escapes special characters within the input string, using a
quoting style appropriate to the underlying driver.
If you are using this function to build SQL statements, you are
strongly recommended to use
PDO::prepare to prepare SQL statements with bound
parameters instead of using PDO::quote to interpolate
user input into a SQL statement. Prepared statements with bound parameters
are not only more portable, more convenient, immune to SQL injection, but
are often much faster to execute than interpolated queries, as both the
server and client side can cache a compiled form of the query.
Not all PDO drivers implement this method (notably PDO_ODBC). Consider
using prepared statements instead.
&reftitle.parameters;
string
The string to be quoted.
parameter_type
Provides a data type hint for drivers that have alternate quoting styles.
The default value is PDO::PARAM_STR.
&reftitle.returnvalues;
Returns a quoted string that is theoretically safe to pass into an
SQL statement. Returns &false; if the driver does not support quoting in
this way.
&reftitle.examples;
Quoting a normal string
quote($string) . "\n";
?>
]]>
&example.outputs;
Quoting a dangerous string
quote($string) . "\n";
?>
]]>
&example.outputs;
Quoting a complex string
quote($string) . "\n";
?>
]]>
&example.outputs;
&reftitle.seealso;
PDO::prepare
PDOStatement::execute