Re: HATBM relations + aggregate functions

2010-01-14 Thread Amit Rawat
Hello,

try this :-

$this->Demo->paginate= array('fields'=>array('You fields','sum(amount)'));

$this->Demo->paginate('Demo');

Regards,

Amit
Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


HATBM relations + aggregate functions

2010-01-14 Thread MOA
Hi,

i have some problems with cakephp paginator helper.

i have two tables with HATBM relation, contributions and details. in
the last one i have an amount field (decimal).

i would like to get the sum(amount) in my paginate resultset.

i try to bind model but it doesnt work for me.

i need your advices..

thanks
Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Tags HATBM Tags?

2010-01-14 Thread John Andersen
I will not state whether it is a good or a bad idea! Rather I would
like to ask the question:

Do you have a need for this relationship Tag HABTM Tag? In other
words, what are the reason/requirement for making this solution?

If you can answer the above, and your solution solves it, then it is a
good idea :)
Enjoy,
   John

On Jan 14, 8:47 pm, Ian R  wrote:
> Hey!  So ideally, in the whole Posts, Users, Tags model, I'd like to
> have Tags which are "related to" other Tags.  This seems simple enough
> though I haven't gotten it working quite yet.
>
> I've set up a "tags_tags" table with fields id, tag1_id and tag2_id...
> and in my Tag model I've set these as the $hasAndBelongsToMany[Tag]
> foreignKey and associationForeignKey.  I'm not really sure what else
> I'll need to do, but here's my issue:
>
> This self-referencing seems a little convoluted (though mostly
> straightforward), and I haven't found any reference in these archives
> or on the internet anywhere, really.  SOMETIMES :) when I have an
> interesting idea like this and can't find evidence that it has already
> been thought of, it turns out that it's not such a great idea.   So,
> basically, is this a stupid idea?  Tags HABTM Tags?
>
> thanks!
> Ian
Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: HATBM

2009-07-15 Thread Claudiu Apetrei

Sorry bad choice of model names. This was just a test example not
related to the application I am building.

The main question is if that's the way cakephp returns data from the
HABTM relations. With the join table array for each.

[Join] => Array
(
[id] => 1
[comment_id] => 1
[post_id] => 1
)

Is can I get my data back without this sub array ?

Thank you,
Claudiu

