本文整理汇总了PHP中SqlFormatter::number_attributes方法的典型用法代码示例。如果您正苦于以下问题:PHP SqlFormatter::number_attributes方法的具体用法?PHP SqlFormatter::number_attributes怎么用?PHP SqlFormatter::number_attributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SqlFormatter
的用法示例。
在下文中一共展示了SqlFormatter::number_attributes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: foreach
/**
* Shows the debugging console, <i>if</i> {@link debug} is TRUE and the viewer's IP address is in the
* {@link debugger_ip} array (or <i>$debugger_ip</i> is an empty array).
*
* <i>This method must be called after all the queries in a script, preferably before </body>!</i>
*
* <b>You should ALWAYS have this method called at the end of your scripts and control whether the debugging console
* will show or not with the {@link debug} property.</b>
*
* @param boolean $return (Optional) If set to TRUE, the output will be returned instead of being printed
* to the screen.
*
* Default is FALSE.
*
* @return void
*/
function show_debug_console($return = false)
{
// if
if ($this->debug && is_array($this->debugger_ip) && (empty($this->debugger_ip) || in_array($_SERVER['REMOTE_ADDR'], $this->debugger_ip))) {
// include the SqlFormatter library
require 'includes/SqlFormatter.php';
// set some properties for the formatter
SqlFormatter::$number_attributes = SqlFormatter::$boundary_attributes = 'class="symbol"';
SqlFormatter::$quote_attributes = 'class="string"';
SqlFormatter::$reserved_attributes = 'class="keyword"';
SqlFormatter::$tab = ' ';
// if warnings are not disabled
if (!$this->disable_warnings) {
// if there are any warning messages iterate through them
foreach (array_keys($this->warnings) as $warning) {
// add them to the debugging console
$this->_log('warnings', array('message' => $this->language['warning_' . $warning]), false);
}
}
// blocks to be shown in the debugging console
$blocks = array('errors' => array('counter' => 0, 'identifier' => 'e', 'generated' => ''), 'successful-queries' => array('counter' => 0, 'identifier' => 'sq', 'generated' => ''), 'unsuccessful-queries' => array('counter' => 0, 'identifier' => 'uq', 'generated' => ''), 'warnings' => array('counter' => 0, 'identifier' => 'w', 'generated' => ''), 'globals' => array('generated' => ''));
// there are no warnings
$warnings = false;
// prepare output for each block
foreach (array_keys($blocks) as $block) {
$output = '';
// if there is any information for the current block
if (isset($this->debug_info[$block])) {
// iterate through the error message
foreach ($this->debug_info[$block] as $debug_info) {
// increment the messages counter
$counter = ++$blocks[$block]['counter'];
$identifier = $blocks[$block]['identifier'];
// if block is about queries
if ($block == 'successful-queries' || $block == 'unsuccessful-queries') {
// format and highlight query
$debug_info['query'] = SqlFormatter::format($debug_info['query']);
}
// all blocks are enclosed in tables
$output .= '
<table cellspacing="0" cellpadding="0" border="0" class="zdc-entry' . ($counter % 2 == 0 ? ' even' : '') . (isset($debug_info['highlight']) && $debug_info['highlight'] == 1 ? ' zdc-highlight' : '') . '">
<tr>
<td class="zdc-counter" valign="top">' . str_pad($counter, 3, '0', STR_PAD_LEFT) . '</td>
<td class="zdc-data">
';
// are there any error messages issued by the script?
if (isset($debug_info['message']) && trim($debug_info['message']) != '') {
$output .= '
<div class="zdc-box zdc-error">
' . $debug_info['message'] . '
</div>
';
}
// are there any error messages issued by MySQL?
if (isset($debug_info['error']) && trim($debug_info['error']) != '') {
$output .= '
<div class="zdc-box zdc-error">
' . $debug_info['error'] . '
</div>
';
}
// are there any warning messages issued by the script?
if (isset($debug_info['warning']) && trim($debug_info['warning']) != '') {
$output .= '
<div class="zdc-box zdc-error">' . $debug_info['warning'] . '
</div>
';
// set a flag so that we show in the minimized debugging console that there are warnings
$warnings = true;
}
// is there a query to be displayed?
if (isset($debug_info['query'])) {
$output .= '
<div class="zdc-box' . (isset($debug_info['transaction']) && $debug_info['transaction'] ? ' zdc-transaction' : '') . '">' . preg_replace('/^\\<br\\>/', '', html_entity_decode($debug_info['query'])) . '
</div>
';
}
// start generating the actions box
$output .= '
<div class="zdc-box zdc-actions">
<ul>
';
// actions specific to successful queries
if ($block == 'successful-queries') {
//.........这里部分代码省略.........
示例2: formatQuery
/**
* Formats and/or highlights the given SQL statement.
*
* @param string $sql
* @param bool $highlightOnly If true the query is not formatted, just highlighted
*
* @return string
*/
public function formatQuery($sql, $highlightOnly = false)
{
\SqlFormatter::$pre_attributes = 'class="highlight highlight-sql"';
\SqlFormatter::$quote_attributes = 'class="string"';
\SqlFormatter::$backtick_quote_attributes = 'class="string"';
\SqlFormatter::$reserved_attributes = 'class="keyword"';
\SqlFormatter::$boundary_attributes = 'class="symbol"';
\SqlFormatter::$number_attributes = 'class="number"';
\SqlFormatter::$word_attributes = 'class="word"';
\SqlFormatter::$error_attributes = 'class="error"';
\SqlFormatter::$comment_attributes = 'class="comment"';
\SqlFormatter::$variable_attributes = 'class="variable"';
if ($highlightOnly) {
$html = \SqlFormatter::highlight($sql);
$html = preg_replace('/<pre class=".*">([^"]*+)<\\/pre>/Us', '\\1', $html);
} else {
$html = \SqlFormatter::format($sql);
$html = preg_replace('/<pre class="(.*)">([^"]*+)<\\/pre>/Us', '<div class="\\1"><pre>\\2</pre></div>', $html);
}
return $html;
}