/** * Executes a prepared statement * * @param array $inputParams * @return bool */ public function execute($inputParams = null) { $mode = OCI_COMMIT_ON_SUCCESS; if ($this->_pdoOci8->isTransaction()) { if (PHP_VERSION_ID > 503020) { $mode = OCI_NO_AUTO_COMMIT; } else { $mode = OCI_DEFAULT; } } // Set up bound parameters, if passed in if (is_array($inputParams)) { foreach ($inputParams as $key => $value) { $bound = $this->bindParam($key, $inputParams[$key]); if (!$bound) { throw new PDOException($inputParams[$key] . ' could not be bound to ' . $key . ' with Oci8PDO_Statement::bindParam()'); } } } if (@oci_execute($this->_sth, $mode)) { return true; } else { $e = oci_error($this->_sth); throw new PDOException($e['message']); } }
/** * 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); } 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); } } } }