本文整理匯總了PHP中SqlFormatter::word_attributes方法的典型用法代碼示例。如果您正苦於以下問題:PHP SqlFormatter::word_attributes方法的具體用法?PHP SqlFormatter::word_attributes怎麽用?PHP SqlFormatter::word_attributes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SqlFormatter
的用法示例。
在下文中一共展示了SqlFormatter::word_attributes方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: 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;
}
示例2: foreach
function sy_format_sql($query, array $data = null)
{
if (!empty($data)) {
foreach ($data as $name => $value) {
$query = str_replace(':' . $name, \Simplify::db()->quote($value), $query);
}
}
\SqlFormatter::$reserved_attributes = 'style="color: #F00; font-weight: bold;"';
\SqlFormatter::$word_attributes = 'style="color: #00F;"';
\SqlFormatter::$use_pre = false;
return "\n" . \SqlFormatter::format($query) . "\n";
}