On Jul 15, 9:15 pm, brian  wrote:
> For Post & Comment, you should probably be using belongsTo & hasMany.
> You're unlikely to have comments that can belong to more than one
> Post.
>
> Post hasMany Comment
> Comment belongsTo Post (so, comments table should have a post_id column)
>
> On Wed, Jul 15, 2009 at 1:58 PM, Claudiu
>
> Apetrei wrote:
>
> > Hello,
>
> > I'm a bit new to cakephp now working on a project and came across
> > HTABM. Did a simple test with a Post model and a comments one.
>
> > Everything works great my only problem is that it also returns for
> > each comment the join table. Is this how it's supose to work ?
>
> > Here is what I get :
>
> > Array
> > (
> >    [0] => Array
> >        (
> >            [Post] => Array
> >                (
> >                    [id] => 1
> >                    [name] => claudiu
> >                    [type] => 1
> >                )
>
> >            [Comment] => Array
> >                (
> >                    [0] => Array
> >                        (
> >                            [id] => 1
> >                            [subiect] => test1
> >                            [comment] => ss
> >                            [Join] => Array
> >                                (
> >                                    [id] => 1
> >                                    [comment_id] => 1
> >                                    [post_id] => 1
> >                                )
> >                        )
> >                )
> >        )
>
> > Thank you,
> > Claudiu
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: HATBM

2009-07-15 Thread brian
For Post & Comment, you should probably be using belongsTo & hasMany.
You're unlikely to have comments that can belong to more than one
Post.

Post hasMany Comment
Comment belongsTo Post (so, comments table should have a post_id column)

On Wed, Jul 15, 2009 at 1:58 PM, Claudiu
Apetrei wrote:
>
> Hello,
>
> I'm a bit new to cakephp now working on a project and came across
> HTABM. Did a simple test with a Post model and a comments one.
>
> Everything works great my only problem is that it also returns for
> each comment the join table. Is this how it's supose to work ?
>
> Here is what I get :
>
> Array
> (
>    [0] => Array
>        (
>            [Post] => Array
>                (
>                    [id] => 1
>                    [name] => claudiu
>                    [type] => 1
>                )
>
>            [Comment] => Array
>                (
>                    [0] => Array
>                        (
>                            [id] => 1
>                            [subiect] => test1
>                            [comment] => ss
>                            [Join] => Array
>                                (
>                                    [id] => 1
>                                    [comment_id] => 1
>                                    [post_id] => 1
>                                )
>                        )
>                )
>        )
>
>
>
> Thank you,
> Claudiu
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



HATBM

2009-07-15 Thread Claudiu Apetrei

Hello,

I'm a bit new to cakephp now working on a project and came across
HTABM. Did a simple test with a Post model and a comments one.

Everything works great my only problem is that it also returns for
each comment the join table. Is this how it's supose to work ?

Here is what I get :

Array
(
[0] => Array
(
[Post] => Array
(
[id] => 1
[name] => claudiu
[type] => 1
)

[Comment] => Array
(
[0] => Array
(
[id] => 1
[subiect] => test1
[comment] => ss
[Join] => Array
(
[id] => 1
[comment_id] => 1
[post_id] => 1
)
)
)
)



Thank you,
Claudiu
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: HATBM returning extra fields

2009-07-12 Thread Claudiu Apetrei

Thank you for the reply,

I already use Containable but can't limit the BreedConnection array
since it's the join table and not associated to the Model that gets
the data.

This is the way I find the data. Does not work with recursive lower
than 1.

$test=$this->RaseCaini->find('first',array
('recursive'=>1,'fields'=>array('id'),'conditions'=>array
('id'=>11),'contain'=>array('User')));

This is the model HABTM relation:

var $hasAndBelongsToMany = array(
'User' => array(
'className' => 'User',
'joinTable' => 'breed_connections',
'associationForeignKey' => 'target_id',
'foreignKey'=> 'rasa_id',
'conditions'=>array('type'=>1),
'fields'=>array('id'),

'dependent'=> false
)
);


Thank you,
Claudiu


On Jul 12, 4:37 pm, Nancy  wrote:
> I think that's fine it is using a little too recursive for what you
> want.  You can set recursive to -1 to only get the User table.   It's
> an option you can put in your query or you can set it like this:
> $this->Model->recursive = -1
>
> There's also a 'behavior' called "Containable" that lets you determine
> which tables you want because sometimes you just don't want the
> default behavior.
>
> Here's an example of a containable query from my project:
>
>     function getCalcParamsByDgid($id, $deviceId)
>     {
>         $this->Behaviors->attach('Containable');
>         $got = $this->find('first', array(
>             'contain' => array(
>                 'Calcparam' => array(
>                     'Calcparamvalue' => array(
>                             'Unit',
>                             'conditions' => array(
>                                 'Calcparamvalue.device_id' =>
> $deviceId)
>                     ),
>                     'Unit',
>                 ),
>             ),
>             'conditions' => array(
>                 'id' => $id,
>             ),
>         ));
>         return ($got);
>     }
>
> On Jul 12, 4:30 am, Claudiu Apetrei  wrote:
>
> > Hello,
>
> > I am trying to get the hasAndBelongsToMany assosciations to work but I
> > just can't get it to return the data right. It always returns the
> > joinTable fields for each relation.
>
> > I have a table BreedConnections and want to get the associated users,
> > I get the user array right but also get in that array the jointable
> > fields. Everything works ok but it's not really good since it doubles
> > the amount.
>
> > This is how it looks for each user :
>
> >  [User] => Array
> >                 (
> >                     [0] => Array
> >                         (
> >                             [id] => 1
> >                             [avatar] => claudiu_apetrei_1
> >                             [avatar_type] => .jpg
> >                             [nume] => Apetrei
> >                             [prenume] => Claudiu
> >                             [BreedConnection] => Array
> >                                 (
> >                                     [id] => 11
> >                                     [rasa_id] => 11
> >                                     [rasa_nume] => Ciobanesc german
> >                                     [rasa_url] => ciobanesc-german
> >                                     [type] => 1
> >                                     [target_id] => 1
> >                                     [data] => -00-00 00:00:00
> >                                     [auto_remove] => 1
> >                                 )
>
> >                         )
>
> >                 )
>
> > Is this how it's supposed to return or am I doing something wrong ?
>
> > Thank You,
> > Claudiu
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: HATBM returning extra fields

2009-07-12 Thread Nancy

I think that's fine it is using a little too recursive for what you
want.  You can set recursive to -1 to only get the User table.   It's
an option you can put in your query or you can set it like this:
$this->Model->recursive = -1

There's also a 'behavior' called "Containable" that lets you determine
which tables you want because sometimes you just don't want the
default behavior.

Here's an example of a containable query from my project:

function getCalcParamsByDgid($id, $deviceId)
{
$this->Behaviors->attach('Containable');
$got = $this->find('first', array(
'contain' => array(
'Calcparam' => array(
'Calcparamvalue' => array(
'Unit',
'conditions' => array(
'Calcparamvalue.device_id' =>
$deviceId)
),
'Unit',
),
),
'conditions' => array(
'id' => $id,
),
));
return ($got);
}


On Jul 12, 4:30 am, Claudiu Apetrei  wrote:
> Hello,
>
> I am trying to get the hasAndBelongsToMany assosciations to work but I
> just can't get it to return the data right. It always returns the
> joinTable fields for each relation.
>
> I have a table BreedConnections and want to get the associated users,
> I get the user array right but also get in that array the jointable
> fields. Everything works ok but it's not really good since it doubles
> the amount.
>
> This is how it looks for each user :
>
>  [User] => Array
>                 (
>                     [0] => Array
>                         (
>                             [id] => 1
>                             [avatar] => claudiu_apetrei_1
>                             [avatar_type] => .jpg
>                             [nume] => Apetrei
>                             [prenume] => Claudiu
>                             [BreedConnection] => Array
>                                 (
>                                     [id] => 11
>                                     [rasa_id] => 11
>                                     [rasa_nume] => Ciobanesc german
>                                     [rasa_url] => ciobanesc-german
>                                     [type] => 1
>                                     [target_id] => 1
>                                     [data] => -00-00 00:00:00
>                                     [auto_remove] => 1
>                                 )
>
>                         )
>
>                 )
>
> Is this how it's supposed to return or am I doing something wrong ?
>
> Thank You,
> Claudiu
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



HATBM returning extra fields

2009-07-12 Thread Claudiu Apetrei

Hello,

I am trying to get the hasAndBelongsToMany assosciations to work but I
just can't get it to return the data right. It always returns the
joinTable fields for each relation.

I have a table BreedConnections and want to get the associated users,
I get the user array right but also get in that array the jointable
fields. Everything works ok but it's not really good since it doubles
the amount.

This is how it looks for each user :

 [User] => Array
(
[0] => Array
(
[id] => 1
[avatar] => claudiu_apetrei_1
[avatar_type] => .jpg
[nume] => Apetrei
[prenume] => Claudiu
[BreedConnection] => Array
(
[id] => 11
[rasa_id] => 11
[rasa_nume] => Ciobanesc german
[rasa_url] => ciobanesc-german
[type] => 1
[target_id] => 1
[data] => -00-00 00:00:00
[auto_remove] => 1
)

)

)


Is this how it's supposed to return or am I doing something wrong ?

Thank You,
Claudiu
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



delete HATBM relation

2008-12-02 Thread Zeugme

Hi,

I'd like to delete HATBM relation between a Person and a Contract.
The HATBM relationship is declared in the Person model and works fine  
for retreiving the right person with all its contracts for example.
How should I submit things to my controller method in term of  
data[ ? ] to just delete the relationship keeping contract ?
I don't understand how to structure the data array on the client side  
(view).

Thanks !

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How to save extra field in join table in HATBM Cake1.2

2008-10-05 Thread GrandiJoos

Hi Andre,

In the HABTM relationship definition you can define an attribute
'with' where you can specify which model acts as the HABTM model (in
your case posts_tags). Then you can create the posts_tags model which
gets saved with the additional fields.
I have not experimented with it but I saw some articles/posts about
this a few days ago (a quick search did not turn up any useful links
so you'll have to search for yourself).
Hope this helps (or at least a little ;)).

Good luck!

GrandiJoos

On 4 okt, 18:28, Andre <[EMAIL PROTECTED]> wrote:
> Hi all,
> I saw "Storing additional data on join 
> table"https://trac.cakephp.org/ticket/828.
> Having, two tables associated with HABTM: tags, posts, posts_tags
> posts_tags{ post_id,tag_id,weight }
>
> Can anyone help me showing how to use it, in the Post 's add or Post
> 's edit view in to populate "weight" field in posts_tags.weight
> column?
>
> I am thinking to use Checkbox options to select related
> posts_tags.weight, And input text to enter weight.
>
> I've been struggling with this issue for few weeks with HABTM where
> the join table record is deleted and reinserted everytime, thus the
> posts_tags.weight column were never saved?
>
> Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How to save extra field in join table in HATBM Cake1.2

2008-10-04 Thread schneimi

Hi Andre,

I use the the following behavior: 
http://bakery.cakephp.org/articles/view/add-delete-habtm-behavior

In the comments of that article someone posted a modification for the
addHabtm-method in order to save extra data, and there you also find
an updateHabtm-method for updating the extra data.

But I remember a problem with addHabtm, because the model save()-
function rebuilds all associated datasets, the extra data of all
datasets got deleted whenever something was added. To avoid that I
replaced the save statement with an insert-query, not beautiful but
did the job.

// $success = $model->save($data);
$success = mysql_query('INSERT INTO '.$joinTable." (".$foreignKey.", ".
$assoc."_id) VALUES (".$id.", ".$assoc_ids[0].")");
(I just notice that it only works for single additions, obviously I
didn't need more *g* But it should be an easy one to loop over all
assoc_ids.)

This is quite a while ago and might not be the best solution with the
latest cakePHP, but I thought I just let you know.

Hope this helps anyway,

Michael


On 4 Okt., 18:28, Andre <[EMAIL PROTECTED]> wrote:
> Hi all,
> I saw "Storing additional data on join 
> table"https://trac.cakephp.org/ticket/828.
> Having, two tables associated with HABTM: tags, posts, posts_tags
> posts_tags{ post_id,tag_id,weight }
>
> Can anyone help me showing how to use it, in the Post 's add or Post
> 's edit view in to populate "weight" field in posts_tags.weight
> column?
>
> I am thinking to use Checkbox options to select related
> posts_tags.weight, And input text to enter weight.
>
> I've been struggling with this issue for few weeks with HABTM where
> the join table record is deleted and reinserted everytime, thus the
> posts_tags.weight column were never saved?
>
> Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How to save extra field in join table in HATBM Cake1.2

2008-10-04 Thread teknoid

This should get you started:
http://teknoid.wordpress.com/2008/09/24/saving-extra-fields-in-the-join-table-for-habtm-models/

On Oct 4, 12:28 pm, Andre <[EMAIL PROTECTED]> wrote:
> Hi all,
> I saw "Storing additional data on join 
> table"https://trac.cakephp.org/ticket/828.
> Having, two tables associated with HABTM: tags, posts, posts_tags
> posts_tags{ post_id,tag_id,weight }
>
> Can anyone help me showing how to use it, in the Post 's add or Post
> 's edit view in to populate "weight" field in posts_tags.weight
> column?
>
> I am thinking to use Checkbox options to select related
> posts_tags.weight, And input text to enter weight.
>
> I've been struggling with this issue for few weeks with HABTM where
> the join table record is deleted and reinserted everytime, thus the
> posts_tags.weight column were never saved?
>
> Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



How to save extra field in join table in HATBM Cake1.2

2008-10-04 Thread Andre

Hi all,
I saw "Storing additional data on join table" 
https://trac.cakephp.org/ticket/828.
Having, two tables associated with HABTM: tags, posts, posts_tags
posts_tags{ post_id,tag_id,weight }

Can anyone help me showing how to use it, in the Post 's add or Post
's edit view in to populate "weight" field in posts_tags.weight
column?


I am thinking to use Checkbox options to select related
posts_tags.weight, And input text to enter weight.

I've been struggling with this issue for few weeks with HABTM where
the join table record is deleted and reinserted everytime, thus the
posts_tags.weight column were never saved?

Thanks

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: cake searches the HATBM join table in the wrong database when using $useDbConfig

2007-04-01 Thread RayChicago

hi again ^3 !

after struggling/searching for two days i finally came across this
one :
http://groups.google.at/group/cake-php/browse_thread/thread/b8816db7ff5854bc/12598076103b0130?lnk=gst&q=3+HABTM&rnum=2#12598076103b0130

which IMHO should be added to the cake-manual, section model,
paragraph "saving habtm - relationships" ASAP ! would have saved me
tons of time.
(added, even if the manual just links to the posting... prefixed with
"MUST READ !")

i finally cracked my problem, which was indeed related to
$useDbConfig, but which i circumvented using a finderQuery where i
prefixed the join-table with the database name. at least it works now
with my mysql - version...

and: what would be truly amazing, if added to the manual : a detailed
description of the inner workings of all those keys in an association-
description.

rtfcc to myself, next time

...anyways, happy easter-holidays,
ray


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: cake searches the HATBM join table in the wrong database when using $useDbConfig

2007-03-30 Thread RayChicago

hi again !

i tried giving different credentials to the two db-configs (different
username/pw) and i also tried switching to mysql_connect... none of
this has helped so far...

i'm still at a kind of loss...

cheers, ray


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: cake searches the HATBM join table in the wrong database when using $useDbConfig

2007-03-30 Thread RayChicago

i just tried these additional things :

- gave the config different user-credentials (usernam/pw)
- switched to mysql_connect ...

and i'm still none the wiser :(

cheers, ray


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



cake searches the HATBM join table in the wrong database when using $useDbConfig

2007-03-30 Thread RayChicago

Hi all !

My (unfortunate) Situation :

I have a Model X in one Database D1, and a Model Y in a Database D2, a
HABTM
relationship between them like outlined below, and the jointable x_y
is in D2.

class X extends AppModel
{
  public $name = "X";
  public $useTable = 'xtable';
  public $useDbConfig = 'D1';
  public $primaryKey = 'id';
  public $hasAndBelongsToMany =
array("Y" =>
array(
  'joinTable'=> 'x_y',
  'foreignKey'   => 'x_id',
  'associationForeignKey'=> 'y_id'
)
);
}

class Y extends AppModel
{
  public $name = "Y";
  public $useTable = 'ytable';
  public $useDbConfig = 'D2';
  public $primaryKey = 'id';
  public $hasAndBelongsToMany =
array("X" =>
array(
  'joinTable'=> 'x_y',
  'foreignKey'   => 'y_id',
  'associationForeignKey'=> 'x_id'
)
);
}

This setup works wonderful when inserting, but when trying to retrieve
data, i get
a "1146: table 'D1.x_y' doesn't exist" from (the) MySQL(i) (module).

Seems like it searches the join table in the model's dbconfig...

I tried setting "persistent" => false in the db-config, as suggested
in one
of the postings I read here, fixed a small bug in dbo_mysqli (trac
#2248), but still
cake does not use the correct db. I'm at a loss here.

Any suggestions would be very helpful ! =)

Cheers, ray


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: HATBM add?

2007-03-01 Thread AD7six



On Feb 27, 12:23 pm, "Devraj Mukherjee" <[EMAIL PROTECTED]> wrote:
> Hi everyone,
>
> I have a HATBM relationship between a User and a Team, so a User
> belongs to  many team and  the table user_team joins them.
>
> Are there any examples of doing an add and delete function for HATBM
> relationships?
>
> I wish to create say a series of check boxes so the user can check a
> team for a user to assign them to it.
>
> Any help is appreciated.
>
> Thanks.
>
> --
> "I never look back darling, it distracts from the now", Edna Mode (The
> Incredibles)

Have a look at rossofts useful ad on methods.
http://www.google.com/search?q=working+with+habtm+cakephp

HTH,

AD


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



HATBM add?

2007-02-27 Thread Devraj Mukherjee

Hi everyone,

I have a HATBM relationship between a User and a Team, so a User
belongs to  many team and  the table user_team joins them.

Are there any examples of doing an add and delete function for HATBM
relationships?

I wish to create say a series of check boxes so the user can check a
team for a user to assign them to it.

Any help is appreciated.

Thanks.

-- 
"I never look back darling, it distracts from the now", Edna Mode (The
Incredibles)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



RE: Multiple HATBM (n:n) using the same model for different purposes

2006-11-28 Thread Adrian Godong

Well, the final choice is always yours. :D

IMO, creting a Model to simulate HABTM would be rough on the programming
side, since you have to define extra logic to save them (e.g., for each
assoc, you need to save it). This is not the case when you use pure HABTM,
just throw in an array, and Cake does the rest.

I'm just being easy. But easy doesn't exactly correct/good.

On a note: if you have several models that behaves similarly, it might well
considering OOP inheritance. That way, you reduce DRY (don't repeat
yourselft), which is one of the reason OOP is invented.

-Original Message-
From: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf
Of clemos
Sent: 29 Nopember 2006 0:08
To: cake-php@googlegroups.com
Subject: Re: Multiple HATBM (n:n) using the same model for different
purposes


hi adrian and marcelo

you're probably right about the "feasibility" of customizing HABTM infos.

then, to me, the solution would rather to make one single additional
model (say : EventStoreRelation) that would "simulate" the HABTM table
:
it would belongTo both one Event and one Store, and would also have a
column like "type", that would define the relationship between the
event and the store, and so on...
these relationships can be defined as an array is this model (like I
said in my previous post).
then if you have to add a "type", you don't even have to make a new
table or a new model, you just have to add an entry in this array...

because it looks like the relationships actually aren't that
different, and anyway this additionnal model can probably handle
different features for the different "types"...
and my experience makes me think it's better to try to have as less
models as possible, especially if several models actually have a
similar behaviour.

or maybe I misunderstood you ?

+++
clemos

On 11/28/06, Adrian Godong <[EMAIL PROTECTED]> wrote:
>
> Is the second solution feasible? I mean AFAIK, if you stick to the default
> CakePHP implementation of HABTM, you can't have any other field other than
> the two PK/FK fields.
>
> Take a look at how CakePHP handles saving HABTM assoc from the manual.
>
> If you want to "relate" model A with model B, when saving model A, you
will
> need to accompany it with array of model B _id's_. There's no extra data
> saved here.
>
> Unless, of course, you have a "fake" HABTM model.
>
> My proposed solution would be the first one. Why?
> 1. It provide a clear disctinction between each relation. Those relations
> are _different_, right?
> 2. It provide a more cohesive structure. When, just in case, you need to
add
> another relation between event and store (say, stores that sells/has rare
> tickets), you won't need to touch the currently running code. You can say
> it's a more pluggable architecture (because it is simpler to add things
> later).
> 3. It's easier to do the associations (one for each assoc), access data
> (don't need to process anything on the logic, everything's done on the
> database), and edit (you know that Cake deletes all of the HABTM relation
> for a specific ID before inserting new ones -- that is, unless you managed
> to create a custom update/save query).
>
> Just my 2 cents.
>
> -Original Message-
> From: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf
> Of clemos
> Sent: 28 Nopember 2006 18:26
> To: cake-php@googlegroups.com
> Subject: Re: Multiple HATBM (n:n) using the same model for different
> purposes
>
>
> hi marcelo
>
> I'm not really a guru, but your second solution looks the best to me.
> Then, if the "relationship_types" don't need to be editable, you can
> just let them "static".
>
> For exemple you can define them as an array in your Event model :
>
> $store_types = array(
>0 => "regular seller",
>1 => "VIP seller",
>2 => "partner"
> );
>
> And you have an int column in your habtm table called store_type or
> something
> At least, that's what I would do.
> The nice thing is you can use this "store_types" array in your form
> with selectTag
>
> +++
> clemos
>
> On 11/27/06, Marcelo de Moraes Serpa <[EMAIL PROTECTED]> wrote:
> > Guys, I really need a hand here!
> >
> > Let's say I've got two models:
> >
> > * Event -> Represents a party event
> > * Store -> A store where the user could buy a ticket to the party
> >
> > A user wants to go to a particular event. So, he enter the event
> > informations page and sees a list of "stores" (places) where he/she can
> buy
> > tickets fo

Re: Multiple HATBM (n:n) using the same model for different purposes

2006-11-28 Thread clemos

hi adrian and marcelo

you're probably right about the "feasibility" of customizing HABTM infos.

then, to me, the solution would rather to make one single additional
model (say : EventStoreRelation) that would "simulate" the HABTM table
:
it would belongTo both one Event and one Store, and would also have a
column like "type", that would define the relationship between the
event and the store, and so on...
these relationships can be defined as an array is this model (like I
said in my previous post).
then if you have to add a "type", you don't even have to make a new
table or a new model, you just have to add an entry in this array...

because it looks like the relationships actually aren't that
different, and anyway this additionnal model can probably handle
different features for the different "types"...
and my experience makes me think it's better to try to have as less
models as possible, especially if several models actually have a
similar behaviour.

or maybe I misunderstood you ?

+++
clemos

On 11/28/06, Adrian Godong <[EMAIL PROTECTED]> wrote:
>
> Is the second solution feasible? I mean AFAIK, if you stick to the default
> CakePHP implementation of HABTM, you can't have any other field other than
> the two PK/FK fields.
>
> Take a look at how CakePHP handles saving HABTM assoc from the manual.
>
> If you want to "relate" model A with model B, when saving model A, you will
> need to accompany it with array of model B _id's_. There's no extra data
> saved here.
>
> Unless, of course, you have a "fake" HABTM model.
>
> My proposed solution would be the first one. Why?
> 1. It provide a clear disctinction between each relation. Those relations
> are _different_, right?
> 2. It provide a more cohesive structure. When, just in case, you need to add
> another relation between event and store (say, stores that sells/has rare
> tickets), you won't need to touch the currently running code. You can say
> it's a more pluggable architecture (because it is simpler to add things
> later).
> 3. It's easier to do the associations (one for each assoc), access data
> (don't need to process anything on the logic, everything's done on the
> database), and edit (you know that Cake deletes all of the HABTM relation
> for a specific ID before inserting new ones -- that is, unless you managed
> to create a custom update/save query).
>
> Just my 2 cents.
>
> -Original Message-
> From: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf
> Of clemos
> Sent: 28 Nopember 2006 18:26
> To: cake-php@googlegroups.com
> Subject: Re: Multiple HATBM (n:n) using the same model for different
> purposes
>
>
> hi marcelo
>
> I'm not really a guru, but your second solution looks the best to me.
> Then, if the "relationship_types" don't need to be editable, you can
> just let them "static".
>
> For exemple you can define them as an array in your Event model :
>
> $store_types = array(
>0 => "regular seller",
>1 => "VIP seller",
>2 => "partner"
> );
>
> And you have an int column in your habtm table called store_type or
> something
> At least, that's what I would do.
> The nice thing is you can use this "store_types" array in your form
> with selectTag
>
> +++
> clemos
>
> On 11/27/06, Marcelo de Moraes Serpa <[EMAIL PROTECTED]> wrote:
> > Guys, I really need a hand here!
> >
> > Let's say I've got two models:
> >
> > * Event -> Represents a party event
> > * Store -> A store where the user could buy a ticket to the party
> >
> > A user wants to go to a particular event. So, he enter the event
> > informations page and sees a list of "stores" (places) where he/she can
> buy
> > tickets for this event:
> >
> > Event information screen:
> >
> > 
> > Event Name
> > (...other informations...)
> >
> > Where to buy regular tickets:
> > * R&B Co.
> > * Shopping 1
> >
> > Whrere to buy VIP tickets:
> > * Carmen Steffens
> > * VIP store
> >
> > Companies that are supporting this event:
> > * Carmen Steffens
> > * VIP store
> >
> >
> > 
> >
> > As you can see, there are 3 lists of store for each event. The store where
> > to buy a regular ticket, the store where to buy a VIP ticket and the
> > "stores" that are supporting this event. And here's where I get c

RE: Multiple HATBM (n:n) using the same model for different purposes

2006-11-28 Thread Adrian Godong

Is the second solution feasible? I mean AFAIK, if you stick to the default
CakePHP implementation of HABTM, you can't have any other field other than
the two PK/FK fields.

Take a look at how CakePHP handles saving HABTM assoc from the manual.

If you want to "relate" model A with model B, when saving model A, you will
need to accompany it with array of model B _id's_. There's no extra data
saved here.

Unless, of course, you have a "fake" HABTM model.

My proposed solution would be the first one. Why?
1. It provide a clear disctinction between each relation. Those relations
are _different_, right?
2. It provide a more cohesive structure. When, just in case, you need to add
another relation between event and store (say, stores that sells/has rare
tickets), you won't need to touch the currently running code. You can say
it's a more pluggable architecture (because it is simpler to add things
later).
3. It's easier to do the associations (one for each assoc), access data
(don't need to process anything on the logic, everything's done on the
database), and edit (you know that Cake deletes all of the HABTM relation
for a specific ID before inserting new ones -- that is, unless you managed
to create a custom update/save query).

