П О Р Т А Л                            
С Е Т Е В Ы Х                          
П Р О Е К Т О В                        
  
Поиск по сайту:
                                                 
Главная

О проекте

Web-мастеру
     HTML & JavaScript
     SSI
     Perl
     PHP
     XML & XSLT
     Unix Shell

MySQL

Безопасность

Хостинг

Другое








Самое читаемое:

Учебник PHP - "Для Чайника".
Просмотров 3500 раз(а).

Иллюстрированный самоучитель по созданию сайтов.
Просмотров 6101 раз(а).

Учебник HTML.
Просмотров 3265 раз(а).

Руководство по PHP5.
Просмотров 5486 раз(а).

Хостинг через призму DNS.
Просмотров 4124 раз(а).

Подборка текстов стандартных документов.
Просмотров 55763 раз(а).

Учебник PHP - Самоучитель
Просмотров 3078 раз(а).

Документация на MySQL (учебник & справочное руководство)
Просмотров 5461 раз(а).

Внешние атаки...
Просмотров 3823 раз(а).

Учебник PHP.
Просмотров 2819 раз(а).

SSI в примерах.
Просмотров 37454 раз(а).



 
 
| Добавить в избранное | Сделать стартовой | Помощь





Руководство по PHP
Пред. След.

PDO::quote

(no version information, might be only in CVS)

PDO::quote --  Quotes a string for use in a query.

Описание

string PDO::quote ( string string [, int parameter_type] )

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.

Список параметров

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.

Возвращаемые значения

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.

Примеры

Пример 1. Quoting a normal string

<?php
$conn
= new PDO('sqlite:/home/lynn/music.sql3');

/* Simple string */
$string = 'Nice';
print
"Unquoted string: $string\n";
print
"Quoted string: " . $conn->quote($string) . "\n";
?>

Результат выполнения данного примера:

Unquoted string: Nice
Quoted string: 'Nice'

Пример 2. Quoting a dangerous string

<?php
$conn
= new PDO('sqlite:/home/lynn/music.sql3');

/* Dangerous string */
$string = 'Naughty \' string';
print
"Unquoted string: $string\n";
print
"Quoted string:" . $conn->quote($string) . "\n";
?>

Результат выполнения данного примера:

Unquoted string: Naughty ' string
Quoted string: 'Naughty '' string'

Пример 3. Quoting a complex string

<?php
$conn
= new PDO('sqlite:/home/lynn/music.sql3');

/* Complex string */
$string = "Co'mpl''ex \"st'\"ring";
print
"Unquoted string: $string\n";
print
"Quoted string: " . $conn->quote($string) . "\n";
?>

Результат выполнения данного примера:

Unquoted string: Co'mpl''ex "st'"ring
Quoted string: 'Co''mpl''''ex "st''"ring'

Смотрите также

PDO::prepare()
PDOStatement::execute()



Если Вы не нашли что искали, то рекомендую воспользоваться поиском по сайту:
 





Copyright © 2005-2016 Project.Net.Ru