コード例 #1
0
ファイル: Statement.php プロジェクト: eltonoliveira/jenkins
 /**
  * Bind parameters from container
  */
 protected function bindParametersFromContainer()
 {
     if ($this->parametersBound) {
         return;
     }
     $parameters = $this->parameterContainer->getNamedArray();
     foreach ($parameters as $name => &$value) {
         if (is_bool($value)) {
             $type = \PDO::PARAM_BOOL;
         } else {
             $type = \PDO::PARAM_STR;
         }
         if ($this->parameterContainer->offsetHasErrata($name)) {
             switch ($this->parameterContainer->offsetGetErrata($name)) {
                 case ParameterContainer::TYPE_INTEGER:
                     $type = \PDO::PARAM_INT;
                     break;
                 case ParameterContainer::TYPE_NULL:
                     $type = \PDO::PARAM_NULL;
                     break;
                 case ParameterContainer::TYPE_LOB:
                     $type = \PDO::PARAM_LOB;
                     break;
             }
         }
         // parameter is named or positional, value is reference
         $parameter = is_int($name) ? $name + 1 : $name;
         $this->resource->bindParam($parameter, $value, $type);
     }
 }
コード例 #2
0
ファイル: Statement.php プロジェクト: Yansor/yafblog
 /**
  * Bind parameters from container
  *
  * @return void
  */
 protected function bindParametersFromContainer()
 {
     $parameters = $this->parameterContainer->getNamedArray();
     $type = '';
     $args = array();
     foreach ($parameters as $name => &$value) {
         if ($this->parameterContainer->offsetHasErrata($name)) {
             switch ($this->parameterContainer->offsetGetErrata($name)) {
                 case ParameterContainer::TYPE_DOUBLE:
                     $type .= 'd';
                     break;
                 case ParameterContainer::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 ParameterContainer::TYPE_INTEGER:
                     $type .= 'i';
                     break;
                 case ParameterContainer::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);
     }
 }
コード例 #3
0
ファイル: Statement.php プロジェクト: razvansividra/pnlzf2-1
 /**
  * Bind parameters from container
  *
  * @param ParameterContainer $pContainer
  */
 protected function bindParametersFromContainer()
 {
     $parameters = $this->parameterContainer->getNamedArray();
     foreach ($parameters as $name => &$value) {
         if ($this->parameterContainer->offsetHasErrata($name)) {
             switch ($this->parameterContainer->offsetGetErrata($name)) {
                 case ParameterContainer::TYPE_NULL:
                     $type = null;
                     $value = null;
                     break;
                 case ParameterContainer::TYPE_DOUBLE:
                 case ParameterContainer::TYPE_INTEGER:
                     $type = SQLT_INT;
                     if (is_string($value)) {
                         $value = (int) $value;
                     }
                     break;
                 case ParameterContainer::TYPE_BINARY:
                     $type = SQLT_BIN;
                     break;
                 case ParameterContainer::TYPE_STRING:
                 default:
                     $type = SQLT_CHR;
                     break;
             }
         } else {
             $type = SQLT_CHR;
         }
         oci_bind_by_name($this->resource, $name, $value, -1, $type);
     }
 }
コード例 #4
0
 /**
  * Bind parameters from container
  *
  * @param ParameterContainer $pContainer
  */
 protected function bindParametersFromContainer()
 {
     $parameters = $this->parameterContainer->getNamedArray();
     foreach ($parameters as $name => &$value) {
         if ($this->parameterContainer->offsetHasErrata($name)) {
             switch ($this->parameterContainer->offsetGetErrata($name)) {
                 case ParameterContainer::TYPE_NULL:
                     $type = null;
                     $value = null;
                     break;
                 case ParameterContainer::TYPE_DOUBLE:
                 case ParameterContainer::TYPE_INTEGER:
                     $type = SQLT_INT;
                     if (is_string($value)) {
                         $value = (int) $value;
                     }
                     break;
                 case ParameterContainer::TYPE_BINARY:
                     $type = SQLT_BIN;
                     break;
                 case ParameterContainer::TYPE_LOB:
                     $type = OCI_B_CLOB;
                     $clob = oci_new_descriptor($this->driver->getConnection()->getResource(), OCI_DTYPE_LOB);
                     $clob->writetemporary($value, OCI_TEMP_CLOB);
                     $value = $clob;
                     break;
                 case ParameterContainer::TYPE_STRING:
                 default:
                     $type = SQLT_CHR;
                     break;
             }
         } else {
             $type = SQLT_CHR;
         }
         $maxLength = -1;
         if ($this->parameterContainer->offsetHasMaxLength($name)) {
             $maxLength = $this->parameterContainer->offsetGetMaxLength($name);
         }
         oci_bind_by_name($this->resource, $name, $value, $maxLength, $type);
     }
 }
コード例 #5
0
ファイル: Statement.php プロジェクト: brikou/zend_db
 /**
  * Bind parameters from container
  * 
  * @param ParameterContainer $container
  */
 protected function bindParametersFromContainer(ParameterContainer $container)
 {
     $parameters = $container->getNamedArray();
     foreach ($parameters as $position => &$value) {
         $type = \PDO::PARAM_STR;
         if ($container->offsetHasErrata($position)) {
             switch ($container->offsetGetErrata($position)) {
                 case ParameterContainer::TYPE_INTEGER:
                     $type = \PDO::PARAM_INT;
                     break;
                 case ParameterContainer::TYPE_NULL:
                     $type = \PDO::PARAM_NULL;
                     break;
                 case ParameterContainer::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($position) ? $position + 1 : $position;
         $this->resource->bindParam($parameter, $value, $type);
     }
 }
コード例 #6
0
 /**
  * @testdox unit test: Test offsetHasErrata() will check if errata exists for a particular key
  * @covers Zend\Db\Adapter\ParameterContainer::offsetHasErrata
  */
 public function testOffsetHasErrata()
 {
     $this->parameterContainer->offsetSetErrata('foo', ParameterContainer::TYPE_INTEGER);
     $this->assertTrue($this->parameterContainer->offsetHasErrata('foo'));
 }