# |
Apr 19th 2017, 09:35 |
Nick5 |
Is there a way to automatically remove and rebuild a query cache when a new item is added? |
# |
Apr 19th 2017, 09:06 |
Martin` |
https://gist.github.com/blieb/27e2f9c3b76e03c778eed4810942139b << why can I not use the "$idsChannels" as a subquery in an array? I can just run it on its own, but not as subquery, then it gives the error you see in the comment |
# |
Apr 19th 2017, 08:52 |
hmic |
so this needs to read $roles->name instead |
# |
Apr 19th 2017, 08:52 |
Neon1024 |
If you’d round a role, you’d get a RoleEntity, so it’d be like $role->get(‘name’) |
# |
Apr 19th 2017, 08:52 |
hmic |
oh, i got it wrong, roles is *one* entity |
# |
Apr 19th 2017, 08:52 |
Neon1024 |
So accessing data using arrays will not work |
# |
Apr 19th 2017, 08:52 |
Neon1024 |
Collections of entity objects |
# |
Apr 19th 2017, 08:51 |
Neon1024 |
Well, not in model keyed arrays, but rather in Collections |
# |
Apr 19th 2017, 08:51 |
Neon1024 |
In Cake 3, data is not in arrays |
# |
Apr 19th 2017, 08:51 |
joop |
this does not worked |
# |
Apr 19th 2017, 08:51 |
hmic |
user will have multiple roles, so you need to filter for an admin role. i'd use the Collection to do so |
# |
Apr 19th 2017, 08:50 |
joop |
okey and if i want to make an if Statement like if($roles['Roles']['name']=='admin') |
# |
Apr 19th 2017, 08:46 |
Neon1024 |
If you go to roles and contain users, you’ll get all the users in that role instead |
# |
Apr 19th 2017, 08:46 |
joop |
yes |
# |
Apr 19th 2017, 08:46 |
Neon1024 |
So you can find the specific user, and then contain all their associated roles |
# |
Apr 19th 2017, 08:46 |
Neon1024 |
$this->Users->find()->contain([‘Roles’])->where([‘Users.id’ => $userId])->first(); |
# |
Apr 19th 2017, 08:45 |
Neon1024 |
So you’ll need to find a user and contain roles |
# |
Apr 19th 2017, 08:45 |
joop |
'UsersRoles.user_id' is gives error |
# |
Apr 19th 2017, 08:44 |
joop |
i checked but for the where(or condition) 'id' =>$this->Auth->user('id') //the id is wrong i need user_id because i would like to query the specific user's roles |
# |
Apr 19th 2017, 08:42 |
Neon1024 |
Instead, we have McDonalds down the road :s |
# |
Apr 19th 2017, 08:41 |
Neon1024 |
Times like this I wish I was in the Netherlands, so I could pop out for a proper coffee and a stroopwaffel |
# |
Apr 19th 2017, 08:41 |
Neon1024 |
Yeah, I’ve had a coffee, but it’s horrible instant coffee |
# |
Apr 19th 2017, 08:41 |
ankr |
neon1024 get that coffee maker running asap |
# |
Apr 19th 2017, 08:39 |
Neon1024 |
That ^ |
# |
Apr 19th 2017, 08:39 |
inoas |
belongsToMany() ;) |
# |
Apr 19th 2017, 08:39 |
Neon1024 |
As it’ll be included automagically |
# |
Apr 19th 2017, 08:39 |
Neon1024 |
If it’s a hasAndBelongsToMany() then you don’t need to contain it |
# |
Apr 19th 2017, 08:39 |
Neon1024 |
Yeah |
# |
Apr 19th 2017, 08:39 |
inoas |
maybe you want a real model then ;) |
# |
Apr 19th 2017, 08:39 |
inoas |
containing a pivot table sounds weirdo |
# |
Apr 19th 2017, 08:38 |
inoas |
the example is still here https://book.cakephp.org/3.0/en/orm/retrieving-data-and-resultsets.html#using-finders-to-load-data |
# |
Apr 19th 2017, 08:38 |
inoas |
urgh |
# |
Apr 19th 2017, 08:38 |
Neon1024 |
https://pastebin.com/wkFB33ep |
# |
Apr 19th 2017, 08:37 |
joop |
Neon would you show me the 3 way please |
# |
Apr 19th 2017, 08:36 |
joop |
Guest71037 try the History tab |
# |
Apr 19th 2017, 08:36 |
Neon1024 |
Well it’s very Cake 2 |
# |
Apr 19th 2017, 08:36 |
Neon1024 |
Your query is all wrong |
# |
Apr 19th 2017, 08:35 |
joop |
https://pastebin.com/TNtPkvwK |
# |
Apr 19th 2017, 08:35 |
Guest71037 |
in debugkit, the sql tab is empty, is there any way to fix this or debug it to see why |
# |
Apr 19th 2017, 08:35 |
joop |
no 3 |
# |
Apr 19th 2017, 08:35 |
Neon1024 |
Ah Cake 2 |