Example #1
0
 public function bindArrayByName($name, &$varArray, $maxTableLength, $maxItemLength = -1, $type = SQLT_AFC)
 {
     set_error_handler(static::getErrorHandler());
     $isSuccess = oci_bind_array_by_name($this->resource, $name, $varArray, $maxTableLength, $maxItemLength, $type);
     restore_error_handler();
     return $isSuccess;
 }
Example #2
0
 /**
  * непосредственное выполнение сформированной процедуры
  *
  * @param $sql
  * @param $params
  * @return mixed
  */
 public function ora_proced($sql, $params)
 {
     $res = oci_parse(self::$_conn, $sql);
     foreach ($params as $key => &$param) {
         if ($param == 'out') {
             oci_bind_by_name($res, ':' . $key, $param, 255);
         } else {
             if (is_array($param)) {
                 oci_bind_array_by_name($res, ':' . $key, $param[0], count($param[0]), -1, $param[1]);
             } else {
                 oci_bind_by_name($res, ':' . $key, $param);
             }
         }
     }
     oci_execute($res, OCI_DEFAULT);
     return $params;
 }
Example #3
0
 /**
  * Special non-PDO function that binds an array parameter to the specified variable name.
  *
  * @see  http://php.net/manual/en/function.oci-bind-array-by-name.php
  * @param string $parameter The Oracle placeholder.
  * @param array $variable An array.
  * @param int $maxTableLength Sets the maximum length both for incoming and result arrays.
  * @param int $maxItemLength Sets maximum length for array items.
  *                           If not specified or equals to -1, oci_bind_array_by_name() will find
  *                           the longest element in the incoming array and will use it as the maximum length.
  * @param int $type Explicit data type for the parameter using the
  * @return bool TRUE on success or FALSE on failure.
  */
 public function bindArray($parameter, &$variable, $maxTableLength, $maxItemLength = -1, $type = SQLT_CHR)
 {
     $this->bindings[] = $variable;
     return oci_bind_array_by_name($this->sth, $parameter, $variable, $maxTableLength, $maxItemLength, $type);
 }
Example #4
0
 /**
  * Bind parameters
  *
  * @access  private
  * @return  none
  */
 function _bind_params($params)
 {
     if (!is_array($params) or !is_resource($this->stmt_id)) {
         return;
     }
     foreach ($params as $param) {
         foreach (array('name', 'value', 'type', 'length') as $val) {
             if (!isset($param[$val])) {
                 $param[$val] = '';
             }
         }
         if ($param['type'] == 'NUM_ARRAY') {
             oci_bind_array_by_name($this->stmt_id, $param['name'], $param['value'], 2000, 30, SQLT_NUM);
         } else {
             if ($param['type'] == 'CHAR_ARRAY') {
                 oci_bind_array_by_name($this->stmt_id, $param['name'], $param['value'], 2000, 255, SQLT_CHR);
             } else {
                 oci_bind_by_name($this->stmt_id, $param['name'], $param['value'], $param['length'], $param['type']);
             }
         }
     }
 }
 /**
  * Binds a parameter to the specified variable name
  *
  * @param string $parameter
  * @param mixed  $variable
  * @param int    $data_type
  * @param int    $length
  * @param null   $driver_options
  *
  * @return bool
  */
 public function bindParam($parameter, &$variable, $data_type = PDO::PARAM_STR, $length = -1, $driver_options = null)
 {
     if ($driver_options !== null) {
         throw new PDOException('$driver_options is not implemented for Oci8PDO_Statement::bindParam()');
     }
     //Not checking for $data_type === PDO::PARAM_INT, because this gives problems when inserting/updating integers into a VARCHAR column.
     //     	if($data_type === PDO::PARAM_INT) {
     //     		if($length == -1) {
     //         		 $length = strlen( (string)$variable );
     //     		}
     //     		return oci_bind_by_name($this->_sth, $parameter, $variable, $length, SQLT_INT);
     //     	} else
     if (is_array($variable)) {
         return oci_bind_array_by_name($this->_sth, $parameter, $variable, count($variable), $length);
     } else {
         if ($length == -1) {
             $length = strlen((string) $variable);
         }
         if ($data_type == Oci8PDO::PARAM_BLOB) {
             $clob = oci_new_descriptor($this->_pdoOci8->getDbh(), OCI_D_LOB);
             $res = oci_bind_by_name($this->_sth, $parameter, $clob, -1, OCI_B_BLOB);
             $clob->writeTemporary($variable, OCI_TEMP_BLOB);
             return $res;
         } else {
             if ($data_type == Oci8PDO::PARAM_CLOB) {
                 $clob = oci_new_descriptor($this->_pdoOci8->getDbh(), OCI_D_LOB);
                 $res = oci_bind_by_name($this->_sth, $parameter, $clob, -1, OCI_B_CLOB);
                 $clob->writeTemporary($variable, OCI_TEMP_CLOB);
                 return $res;
             } else {
                 return oci_bind_by_name($this->_sth, $parameter, $variable, $length);
             }
         }
     }
 }
