Convert sql queries to CakePHP code