You are currently browsing Crystal’s documentation for the 0.4 version - Switch to version: 0.3

Queries - debug and optimization

Crystal provides several ways for optimizing and debugging queries.

print_sql()

$db->get('table')->print_sql();
// Prints SELECT * FROM `table` 

You can use the print_sql function when you want to see the query string before Crystal sends it to the database. The print_sql function doesn't connect to the database. It just prints the SQL string.

query_time()

$db->get('table')->query_time();
// Prints Query took 0.0004 sec