Just my 2 cents. 

-Original Message-
From: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf
Of clemos
Sent: 28 Nopember 2006 18:26
To: cake-php@googlegroups.com
Subject: Re: Multiple HATBM (n:n) using the same model for different
purposes


hi marcelo

I'm not really a guru, but your second solution looks the best to me.
Then, if the "relationship_types" don't need to be editable, you can
just let them "static".

For exemple you can define them as an array in your Event model :

$store_types = array(
   0 => "regular seller",
   1 => "VIP seller",
   2 => "partner"
);

And you have an int column in your habtm table called store_type or
something
At least, that's what I would do.
The nice thing is you can use this "store_types" array in your form
with selectTag

+++
clemos

On 11/27/06, Marcelo de Moraes Serpa <[EMAIL PROTECTED]> wrote:
> Guys, I really need a hand here!
>
> Let's say I've got two models:
>
> * Event -> Represents a party event
> * Store -> A store where the user could buy a ticket to the party
>
> A user wants to go to a particular event. So, he enter the event
> informations page and sees a list of "stores" (places) where he/she can
buy
> tickets for this event:
>
> Event information screen:
>
> 
> Event Name
> (...other informations...)
>
> Where to buy regular tickets:
> * R&B Co.
> * Shopping 1
>
> Whrere to buy VIP tickets:
> * Carmen Steffens
> * VIP store
>
> Companies that are supporting this event:
> * Carmen Steffens
> * VIP store
>
>
> 
>
> As you can see, there are 3 lists of store for each event. The store where
> to buy a regular ticket, the store where to buy a VIP ticket and the
> "stores" that are supporting this event. And here's where I get confused
on
> how to model this kind of association.
>
> I see 3 possible solutions for this problem:
>
> 1) having a n:n relationship table for each of the HABTM associations
> (events_storeregularticket, events_supportstores... each having a event_id
> and store_id of course)
> 2) having only one "general" events_stores whith a "relationship_type"
field
> so I could filter the correspondent records for each of HABTM
relationship;
> 3) Fake RoR's throughassociation (see Felix's post here:
>
http://www.thinkingphp.org/2006/10/26/modeling-relationships-in-cakephp-faki
ng-rails-throughassociation/
> ) transforming each of the HABTM association into an entitity itself, so I
> would have a model (and a corresponding table) for:
>  * PlacesToBuyRegularTickets model;
>  * PlacesToBuyVipTickets model;
>  * EventSupportingStores model;
>
> Particulary, I find the second one to be a more clean solution as I keep
> only one table, but I see that I would need to create another table to
keep
> the kinds of relationships :/
>
> I'm really confused on the best way to model this in Cake. What would you
> do/What have you done on your projects?
>
> Thanks in advance!
>
> Marcelo.
>
>
>  >
>



