Cakephp 1.3 get last executed query


#1

$this -> paginate = array(‘joins’ => array( array(‘table’ => ‘users’, ‘alias’ => ‘u’, ‘type’ => ‘left’, ‘foreignKey’ => false, ‘conditions’ => array(‘Patient.user_id = u.id’,‘Patient.is_active’ => 1))),
‘conditions’ => array($conditions[‘Patient.is_active’] = 1,
‘OR’ => array( array(‘u.created_by’ => $conditions[‘Patient.user_id’], ), ‘u.id’ => $conditions[‘Patient.user_id’]),
‘OR’ => array( array(‘Patient.first_name LIKE’ => ‘%’.$this -> data[‘Patient’][‘search_by_keywords’].’%’, ), ‘Patient.last_name LIKE’ => ‘%’.$this -> data[‘Patient’][‘search_by_keywords’].’%’),‘AND’ => array(‘Patient.is_active = 1’),‘AND’ => array('Patient.user_id = '.$conditions[‘Patient.user_id’],‘Patient.is_active = 1’)
),
‘fields’ => array(‘u.id’, ‘Patient.first_name’, ‘Patient.last_name’), ‘order’ => array(‘Patient.last_name ASC’, ‘Patient.first_name ASC’));

How to display the Raw mysql query for the above?


#2

Hi,
I’m not sure, it works in 2.x, but you can try:
Configure::write(‘debug’, 2);
$log = $this->Model_Name->getDataSource()->getLog(false, false);
debug($log);
In your case looks : Model_Name = Patient;