Ejemplo n.º 1
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);
     }
 }
Ejemplo n.º 2
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);
     }
 }
Ejemplo n.º 3
0
 protected function processSubSelect(Select $subselect, PlatformInterface $platform, Driver\DriverInterface $driver = null, Parameters $parameters = null)
 {
     if ($driver) {
         // Track subselect prefix and count for parameters
         $this->processInfo['subselectCount']++;
         $subselect->processInfo['subselectCount'] = $this->processInfo['subselectCount'];
         $subselect->processInfo['paramPrefix'] = 'subselect' . $subselect->processInfo['subselectCount'];
         // call subselect
         $stmt = $subselect->prepareStatement($platform, $driver);
         // copy count
         $this->processInfo['subselectCount'] = $subselect->processInfo['subselectCount'];
         if ($parameters) {
             $parameters->merge($stmt->getParameters());
         }
         $sql = $stmt->getSql();
     } else {
         $sql = $subselect->getSqlString($platform);
     }
     return $sql;
 }
Ejemplo n.º 4
0
 protected function processOffset(PlatformInterface $platform, DriverInterface $driver = null, Parameters $parameters = null)
 {
     if ($this->offset === null) {
         return null;
     }
     if ($driver) {
         $parameters->offsetSet('offset', $this->offset, Parameters::TYPE_INTEGER);
         return array($driver->formatParameterName('offset'));
     }
     return array($platform->quoteLimitOffset($this->offset));
 }