本文整理汇总了PHP中OCIError函数的典型用法代码示例。如果您正苦于以下问题:PHP OCIError函数的具体用法?PHP OCIError怎么用?PHP OCIError使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OCIError函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __conecta
/**
* Método de conexão com o banco de dados mysql
* @name __conecta
* @return Object
* @access Protected
* @author Paulo Teixeira
* @package connectionDb
*/
public function __conecta()
{
global $typedb;
$this->datasource = "FW";
$this->host = "localhost";
//$this -> username = "framework";
$this->username = "root";
$this->senha = "090302";
//$this -> dbName = "xe";
//$this -> port = 1521;
$this->dbName = "infinitum_eprocurement";
$this->port = 3306;
if ($this->typedb == "mysql") {
$this->mysql = new mysqli($this->host, $this->username, $this->senha, $this->dbName, $this->port);
return $this->mysql;
}
if ($this->typedb == "oracle") {
$this->dbDescription = "(DESCRIPTION=";
$this->dbDescription .= " (ADDRESS_LIST=";
$this->dbDescription .= " (ADDRESS=(PROTOCOL=TCP)";
$this->dbDescription .= " (HOST={$this->host})(PORT={$this->port})";
$this->dbDescription .= " )";
$this->dbDescription .= " )";
$this->dbDescription .= " (CONNECT_DATA=(SERVICE_NAME={$this->dbName}))";
$this->dbDescription .= ")";
if ($this->oracle = OCILogon($this->username, $this->senha, $this->dbDescription)) {
return $this->oracle;
} else {
$this->err = OCIError();
return false;
}
}
}
示例2: ReportError
function ReportError($res = null, $retVal = -1)
{
$a = OCIError($res);
if ($a) {
printf('OCI Error %d: %s', $a['code'], $a['message']);
}
return $retVal;
}
示例3: QueryB
function QueryB($sql)
{
global $conn;
$stmt = OCIParse($conn, $sql);
$DBody = OCINewDescriptor($conn, OCI_D_LOB);
OCIBindByName($stmt, ":Body_Loc", $DBody, -1, OCI_B_BLOB);
$err = OCIExecute($stmt, OCI_DEFAULT);
if (!$err) {
$error = OCIError($stmt);
//echo '<strong>Произошла ошибка: <font color="#889999">'.$error["message"].'</font><br>Запрос: <font color="#889999">'.$error["sqltext"].'</font></strong>';
QError($error);
die;
}
return $DBody;
}
示例4: consultar
function consultar($conexao, $consulta)
{
$result = @oci_parse($conexao, $consulta);
if (!$result) {
$oerr = OCIError($result);
echo "Fetch Code 1:" . $oerr["message"];
exit;
}
@oci_execute($result, OCI_DEFAULT);
$resp = NULL;
$a = 0;
while ($row = @oci_fetch_array($result, OCI_BOTH + OCI_RETURN_LOBS)) {
$resp[$a++] = $row;
}
@oci_free_statement($result);
return $resp;
}
示例5: DBQuery
function DBQuery($sql)
{
global $DatabaseType;
$connection = db_start();
switch ($DatabaseType) {
case 'oracle':
$result = @ociparse($connection, $sql);
// TRANSLATION: do NOT translate these since error messages need to stay in English for technical support
if ($result === false) {
$errors = OCIError($connection);
db_show_error($sql, "DB Parse Failed.", $errors['message']);
}
if (!@OciExecute($result)) {
$errors = OCIError($result);
db_show_error($sql, "DB Execute Failed.", $errors['message']);
}
OciCommit($connection);
OciLogoff($connection);
break;
case 'postgres':
// TRANSLATION: do NOT translate these since error messages need to stay in English for technical support
$sql = preg_replace("/([,\\(=])[\r\n\t ]*''/", '\\1NULL', $sql);
$result = @pg_exec($connection, $sql);
if ($result === false) {
$errstring = pg_last_error($connection);
db_show_error($sql, "DB Execute Failed.", $errstring);
}
break;
case 'mysql':
// TRANSLATION: do NOT translate these since error messages need to stay in English for technical support
mysql_query("SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE");
mysql_query("SET SESSION SQL_MODE='ANSI'");
$sql = preg_replace("/([,\\(=])[\r\n\t ]*''/", '\\1NULL', $sql);
$result = mysql_query($sql);
if ($result === false) {
$errstring = mysql_error();
db_show_error($sql, "DB Execute Failed.", $errstring);
}
break;
}
return $result;
}
示例6: query
/**
* Performs an SQL query.
*
* @param string $query
* @param mixed $limit
* @param boolean $warnOnFailure
* @access public
*/
function query($query, $limit = false, $warnOnFailure = true)
{
if ($limit != false) {
$query = sprintf('SELECT * FROM (%s) WHERE ROWNUM <= %d', $query, $limit);
}
if ($this->config['debug_level'] > 1) {
$this->debugQuery($query);
}
@OCIFreeStatement($this->result);
$this->result = @OCIParse($this->connection, $query);
if (!$this->result) {
$error = OCIError($this->result);
phpOpenTracker::handleError($error['code'] . $error['message'], E_USER_ERROR);
}
@OCIExecute($this->result);
if (!$this->result && $warnOnFailure) {
$error = OCIError($this->result);
phpOpenTracker::handleError($error['code'] . $error['message'], E_USER_ERROR);
}
}
示例7: error
/** build error output
* type can be stmt|conn|global
*/
function error($type = "")
{
if (!$type) {
$type = $this->stmt;
}
$error = OCIError($type);
if ($error) {
$errorstring = "<br>\nOCIError: " . $error["code"] . " " . $error["message"] . " <br>\nAction: " . $this->query . "<br>\n";
$this->errorstring = $errorstring;
//trace(2,__LINE__,get_class($this), $errorstring);
$this->errorcode = $error["code"];
$this->errormessage = $error["message"];
$this->error = false;
return FALSE;
} else {
$this->errorcode = FALSE;
$this->errormessage = FALSE;
$this->error = true;
return TRUE;
}
}
示例8: print_error
function print_error($title = "SQL/DB Error", $str = "")
{
// All erros go to the global error array $EZSQL_ERROR..
global $EZSQL_ERROR;
// If no error string then assume an oracle error is required
if (!$str) {
$error = OCIError();
$str = $error["message"] . "-" . $error["code"];
}
// Log this error to the global array..
$EZSQL_ERROR[] = array("query" => $this->last_query, "error_str" => $str);
// Is error output turned on or not..
if ($this->show_errors) {
// If there is an error then take note of it
print "<blockquote><font face=arial size=2 color=ff0000>";
print "<b>{$title} --</b> ";
print "[<font color=000077>{$str}</font>]";
print "</font></blockquote>";
} else {
return false;
}
}
示例9: query
public static function query($sql)
{
$sts = '';
switch (Db::$db) {
case 'Pg':
$data = pg_query($sql);
if (!$data) {
$sts = pg_last_error();
} else {
$sts = 1;
}
break;
case 'Mysql':
$data = mysql_query($sql);
if (!$data) {
$sts = mysql_error();
} else {
$sts = 1;
}
break;
case 'Oci':
//echo $sql.'<br>';
$data = oci_parse(Db::$conn, $sql);
oci_execute($data, OCI_DEFAULT);
// if (!$data)
// {
$err = OCIError($data);
if ($err != '') {
$sts = $err["message"];
echo $sql . '<br>';
} else {
$sts = 1;
}
$commit = oci_parse(Db::$conn, "commit");
oci_execute($commit, OCI_DEFAULT);
break;
}
return array($data, $sts);
}
示例10: dbi_error
/**
* Gets the latest database error message.
*
* @return string The text of the last database error. (The type of
* information varies depending on the which type of database
* is being used.)
*/
function dbi_error()
{
if (strcmp($GLOBALS["db_type"], "mysql") == 0) {
$ret = mysql_error();
} else {
if (strcmp($GLOBALS["db_type"], "mysqli") == 0) {
$ret = mysqli_error($GLOBALS["db_connection"]);
} else {
if (strcmp($GLOBALS["db_type"], "mssql") == 0) {
// no real mssql_error function. this is as good as it gets
$ret = mssql_get_last_message();
} else {
if (strcmp($GLOBALS["db_type"], "oracle") == 0) {
$ret = OCIError($GLOBALS["oracle_connection"]);
} else {
if (strcmp($GLOBALS["db_type"], "postgresql") == 0) {
$ret = pg_errormessage($GLOBALS["postgresql_connection"]);
} else {
if (strcmp($GLOBALS["db_type"], "odbc") == 0) {
// no way to get error from ODBC API
$ret = "Unknown ODBC error";
} else {
if (strcmp($GLOBALS["db_type"], "ibm_db2") == 0) {
$ret = db2_conn_errormsg();
if ($ret == '') {
$ret = db2_stmt_errormsg();
}
} else {
if (strcmp($GLOBALS["db_type"], "ibase") == 0) {
$ret = ibase_errmsg();
} else {
$ret = "dbi_error(): db_type not defined.";
}
}
}
}
}
}
}
}
if (strlen($ret)) {
return $ret;
} else {
return "Unknown error";
}
}
示例11: ErrorNo
function ErrorNo()
{
if ($this->_errorCode !== false) {
return $this->_errorCode;
}
if (is_resource($this->_stmt)) {
$arr = @OCIError($this->_stmt);
}
if (empty($arr)) {
$arr = @OCIError($this->_connectionID);
if ($arr == false) {
$arr = @OCIError();
}
if ($arr == false) {
return '';
}
}
$this->_errorMsg = $arr['message'];
$this->_errorCode = $arr['code'];
return $arr['code'];
}
示例12: oci8RaiseError
/**
* Gather information about an error, then use that info to create a
* DB error object and finally return that object.
*
* @param integer $errno PEAR error number (usually a DB constant) if
* manually raising an error
* @return object DB error object
* @see DB_common::errorCode()
* @see DB_common::raiseError()
*/
function oci8RaiseError($errno = null)
{
if ($errno === null) {
$error = @OCIError($this->connection);
return $this->raiseError($this->errorCode($error['code']), null, null, null, $error['message']);
} elseif (is_resource($errno)) {
$error = @OCIError($errno);
return $this->raiseError($this->errorCode($error['code']), null, null, null, $error['message']);
}
return $this->raiseError($this->errorCode($errno));
}
示例13: _doConnect
/**
* do the grunt work of the connect
*
* @return connection on success or MDB2 Error Object on failure
* @access protected
*/
function _doConnect($username, $password, $persistent = false)
{
if (!PEAR::loadExtension($this->phptype)) {
return $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null, 'extension ' . $this->phptype . ' is not compiled into PHP', __FUNCTION__);
}
$sid = '';
if (!empty($this->dsn['service']) && $this->dsn['hostspec']) {
//oci8://username:password@foo.example.com[:port]/?service=service
// service name is given, it is assumed that hostspec is really a
// hostname, we try to construct an oracle connection string from this
$port = $this->dsn['port'] ? $this->dsn['port'] : 1521;
$sid = sprintf("(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)\n (HOST=%s) (PORT=%s)))\n (CONNECT_DATA=(SERVICE_NAME=%s)))", $this->dsn['hostspec'], $port, $this->dsn['service']);
} elseif ($this->dsn['hostspec']) {
// we are given something like 'oci8://username:password@foo/'
// we have hostspec but not a service name, now we assume that
// hostspec is a tnsname defined in tnsnames.ora
$sid = $this->dsn['hostspec'];
} else {
// oci://username:password@
// if everything fails, we have to rely on environment variables
// not before a check to 'emulate_database'
if (!$this->options['emulate_database'] && $this->database_name) {
$sid = $this->database_name;
} elseif (getenv('ORACLE_SID')) {
$sid = getenv('ORACLE_SID');
} elseif ($sid = getenv('TWO_TASK')) {
$sid = getenv('TWO_TASK');
} else {
return $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null, 'not a valid connection string or environment variable [ORACLE_SID|TWO_TASK] not set', __FUNCTION__);
}
}
if (function_exists('oci_connect')) {
if (isset($this->dsn['new_link']) && ($this->dsn['new_link'] == 'true' || $this->dsn['new_link'] === true)) {
$connect_function = 'oci_new_connect';
} else {
$connect_function = $persistent ? 'oci_pconnect' : 'oci_connect';
}
$charset = empty($this->dsn['charset']) ? null : $this->dsn['charset'];
$connection = @$connect_function($username, $password, $sid, $charset);
$error = @OCIError();
if (isset($error['code']) && $error['code'] == 12541) {
// Couldn't find TNS listener. Try direct connection.
$connection = @$connect_function($username, $password, null, $charset);
}
} else {
$connect_function = $persistent ? 'OCIPLogon' : 'OCILogon';
$connection = @$connect_function($username, $password, $sid);
if (!empty($this->dsn['charset'])) {
$result = $this->setCharset($this->dsn['charset'], $connection);
if (PEAR::isError($result)) {
return $result;
}
}
}
if (!$connection) {
return $this->raiseError(MDB2_ERROR_CONNECT_FAILED, null, null, 'unable to establish a connection', __FUNCTION__);
}
if (empty($this->dsn['disable_iso_date'])) {
$query = "ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'";
$err =& $this->_doQuery($query, true, $connection);
if (PEAR::isError($err)) {
$this->disconnect(false);
return $err;
}
}
$query = "ALTER SESSION SET NLS_NUMERIC_CHARACTERS='. '";
$err =& $this->_doQuery($query, true, $connection);
if (PEAR::isError($err)) {
$this->disconnect(false);
return $err;
}
return $connection;
}
示例14: nextid
function nextid($seqname)
{
$this->connect();
$Query_ID = @ociparse($this->Link_ID, "SELECT {$seqname}.NEXTVAL FROM DUAL");
if (!@ociexecute($Query_ID)) {
$this->Error = @OCIError($Query_ID);
if ($this->Error["code"] == 2289) {
$Query_ID = ociparse($this->Link_ID, "CREATE SEQUENCE {$seqname}");
if (!ociexecute($Query_ID)) {
$this->Error = OCIError($Query_ID);
$this->Errors->addError("Database error: " . $this->Error["message"]);
return 0;
} else {
$Query_ID = ociparse($this->Link_ID, "SELECT {$seqname}.NEXTVAL FROM DUAL");
ociexecute($Query_ID);
}
}
}
if (ocifetch($Query_ID)) {
$next_id = ociresult($Query_ID, "NEXTVAL");
} else {
$next_id = 0;
}
ocifreestatement($Query_ID);
return $next_id;
}
示例15: RollbackTransaction
function RollbackTransaction()
{
$this->Debug("Rollback Transaction");
if ($this->auto_commit) {
return $this->SetError("Rollback transaction", "transactions can not be rolled back when changes are auto commited");
}
if ($this->uncommitedqueries) {
if (!OCIRollback($this->connection)) {
return $this->SetOCIError("Rollback transaction", "Could not rollback pending transaction", OCIError());
}
$this->uncommitedqueries = 0;
}
return 1;
}