Comments on: Modelizing HABTM join tables in CakePHP 1.2: with and auto-with models /cakephp/modelizing-habtm-join-tables-in-cakephp-1-2-with-and-auto-with-models/?utm_source=rss&utm_medium=rss&utm_campaign=modelizing-habtm-join-tables-in-cakephp-1-2-with-and-auto-with-models A glimpse at a coder's troubled mind Tue, 21 Jun 2011 13:27:40 +0000 hourly 1 http://wordpress.org/?v=3.2.1 By: Hammy /cakephp/modelizing-habtm-join-tables-in-cakephp-1-2-with-and-auto-with-models/comment-page-1/#comment-591 Hammy Fri, 19 Feb 2010 05:42:40 +0000 /1/modelizing-habtm-join-tables-in-cakephp-1-2-with-and-auto-with-models/#comment-591 I could kiss you! This has been killing me. I could kiss you! This has been killing me.

]]>
By: CChaos [Visitor] /cakephp/modelizing-habtm-join-tables-in-cakephp-1-2-with-and-auto-with-models/comment-page-1/#comment-135 CChaos [Visitor] Fri, 24 Apr 2009 08:18:00 +0000 /1/modelizing-habtm-join-tables-in-cakephp-1-2-with-and-auto-with-models/#comment-135 FINALLLY someone who actually EXPLAINS what the 'with' key is all about.<br /> <br /> Being a newb, I was banging my head for the past 5 hours on this. And of course there's actually as simple of an answer as this.<br /> <br /> THANK YOU! FINALLLY someone who actually EXPLAINS what the ‘with’ key is all about.

Being a newb, I was banging my head for the past 5 hours on this. And of course there’s actually as simple of an answer as this.

THANK YOU!

]]>
By: Jordi [Visitor] /cakephp/modelizing-habtm-join-tables-in-cakephp-1-2-with-and-auto-with-models/comment-page-1/#comment-134 Jordi [Visitor] Tue, 07 Apr 2009 18:29:00 +0000 /1/modelizing-habtm-join-tables-in-cakephp-1-2-with-and-auto-with-models/#comment-134 Mariano, you're the best!<br /> <br /> Thanks for making my life easier with your explanation. Mariano, you’re the best!

Thanks for making my life easier with your explanation.

]]>
By: Christian [Visitor] /cakephp/modelizing-habtm-join-tables-in-cakephp-1-2-with-and-auto-with-models/comment-page-1/#comment-133 Christian [Visitor] Wed, 04 Feb 2009 17:30:00 +0000 /1/modelizing-habtm-join-tables-in-cakephp-1-2-with-and-auto-with-models/#comment-133 Mariano, la verdad, excelente como siempre tus posts.<br /> Ahora, tengo un tema (q antes no pasaba, deje cake un tiempo x un proyecto y volvi para la 1.2), los resultados se agrupan... es decir, si tengo 2 veces linkeado el tag 3, en el result solo me aparece una vez. Si bien en el caso de tags esto es practico, para lo que yo estaba usando el join necesitaba que aparezcan todos. Sabes si esto es configurable? Desde ya gracias si me podes tirar una mano.<br /> ehm... keep it up bro! Mariano, la verdad, excelente como siempre tus posts.
Ahora, tengo un tema (q antes no pasaba, deje cake un tiempo x un proyecto y volvi para la 1.2), los resultados se agrupan… es decir, si tengo 2 veces linkeado el tag 3, en el result solo me aparece una vez. Si bien en el caso de tags esto es practico, para lo que yo estaba usando el join necesitaba que aparezcan todos. Sabes si esto es configurable? Desde ya gracias si me podes tirar una mano.
ehm… keep it up bro!

]]>
By: picca [Visitor] /cakephp/modelizing-habtm-join-tables-in-cakephp-1-2-with-and-auto-with-models/comment-page-1/#comment-132 picca [Visitor] Mon, 26 Jan 2009 10:46:00 +0000 /1/modelizing-habtm-join-tables-in-cakephp-1-2-with-and-auto-with-models/#comment-132 Man, you are totally life saver. At least you saved me hours of typing stupid, redundant code. Thank you. Man, you are totally life saver. At least you saved me hours of typing stupid, redundant code. Thank you.

]]>
By: nico.m [Visitor] /cakephp/modelizing-habtm-join-tables-in-cakephp-1-2-with-and-auto-with-models/comment-page-1/#comment-131 nico.m [Visitor] Thu, 15 Jan 2009 15:50:00 +0000 /1/modelizing-habtm-join-tables-in-cakephp-1-2-with-and-auto-with-models/#comment-131 Good article, I spent hours looking for this.<br /> <br /> But now I'll keep on looking for this same behavior using $this->paginate()... I have a lot of Posts with the same Tag and don't want to have enormous pages...<br /> <br /> <br /> any suggestion?<br /> <br /> Good article, I spent hours looking for this.

But now I’ll keep on looking for this same behavior using $this->paginate()… I have a lot of Posts with the same Tag and don’t want to have enormous pages…

