Ejemplo n.º 1
0
    /**
     * Render all {@link ProfilerSQLNode} queries for the given node, and traverse it's child nodes
     * to render their queries also.
     *
     * @param ProfilerNode $node The node to begin rendering
     */
    public static function renderNodeSQL($node)
    {
        if ($node->hasSQLQueries()) {
            $c = 0;
            //row counter
            $nodeQueries = $node->getSQLQueries();
            ?>
			
			<tr class="profiler-query-node-name" id="profiler-node-queries-<?php 
            echo md5($node->getName() . $node->getStart());
            ?>
">
				<th colspan="4"><?php 
            echo $node->getName();
            ?>
</th>
			</tr>
		
			<?php 
            foreach ($nodeQueries as $query) {
                ?>
				<tr class="profiler-query-info-header profiler-node-queries-<?php 
                echo md5($node->getName() . $node->getStart());
                ?>
">
					<th class="profiler-gutter">&nbsp;</td>
					<th>start time (ms)</th>
					<th>duration (ms)</th>
					<th>query type</th>
				</tr>
				<tr class="profiler-query-info profiler-node-queries-<?php 
                echo md5($node->getName() . $node->getStart());
                ?>
">
					<td>&nbsp;</td>
					<td class="profiler-query-start-timer profiler-monospace">
						<span class="profiler-unit">T+</span><?php 
                echo round($query->getStart() - Profiler::getGlobalStart(), 1);
                ?>
					</td>
					<td class="profiler-query-duration profiler-monospace"><?php 
                echo $query->getDuration();
                ?>
</td>
					<td class="profiler-query-type"><?php 
                echo $query->getQueryType();
                ?>
</td>
				</tr>
				<tr>
					<td class="profiler-node-queries-<?php 
                echo md5($node->getName() . $node->getStart());
                ?>
">&nbsp;</td>
					<td class="profiler-node-queries-<?php 
                echo md5($node->getName() . $node->getStart());
                ?>
" colspan="3">
						<pre class="prettyprint lang-sql"><?php 
                echo $query->getQuery();
                ?>
</pre>
					</td>
				</tr>
				<tr>
					<td colspan="4" class="profiler-query-more-info-links">
						<a href="#profiler-results" class="profiler-back-to-top">top</a>
						&nbsp;&middot;&nbsp;
						<a href="#<?php 
                echo md5($query->getQuery()) . "_query_callstack";
                ?>
" class="profiler-show-callstack" data-query-id="<?php 
                echo md5($query->getQuery());
                ?>
">show callstack</a>
					</td>
				</tr>
				<tr class="profiler-hidden" id="<?php 
                echo md5($query->getQuery()) . "_query_callstack";
                ?>
">
					<td>&nbsp;</td>
					<td colspan="3">
						<table class="profiler-query_callstack">
							<?php 
                foreach ($query->getCallstack() as $stackStep) {
                    ?>
								<tr class="<?php 
                    echo ++$c % 2 ? 'odd' : 'even';
                    ?>
">
									<td class="profiler-callstack-method"><code class="prettyprint"><?php 
                    echo (!empty($stackStep['class']) ? $stackStep['class'] . $stackStep['type'] : '') . $stackStep['function'];
                    ?>
</code></td>
								</tr>
							<?php 
                }
                ?>
						</table>
					</td>
				</tr>
				<tr class="profiler-query-seperator">
					<td colspan="4"><div class="profiler-hr"><hr /></div></td>
				</tr>
				
			<?php 
            }
        }
        if ($node->hasChildren()) {
            foreach ($node->getChildren() as $childNode) {
                self::renderNodeSQL($childNode);
            }
        }
    }