/** * Bind parameters from container * * @param ParameterContainerInterface $pContainer */ protected function bindParametersFromContainer(ParameterContainerInterface $pContainer) { $parameters = $pContainer->toArray(); $type = ''; $args = array(); foreach ($parameters as $position => &$value) { switch ($pContainer->offsetGetErrata($position)) { case ParameterContainerInterface::TYPE_DOUBLE: $type .= 'd'; break; case ParameterContainerInterface::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 // 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 // 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 // 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 ParameterContainerInterface::TYPE_INTEGER: $type .= 'i'; break; case ParameterContainerInterface::TYPE_STRING: default: $type .= 's'; break; } $args[] =& $value; } if ($args) { array_unshift($args, $type); call_user_func_array(array($this->resource, 'bind_param'), $args); } }
/** * Bind parameters from container * * @param ParameterContainerInterface $container */ protected function bindParametersFromContainer(ParameterContainerInterface $container) { $parameters = $container->toArray(); foreach ($parameters as $position => &$value) { $type = \PDO::PARAM_STR; if ($container->offsetHasErrata($position)) { switch ($container->offsetGetErrata($position)) { case ParameterContainerInterface::TYPE_INTEGER: $type = \PDO::PARAM_INT; break; case ParameterContainerInterface::TYPE_NULL: $type = \PDO::PARAM_NULL; break; case ParameterContainerInterface::TYPE_LOB: $type = \PDO::PARAM_LOB; break; case is_bool($value): $type = \PDO::PARAM_BOOL; break; } } // position is named or positional, value is reference $this->resource->bindParam(is_int($position) ? $position + 1 : $position, $value, $type); } }