any suggestion?

]]>
By: Paul [Visitor] /cakephp/modelizing-habtm-join-tables-in-cakephp-1-2-with-and-auto-with-models/comment-page-1/#comment-130 Paul [Visitor] Fri, 26 Dec 2008 20:45:00 +0000 /1/modelizing-habtm-join-tables-in-cakephp-1-2-with-and-auto-with-models/#comment-130 User Model<br /> var $hasAndBelongsToMany = array('event',array('with'=>'EventsUser'));<br /> <br /> Event Model<br /> var $hasAndBelongsToMany = array('user',array('with'=>'EventsUser'));<br /> <br /> Join Model<br /> class EventsUser extends AppModel {<br /> var $name = 'EventsUser';<br /> var $useTable = "events_users";<br /> var $belongsTo = array('Event', 'User');<br /> }<br /> <br /> <br /> <br /> I keep getting "Table arrays for Model Array" Errors. Whats wrong? User Model
var $hasAndBelongsToMany = array(‘event’,array(‘with’=>’EventsUser’));

Event Model
var $hasAndBelongsToMany = array(‘user’,array(‘with’=>’EventsUser’));

Join Model
class EventsUser extends AppModel {
var $name = ‘EventsUser’;
var $useTable = “events_users”;
var $belongsTo = array(‘Event’, ‘User’);
}

I keep getting “Table arrays for Model Array” Errors. Whats wrong?

]]>
By: xumix [Visitor] /cakephp/modelizing-habtm-join-tables-in-cakephp-1-2-with-and-auto-with-models/comment-page-1/#comment-129 xumix [Visitor] Fri, 11 Jul 2008 06:49:00 +0000 /1/modelizing-habtm-join-tables-in-cakephp-1-2-with-and-auto-with-models/#comment-129 @mariano.iglesias: about saving additional data<br /> oh, rly it has been discussed? look at the model code and this<br /> http://groups.google.com/group/cake-php/browse_thread/thread/bf91d27adf090826?tvc=2 @mariano.iglesias: about saving additional data
oh, rly it has been discussed? look at the model code and this
http://groups.google.com/group/cake-php/browse_thread/thread/bf91d27adf090826?tvc=2

]]>
By: paydjo [Visitor] /cakephp/modelizing-habtm-join-tables-in-cakephp-1-2-with-and-auto-with-models/comment-page-1/#comment-128 paydjo [Visitor] Mon, 14 Apr 2008 03:01:00 +0000 /1/modelizing-habtm-join-tables-in-cakephp-1-2-with-and-auto-with-models/#comment-128 <code>SELECT `Article`.`id`, `Article`.`title`, `Article`.`body`, `Article`.`created`, `Article`.`modified` FROM `articles` AS `Article` WHERE 1 = 1;<br /> <br /> SELECT `Tag`.`id`, `Tag`.`name`, `Tag`.`created`, `Tag`.`modified`, `ArticlesTag`.`id`, `ArticlesTag`.`article_id`, `ArticlesTag`.`tag_id` FROM `tags` AS `Tag` JOIN `articles_tags` AS `ArticlesTag` ON (`ArticlesTag`.`article_id` IN (1, 5) AND `ArticlesTag`.`tag_id` = `Tag`.`id`)</code><br /> <br /> how to change the 2nd query with LEFT JOIN<br /> <br /> <code>SELECT `Tag`.`id`, `Tag`.`name`, `Tag`.`created`, `Tag`.`modified`, `ArticlesTag`.`id`, `ArticlesTag`.`article_id`, `ArticlesTag`.`tag_id` FROM `tags` AS `Tag` <strong>LEFT JOIN</strong> `articles_tags` AS `ArticlesTag` ON (`ArticlesTag`.`article_id` IN (1, 5) AND `ArticlesTag`.`tag_id` = `Tag`.`id`)</code> SELECT `Article`.`id`, `Article`.`title`, `Article`.`body`, `Article`.`created`, `Article`.`modified` FROM `articles` AS `Article` WHERE 1 = 1;

SELECT `Tag`.`id`, `Tag`.`name`, `Tag`.`created`, `Tag`.`modified`, `ArticlesTag`.`id`, `ArticlesTag`.`article_id`, `ArticlesTag`.`tag_id` FROM `tags` AS `Tag` JOIN `articles_tags` AS `ArticlesTag` ON (`ArticlesTag`.`article_id` IN (1, 5) AND `ArticlesTag`.`tag_id` = `Tag`.`id`)

how to change the 2nd query with LEFT JOIN

SELECT `Tag`.`id`, `Tag`.`name`, `Tag`.`created`, `Tag`.`modified`, `ArticlesTag`.`id`, `ArticlesTag`.`article_id`, `ArticlesTag`.`tag_id` FROM `tags` AS `Tag` LEFT JOIN `articles_tags` AS `ArticlesTag` ON (`ArticlesTag`.`article_id` IN (1, 5) AND `ArticlesTag`.`tag_id` = `Tag`.`id`)

]]>
By: mariano.iglesias [Member] /cakephp/modelizing-habtm-join-tables-in-cakephp-1-2-with-and-auto-with-models/comment-page-1/#comment-127 mariano.iglesias [Member] Sun, 06 Apr 2008 14:16:00 +0000 /1/modelizing-habtm-join-tables-in-cakephp-1-2-with-and-auto-with-models/#comment-127 @reality: I trust the Cake core and community, which have been in this for years, more than anyone else to decide what's cakey and what isn't.<br /> <br /> You are right, I implemented Bindable, because I understand a framework is not about providing solutions for every possible given problem, but to solve 80% of them out of the box, and lay out the playfield for you to easily solve the other 20%. And that's exactly what CakePHP does. @reality: I trust the Cake core and community, which have been in this for years, more than anyone else to decide what’s cakey and what isn’t.

You are right, I implemented Bindable, because I understand a framework is not about providing solutions for every possible given problem, but to solve 80% of them out of the box, and lay out the playfield for you to easily solve the other 20%. And that’s exactly what CakePHP does.

]]>