Search code examples
phpmysqlidiorm

idiorm view sql for debug


Using https://github.com/j4mie/idiorm for my php website.

How do I view the actual SQL that is generate?

ie:

$sql        = ORM::for_table('tbl')->create();
$sql->set(array(
    'another_id'=> $another_id,
    'name'  => $name,
    'active'    => 0
));
$sql->save();

Is generating an error, would like to view the output T-SQL, sometimes its just better to debug that way.

Ta


Solution

  • I am pretty sure using the set() is usually for updating records(that could be wrong). I would just do this:

    $sql = ORM::for_table('tbl')->create();
    
    $sql->another_id = $another_id;
    $sql->name = $name;
    $sql->active = 0;
    
    $sql->save();
    

    As far as getting the query, there is a 'logging' option in the config as well as a get_last_query function.