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


PHP Connection::highlightSql方法代码示例

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


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

示例1: getPanel

    public function getPanel()
    {
        $s = '';
        $h = 'htmlSpecialChars';
        foreach ($this->queries as $i => $query) {
            list($sql, $params, $time, $rows, $connection, $source) = $query;
            $explain = NULL;
            // EXPLAIN is called here to work SELECT FOUND_ROWS()
            if ($this->explain && preg_match('#\\s*SELECT\\s#iA', $sql)) {
                try {
                    $explain = $connection->queryArgs('EXPLAIN ' . $sql, $params)->fetchAll();
                } catch (\PDOException $e) {
                }
            }
            $s .= '<tr><td>' . sprintf('%0.3f', $time * 1000);
            if ($explain) {
                $s .= "<br /><a href='#' class='nette-toggler' rel='#nette-debug-database-row-{$h($this->name)}-{$i}'>explain&nbsp;&#x25ba;</a>";
            }
            $s .= '</td><td class="database-sql">' . Connection::highlightSql(Nette\String::truncate($sql, self::$maxLength));
            if ($explain) {
                $s .= "<table id='nette-debug-database-row-{$h($this->name)}-{$i}' class='nette-collapsed'><tr>";
                foreach ($explain[0] as $col => $foo) {
                    $s .= "<th>{$h($col)}</th>";
                }
                $s .= "</tr>";
                foreach ($explain as $row) {
                    $s .= "<tr>";
                    foreach ($row as $col) {
                        $s .= "<td>{$h($col)}</td>";
                    }
                    $s .= "</tr>";
                }
                $s .= "</table>";
            }
            if ($source) {
                list($file, $line) = $source;
                $s .= (Nette\Debug::$editor ? "<a href='{$h(Nette\DebugHelpers::editorLink($file, $line))}'" : '<span') . " class='database-source' title='{$h($file)}:{$line}'>" . "{$h(basename(dirname($file)) . '/' . basename($file))}:{$line}" . (Nette\Debug::$editor ? '</a>' : '</span>');
            }
            $s .= '</td><td>';
            foreach ($params as $param) {
                $s .= "{$h(Nette\String::truncate($param, self::$maxLength))}<br>";
            }
            $s .= '</td><td>' . $rows . '</td></tr>';
        }
        return empty($this->queries) ? '' : '<style> #nette-debug-database td.database-sql { background: white !important }
			#nette-debug-database .database-source { color: #BBB !important }
			#nette-debug-database tr table { margin: 8px 0; max-height: 150px; overflow:auto } </style>
			<h1>Queries: ' . count($this->queries) . ($this->totalTime ? ', time: ' . sprintf('%0.3f', $this->totalTime * 1000) . ' ms' : '') . '</h1>
			<div class="nette-inner">
			<table>
				<tr><th>Time&nbsp;ms</th><th>SQL Statement</th><th>Params</th><th>Rows</th></tr>' . $s . '
			</table>
			</div>';
    }
开发者ID:JanTvrdik,项目名称:nette,代码行数:54,代码来源:DatabasePanel.php

示例2: getPanel

	public function getPanel()
	{
		$s = '';
		foreach ($this->queries as $query) {
			list($sql, $params, $time, $rows) = $query;
			$s .= '<tr><td>' . sprintf('%0.3f', $time * 1000) . '</td><td class="database-sql">' . Connection::highlightSql(Nette\String::truncate($sql, self::$maxLength))
				. '</td><td>' . htmlSpecialChars(implode(', ', $params)) . '</td><td>' . $rows . '</td></tr>';
		}

		return empty($this->queries) ? '' :
			'<style> #nette-debug-database td.database-sql { background: white !important } </style>
			<h1>Queries: ' . count($this->queries) . ($this->totalTime ? ', time: ' . sprintf('%0.3f', $this->totalTime * 1000) . ' ms' : '') . '</h1>
			<div class="nette-inner">
			<table>
				<tr><th>Time&nbsp;ms</th><th>SQL Statement</th><th>Params</th><th>Rows</th></tr>' . $s . '
			</table>
			</div>';
	}
