Re: SQL Cartesian Product with CakePHP find
Yes, you can use union in cake 3, paginating union queries is tricky as the different databases will interpret the ORDER BY and LIMIT differently. Waht you need to to in that case is passing a select * form (all union queries) to the paginator and it will work. On Tuesday, February 3, 2015 at 5:57:43 AM UTC-4:30, Gildonei Mendes Anacleto Junior wrote: Left join won't bring me the same results, as I said this isn't a join, I am forcing the query to bring me the prdoduct between t1 and t2 and in this case I will always have all the possible combination among this tables. Using left join, I can have null on right table (t2) if a record doesn't exists. I guess only with CakePHP 3 I will be able to do something like this. By the way, in the new ORM in CakePHP 3.x am I be able to use union statement or a bit more complex select and use paginator component without need of customize it? Thanks again, Junior -- 2015-02-02 21:22 GMT-02:00 José Lorenzo jose@gmail.com: You can do a LEFT join, and get the sae results On Monday, February 2, 2015 at 6:26:56 AM UTC-4:30, Gildonei Mendes Anacleto Junior wrote: Hi, How could I do a cartesian product with 2 different tables in CakePHP 2.x ? EX: *SELECT t1.id http://t1.id, t1.field, t2.id http://t2.id, td.field* *FROM table1 AS t1,* *(SELECT t2.id http://t2.id, t2.field FROM table2) AS t2* *WHERE t1.id http://t1.id = 10* note this isn't a join, I need these cartesian product to apply another filter conditions. -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to a topic in the Google Groups CakePHP group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/cake-php/jg8ZwGJ0wYU/unsubscribe. To unsubscribe from this group and all its topics, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout. -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Re: SQL Cartesian Product with CakePHP find
Great info! Thank you again. 2015-02-04 14:09 GMT-02:00 José Lorenzo jose@gmail.com: Yes, you can use union in cake 3, paginating union queries is tricky as the different databases will interpret the ORDER BY and LIMIT differently. Waht you need to to in that case is passing a select * form (all union queries) to the paginator and it will work. On Tuesday, February 3, 2015 at 5:57:43 AM UTC-4:30, Gildonei Mendes Anacleto Junior wrote: Left join won't bring me the same results, as I said this isn't a join, I am forcing the query to bring me the prdoduct between t1 and t2 and in this case I will always have all the possible combination among this tables. Using left join, I can have null on right table (t2) if a record doesn't exists. I guess only with CakePHP 3 I will be able to do something like this. By the way, in the new ORM in CakePHP 3.x am I be able to use union statement or a bit more complex select and use paginator component without need of customize it? Thanks again, Junior -- 2015-02-02 21:22 GMT-02:00 José Lorenzo jose@gmail.com: You can do a LEFT join, and get the sae results On Monday, February 2, 2015 at 6:26:56 AM UTC-4:30, Gildonei Mendes Anacleto Junior wrote: Hi, How could I do a cartesian product with 2 different tables in CakePHP 2.x ? EX: *SELECT t1.id http://t1.id, t1.field, t2.id http://t2.id, td.field* *FROM table1 AS t1,* *(SELECT t2.id http://t2.id, t2.field FROM table2) AS t2* *WHERE t1.id http://t1.id = 10* note this isn't a join, I need these cartesian product to apply another filter conditions. -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to a topic in the Google Groups CakePHP group. To unsubscribe from this topic, visit https://groups.google.com/d/ topic/cake-php/jg8ZwGJ0wYU/unsubscribe. To unsubscribe from this group and all its topics, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout. -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to a topic in the Google Groups CakePHP group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/cake-php/jg8ZwGJ0wYU/unsubscribe. To unsubscribe from this group and all its topics, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout. -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Re: SQL Cartesian Product with CakePHP find
Left join won't bring me the same results, as I said this isn't a join, I am forcing the query to bring me the prdoduct between t1 and t2 and in this case I will always have all the possible combination among this tables. Using left join, I can have null on right table (t2) if a record doesn't exists. I guess only with CakePHP 3 I will be able to do something like this. By the way, in the new ORM in CakePHP 3.x am I be able to use union statement or a bit more complex select and use paginator component without need of customize it? Thanks again, Junior -- 2015-02-02 21:22 GMT-02:00 José Lorenzo jose@gmail.com: You can do a LEFT join, and get the sae results On Monday, February 2, 2015 at 6:26:56 AM UTC-4:30, Gildonei Mendes Anacleto Junior wrote: Hi, How could I do a cartesian product with 2 different tables in CakePHP 2.x ? EX: *SELECT t1.id http://t1.id, t1.field, t2.id http://t2.id, td.field* *FROM table1 AS t1,* *(SELECT t2.id http://t2.id, t2.field FROM table2) AS t2* *WHERE t1.id http://t1.id = 10* note this isn't a join, I need these cartesian product to apply another filter conditions. -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to a topic in the Google Groups CakePHP group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/cake-php/jg8ZwGJ0wYU/unsubscribe. To unsubscribe from this group and all its topics, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout. -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Re: SQL Cartesian Product with CakePHP find
You can do a LEFT join, and get the sae results On Monday, February 2, 2015 at 6:26:56 AM UTC-4:30, Gildonei Mendes Anacleto Junior wrote: Hi, How could I do a cartesian product with 2 different tables in CakePHP 2.x ? EX: *SELECT t1.id http://t1.id, t1.field, t2.id http://t2.id, td.field* *FROM table1 AS t1,* *(SELECT t2.id http://t2.id, t2.field FROM table2) AS t2* *WHERE t1.id http://t1.id = 10* note this isn't a join, I need these cartesian product to apply another filter conditions. -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Re: SQL Cartesian Product with CakePHP find
I would do a raw query, as Cake 2 does not support using derived table queries. You can use Cake 3, though. On Monday, February 2, 2015 at 6:26:56 AM UTC-4:30, Gildonei Mendes Anacleto Junior wrote: Hi, How could I do a cartesian product with 2 different tables in CakePHP 2.x ? EX: *SELECT t1.id http://t1.id, t1.field, t2.id http://t2.id, td.field* *FROM table1 AS t1,* *(SELECT t2.id http://t2.id, t2.field FROM table2) AS t2* *WHERE t1.id http://t1.id = 10* note this isn't a join, I need these cartesian product to apply another filter conditions. -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.