Re: CakePHP 2 - HABTM saving issue

2011-08-27 Thread Ben McClure
Figured it out myself... maybe I should give myself a 24-hour rule from the time I write my post to the time I actually post it :) Anyway, to get model deleting to work I set the 'dependent' property to True in the User model's hasMany relationship for AuthSourcesUser, and my array to save it l

Re: CakePHP 2 - HABTM saving issue

2011-08-27 Thread Ben McClure
Ok, I'm getting a little closer. Some digging in more documentation brought me to this array to use instead: Array ( [User] => Array ( [email] => (my email here) [first_name] => Ben [last_name] => McClure ) [AuthSource] => Array

Re: CakePHP 2 - HABTM saving issue

2011-08-27 Thread Ben McClure
Well, I realized as soon as I posted that the reason the auth_sources_users records aren't getting deleted is that their user_id fields are blank... so I don't know if there's going to be a problem deleting the records or not... But what am I doing wrong when saving the data using the manually-c

CakePHP 2 - HABTM saving issue

2011-08-27 Thread Ben McClure
I have a 'users' table, an 'auth_sources' table, and an 'auth_sources_users' table to join them. I added an extra field, 'unique_value' to the auth_sources_users table which stores a unique value to identify that user against the chosen auth source. In my User model, I have this: var $hasMany

Re: habtm saving: is my really simple solution fragile? using a model for habtm-table

2010-09-27 Thread Tomfox Wiranata
;id') to > make acting on the table as easy as any other model." (http:// > book.cakephp.org/view/1044/hasAndBelongsToMany-HABTM) > Which isn't as explicit but definitely implies that it's ok. > > On Sep 26, 1:50 pm, Tomfox Wiranata wrote: > > > hi e

Re: habtm saving: is my really simple solution fragile? using a model for habtm-table

2010-09-27 Thread Sam
to add an additional primary key field (by convention 'id') to make acting on the table as easy as any other model." (http:// book.cakephp.org/view/1044/hasAndBelongsToMany-HABTM) Which isn't as explicit but definitely implies that it's ok. On Sep 26, 1:50 pm, Tomfox Wiranata

habtm saving: is my really simple solution fragile? using a model for habtm-table

2010-09-26 Thread Tomfox Wiranata
hi everyone, I found this habtm saving tutorial on the net and it wont work for me: http://bakery.cakephp.org/articles/view/add-delete-habtm-behavior it uses both models in the relation and combines them to save or delete data in the habtm-relation. now I had Problems with habtmAdd and

Re: habtm saving

