Following UNION syntax works properly in CakePHP 2.4.6 version but it doesn’t work in CakePHP 2.5.2 version:
$unionQuery = $dbo->buildStatement ( array( 'fields' => array( required fields), 'table' => $dbo->fullTableName(database_table_name), 'alias' => 'customObject1', 'limit' => null, 'offset' => null, 'joins' => $joins, 'conditions' => $conditions, 'order' => null, 'group' => null ), $this->customObject1 ); $unionQuery .= ' UNION '; $unionQuery .= $dbo->buildStatement( array ( 'fields' => array(required fields), 'table' => $dbo->fullTableName(manage_course_payment_users), 'alias' => 'customObject2', 'limit' => null, 'offset' => null, 'joins' => $joins, 'conditions' => $conditions, 'order' => null, 'group' => null ), $this->customObject2 ); $result = $this->query($query);