--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Multiple HATBM (n:n) using the same model for different purposes

2006-11-28 Thread Marcelo de Moraes Serpa
Hi clemos, thanks for the reply and for sharing your thoughts :)

On 11/28/06, clemos <[EMAIL PROTECTED]> wrote:
>
>
> hi marcelo
>
> I'm not really a guru, but your second solution looks the best to me.
> Then, if the "relationship_types" don't need to be editable, you can
> just let them "static".
>
> For exemple you can define them as an array in your Event model :
>
> $store_types = array(
>0 => "regular seller",
>1 => "VIP seller",
>2 => "partner"
> );
>
> And you have an int column in your habtm table called store_type or
> something
> At least, that's what I would do.
> The nice thing is you can use this "store_types" array in your form
> with selectTag
>
> +++
> clemos
>
> On 11/27/06, Marcelo de Moraes Serpa <[EMAIL PROTECTED]> wrote:
> > Guys, I really need a hand here!
> >
> > Let's say I've got two models:
> >
> > * Event -> Represents a party event
> > * Store -> A store where the user could buy a ticket to the party
> >
> > A user wants to go to a particular event. So, he enter the event
> > informations page and sees a list of "stores" (places) where he/she can
> buy
> > tickets for this event:
> >
> > Event information screen:
> >
> > 
> > Event Name
> > (...other informations...)
> >
> > Where to buy regular tickets:
> > * R&B Co.
> > * Shopping 1
> >
> > Whrere to buy VIP tickets:
> > * Carmen Steffens
> > * VIP store
> >
> > Companies that are supporting this event:
> > * Carmen Steffens
> > * VIP store
> >
> >
> > 
> >
> > As you can see, there are 3 lists of store for each event. The store
> where
> > to buy a regular ticket, the store where to buy a VIP ticket and the
> > "stores" that are supporting this event. And here's where I get confused
> on
> > how to model this kind of association.
> >
> > I see 3 possible solutions for this problem:
> >
> > 1) having a n:n relationship table for each of the HABTM associations
> > (events_storeregularticket, events_supportstores... each having a
> event_id
> > and store_id of course)
> > 2) having only one "general" events_stores whith a "relationship_type"
> field
> > so I could filter the correspondent records for each of HABTM
> relationship;
> > 3) Fake RoR's throughassociation (see Felix's post here:
> >
> http://www.thinkingphp.org/2006/10/26/modeling-relationships-in-cakephp-faking-rails-throughassociation/
> > ) transforming each of the HABTM association into an entitity itself, so
> I
> > would have a model (and a corresponding table) for:
> >  * PlacesToBuyRegularTickets model;
> >  * PlacesToBuyVipTickets model;
> >  * EventSupportingStores model;
> >
> > Particulary, I find the second one to be a more clean solution as I keep
> > only one table, but I see that I would need to create another table to
> keep
> > the kinds of relationships :/
> >
> > I'm really confused on the best way to model this in Cake. What would
> you
> > do/What have you done on your projects?
> >
> > Thanks in advance!
> >
> > Marcelo.
> >
> >
> >  >
> >
>
> >
>


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---