2010-09-19 Thread Tomfox Wiranata
ok I got it: I had to change the parameter "unique" to false^^ On 18 Sep., 19:53, Tomfox Wiranata wrote: > ok i tried this and it works, but not perfectly > >                 $saved = $this->User->save(array( >                         'User' => array( >                                 'id' =

Re: habtm saving

2010-09-18 Thread Tomfox Wiranata
ok i tried this and it works, but not perfectly $saved = $this->User->save(array( 'User' => array( 'id' => 1, ), 'Product' => array( 'Product' =>

Re: habtm saving

2010-09-18 Thread Tomfox Wiranata
ok after two close nervous breakdowns i got it. for everyone else who has probs with habtm saving: used this behaviour http://bakery.cakephp.org/articles/view/add-delete-habtm-behavior works pretty fine. :) On 18 Sep., 16:39, Tomfox Wiranata wrote: > hi everyone, > > I have t

habtm saving

2010-09-18 Thread Tomfox Wiranata
hi everyone, I have two models: User and Product with tables users and products. there is a HABTM relation involved. so I coded in the product model: var $hasAndBelongsToMany = array( 'User' => array('className'=> 'User', 'joinTable'

Re: HABTM Saving

2010-07-28 Thread sanedevil
thanks, but this dint work as well :( i can link one Profile to the user at a time, but not more than one :( is there any other specific setting that i need to take care of? On Jul 28, 3:40 am, DCrews wrote: > if $this->data is structured like the following: > > array( >      ['User'] = array( >

Re: HABTM Saving

2010-07-27 Thread DCrews
if $this->data is structured like the following: array( ['User'] = array( 'id' = xxx ), ['Profile'] = array( [0] = array( 'id' = xxx, 'whatever' = whatever, etc... [1] = array( 'id' = xxx,

Re: HABTM Saving

2010-07-27 Thread sanedevil
Thanks Norman, However, it dint work :( The problem is that I can't save multiple links of Profile and User. I can only do one at a time. hence, $data['Profile']['id'] = 1234 works, but $data['Profile'][0] ['id'] = 1234 doesn't work :( any lights? On Jul 27, 1:15 am, Norman Paniagua wrote: > T

Re: HABTM Saving

2010-07-26 Thread Norman Paniagua
Try $data['User']['id'] = 1010; $data['Profile'][0]['id'] = 1234; $data['Profile'][1]['id'] = 5678; foreach ($data['Profile'] as $i=>$v): $data['Profile'][$i]['user_id'] = $data['User']['id']; endforeach; $this->User->save($data); $this->User-->Profile->saveAll($data); I dont know if do

HABTM Saving

2010-07-26 Thread sanedevil
For my problem, a User HABTM Profiles A user can select multiple profiles via a screen. I get these values in my controller. I want to "link" all these profiles with the user. Currently i'm doing: $profile_1['Profile']['id'] = 1234; //the profile id $profile_1['Us

Re: SaveAll HABTM Saving to wrong tables...

2010-04-07 Thread WebbedIT
Cake magic can only work in a HABTM situation when both records already exist. For what it's worth I still think you're heading for a few headaches as previously stated. How are you going to structure your forms so it allows you to both select from existing telephone numbers or add multiple new on

Re: SaveAll HABTM Saving to wrong tables...

2010-04-06 Thread Mark
Thanks to both you and nurzvy. You are right - the reason I need a HABTM relationship is that two people can share the same phone number. So the only way to do this (once I get the actual syntax right) will be to save the phones first, gather their ID's, and reformat the data array, and then do a

Re: SaveAll HABTM Saving to wrong tables...

2010-03-10 Thread WebbedIT
You're probably right nurvzy, but if many contacts can have the same phone number, then he could want a HABTM association. If so there are a few other issues with his setup Table contacts_phone should be contacts_phones, as nurvzy said, but it also requires an id field (all cake tables require an

Re: SaveAll HABTM Saving to wrong tables...

2010-03-09 Thread nurvzy
First, your table name is wrong, should be contacts_phones instead of contacts_phone. Second, you're not forming your data correctly in your view for a hasAndBelongsToMany relationship. CakePHP expects a HABTM relationship to come in as [Model][Model][id]s. What you have there is a hasMany rela

SaveAll HABTM Saving to wrong tables...

2010-03-09 Thread Mark
I am working on a project that involves a lot of many to many relationships, and for some reason cakephp isn't playing nice with them. Take the following tables: Table: contacts id name created updated Table: phones id number Table: contacts_phone contact_id phone_id Here are my two models: c

Re: HABTM saving problem - solved (I think)

2009-07-20 Thread seb
Thanks for posting the solution. Well I've got the same problem! But it looks like you have the fix. However I can't quite get my head around it because in your example you refer to $category in $category["CandidateItem"]["CandidateItem"][$count] = this->Category- >CandidateItem->getLastInsertI

Re: HABTM saving problem - solved (I think)

2009-07-14 Thread cc_humbry
Finally sorted this for anyone else who has the same problem... iterate over my array and save each item individually. Get each id of inserted row and add to new data array and then save Category. This then creates the associations in the link table. foreac

HABTM saving problem

2009-07-14 Thread cc_humbry
Hi, Can't figure this one out, not for the want of trying though. Models involved are Category, CandidateItem which are associated in each model as HABTM. I created a temp baked project to see if the association definition was correct and it appears to be. In my categories_controller I have a me

HABTM saving duplicates

2009-06-12 Thread Lucas Prim
Hi all! I was starting to work with some HABTM relations and I've found the following problem: Whenever I try to save the relationship between the models I'm using (subject,teacher) more than one time, cake creates duplicate entries into the subjects_teachers table. I've created an unike key so i

HABTM saving associations

2008-11-03 Thread FluF
Hello, I have models: class User extends AppModel { public $hasAndBelongsToMany = array( 'Right' => array( 'className' => 'Right', 'joinTable' => 'users_rights', ), ); } class Right extends AppM

HABTM saving duplicates

2008-10-20 Thread [EMAIL PROTECTED]
I am going to try to do my best to explain. I have three tables, items and tags and items_tags. Many items can belong to many tags, and many tags can belong to many items.When I add an Item via the add() function in the items_controller.php below, I get the following query (sorry for the la

New HABTM saving process in cake 1.2?

2008-08-27 Thread blablu
Hi, I just updated to the new 1.2 RC2 release, I made the necessary changes but I still have some trouble with saving habtm relations. I have the two models German and English with the following relation: German Model: var $hasAndBelongsToMany = array( 'English' =>

Re: HABTM saving again... sorry

2008-02-18 Thread [EMAIL PROTECTED]
Well, after a lot of echo's in model.php I finally found out that the problem was the most annoying simple crap possible. CakePHP 1.2 is a bit more picky about how you define associations. This is BAD: var $hasAndBelongsToMany = array('Module'); This is GOOD: var $hasAndBelongsToMany = array(

Re: HABTM saving again... sorry

2008-02-18 Thread [EMAIL PROTECTED]
Thanks but I don't think that was it. I altered my model.php but my problem remains. I do not even get any SQL queries that save anything. Not even buggy data. I am starting to think that it somewhere decides that the model hasn't changed and doesn't bother saving. (I am running $this->read() )

Re: HABTM saving again... sorry

2008-02-18 Thread jakecake
You are probably victim of this bug : http://groups.google.com/group/cake-php/browse_thread/thread/2ad48c4e10f58fc0/c7c4511051071b52 There are many threads here about problems with HABTM due to this bug. I cannot understand why the cake home page still propose to download a beta version contain

HABTM saving again... sorry

2008-02-18 Thread [EMAIL PROTECTED]
I really don't know what else to do. I have checked my data against the pages in frequent discussions and searched and read-through a lot of posts. None actually helped me in this situation. I am trying to save HABTM (in 1.2.6311). Problem is I don't get any errors, I dont see any insets or updat

Re: HABTM saving problem

2007-04-25 Thread [EMAIL PROTECTED]
Can you post an example please? When I do $this->Post->save it only saves Post info and not related Tags ... Thanks in advance .. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this gr

Re: HABTM saving problem

2007-03-27 Thread feelexit
I got it work now --~--~-~--~~~---~--~~ 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

Re: HABTM saving problem

2007-03-27 Thread [EMAIL PROTECTED]
feelexit, in order to save the data to tags table you must have in the data returned ($this->data) data relating to the Tag model like this data['Tag'['Tag'] = array ( 'id' => '1' , 'id' => '2'...) where ['Tag']['Tag'] contains an array of id's corresponding to tag id's. You can find more info o

Re: HABTM saving problem

2007-03-27 Thread feelexit
another question is , in the posts with tags example, when I am doing save, only save post table or posts_tags will be saved as well ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to t

HABTM saving problem

2007-03-27 Thread feelexit
I have 3 tables tags resources resources_tags in my controller, i use " print_r ($this->data); " to print out data structure Array ( [Resource] => Array ( [title] => hhh [description] => [user_id] => 1 ) ) it only has data for Resource, there's no data for Tag. here's my HTML code.

Re: HABTM saving with checkboxes

2006-09-29 Thread [EMAIL PROTECTED]
I think the manual talks about using the table/field name of Category/Category and making it a multiple selection dropdown. Then it will save the HABTM relationship automatically on create. Now, I am not sure if there is something automagic if you need to maintain the relationship. One thing I

HABTM saving with checkboxes

2006-09-29 Thread Andre
Hi everyone. Concerning the subject, the example in the manual uses a multiple select tag, but I prefer checkboxes for usability reasons. Is there a simple way to do that automatically, or should I going on coding it by myself? function admin_add() { $this->layout = 'admin'; $cat