Archive for February, 2010

CakePHP: catching errors in Model->query()

In my recent CakePHP application I use some custom SQL queries that I fire at the database using the $model->query($sql) syntax. Works great, until you have an error in your $sql. I tried the obvious error handling with try … catch: try {   $this->Model->query(’INSERT INTO model WHERE id=invalid’); } catch (exception $ex) {   [...]

More »