I use this to force a sql dump after a request - I have it in app_controller

    public function dsql() {

        if (!class_exists('ConnectionManager') || Configure::read('debug') <
2) {
            return false;
        }

        $sources = ConnectionManager::sourceList();
        if (!isset($logs)):
            $logs = array();
            foreach ($sources as $source):
                $db =& ConnectionManager::getDataSource($source);
                if (!$db->isInterfaceSupported('getLog')):
                    continue;
                endif;
                $logs[$source] = $db->getLog();
            endforeach;
        endif;

        foreach ($logs as $source => $logInfo):
            $text = $logInfo['count'] > 1 ? 'queries' : 'query';
            printf(
                '<pre><table class="cake-sql-log" id="cakeSqlLog_%s"
summary="Cake SQL Log" cellspacing="0" border = "0">',
                preg_replace('/[^A-Za-z0-9_]/', '_', uniqid(time(), true))
            );
            printf('<caption>(%s) %s %s took %s ms</caption>', $source,
$logInfo['count'], $text, $logInfo['time']);
            foreach ($logInfo['log'] as $k => $i) :
                echo "<tr><td>" . ($k + 1) . "</td><td>" . h($i['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";
            endforeach;
            echo "</tbody></table></pre>";

        endforeach;

    }


On 24 May 2011 02:56, OldWest <[email protected]> wrote:

> My problem now is I cannot get the sql dump for the tool to display as this
> is an ajax request.
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group
> at http://groups.google.com/group/cake-php
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to