Forums
 
Return To The Forum
SQL output from a shell
Posted On Dec 25, 2011 at 4:21 PM

Author Message
admin


Administrator

Joined: Jan 24, 2010
Last Visit: Feb 13, 2012
Posts: 1


View All Posts By admin
If you are using shells and want to output SQL for debugging, simply do this:

In your shell or other accessible file, create this function:


public function sqlDump($dbConfig = 'default', $exit = true) {    

ConnectionManager::getDataSource($dbConfig)->showLog(); 

    if($exit){ 

        exit; 

    }

}



Next, in your shell create a destructor, like so:

public function __destruct() {

    $this->hr();

    $this->sqlDump();

}



Now, after your shell ends, you'll see the SQL log of all model calls.



All Times Are Hours
Jump To Forum: