Пример #1
0
 /**
  * Bind parameters from container
  */
 protected function bindParameters()
 {
     if ($this->parametersBound) {
         return;
     }
     $parameters = $this->parameters->getNamedArray();
     foreach ($parameters as $name => &$value) {
         $type = \PDO::PARAM_STR;
         if ($this->parameters->offsetHasErrata($name)) {
             switch ($this->parameters->offsetGetErrata($name)) {
                 case Parameters::TYPE_INTEGER:
                     $type = \PDO::PARAM_INT;
                     break;
                 case Parameters::TYPE_NULL:
                     $type = \PDO::PARAM_NULL;
                     break;
                 case Parameters::TYPE_LOB:
                     $type = \PDO::PARAM_LOB;
                     break;
                 case is_bool($value):
                     $type = \PDO::PARAM_BOOL;
                     break;
             }
         }
         // parameter is named or positional, value is reference
         $parameter = is_int($name) ? $name + 1 : $name;
         $this->resource->bindParam($parameter, $value, $type);
     }
 }
Пример #2
0
 /**
  * Bind parameters from container
  *
  * @return void
  */
 protected function bindParameters()
 {
     $parameters = $this->parameters->getNamedArray();
     $type = '';
     $args = array();
     foreach ($parameters as $name => &$value) {
         if ($this->parameters->offsetHasErrata($name)) {
             switch ($this->parameters->offsetGetErrata($name)) {
                 case Parameters::TYPE_DOUBLE:
                     $type .= 'd';
                     break;
                 case Parameters::TYPE_NULL:
                     $value = null;
                     // as per @see http://www.php.net/manual/en/mysqli-stmt.bind-param.php#96148
                 // as per @see http://www.php.net/manual/en/mysqli-stmt.bind-param.php#96148
                 case Parameters::TYPE_INTEGER:
                     $type .= 'i';
                     break;
                 case Parameters::TYPE_STRING:
                 default:
                     $type .= 's';
                     break;
             }
         } else {
             $type .= 's';
         }
         $args[] =& $value;
     }
     if ($args) {
         array_unshift($args, $type);
         call_user_func_array(array($this->resource, 'bind_param'), $args);
     }
 }