How to Make a Query in CakePHP?

CakePHP

To Query from Table in CakePHP we can use the below code. We can also Query like ORDER_BY, Select Table FIELDS etc.

# Find Order from Order Table in CakePHP

$this->Order->find('all', array(
   'recursive' => -1,
   'conditions'=>array( 'Order.id'=>1 ),
   'fields' => array( 'Order.date', 'Order.id', 'Order.total'),
   'order' => array('Order.date' => 'DESC'),
));


# For Order By filter in Querry, we can use.

   'order' => array('Order.date' => 'DESC'),
or,
   'order' => array('Order.date DESC'),
or,
   'order' => 'Order.date ASC',

Disable ONLY_FULL_GROUP_BY

Disable ONLY_FULL_GROUP_BY

 

Solution 1: Remove ONLY_FULL_GROUP_BY from mysql console

mysql > SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));

Solution 2: Remove ONLY_FULL_GROUP_BY from phpmyadmin

– Open phpmyadmin & select localhost

– Click on menu Variables & scroll down for sql mode

– Click on edit button to change the values & remove ONLY_FULL_GROUP_BY & click on save

 

 

 

 

To keep your current mysql settings and

disable ONLY_FULL_GROUP_BY

I suggest to visit your phpmyadmin or whatever client you are using and type:

SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY','')  copy_me

 

next copy result to your my.ini file.

For mint:

sudo nano /etc/mysql/my.cnf

For ubuntu 16 and up:

sudo nano /etc/mysql/my.cnf

For ubuntu 14-16:

/etc/mysql/mysql.conf.d/mysqld.cnf