# |
Oct 1st 2016, 13:03 |
prophet |
Yes, it does. I called 'ManyUsers' 'Members'. I get a Database Error. |
# |
Oct 1st 2016, 12:59 |
hmic |
makes sense, does it? |
# |
Oct 1st 2016, 12:59 |
hmic |
and you do need to contain both, if you want both, so contain => ['Users', 'ManyUsers'] |
# |
Oct 1st 2016, 12:59 |
hmic |
so : belongsTo('Users'), belongsToMany('ManyUsers') |
# |
Oct 1st 2016, 12:58 |
hmic |
first you even need to call the associations differently |
# |
Oct 1st 2016, 12:58 |
hmic |
prophet, you need to add a propertyName key to the belongsTo(Many) definitions(s) |
# |
Oct 1st 2016, 12:48 |
prophet |
My AssociationsTable is linked to Users via belongsTo and belongsToMany. But only the belongsToMany relation is loaded when I get the association with 'contain' => ['Users']. http://pastebin.com/7QPkKRiQ What should I check to get it working? |
# |
Oct 1st 2016, 12:30 |
cakephp861 |
Friends help |
# |
Oct 1st 2016, 12:24 |
cakephp861 |
I mean what kind of table association i have to use: 1) course and student or 2)course and users |
# |
Oct 1st 2016, 12:23 |
cakephp861 |
Hi, I need help in setup Many to many relation. I have two kind of users(admin, student), Student can opt for courses. So for Many to many relation we should courses_students or courses_users. As using auth we can get user_id easyly |
# |
Oct 1st 2016, 12:14 |
hmic |
welcome |
# |
Oct 1st 2016, 12:11 |
maikh |
dumbass |
# |
Oct 1st 2016, 12:11 |
maikh |
it needed the plurals 'S' |
# |
Oct 1st 2016, 12:11 |
maikh |
it was a naming problem. :slightly_smiling_face: |
# |
Oct 1st 2016, 12:11 |
maikh |
oh... now it works. |
# |
Oct 1st 2016, 12:09 |
maikh |
hm, i dont understand. i have some more n:m associations that works. but only this one not... |
# |
Oct 1st 2016, 12:02 |
hmic |
i'd suggest naming the jointable manually in those relations |
# |
Oct 1st 2016, 11:58 |
maikh |
hm, i think there is something more wrong. |
# |
Oct 1st 2016, 11:55 |
maikh |
http://pastebin.com/VNnBXsAF |
# |
Oct 1st 2016, 11:54 |
hmic |
what did solve it? |
# |
Oct 1st 2016, 11:54 |
maikh |
yes, sorry. this is solved. :slightly_smiling_face: |
# |
Oct 1st 2016, 11:50 |
hmic |
you asked about a table not beeing found |
# |
Oct 1st 2016, 11:50 |
hmic |
this is not the problem you asked for in the beginning |
# |
Oct 1st 2016, 11:49 |
maikh |
yes, they are. and in ```$this->request->data['floors'], ['floorsmovein'] there are the selected ids. but nothing goes into my databasetables. ```$this->Forms->patchEntity($form, $this->request->data, [ 'associated' => [ 'Rooms','Floors','Floorsmovein','Specialremovals', 'Dismantles', 'Assembles' ] ]);``` |
# |
Oct 1st 2016, 11:46 |
hmic |
you tell me! |
# |
Oct 1st 2016, 11:45 |
maikh |
@hmic hm... floors_forms and floorsmovein_forms are my joinTables arent they? |
# |
Oct 1st 2016, 11:44 |
hmic |
!tell maikh about gist |
# |
Oct 1st 2016, 11:43 |
hmic |
show the schema, show the code, explain from there |
# |
Oct 1st 2016, 11:43 |
hmic |
still your text example does not reveal your current database setup or actual problem. |
# |
Oct 1st 2016, 11:43 |
hmic |
you need a jointable for belongsToMany to work. even if its a self-relation (afaiu) |
# |
Oct 1st 2016, 11:39 |
slackebot |
i think, but nothing is saved in floorsmovein_forms. |
# |
Oct 1st 2016, 11:39 |
maikh |
@hmic i have a form with many many inputs. on the one hand i have a multi select where the user checks the floors which he is living on moving out. On the other hand the user has to select floors in which he is moving in. these two should be belongsToMany assocs with floors. In the floors table there are floors which can be selected by users. so in my form i have one field named ```floors._ids``` and the other one ```floorsmovein._ids``` The as |
# |
Oct 1st 2016, 11:36 |
hmic |
maikh: belongsToMany uses a jointable, ever. i dont understand what you want to archive, but if you are sure you dont need one, you might want to use hasMany instead? |
# |
Oct 1st 2016, 11:18 |
maikh |
but allways get an cake error ```SQLSTATE[42S02]: Base table or view not found: 1146 Table 'dmsdigital.floorsmovein' doesn't exist``` |
# |
Oct 1st 2016, 11:18 |
maikh |
i tried it with this: ```$this->belongsToMany('Floors', [ 'className' => 'Floors', 'foreign_key' => 'floor_id', 'propertyName' => 'Floors' ]); $this->belongsToMany('Floorsmovein', [ 'className' => 'Floors', 'foreign_key' => 'floorsmovein_id', 'propertyName' => 'Floorsmovein' ]);``` |
# |
Oct 1st 2016, 11:14 |
maikh |
hey there. i have a model named ```floors``` in this table there are records for floors. Then i have a n:m association to which saves the floors in forms_floors now, i need a new model which should save the floors in forms_floorsmovein how do i realize this with only one table for the floors? |
# |
Oct 1st 2016, 09:09 |
birdy247 |
the through option :) |
# |
Oct 1st 2016, 08:57 |
birdy247 |
how can I enforce school_type_id is not empty? |
# |
Oct 1st 2016, 08:57 |
birdy247 |
I dont have a Table for the joinTable |
# |
Oct 1st 2016, 08:57 |
birdy247 |
echo $this->Form->input('schools.0._joinData.school_type_id', ['empty' => '--Select--']); |
# |
Oct 1st 2016, 08:57 |
birdy247 |
I have a field like this |