PDO::quote() places quotes around the input string and escapes and single quotes 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, and vastly more secure, but are often much faster than interpolating user input into slight variations on the same basic SQL statement.
Not all PDO drivers implement this method (notably PDO_ODBC). Consider using prepared statements instead.
The string to be quoted.
Provides a data type hint for drivers that have alternate quoting styles. The default value is PDO_PARAM_STR.
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.
Beispiel 2. Quoting a dangerous string
Das oben gezeigte Beispiel erzeugt folgende Ausgabe:
|
Beispiel 3. Quoting a complex string
Das oben gezeigte Beispiel erzeugt folgende Ausgabe:
|
Zurück | Zum Anfang | Weiter |
PDO::query | Nach oben | PDO::rollBack |