/** * @see Yun_Db_Adapter_Interface::quote() */ public function quote($string) { if (null === $this->pdo) { return false; } $string = $this->pdo->quote($string); $string = substr($string, 1, strlen($string) - 2); return $string; }
$name = "John O'Neil"; $pdo = new PDO($dsn, $user, $password); $escaped_name = $pdo->quote($name); echo $escaped_name;
'John O\'Neil'
$age = 25; $pdo = new PDO($dsn, $user, $password); $escaped_age = $pdo->quote($age); echo $escaped_age;
'25'Even though integers don't need to be escaped in SQL statements, PDO quote still works by converting the integer to a string and quoting it. Package/library: PDO is a PHP extension/library for interacting with databases, and PDO quote is one of its built-in functions.
/** * @see Yun_Db_Adapter_Interface::quote() */ public function quote($string) { if (null === $this->pdo) { return false; } $string = $this->pdo->quote($string); $string = substr($string, 1, strlen($string) - 2); return $string; }