02.05
php
saved
grigri
Note
Overriding the datasource for fun and profit.
Overriding the datasource for fun and profit.
- <?php
- require_once (LIBS . 'model' . DS . 'datasources' . DS . 'dbo' . DS . 'dbo_mysql.php');
- class DboMysqlEx extends DboMysql {
- var $description = "MySQL DBO Driver - Extended";
- // Override resultSet to allow for Model__field type aliases
- function resultSet(&$results) {
- $this->results =& $results;
- $index = 0;
- $j = 0;
- while ($j < $num_fields) {
- } else {
- } else {
- }
- }
- $j++;
- }
- }
- // Override logQuery to provide backtrace information
- function logQuery($sql) {
- $logEntry = false;
- foreach ($trace as $step) {
- break;
- }
- //if (preg_match('#_controller.php$#', $file)) {
- if ($logEntry) {
- $function = $step['function'];
- if ($step['class'] == 'Model' && $step['type'] == '->' && $step['function'] == 'find') {
- $function .= '(\'' . $step['args'][0] . '\')';
- }
- }
- '%s - %s , [%s] %s%s%s',
- $file,
- $step['line'],
- $step['class'],
- $step['type'],
- $function
- );
- }
- $logEntry = true;
- }
- }
- }
- }
- $ret = parent::logQuery($sql);
- return $ret;
- }
- // Override showLog to display syntax-highlighted SQL in the log.
- // Uses geshi - ensure geshi is in app/vendors/geshi.php
- function showLog($sorted = false) {
- if ($sorted) {
- $log = sortByKey($this->_queriesLog, 'took', 'desc', SORT_NUMERIC);
- } else {
- $log = $this->_queriesLog;
- }
- if ($this->_queriesCnt > 1) {
- $text = 'queries';
- } else {
- $text = 'query';
- }
- require_once APP . 'vendors' . DS . 'geshi.php';
- $geshi = new GeSHi('', 'mysql');
- $geshi->set_header_type(GESHI_HEADER_NONE);
- print ("<table class=\"cake-sql-log\" id=\"cakeSqlLog_" . preg_replace('/[^A-Za-z0-9_]/', '_', uniqid(time(), true)) . "\" summary=\"Cake SQL Log\" cellspacing=\"0\" border = \"0\">\n<caption>{$this->_queriesCnt} {$text} took {$this->_queriesTime} ms</caption>\n");
- print ("<thead>\n<tr><th>Nr</th><th>Query</th><th>Error</th><th>Affected</th><th>Num. rows</th><th>Took (ms)</th></tr>\n</thead>\n<tbody>\n");
- foreach ($log as $k => $i) {
- $geshi->set_source($i['query']);
- $query = $geshi->parse_code();
- print ("<tr><td>" . ($k + 1) . "</td><td>" . $query . "</td><td>{$i['error']}</td><td style = \"text-align: right\">{$i['affected']}</td><td style = \"text-align: right\">{$i['numRows']}</td><td style = \"text-align: right\">{$i['took']}</td></tr>\n");
- }
- } else {
- foreach ($log as $k => $i) {
- }
- }
- }
- }
- ?>
Parsed in 0.245 seconds, using GeSHi 1.0.7.14