O'Reilly logo

CakePHP 1.3 Application Development Cookbook by Mariano Iglesias

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Improving the SQL datasource query log

This recipe shows how to create a component that will offer extended logging of all queries executed on any SQL-based datasource that supports the EXPLAIN command (this recipe is designed to work with MySQL, but can be adapted to other SQL based datasources), and show that information when the appropriate debug setting is set.

Getting ready

To go through this recipe we need a sample table to work with. Create a table named accounts, using the following SQL statement:

CREATE TABLE `accounts`(
`id` INT UNSIGNED AUTO_INCREMENT NOT NULL,
`email` VARCHAR(255) NOT NULL,
PRIMARY KEY(`id`)
);

Create a table named profiles, using the following SQL statement:

CREATE TABLE `profiles`( `id` INT UNSIGNED AUTO_INCREMENT ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required