/** * @see DBManager::checkError() */ public function checkError($msg = '', $dieOnError = false, $stmt = null) { if (parent::checkError($msg, $dieOnError)) { return true; } if (empty($stmt)) { return false; } $err = oci_error($stmt); if ($err) { $error = $err['code'] . "-" . $err['message']; $this->registerError($msg, $error, $dieOnError); return true; } return false; }
/** * Finalize after statement execution * @param mixed $res Result. If false, it failed * @param string $msg Error message * @return false|PreparedStatement */ protected function finishStatement($res, $msg) { $this->DBM->query_time = microtime(true) - $this->DBM->query_time; $GLOBALS['log']->info('Query Execution Time:' . $this->DBM->query_time); if ($this->DBM->checkError("{$msg}: Query Failed")) { $this->stmt = false; return false; } if (!$res) { $this->DBM->registerError($msg, "Query Failed"); $this->stmt = false; // Making sure we don't use the statement resource for error reporting } else { if ($this->DBM->dump_slow_queries($this->parsedSQL)) { $this->DBM->track_slow_queries($this->parsedSQL); } } return $this; }
/** * @see DBManager::checkError() */ public function checkError($msg = '', $dieOnError = false) { if (parent::checkError($msg, $dieOnError)) { return true; } if (mysql_errno($this->getDatabase())) { if ($this->dieOnError || $dieOnError) { $GLOBALS['log']->fatal("MySQL error " . mysql_errno($this->database) . ": " . mysql_error($this->database)); sugar_die($msg . "MySQL error " . mysql_errno($this->database) . ": " . mysql_error($this->database)); } else { $this->last_error = $msg . "MySQL error " . mysql_errno($this->database) . ": " . mysql_error($this->database); $GLOBALS['log']->error("MySQL error " . mysql_errno($this->database) . ": " . mysql_error($this->database)); } return true; } return false; }
/** * @see DBManager::checkError() */ public function checkError($msg = '', $dieOnError = false) { if (DBManager::checkError($msg, $dieOnError)) { return true; } $userMsg = inDeveloperMode() ? "{$msg}: " : ""; if (mysqli_errno($this->getDatabase())) { if ($this->dieOnError || $dieOnError) { $GLOBALS['log']->fatal("{$msg}: MySQL error " . mysqli_errno($this->database) . ": " . mysqli_error($this->database)); sugar_die($userMsg . $GLOBALS['app_strings']['ERR_DB_FAIL']); } else { $this->last_error = $userMsg . "MySQL error " . mysqli_errno($this->database) . ": " . mysqli_error($this->database); $GLOBALS['log']->error("{$msg}: MySQL error " . mysqli_errno($this->database) . ": " . mysqli_error($this->database)); } return true; } return false; }
/** * @see DBManager::checkError() */ public function checkError($msg = '', $dieOnError = false) { if (parent::checkError($msg, $dieOnError)) { return true; } if (mysql_errno($this->getDatabase())) { if ($this->dieOnError || $dieOnError) { //$GLOBALS['log']->fatal("MySQL error ".mysql_errno($this->database).": ".mysql_error($this->database)); if ($_REQUEST['debug'] == 1) { ts_die($msg . "SQL Error " . mysql_errno($this->database) . ": " . mysql_error($this->database)); } else { ts_die("SQL Error :Line 126"); } } else { $this->last_error = $msg . "MySQL error " . mysql_errno($this->database) . ": " . mysql_error($this->database); //$GLOBALS['log']->error("MySQL error ".mysql_errno($this->database).": ".mysql_error($this->database)); } return true; } return false; }
/** * @see DBManager::checkError() */ public function checkError($msg = '', $dieOnError = false) { if (DBManager::checkError($msg, $dieOnError)) { return true; } $sqlmsg = $this->_getLastErrorMessages(); $sqlpos = strpos($sqlmsg, 'Changed database context to'); if ($sqlpos !== false) { $sqlmsg = ''; } else { global $app_strings; //ERR_MSSQL_DB_CONTEXT: localized version of 'Changed database context to' message if (empty($app_strings) or !isset($app_strings['ERR_MSSQL_DB_CONTEXT']) or !isset($app_strings['ERR_MSSQL_WARNING'])) { //ignore the message from sql-server if $app_strings array is empty. This will happen //only if connection if made before languge is set. $GLOBALS['log']->debug("Ignoring this database message: " . $sqlmsg); $sqlmsg = ''; } else { $sqlpos = strpos($sqlmsg, $app_strings['ERR_MSSQL_DB_CONTEXT']); $sqlpos2 = strpos($sqlmsg, $app_strings['ERR_MSSQL_WARNING']); if ($sqlpos !== false || $sqlpos2 !== false) { $sqlmsg = ''; } } } if (strlen($sqlmsg) > 2) { $GLOBALS['log']->fatal("SQL Server error: " . $sqlmsg); return true; } return false; }
/** * @see DBManager::checkError() */ public function checkError($msg = '', $dieOnError = false) { if (parent::checkError($msg, $dieOnError)) { return true; } $sqlmsg = mssql_get_last_message(); $sqlpos = strpos($sqlmsg, 'Changed database context to'); $sqlpos2 = strpos($sqlmsg, 'Warning:'); $sqlpos3 = strpos($sqlmsg, 'Checking identity information:'); if ($sqlpos !== false || $sqlpos2 !== false || $sqlpos3 !== false) { $sqlmsg = ''; } else { global $app_strings; //ERR_MSSQL_DB_CONTEXT: localized version of 'Changed database context to' message if (empty($app_strings) or !isset($app_strings['ERR_MSSQL_DB_CONTEXT'])) { //ignore the message from sql-server if $app_strings array is empty. This will happen //only if connection if made before languge is set. $GLOBALS['log']->debug("Ignoring this database message: " . $sqlmsg); $sqlmsg = ''; } else { $sqlpos = strpos($sqlmsg, $app_strings['ERR_MSSQL_DB_CONTEXT']); if ($sqlpos !== false) { $sqlmsg = ''; } } } if (strlen($sqlmsg) > 2) { $GLOBALS['log']->fatal("{$msg}: SQL Server error: " . $sqlmsg); return true; } return false; }
/** * @see DBManager::checkError() */ public function checkError($msg = '', $dieOnError = false) { if (parent::checkError($msg, $dieOnError)) { return true; } $sqlmsg = mssql_get_last_message(); $sqlpos = strpos($sqlmsg, 'Changed database context to'); $sqlpos2 = strpos($sqlmsg, 'Caution: Changing any part of an object name could break scripts and stored procedures.'); if ($sqlpos !== false || $sqlpos2 !== false) { $sqlmsg = ''; } else { global $app_strings; //ERR_MSSQL_DB_CONTEXT: localized version of 'Changed database context to' message if (empty($app_strings) or !isset($app_strings['ERR_MSSQL_DB_CONTEXT'])) { //ignore the message from sql-server if $app_strings array is empty. This will happen //only if connection if made before languge is set. //$GLOBALS['log']->debug("Ignoring this database message: " . $sqlmsg); $sqlmsg = ''; } else { $sqlpos = strpos($sqlmsg, $app_strings['ERR_MSSQL_DB_CONTEXT']); if ($sqlpos !== false) { $sqlmsg = ''; } } } if (strlen($sqlmsg) > 2) { //$GLOBALS['log']->fatal("SQL Server error: " . $sqlmsg); return true; } return false; }
public function testDisconnect() { $this->_db->disconnect(); $this->assertTrue($this->_db->checkError()); $this->_db = DBManagerFactory::getInstance(); }
/** * @return array */ public function errorInfo() { $this->_db->checkError(); return array(0, 0, $this->_db->lastError()); }