# |
Jan 23rd 2020, 20:26 |
k4t |
if I add contain it will again generate additional queries |
# |
Jan 23rd 2020, 20:26 |
challgren |
Are you missing a contain()? |
# |
Jan 23rd 2020, 20:25 |
k4t |
let me explain |
# |
Jan 23rd 2020, 20:25 |
k4t |
It will, and it will generally generate query which interests me but my problem is that $results now contain data in "bad" format |
# |
Jan 23rd 2020, 20:25 |
challgren |
Ahh theres the ORM expert |
# |
Jan 23rd 2020, 20:25 |
ndm |
it will |
# |
Jan 23rd 2020, 20:24 |
challgren |
Im not sure on that one |
# |
Jan 23rd 2020, 20:23 |
k4t |
let's say we have relation Posts hasMany Comments and I will do: $results = $posts->find()->matching('Comments', function($q) { return $q->where(['Comments.user_id' => 2]) })->toArray(); It will generate 1 SQL query with INNER JOIN, right? |
# |
Jan 23rd 2020, 20:20 |
challgren |
Im not an ORM expert by any means but Ill try to help my best |
# |
Jan 23rd 2020, 20:17 |
k4t |
you are right but hmm... generally I have a big problem with CakePHP ORM and I can not solve it from years... let me write some details (sec) |
# |
Jan 23rd 2020, 20:15 |
challgren |
For example your hasMany is Comments, and you have a Post, with what your talking about you would have 30 duplicate Posts for the 30 comments |
# |
Jan 23rd 2020, 20:14 |
challgren |
And not duplicating the original data |
# |
Jan 23rd 2020, 20:14 |
challgren |
How would you do it in regular SQL without 2 queries? |
# |
Jan 23rd 2020, 20:14 |
k4t |
it will still generate two queries |
# |
Jan 23rd 2020, 20:14 |
challgren |
But you can change the strategy https://book.cakephp.org/3/en/orm/associations.html#hasmany-associations |
# |
Jan 23rd 2020, 20:13 |
challgren |
How else would you do it without duplicating the original table entries in the results? |
# |
Jan 23rd 2020, 20:05 |
k4t |
is it possible to change it? |
# |
Jan 23rd 2020, 20:05 |
k4t |
Why CakePHP 3 for hasMany relations generates 2 selects instead of one with JOIN? |
# |
Jan 23rd 2020, 19:19 |
challgren |
You could also do a Plugin approach too. It just really depends on what your trying to accomplish specifically |
# |
Jan 23rd 2020, 19:18 |
mocelle |
Hm... Good idea. I will try it |
# |
Jan 23rd 2020, 19:18 |
challgren |
You could also use Traits |
# |
Jan 23rd 2020, 19:17 |
challgren |
Like validators? |
# |
Jan 23rd 2020, 19:17 |
mocelle |
Trying to separate BL to own directory |
# |
Jan 23rd 2020, 19:14 |
challgren |
I’ve never really seen a use case that would require an extended table except in CakeDC/Users plugin |
# |
Jan 23rd 2020, 19:14 |
challgren |
What are you trying to accomplish? |
# |
Jan 23rd 2020, 19:13 |
mocelle |
Extended class should be inside Model/Table directory? I became ‚Cannot describe Test It has 0 columns |
# |
Jan 23rd 2020, 19:11 |
luizcmarin |
I will keep informed |
# |
Jan 23rd 2020, 19:10 |
luizcmarin |
tomorrow I will test this |
# |
Jan 23rd 2020, 19:10 |
luizcmarin |
:man-facepalming: thanks @challgren. Amanhã vou testar isso |
# |
Jan 23rd 2020, 19:08 |
challgren |
All it means is the code coverage decreased from the previous commit. Nothing to really worry about. If it was continuous-integration that would be a different story. |
# |
Jan 23rd 2020, 19:06 |
challgren |
Did you hover over the x to see what failed? |
# |
Jan 23rd 2020, 19:05 |
luizcmarin |
I haven't used it yet because of that .... I expected change here |
# |
Jan 23rd 2020, 19:05 |
luizcmarin |
@challgren |
# |
Jan 23rd 2020, 19:05 |
luizcmarin |
this has nothing to do? Because I think it was wrong. What does that mean? |
# |
Jan 23rd 2020, 19:02 |
challgren |
https://github.com/UseMuffin/Sti/releases/tag/2.0.0-beta |
# |
Jan 23rd 2020, 19:01 |
challgren |
Sti? Yes we fixed it up for you |
# |
Jan 23rd 2020, 19:01 |
luizcmarin |
@challgren is it ok to use in cake 4? |
# |
Jan 23rd 2020, 18:49 |
challgren |
https://github.com/UseMuffin/Sti might be useful too |
# |
Jan 23rd 2020, 18:48 |
challgren |
MyOtherModel extends CustomerTable |
# |
Jan 23rd 2020, 18:46 |
mocelle |
I trying to extend Model Table. For example: I have CustomerTable and I want to extend it. Is there way to extend Model Table? |
# |
Jan 23rd 2020, 18:40 |
megan |
@luizcmarin please share with us what you've learnt and what you are up to! (please email me community@cakephp.org - we'd love to hear more and maybe share it with the rest of the community via our channels) :) |