本文整理匯總了PHP中YDDebugUtil::error方法的典型用法代碼示例。如果您正苦於以下問題:PHP YDDebugUtil::error方法的具體用法?PHP YDDebugUtil::error怎麽用?PHP YDDebugUtil::error使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類YDDebugUtil
的用法示例。
在下文中一共展示了YDDebugUtil::error方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: str_replace
/**
* This function will connect to the database, execute a query and will return the result handle.
*
* @param $sql The SQL statement to execute.
*
* @returns Handle to the result of the query.
*
* @internal
*/
function &_connectAndExec($sql)
{
// Add the table prefix
$sql = str_replace(' #_', ' ' . YDConfig::get('YD_DB_TABLEPREFIX', ''), $sql);
$sql = str_replace(' `#_', ' `' . YDConfig::get('YD_DB_TABLEPREFIX', ''), $sql);
// Connect
$result = $this->connect();
// Handle errors
if (!$result && is_null($this->_conn) && $this->_failOnError === true) {
trigger_error(mysql_error(), YD_ERROR);
}
if (!$result && !is_null($this->_conn) && $this->_failOnError === true) {
trigger_error(mysql_error($this->_conn), YD_ERROR);
}
// Record the start time
$timer = new YDTimer();
// Execute the query
$result = @mysql_query($sql, $this->_conn);
// Handle errors
if ($result === false && $this->_failOnError === true) {
YDDebugUtil::error('[' . mysql_errno($this->_conn) . '] ' . mysql_error($this->_conn), $sql);
}
// Log the statement
$this->_logSql($sql, $timer->getElapsed());
// Return the result
return $result;
}
示例2: str_replace
/**
* This function will connect to the database, execute a query and will return the result handle.
*
* @param $sql The SQL statement to execute.
*
* @returns Handle to the result of the query.
*
* @internal
*/
function &_connectAndExec($sql)
{
// Add the table prefix
$sql = str_replace(' #_', ' ' . YDConfig::get('YD_DB_TABLEPREFIX', ''), $sql);
$sql = str_replace(' `#_', ' `' . YDConfig::get('YD_DB_TABLEPREFIX', ''), $sql);
// Update the language placeholders
$languageIndex = YDConfig::get('YD_DB_LANGUAGE_INDEX', null);
if (!is_null($languageIndex)) {
$sql = str_replace('_@', '_' . $languageIndex, $sql);
}
// Connect
$result = $this->connect();
// Handle errors
if (!$result && is_null($this->_conn) && $this->_failOnError === true) {
trigger_error(mysql_error(), YD_ERROR);
}
if (!$result && !is_null($this->_conn) && $this->_failOnError === true) {
trigger_error(mysql_error($this->_conn), YD_ERROR);
}
// Record the start time
$timer = new YDTimer();
// Execute the query
$result = @mysql_query($sql, $this->_conn);
// Log the statement
$this->_logSql($sql, $timer->getElapsed());
// Handle errors
if ($result === false) {
$callback = YDConfig::get('YD_DB_ERROR_CALLBACK');
// check if we should display the error or execute some callback
if (is_string($callback) || is_array($callback)) {
return call_user_func($callback, $sql, mysql_error($this->_conn), mysql_errno($this->_conn));
} elseif ($callback === false && $this->_failOnError === true) {
YDDebugUtil::error('[' . mysql_errno($this->_conn) . '] ' . mysql_error($this->_conn), $sql);
}
}
// Return the result
return $result;
}