Re: Multiple HATBM (n:n) using the same model for different purposes

2006-11-28 Thread clemos

hi marcelo

I'm not really a guru, but your second solution looks the best to me.
Then, if the "relationship_types" don't need to be editable, you can
just let them "static".

For exemple you can define them as an array in your Event model :

$store_types = array(
   0 => "regular seller",
   1 => "VIP seller",
   2 => "partner"
);

And you have an int column in your habtm table called store_type or something
At least, that's what I would do.
The nice thing is you can use this "store_types" array in your form
with selectTag

+++
clemos

On 11/27/06, Marcelo de Moraes Serpa <[EMAIL PROTECTED]> wrote:
> Guys, I really need a hand here!
>
> Let's say I've got two models:
>
> * Event -> Represents a party event
> * Store -> A store where the user could buy a ticket to the party
>
> A user wants to go to a particular event. So, he enter the event
> informations page and sees a list of "stores" (places) where he/she can buy
> tickets for this event:
>
> Event information screen:
>
> 
> Event Name
> (...other informations...)
>
> Where to buy regular tickets:
> * R&B Co.
> * Shopping 1
>
> Whrere to buy VIP tickets:
> * Carmen Steffens
> * VIP store
>
> Companies that are supporting this event:
> * Carmen Steffens
> * VIP store
>
>
> 
>
> As you can see, there are 3 lists of store for each event. The store where
> to buy a regular ticket, the store where to buy a VIP ticket and the
> "stores" that are supporting this event. And here's where I get confused on
> how to model this kind of association.
>
> I see 3 possible solutions for this problem:
>
> 1) having a n:n relationship table for each of the HABTM associations
> (events_storeregularticket, events_supportstores... each having a event_id
> and store_id of course)
> 2) having only one "general" events_stores whith a "relationship_type" field
> so I could filter the correspondent records for each of HABTM relationship;
> 3) Fake RoR's throughassociation (see Felix's post here:
> http://www.thinkingphp.org/2006/10/26/modeling-relationships-in-cakephp-faking-rails-throughassociation/
> ) transforming each of the HABTM association into an entitity itself, so I
> would have a model (and a corresponding table) for:
>  * PlacesToBuyRegularTickets model;
>  * PlacesToBuyVipTickets model;
>  * EventSupportingStores model;
>
> Particulary, I find the second one to be a more clean solution as I keep
> only one table, but I see that I would need to create another table to keep
> the kinds of relationships :/
>
> I'm really confused on the best way to model this in Cake. What would you
> do/What have you done on your projects?
>
> Thanks in advance!
>
> Marcelo.
>
>
>  >
>

