Log message #4051502

# At Username Text
# Jul 13th 2017, 06:16 spriz Question regarding syntax for the 3.x orm - which one do you prefer and why? https://gist.github.com/Spriz/645b9e96c1430f141f3d49e225e4ede6
# Jul 12th 2017, 22:03 spencdev But generally, and I don't know you're situation so take it for what it's worth, you use the same controller as your model, unless it's an associated table. Or like I said, depending on the situation
# Jul 12th 2017, 22:01 spencdev You can, I just didn't mean that modifying is the ONLY thing you can do
# Jul 12th 2017, 22:00 aaronc Gotcha, working now. Why did you explicitly state that I can't modify anything from that Model? Should I just create an edit method for each of those controllers and redirect to that if they choose to edit it?
# Jul 12th 2017, 21:57 spencdev Not modify, but work with
# Jul 12th 2017, 21:56 spencdev If you're purposely trying to use ListsController to modify Tests table, you have to load that table in using `$this->loadModel('Tests');`
# Jul 12th 2017, 21:55 aaronc Yeah the plan was to have a ListsController that can edit the information in several other Tables all in one place. I do have a functional TestsController and TestTable
# Jul 12th 2017, 21:55 konstanting @chris-andre this looks interesting thanks
# Jul 12th 2017, 21:53 spencdev Your controller is Lists controller, but you are trying to query using Tests table?
# Jul 12th 2017, 21:50 slackebot the model?
# Jul 12th 2017, 21:50 aaronc So I'm still struggling with something that is certainly a basic feature. How do I just query my table manually? I have my controller ``` use Cake\ORM\Query; class ListsController extends AppController { public function index() { $result = $this->Tests->query(); pr($result); } } ``` But it throws an error "Call to a member function query() on boolean. So my Tests variable is a boolean? Does it need to referenced somehow so that it
# Jul 12th 2017, 21:49 chris-andre @konstanting Have a look https://stackoverflow.com/questions/37658120/linking-two-tables-with-two-composite-foreign-key-relation
# Jul 12th 2017, 21:47 konstanting Alright then thank you all for your help and input :thumbsup:
# Jul 12th 2017, 21:45 konstanting yes I think thats the only solution i belongstomany is used
# Jul 12th 2017, 21:44 chris-andre Right, only I can think of is to have two associations with alias UserA and UserB, then `->contain(['UserA', 'UserB'])`
# Jul 12th 2017, 21:43 konstanting It would be nice to just contain(['Friends']) but this only works for UserA -> UserB and not if I select userB to contain UserA
# Jul 12th 2017, 21:40 konstanting (sorry for answering this late)
# Jul 12th 2017, 21:39 konstanting @chris-andre Thats essentially what the users_users table is. This works in one direction but not in both.
# Jul 12th 2017, 21:25 ericadeefox ^^ty for this, I am so bad at convention
# Jul 12th 2017, 21:23 chris-andre Just to give you an input on join tables, according the docs: >Join tables, used in BelongsToMany relationships between models, should be named after the model tables they will join, arranged in alphabetical order (articles_tags rather than tags_articles).
# Jul 12th 2017, 21:22 ericadeefox ^^oh no that's much better, to have a users_groups and a users_friendships
# Jul 12th 2017, 21:20 chris-andre That would be "easier". That would be a groups (or something similar) with groups_users.
# Jul 12th 2017, 21:19 ericadeefox @chris-andre ahh good point if there are just 2 users per friendship, I was thinking a "friendship" would have >= 2 users, as many as necessary lol
# Jul 12th 2017, 21:18 chris-andre @konstanting I would go for one table named whatever (friendships) with id:integer user_a:integer user_b:integer. Two rows for one friendship should not be necessary. Now, I'm haven't thought about the a nice cake-way to create the association.
# Jul 12th 2017, 21:16 ericadeefox in the Friendships model, you'd put that Friendships entities have many Users entities. in this instance, a Friendship is just, like, an entity that multiple Users can collaborate on. no different than if an article had multiple authors for example.
# Jul 12th 2017, 21:14 ericadeefox if UserA and UserB have Friendship1, then that's how they relate. in `users_friends`, there'd be a row for UserA and Friendship1, and a separate row for UserB and Friendship1
# Jul 12th 2017, 21:13 konstanting ```$this->belongsToMany('Friends', [ 'className' => 'Users', 'joinTable' => 'users_users', 'targetForeignKey' => 'friend_id' ]);```
# Jul 12th 2017, 21:13 konstanting Maybe the following makes it clearer
# Jul 12th 2017, 21:13 konstanting @ericadeefox But what would I put in the Friendships Model? If I want relate UserA to UserB I need to connect these Models and not another one.
# Jul 12th 2017, 21:12 ericadeefox gbye @sturm!! :)
# Jul 12th 2017, 21:12 saeideng good by
# Jul 12th 2017, 21:12 saeideng goof by
# Jul 12th 2017, 21:11 sturm End of workday; I’m heading home. See you all tomorrow, most likely.
# Jul 12th 2017, 21:10 saeideng if your table is `users_friends` you should use `users_friends`]
# Jul 12th 2017, 21:09 ericadeefox you want many users to be able to have many friendships, and many friendships to be able to have many users, like social media yes? those 'Friendships' are entities also and need their own models.
# Jul 12th 2017, 21:08 ericadeefox probably, I'm horrible at following convention. @konstanting you're gonna want a model for your 'Friendships' as well.
# Jul 12th 2017, 21:08 sturm Also, @ericadeefox, doesn’t the join table have to be in alphabetical order? i.e., `friends_users` instead of `users_friends`? Not sure if it makes that much of a difference, though.
# Jul 12th 2017, 21:08 konstanting @ericadeefox No it's just imaginary
# Jul 12th 2017, 21:07 ericadeefox @konstanting do you have a model built for 'Friendships'?
# Jul 12th 2017, 21:06 sturm Okay, thanks @saeideng.
# Jul 12th 2017, 21:06 ericadeefox yes, 'localproject' in this case would be the same as your 'friendship's.