Example #6
0
 /**
  * Binds a parameter to the specified variable name
  *
  * @param string $parameter
  * @param mixed $variable
  * @param int $data_type
  * @param int $length
  * @param array $driver_options
  * @return bool
  */
 public function bindParam($parameter, &$variable, $data_type = PDO::PARAM_STR, $length = -1, $driver_options = null)
 {
     if (is_numeric($parameter)) {
         throw new PDOException('Oci8\\Statement::bindParam() does not implement binding numerical params.');
     }
     if (is_array($variable)) {
         return oci_bind_array_by_name($this->sth, $parameter, $variable, count($variable), $length, $data_type);
     }
     if ($length == -1) {
         $length = strlen((string) $variable);
     }
     switch ($data_type) {
         case PDO::PARAM_BOOL:
             $oci_type = SQLT_INT;
             break;
         case PDO::PARAM_NULL:
             $oci_type = SQLT_CHR;
             break;
         case PDO::PARAM_INT:
             $oci_type = SQLT_INT;
             break;
         case PDO::PARAM_STR:
             $oci_type = SQLT_CHR;
             break;
         case Oci8::PARAM_NUM:
             $oci_type = SQLT_NUM;
             break;
         case Oci8::PARAM_BLOB:
         case Oci8::PARAM_CLOB:
             $oci_type = $data_type;
             break;
         case PDO::PARAM_STMT:
             $oci_type = OCI_B_CURSOR;
             break;
         case SQLT_NTY:
             $oci_type = SQLT_NTY;
             break;
         default:
             $oci_type = SQLT_CHR;
             break;
     }
     return oci_bind_by_name($this->sth, $parameter, $variable, $length, $oci_type);
 }
 /**
  * Binds a parameter to the specified variable name
  * @param string $parameter
  * @param mixed $variable
  * @param int $data_type
  * @param int $length
  * @param array $driver_options
  * @return bool
  */
 public function bindParam($parameter, &$variable, $data_type = PDO::PARAM_STR, $length = 4000, $driver_options = null)
 {
     if (strpos($parameter, ':') === false) {
         $parameter = ':' . $parameter;
     }
     if (stripos($this->queryString, $parameter) === false) {
         return true;
     }
     $isOutputParameter = $this->checkBitFlag($data_type, PDO::PARAM_INPUT_OUTPUT);
     $data_type = $this->removeBitFlag($data_type, PDO::PARAM_INPUT_OUTPUT);
     $ociParamType = $this->pdo2OciParamConst($data_type);
     if ($ociParamType === SQLT_CHR) {
         $variable = (string) $variable;
     }
     if (is_array($variable)) {
         // TODO Не съм сигурен, дали ще се използва някога
         $res = @oci_bind_array_by_name($this->stmt, $parameter, $variable, count($variable), $length, $ociParamType);
         $this->checkError($res);
     } else {
         // Cursor
         if ($ociParamType == OCI_B_CURSOR) {
             $statementType = @oci_statement_type($this->stmt);
             $this->checkError($statementType);
             if (!in_array($statementType, array('BEGIN', 'DECLARE'))) {
                 throw new Exception('Bind cursor only in BEGIN or DECLARE statement');
             }
             $this->_cursor = @oci_new_cursor($this->ociPdoAdapter->getOciConnection());
             $res = $this->_cursor;
             $this->checkError($res);
             $res = @oci_bind_by_name($this->stmt, $parameter, $this->_cursor, -1, $ociParamType);
             $this->checkError($res);
         } elseif ($lob_desc = $this->oci_lob_desc($ociParamType)) {
             $this->_lobs[$this->_lobsCount]['type'] = $ociParamType;
             $this->_lobs[$this->_lobsCount]['lob'] = @oci_new_descriptor($this->ociPdoAdapter->getOciConnection(), $lob_desc);
             $res = $this->_lobs[$this->_lobsCount]['lob'];
             $this->checkError($res);
             $res = @oci_bind_by_name($this->stmt, $parameter, $this->_lobs[$this->_lobsCount]['lob'], -1, $ociParamType);
             $this->checkError($res);
             if (!$isOutputParameter) {
                 if (is_resource($variable) && get_resource_type($variable) === 'stream') {
                     $this->_lobs[$this->_lobsCount]['var'] = '';
                     $res = @$this->_lobs[$this->_lobsCount]['lob']->writeTemporary($this->_lobs[$this->_lobsCount]['var'], $ociParamType == SQLT_BLOB ? OCI_TEMP_BLOB : OCI_TEMP_CLOB);
                     $this->checkError($res);
                     $buffer = 8192;
                     while (!feof($variable)) {
                         $res = @$this->_lobs[$this->_lobsCount]['lob']->write(fread($variable, $buffer));
                         $this->checkError($res);
                         $res = @$this->_lobs[$this->_lobsCount]['lob']->flush();
                         $this->checkError($res);
                     }
                 } else {
                     $variable = (string) $variable;
                     $this->_lobs[$this->_lobsCount]['var'] =& $variable;
                     $res = @$this->_lobs[$this->_lobsCount]['lob']->writeTemporary($this->_lobs[$this->_lobsCount]['var'], $ociParamType == SQLT_BLOB ? OCI_TEMP_BLOB : OCI_TEMP_CLOB);
                     $this->checkError($res);
                     $res = @$this->_lobs[$this->_lobsCount]['lob']->flush();
                     $this->checkError($res);
                 }
             } else {
                 $this->_lobs[$this->_lobsCount]['var'] =& $variable;
             }
             $this->_lobs[$this->_lobsCount]['input'] = !$isOutputParameter;
             $this->_lobsCount++;
         } else {
             $res = @oci_bind_by_name($this->stmt, $parameter, $variable, $length, $ociParamType);
             $this->checkError($res);
         }
     }
     return $res;
 }