开发者ID:newPOPE,项目名称:screencast,代码行数:18,代码来源:DatabasePanel.php

示例3: processQuery

	/**
	 * @param array
	 * @return string
	 */
	protected function processQuery(array $query)
	{
		$s = '';
		$h = 'htmlSpecialChars';
		list($sql, $params, $time, $rows, $connection, $source) = $query;

		$s .= '<tr><td>' . sprintf('%0.3f', $time * 1000);

		$s .= '</td><td class="nette-Doctrine2Panel-sql">' . Connection::highlightSql($sql);
		if ($source) {
			list($file, $line) = $source;
			if (Debugger::$editor) {
				$s .= \Nette\Diagnostics\Helpers::editorLink($file, $line);
			} else {
				$s .= "<span class='nette-Doctrine2Panel-source' title='{$h($file)}:$line'>"
					. $h(basename(dirname($file)) . '/' . basename($file)) . ":" . $line . "</span>";
			}
		}

		$s .= '</td><td>';
		$s .= \Nette\Diagnostics\Helpers::clickableDump($params, TRUE);
		$s .= '</td><td>' . $rows . '</td></tr>';
		return $s;
	}
开发者ID:norbe,项目名称:framework,代码行数:28,代码来源:Panel.php

示例4: getPanel

    public function getPanel()
    {
        $this->disabled = TRUE;
        $s = '';
        $h = 'htmlSpecialChars';
        foreach ($this->queries as $i => $query) {
            list($sql, $params, $time, $rows, $connection, $source) = $query;
            $explain = NULL;
            // EXPLAIN is called here to work SELECT FOUND_ROWS()
            if ($this->explain && preg_match('#\\s*SELECT\\s#iA', $sql)) {
                try {
                    $explain = $connection->queryArgs('EXPLAIN ' . $sql, $params)->fetchAll();
                } catch (\PDOException $e) {
                }
            }
            $s .= '<tr><td>' . sprintf('%0.3f', $time * 1000);
            if ($explain) {
                static $counter;
                $counter++;
                $s .= "<br /><a href='#' class='nette-toggler' rel='#nette-DbConnectionPanel-row-{$counter}'>explain&nbsp;&#x25ba;</a>";
            }
            $s .= '</td><td class="nette-DbConnectionPanel-sql">' . Connection::highlightSql(Nette\Utils\Strings::truncate($sql, self::$maxLength));
            if ($explain) {
                $s .= "<table id='nette-DbConnectionPanel-row-{$counter}' class='nette-collapsed'><tr>";
                foreach ($explain[0] as $col => $foo) {
                    $s .= "<th>{$h($col)}</th>";
                }
                $s .= "</tr>";
                foreach ($explain as $row) {
                    $s .= "<tr>";
                    foreach ($row as $col) {
                        $s .= "<td>{$h($col)}</td>";
                    }
                    $s .= "</tr>";
                }
                $s .= "</table>";
            }
            if ($source) {
                $s .= Nette\Diagnostics\Helpers::editorLink($source[0], $source[1])->class('nette-DbConnectionPanel-source');
            }
            $s .= '</td><td>';
            foreach ($params as $param) {
                $s .= Debugger::dump($param, TRUE);
            }
            $s .= '</td><td>' . $rows . '</td></tr>';
        }
        return empty($this->queries) ? '' : '<style> #nette-debug td.nette-DbConnectionPanel-sql { background: white !important }
			#nette-debug .nette-DbConnectionPanel-source { color: #BBB !important }
			#nette-debug nette-DbConnectionPanel tr table { margin: 8px 0; max-height: 150px; overflow:auto } </style>
			<h1>Queries: ' . count($this->queries) . ($this->totalTime ? ', time: ' . sprintf('%0.3f', $this->totalTime * 1000) . ' ms' : '') . '</h1>
			<div class="nette-inner nette-DbConnectionPanel">
			<table>
				<tr><th>Time&nbsp;ms</th><th>SQL Statement</th><th>Params</th><th>Rows</th></tr>' . $s . '
			</table>
			</div>';
    }
开发者ID:hleumas,项目名称:databaza,代码行数:56,代码来源:ConnectionPanel.php


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