当前位置: 首页>>代码示例>>PHP>>正文


PHP SqlFormatter::pre_attributes方法代码示例

本文整理汇总了PHP中SqlFormatter::pre_attributes方法的典型用法代码示例。如果您正苦于以下问题:PHP SqlFormatter::pre_attributes方法的具体用法?PHP SqlFormatter::pre_attributes怎么用?PHP SqlFormatter::pre_attributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SqlFormatter的用法示例。


在下文中一共展示了SqlFormatter::pre_attributes方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: init

 public static function init(&$report)
 {
     $environments = PhpReports::$config['environments'];
     if (!isset($environments[$report->options['Environment']][$report->options['Database']])) {
         throw new Exception("No " . $report->options['Database'] . " database defined for environment '" . $report->options['Environment'] . "'");
     }
     //make sure the syntax highlighting is using the proper class
     SqlFormatter::$pre_attributes = "class='prettyprint linenums lang-sql'";
     $object = spyc_load($report->raw_query);
     $report->raw_query = array();
     //if there are any included reports, add the report sql to the top
     if (isset($report->options['Includes'])) {
         $included_sql = '';
         foreach ($report->options['Includes'] as &$included_report) {
             $included_sql .= trim($included_report->raw_query) . "\n";
         }
         if (strlen($included_sql) > 0) {
             $report->raw_query[] = $included_sql;
         }
     }
     $report->raw_query[] = $object;
     //set a formatted query here for debugging.  It will be overwritten below after macros are substituted.
     //We can not set the query here - it's not a query just yet...
     //$report->options['Query_Formatted'] = SqlFormatter::format($report->raw_query);
 }
开发者ID:doekia,项目名称:php-reports,代码行数:25,代码来源:AdoPivotReportType.php

示例2: init

 public static function init(&$report)
 {
     $environments = PhpReports::$config['environments'];
     if (!isset($environments[$report->options['Environment']][$report->options['Database']])) {
         throw new Exception("No " . $report->options['Database'] . " info defined for environment '" . $report->options['Environment'] . "'");
     }
     //make sure the syntax highlighting is using the proper class
     SqlFormatter::$pre_attributes = "class='prettyprint linenums lang-sql'";
     $mysql = $environments[$report->options['Environment']][$report->options['Database']];
     //default host macro to mysql's host if it isn't defined elsewhere
     if (!isset($report->macros['host'])) {
         $report->macros['host'] = $mysql['host'];
     }
     //replace legacy shorthand macro format
     foreach ($report->macros as $key => $value) {
         if (isset($report->options['Variables'][$key])) {
             $params = $report->options['Variables'][$key];
         } else {
             $params = array();
         }
         //macros shortcuts for arrays
         if (isset($params['multiple']) && $params['multiple']) {
             //allow {macro} instead of {% for item in macro %}{% if not item.first %},{% endif %}{{ item.value }}{% endfor %}
             //this is shorthand for comma separated list
             $report->raw_query = preg_replace('/([^\\{])\\{' . $key . '\\}([^\\}])/', '$1{% for item in ' . $key . ' %}{% if not loop.first %},{% endif %}\'{{ item }}\'{% endfor %}$2', $report->raw_query);
             //allow {(macro)} instead of {% for item in macro %}{% if not item.first %},{% endif %}{{ item.value }}{% endfor %}
             //this is shorthand for quoted, comma separated list
             $report->raw_query = preg_replace('/([^\\{])\\{\\(' . $key . '\\)\\}([^\\}])/', '$1{% for item in ' . $key . ' %}{% if not loop.first %},{% endif %}(\'{{ item }}\'){% endfor %}$2', $report->raw_query);
         } else {
             //allow {macro} instead of {{macro}} for legacy support
             $report->raw_query = preg_replace('/([^\\{])(\\{' . $key . '+\\})([^\\}])/', '$1{$2}$3', $report->raw_query);
         }
     }
     //if there are any included reports, add the report sql to the top
     if (isset($report->options['Includes'])) {
         $included_sql = '';
         foreach ($report->options['Includes'] as &$included_report) {
             $included_sql .= trim($included_report->raw_query) . "\n";
         }
         $report->raw_query = $included_sql . $report->raw_query;
     }
     //set a formatted query here for debugging.  It will be overwritten below after macros are substituted.
     $report->options['Query_Formatted'] = SqlFormatter::format($report->raw_query);
 }
开发者ID:edu-bob,项目名称:php-reports,代码行数:44,代码来源:MysqlReportType.php

示例3: 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;
 }
开发者ID:tsurune,项目名称:Pruebas,代码行数:29,代码来源:DoctrineExtension.php

示例4: highlightSQL

 /**
  * Highlight SQL syntax.
  *
  * @param string $sql
  * @return string
  */
 public function highlightSQL($sql)
 {
     \SqlFormatter::$pre_attributes = '';
     return trim(substr(\SqlFormatter::highlight($sql), 6, -6));
 }
开发者ID:milky-ashes,项目名称:profiler,代码行数:11,代码来源:ProfilerWrapper.php

示例5: getPanel

 /**
  * Renders HTML code for custom panel.
  * @return string
  */
 public function getPanel()
 {
     $queries = $this->queries;
     $html = '<h1>' . self::$title . '</h1>';
     $html .= '<div class="tracy-inner tracy-InfoPanel"><table width="300">';
     \SqlFormatter::$pre_attributes = 'style="color: black;"';
     foreach ($queries as $query) {
         $html .= '<tr><td>' . \SqlFormatter::highlight($query) . '</td></tr>';
     }
     $html .= '</table></div>';
     return $html;
 }
开发者ID:filisko,项目名称:tracy-redbean,代码行数:16,代码来源:RedBeanBarPanel.php


注:本文中的SqlFormatter::pre_attributes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。