--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Multiple HATBM (n:n) using the same model for different purposes

2006-11-28 Thread Marcelo de Moraes Serpa
So... anyone ? :(

On 11/27/06, Marcelo de Moraes Serpa <[EMAIL PROTECTED]> wrote:
>
> Guys, I really need a hand here!
>
> Let's say I've got two models:
>
> * Event -> Represents a party event
> * Store -> A store where the user could buy a ticket to the party
>
> A user wants to go to a particular event. So, he enter the event
> informations page and sees a list of "stores" (places) where he/she can buy
> tickets for this event:
>
> Event information screen:
>
> 
> Event Name
> (...other informations...)
>
> Where to buy regular tickets:
> * R&B Co.
> * Shopping 1
>
> Whrere to buy VIP tickets:
> * Carmen Steffens
> * VIP store
>
> Companies that are supporting this event:
> * Carmen Steffens
> * VIP store
>
>
> 
>
> As you can see, there are 3 lists of store for each event. The store where
> to buy a regular ticket, the store where to buy a VIP ticket and the
> "stores" that are supporting this event. And here's where I get confused on
> how to model this kind of association.
>
> I see 3 possible solutions for this problem:
>
> 1) having a n:n relationship table for each of the HABTM associations
> (events_storeregularticket, events_supportstores... each having a event_id
> and store_id of course)
> 2) having only one "general" events_stores whith a "relationship_type"
> field so I could filter the correspondent records for each of HABTM
> relationship;
> 3) Fake RoR's throughassociation (see Felix's post here:
> http://www.thinkingphp.org/2006/10/26/modeling-relationships-in-cakephp-faking-rails-throughassociation/)
>  transforming each of the HABTM association into an entitity itself, so I
> would have a model (and a corresponding table) for:
>  * PlacesToBuyRegularTickets model;
>  * PlacesToBuyVipTickets model;
>  * EventSupportingStores model;
>
> Particulary, I find the second one to be a more clean solution as I keep
> only one table, but I see that I would need to create another table to keep
> the kinds of relationships :/
>
> I'm really confused on the best way to model this in Cake. What would you
> do/What have you done on your projects?
>
> Thanks in advance!
>
> Marcelo.
>
>


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---


