quote() public method

If an array is passed as the value, the array values are quoted and then returned as a comma-separated string; this is useful for generating IN() lists. {{code: php $sql = Solar::factory('Solar_Sql'); $safe = $sql->quote('foo"bar"'); $safe == "'foo\"bar\"'" $safe = $sql->quote(array('one', 'two', 'three')); $safe == "'one', 'two', 'three'" }}
public quote ( mixed $val ) : string
$val mixed The value to quote.
return string An SQL-safe quoted value (or a string of separated-and-quoted values).
示例#1
0
 /**
  * 
  * Safely quotes a value for an SQL statement; unlike the main adapter,
  * the SQLite adapter **does not** quote numeric values.
  * 
  * If an array is passed as the value, the array values are quoted
  * and then returned as a comma-separated string; this is useful 
  * for generating IN() lists.
  * 
  * {{code: php
  *     $sql = Solar::factory('Solar_Sql');
  *     
  *     $safe = $sql->quote('foo"bar"');
  *     // $safe == "'foo\"bar\"'"
  *     
  *     $safe = $sql->quote(array('one', 'two', 'three'));
  *     // $safe == "'one', 'two', 'three'"
  * }}
  * 
  * @param mixed $val The value to quote.
  * 
  * @return string An SQL-safe quoted value (or a string of 
  * separated-and-quoted values).
  * 
  */
 public function quote($val)
 {
     if (is_numeric($val)) {
         return $val;
     } else {
         return parent::quote($val);
     }
 }