CakePHP related

It’s been ages to post here (as usual), so I just thought of putting couple of things about CakePHP and stuff related.

First of all, if you are developing under windows, and the production server is running Linux, keep in mind that Linux file system is case-sensitive. So if you create an image linked to logo.jpg, while the file will be logo.JPG – it won’t work. CakePHP tries to locate file on filesystem and it will look only for logo.jpg and fail in case you put logo.JPG.

Second, if you need to have direct access to MySQL to run some queries using native PHP mysql_query methods, but you don’t want to specify DB settings twice, you can always extract current connection from CakePHP models as follows (assuming you are using some model called ‘User’ and it is available in the current class):

$dataSource = $this->User->getDataSource();
$db = $dataSource->connection;
$result = mysql_query("SELECT .... WHERE .... LIMIT 10,20",$db);

I use this when I need to work with huge tables to run some CakePHP shell scripts faster :)