Re: Major help on multiple lists and HATBM

2006-09-14 Thread [EMAIL PROTECTED]

Absolutely YES! I love Cake...I've (and currently I'm) developed an
entire (and very complex) Intranet application...but this "issue" in
saving HATBM relations; if only it was possible to save them as easily
as you can do with, for example, belongsTo relations.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Major help on multiple lists and HATBM

2006-09-14 Thread [EMAIL PROTECTED]

It still makes the developers life easier.  And there is a mechanism to
save HABTM relationships.  But the way you are wanting to save them
probably isn't using that mechanism so you are left to your own
devices.  Keep in mind these devices of running custom SQL (what you
wrote a whole four custom SQL queries) are still returned to you in
pretty CakePHP arrays.

::breathe, breathe::

CakePHP is still good.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Major help on multiple lists and HATBM

2006-09-14 Thread [EMAIL PROTECTED]

Well, I've made some custom SQL too (also to avoid while editing the
inserting of already-existant records) but I don't see the point;
CakePHP is made to make developer life easier...if we have to write
custom SQL I think it's not soo good. Maybe there's a more elegant way
and I didn't found it...


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Major help on multiple lists and HATBM

2006-09-14 Thread [EMAIL PROTECTED]

I had a similiar problem of needing to save coupons to orders.  It is a
HABTM relationship, but the order is saved well before the user tries
to enter coupons.  I ended up writing custom SQL to update the join
table of the HABTM relationship.  So, in this manner it is much like a
belongsTo or hasMany relationship where you are accustomed to
populating the join field yourself.

For most HABTM relationships CakePHP will be wonderful for retrieving
the data.  But since they are so complex and how people add and remove
the joined data can vary you will be left to your own devices to manage
the join table.

I also saw a solution for in the join table of a HABTM relationship
needed to have fields.  Then, instead of HABTM of two models you would
have three models and belongsTo and hasMany relationships between them.
 In this manner you would still be maintaining the join fields
yourself, but in the more accustomed to manner of belongsTo and hasMany
relationships that people seem so much more comfortable with.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Major help on multiple lists and HATBM

2006-09-14 Thread [EMAIL PROTECTED]

Hi all!

I've already searched for this topic around the Net and this newsgroup
and I didn't found anything; anyway, here's the issue: I've a review
that can be submitted by some groups so in the "add" view I've a
multiple list with the groups. To here, no problems at all.

The big one comes when I need to edit the review, my questions are:

1) how can I show as "selected" the groups that submitted the review
2) how can I make that if I selecte more groups it adds them or if I
de-select some groups it removes them

Please help me!!

Alberto


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---