I'm using cake php version 2.4.1
I want change this SQL query into PHP code for my controller in cakePHP
SELECT id,name
FROM providers
WHERE id not in
(SELECT c.provider_id
FROM token_maps a
INNER JOIN token_map_groups b ON b.token_map_id = a.id
INNER JOIN token_map_group_providers c on c.token_map_group_id=b.id
LEFT JOIN providers p on p.id=c.provider_id
WHERE a.id=2
)
I can't use $this->Provider->query('sql query');
because it will give me false result different from when I execute the query in mysql.
can anyone help me?
Provider.php, use:$this->query('sql query');. If you in other model, write your way is ok. If your model class don't load, try$Provider_Model = ClassRegistry::init('Provider'); $result_array = $Provider_Model->query(...);.