Example #8
0
 /**
  * Binds a parameter to the specified variable name
  *
  * @param string $parameter
  * @param mixed $variable
  * @param int $data_type
  * @param int $length
  * @param array $options
  * @return bool
  */
 public function bindParam($parameter, &$variable, $data_type = PDO::PARAM_STR, $length = -1, $driver_options = null)
 {
     if ($driver_options !== null) {
         throw new PDOException('$driver_options is not implemented for Oci8PDO_Statement::bindParam()');
     }
     //Not checking for $data_type === PDO::PARAM_INT, because this gives problems when inserting/updating integers into a VARCHAR column.
     //     	if($data_type === PDO::PARAM_INT) {
     //     		if($length == -1) {
     //         		 $length = strlen( (string)$variable );
     //     		}
     //     		return oci_bind_by_name($this->_sth, $parameter, $variable, $length, SQLT_INT);
     //     	} else
     if (is_array($variable)) {
         return oci_bind_array_by_name($this->_sth, $parameter, $variable, count($variable), $length);
     } else {
         if ($length == -1) {
             $length = strlen((string) $variable);
         }
         return oci_bind_by_name($this->_sth, $parameter, $variable, $length);
     }
 }
Example #9
0
 /**
  * Binds a parameter to the specified variable name
  *
  * @param string $parameter
  * @param mixed $variable
  * @param int $dataType
  * @param int $maxLength
  * @param array $options
  * @return bool
  * @todo Map PDO datatypes to oci8 datatypes and implement support for datatypes and length.
  */
 public function bindParam($parameter, &$variable, $dataType = PDO::PARAM_STR, $maxLength = -1, $options = null)
 {
     if (is_array($variable)) {
         return oci_bind_array_by_name($this->_sth, $parameter, $variable, count($variable));
     }
     return oci_bind_by_name($this->_sth, $parameter, $variable);
 }