本文整理汇总了PHP中YDDebugUtil::getStackTrace方法的典型用法代码示例。如果您正苦于以下问题:PHP YDDebugUtil::getStackTrace方法的具体用法?PHP YDDebugUtil::getStackTrace怎么用?PHP YDDebugUtil::getStackTrace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类YDDebugUtil
的用法示例。
在下文中一共展示了YDDebugUtil::getStackTrace方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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. In case of an error, this function triggers an error.
*
* @internal
*/
function &_connectAndExec($sql)
{
// Add the table prefix
$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 && $this->_failOnError === true) {
$error = ocierror();
trigger_error($error['message'], YD_ERROR);
}
// Record the start time
$timer = new YDTimer();
// Create statement
$stmt = OCIParse($this->_conn, $sql);
// Handle errors
if (!$stmt && $this->_failOnError === true) {
$error = ocierror($stmt);
trigger_error($error['message'], YD_ERROR);
}
// Execute
$result = @OCIExecute($stmt);
// Handle errors
if ($result === false && $this->_failOnError === true) {
$error = ocierror($stmt);
if (!empty($error['sqltext'])) {
$error['message'] .= ' (SQL: ' . $error['sqltext'] . ')';
}
echo '<b>Stacktrace:</b> <pre>' . YDDebugUtil::getStackTrace() . '</pre>';
echo '<b>SQL Statement:</b> <pre>' . $this->formatSql($sql) . '</pre>';
trigger_error($error['message'], YD_ERROR);
}
// Log the statement
$this->_logSql($sql, $timer->getElapsed());
// Return the result
return $stmt;
}
示例2: stackTrace
/**
* This function will print a stack trace.
*
* @static
*/
function stackTrace()
{
if (YDConfig::get('YD_DEBUG') == 1 || YDConfig::get('YD_DEBUG') == 2) {
$err = 'URI: ' . YD_SELF_URI . YD_CRLF . YDDebugUtil::getStackTrace();
if (ini_get('display_errors') == 1) {
echo '<pre>' . YD_CRLF . htmlentities($err) . '</pre>';
}
error_log($err, 0);
}
}
示例3: _logSql
/**
* This function will log the SQL statement to the debug log and keep track of the number of queries that were
* executed. This will only happen if YD_DEBUG equals 1 or 2
*
* @param $sql The SQL statement to log.
* @param $elapsed (optional) The time the query needed to be executed.
*
* @internal
*/
function _logSql($sql, $elapsed = null)
{
// Show debugging info if needed
if (YDConfig::get('YD_DEBUG') == 1 || YDConfig::get('YD_DEBUG') == 2) {
// Construct the array with the data for the SQL statement
$data = array('trace' => YDDebugUtil::getStackTrace(), 'sql' => $sql = $this->formatSql($sql), 'time' => $elapsed);
// Add it to the query log
array_push($GLOBALS['YD_SQL_QUERY'], $data);
}
}
示例4: 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);
// 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();
// Record the start time
$timer = new YDTimer();
// Perform the query
$result = $this->_conn->queryExec($sql);
// Handle errors
if ($result === false && $this->_failOnError === true) {
echo '<b>Stacktrace:</b> <pre>' . YDDebugUtil::getStackTrace() . '</pre>';
echo '<b>SQL Statement:</b> <pre>' . $this->formatSql($sql) . '</pre>';
$msg = $this->_conn->errorInfo();
trigger_error('<b>SQLite error message: </b>' . $msg[2], YD_ERROR);
}
// Log the statement
$this->_logSql($sql, $timer->getElapsed());
// Return the result
return $result;
}
示例5: 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);
// Update the language placeholders
$languageIndex = YDConfig::get('YD_DB_LANGUAGE_INDEX', null);
if (!is_null($languageIndex)) {
$sql = str_replace('_@', '_' . $languageIndex, $sql);
}
// Connect to database
$result = $this->connect();
// Handle errors
if (!$result && $this->_failOnError === true) {
trigger_error($GLOBALS['YD_SQLITE_error'], YD_ERROR);
}
// Record the start time
$timer = new YDTimer();
// Execute the query
$result = @sqlite_query($sql, $this->_conn);
// Handle errors
if ($result === false && $this->_failOnError === true) {
echo '<b>Stacktrace:</b> <pre>' . YDDebugUtil::getStackTrace() . '</pre>';
echo '<b>SQL Statement:</b> <pre>' . $this->formatSql($sql) . '</pre>';
trigger_error(sqlite_error_string(sqlite_last_error($this->_conn)), YD_ERROR);
}
// Log the statement
$this->_logSql($sql, $timer->getElapsed());
// Return the result
return $result;
}
示例6: 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);
// Connect
$result = $this->connect();
// Handle errors
if (!$result && $this->_failOnError === true) {
trigger_error(pg_last_error(), YD_ERROR);
}
// Record the start time
$timer = new YDTimer();
// Perform the query
$result = @pg_query($this->_conn, $sql);
// Handle errors
if ($result === false && $this->_failOnError === true) {
echo '<b>Stacktrace:</b> <pre>' . YDDebugUtil::getStackTrace() . '</pre>';
echo '<b>SQL Statement:</b> <pre>' . $this->formatSql($sql) . '</pre>';
trigger_error(pg_last_error($this->conn), YD_ERROR);
}
// Log the statement
$this->_logSql($sql, $timer->getElapsed());
// Return the result
return $result;
}