Log message #4223149

# At Username Text
# Jan 20th 2020, 17:57 ricksaccous so I'm setting the local path to my project/data folder
# Jan 20th 2020, 17:56 ndm @turkles I'm not sure that I can follow... but if you need to add indexes on query level, that's certainly possible, using for example a result formatter, something like: ```$query->formatResults(function (\Cake\Collection\CollectionInterface $results) { return $results->map(function ($row) { $row['roles'] = collection($row['roles']) ->indexBy('id') ->toArray(); return $row; }); });```
# Jan 20th 2020, 17:51 ricksaccous @neon1024 using local
# Jan 20th 2020, 17:38 turkles well atm I have checkboxes, with the checked state depending on current list, but when I submit it I want to remove and re-add where needed. Problem is I am paginating the list as there are too many, so I only want to remove/add items as required, which I can't do without some complex processing
# Jan 20th 2020, 17:33 ndm `$hasRole = collection($user->roles)->firstMatch(['id' => $roleId]) !== null;`
# Jan 20th 2020, 17:33 ndm If you just need it for a single check somewhere, then maybe just convert it to a collection and match it
# Jan 20th 2020, 17:27 turkles I have a bunch of user roles my users can opt into, and finding it hard to check if they already have it as its User.Roles[0], User.Roles[1] etc, would be much easier if the index was role_id
# Jan 20th 2020, 17:23 turkles Is it possible to index contains by a field/key?
# Jan 20th 2020, 17:16 ndm `execute()` is a method of the inherited, "lower level" database query class, which has no ORM features like containments
# Jan 20th 2020, 17:13 ndm @kiwi_72 Under the hood `get()` uses `find()` too. In your example you are using `execute()`, not sure if that's in your actual code, or just for the example, but that won't include containments, as it will only execute the SQL that this query object creates, not the ones created by the eager loadables (containments). Use `all()`, `toArray()`, one of the collection methos, or iterate the query object instead.
# Jan 20th 2020, 17:06 kiwi_72 using get() works with the hasMany() association. something with find behaves differently than I expected it to be. @btx, @ndm thank you both for your pointers!
# Jan 20th 2020, 16:55 neon1024 https://flysystem.thephpleague.com/v1/docs/adapter/local/
# Jan 20th 2020, 16:54 neon1024 Are you using a local file system or a remote one?
# Jan 20th 2020, 16:54 neon1024 The documentation for the Flysystem library says you set a path when you setup the adapter
# Jan 20th 2020, 16:51 ricksaccous nothing makes sense here
# Jan 20th 2020, 16:51 ricksaccous but not where
# Jan 20th 2020, 16:51 ricksaccous I know they are somewhere
# Jan 20th 2020, 16:50 ricksaccous I don't know where the hell my files are being put
# Jan 20th 2020, 16:50 ricksaccous I'm running into a really stupid problem with flysystem
# Jan 20th 2020, 16:26 kiwi_72 ok i see
# Jan 20th 2020, 16:25 ndm It happens automatically under the hood, nothing you'd need to worry about
# Jan 20th 2020, 16:25 kiwi_72 or you mean what is happening in tunder the hood of cakephp?
# Jan 20th 2020, 16:25 kiwi_72 nothing I can find about additinal queries
# Jan 20th 2020, 16:24 kiwi_72 in the examples on https://book.cakephp.org/3/en/orm/retrieving-data-and-resultsets.html#retrieving-associated-data there is one find with contains, witch returns all the associated data
# Jan 20th 2020, 16:24 ndm what procedure?
# Jan 20th 2020, 16:24 kiwi_72 ndm: could you please elaborate on the procedure?
# Jan 20th 2020, 16:22 ndm `hasMany` and `belongsToMany` associations are generally being retrieved in separate/additional queries
# Jan 20th 2020, 16:20 kiwi_72 btx: i've got the query statements form the query object. and it is missing the association as soon as the table association is hasMany. (and vardumping the result is just accoring to this, it doesn't contain anything about the second table)
# Jan 20th 2020, 16:19 lorenzo haha
# Jan 20th 2020, 16:17 btx (my answers are always a trick to get a more qualified person to correct me)
# Jan 20th 2020, 16:16 lorenzo contain is always eager
# Jan 20th 2020, 16:16 lorenzo the orm does not lazy load
# Jan 20th 2020, 16:16 btx the new ORM lazy loads, it probably wont pull it back unless asked to
# Jan 20th 2020, 16:16 btx what happens when you actually vardump the executed object
# Jan 20th 2020, 16:15 kiwi_72 I have checked with find() as you suggested, and it behaves the same
# Jan 20th 2020, 16:15 btx because you’re using find(‘all’), probably
# Jan 20th 2020, 16:14 kiwi_72 I see, but do you have any hints on why is the other table completely omitted in the query if the relation is hasMany() (with the same,and proven to work paramters (foreingKey/bindingKey)?
# Jan 20th 2020, 16:09 btx also I wouldn’t specify the `hasMany` params unless you’re overriding them, but that’s just me
# Jan 20th 2020, 16:09 btx kiwi, I would do `$ordersTable->find()->contain(['Tablebs'])` instead of `find('all')`
# Jan 20th 2020, 16:06 kiwi_72 on https://pastebin.com/TUSQt5Va i try to explain in more detail
# Jan 20th 2020, 15:59 val @lorenzo I see `firstOrFail()` method that could be used as an example. That might work. What if I would like to do similar thing with `null` associated records returned by `find('all')` ?