Re: UNION CakePHP/MySQL

2008-05-19 Thread grigri
> One thing, though. The $order ('duedate ASC') shouldn't be necessary, > as you're selecting on just a single date. Well spotted! That's very true - it's a bit like saying "pick all the blue M&Ms and arrange them by colour". I wasn't paying attention to that bit... --~--~-~--~~--

Re: UNION CakePHP/MySQL

2008-05-16 Thread b logica
One thing, though. The $order ('duedate ASC') shouldn't be necessary, as you're selecting on just a single date. On Fri, May 16, 2008 at 11:09 AM, Pierre MARCOURT <[EMAIL PROTECTED]> wrote: > Yes I do. > In your code, you do a "or" condition. I did not think it was possible that > way because of

Re: UNION CakePHP/MySQL

2008-05-16 Thread Pierre MARCOURT
Yes I do. In your code, you do a "or" condition. I did not think it was possible that way because of my second condition user_id != $user_id. But now I know by using 'or' and '<>' I can make it works. Thanks ! grigri wrote: >> I am using 1.1 and your last code works just fine !!! >> Thank you ve

Re: UNION CakePHP/MySQL

2008-05-16 Thread grigri
> I am using 1.1 and your last code works just fine !!! > Thank you very much, it is just what I needed ! Glad I could help. Do you understand *why* it works? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP"

Re: UNION CakePHP/MySQL

2008-05-16 Thread Pierre MARCOURT
I am using 1.1 and your last code works just fine !!! Thank you very much, it is just what I needed ! grigri wrote: > Very odd indeed. Works fine for me... what version are you using? This > was on a bleeding edge 1.2 but it works on older versions too. > > If you're on 1.1, try this: > > $tasks

Re: UNION CakePHP/MySQL

2008-05-16 Thread grigri
Very odd indeed. Works fine for me... what version are you using? This was on a bleeding edge 1.2 but it works on older versions too. If you're on 1.1, try this: $tasks = $this->Task->findAll( array( 'or' => array( array('user_id' => $user_id), array('alternate_id' => $user_id,

Re: UNION CakePHP/MySQL

2008-05-16 Thread Pierre MARCOURT
It does not work... I have a SQL Error. Here it is : *Notice*: Undefined offset: 0 in *Z:\dev\frameworks\cake\cake\libs\model\datasources\dbo_source.php* on line *1388* *Notice*: Undefined offset: 0 in *Z:\dev\frameworks\cake\cake\libs\model\datasources\dbo_source.php* on line *1390* *Notice*:

Re: UNION CakePHP/MySQL

2008-05-16 Thread grigri
Try this: $tasks = $this->Task->find('all', array( 'conditions' => array( 'or' => array( array('user_id' => $user_id), array('alternate_id' => $user_id, 'user_id' => '<> ' . $user_id) ), 'duedate' => date('Y-m-d') ), 'order' => 'duedate ASC' )); On May 16, 2:53 pm,

Re: UNION CakePHP/MySQL

2008-05-16 Thread Pierre MARCOURT
Here are the requests I am doing : $tab1 = $this->Task->findAll('user_id = ' . $user_id . ' AND duedate = "' . date('Y-m-d') . '"', null, 'duedate ASC'); $tab2 = $this->Task->findAll('alternate_id = ' . $user_id . ' AND user_id != '.$user_id.' AND duedate = "' . date('Y-m-d') . '"', null, 'dued

Re: UNION CakePHP/MySQL

2008-05-16 Thread grigri
In a word, no. In a UNION, MySQL does not return any table information with each column [since it can't, because a union can be from different tables], and cakephp's dbo_mysql class relies on this information to map the result rows to the originating model (think left joins). What exactly is the

UNION CakePHP/MySQL

2008-05-16 Thread Pierre MARCOURT
Hi, I would like to make a MySQL request with an UNION but I can't find out a way to do it by using CakePHP methods. I looked at Google but it seems that the only way to do it is to make a custom request by using /query()/. But I don't want to do it that way because I need the recursive option