Beispiel #1
0
 /**
  * bind parameters
  *
  * @param  \PDOStatement $stmt
  * @param  array $parameters
  * @return bool
  * @access protected
  */
 protected function bindParameters(\PDOStatement $stmt, array $parameters)
 {
     foreach ($parameters as $name => &$value) {
         $type = Types::guessType($value);
         $param = is_int($name) ? $name + 1 : ($name[0] === ':' ? $name : ':' . $name);
         if (false === $stmt->bindParam($param, $value, $type)) {
             return false;
         }
     }
     return true;
 }
Beispiel #2
0
 /**
  * bind parameters
  *
  * @param  \mysqli_stmt $stmt
  * @param  array $parameters
  * @return bool
  * @access protected
  */
 protected function bindParameters(\mysqli_stmt $stmt, array $parameters)
 {
     $types = '';
     $args = [];
     foreach ($parameters as $name => &$value) {
         $type = Types::guessType($value);
         switch ($type) {
             case Types::PARAM_INT:
             case Types::PARAM_BOOL:
                 $types .= 'i';
                 break;
             default:
                 $types .= 's';
                 break;
         }
         $args[] =& $value;
     }
     if (count($args)) {
         array_unshift($args, $types);
         return call_user_func_array([$stmt, 'bind_param'], $args);
     }
     return true;
 }
Beispiel #3
0
 /**
  * {@inheritDoc}
  */
 public function quote($string, $type = Types::PARAM_STR)
 {
     // try connect first
     $this->connect();
     // guess type with suggestion from $type
     $guess = Types::guessType($string, $type);
     // driver specific quote
     return $this->realQuote($string, $guess);
 }