# |
Jul 1st 2019, 13:34 |
admad |
might also need to clear dirty fields |
# |
Jul 1st 2019, 13:34 |
dereuromark |
ah, or this: $joinData = $tag->_joinData; $tag = $existing; $tag->_joinData = $joinData; $entity->tags[$k] = $tag; ^^ |
# |
Jul 1st 2019, 13:33 |
admad |
@dereuromark set id field for the entity and set `isNew()` to false :slightly_smiling_face: |
# |
Jul 1st 2019, 13:32 |
mdotobie |
My experience is changes to existing child entities don’t get marked as dirty on the parent entity, only in the child |
# |
Jul 1st 2019, 13:32 |
inoas |
I am a little confused if EXISTS() can help me out |
# |
Jul 1st 2019, 13:31 |
mdotobie |
I think you probably need to patch the entity first, add it to the association and mark it as dirty |
# |
Jul 1st 2019, 13:31 |
mdotobie |
oh so you’re trying to patch the “existing” tag entity and save it with the parent object @dereuromark? |
# |
Jul 1st 2019, 13:30 |
inoas |
ndm join() or innerJoin() / I cannot use innerJoinWith() unless hmmm... add a self join association ? |
# |
Jul 1st 2019, 13:29 |
inoas |
ndm what do you mean / the limit operator? |
# |
Jul 1st 2019, 13:29 |
dereuromark |
i probably need to do some re-patching here though |
# |
Jul 1st 2019, 13:29 |
dereuromark |
i tried $entity->tags[$k] = ['id' => $existingId] + ['_joinData' => $tag->_joinData]; etc |
# |
Jul 1st 2019, 13:29 |
mdotobie |
well I’m assuming a parent object is being saved and a “new” child entity |
# |
Jul 1st 2019, 13:28 |
mdotobie |
can’t you just pass an array with the ID of the existing one to the associated property @dereuromark? |
# |
Jul 1st 2019, 13:27 |
dereuromark |
How can I replace a "new Entity" being saved in a beforeSave with an existing id (entity)? Any quick way? |
# |
Jul 1st 2019, 13:27 |
ndm |
@ionas it works in joins IIRC |
# |
Jul 1st 2019, 13:21 |
ndm |
yep |
# |
Jul 1st 2019, 13:19 |
admad |
@ndm right, so it will be always cast when doing array <=> object conversion |
# |
Jul 1st 2019, 13:18 |
inoas |
with limit 1 |
# |
Jul 1st 2019, 13:18 |
inoas |
instead of column IN (SELECT id FROM... ) |
# |
Jul 1st 2019, 13:18 |
inoas |
wasnt there some other syntax but in... I just need a virtual table, not a join |
# |
Jul 1st 2019, 13:17 |
inoas |
This version of MariaDB doesn't yet support 'LIMIT and IN/ALL/ANY/SOME subquery ... whats your way around? |
# |
Jul 1st 2019, 13:16 |
ndm |
https://wiki.php.net/rfc/convert_numeric_keys_in_object_array_casts |
# |
Jul 1st 2019, 13:16 |
inoas |
I just hope they introduce another concept of arrays instead of tinkering with those what they are |
# |
Jul 1st 2019, 13:16 |
ndm |
@admad I should have been a little more precise, I ment circumvenving the casting isn't possible anymore... it was possible to do that casting an object to an array, but now the same casting rules apply there |
# |
Jul 1st 2019, 13:16 |
dereuromark |
they sure think things through :P |
# |
Jul 1st 2019, 13:16 |
admad |
i highly doubt the behavior of numeric array keys will change in 7.x |
# |
Jul 1st 2019, 13:15 |
admad |
https://3v4l.org/frjFs |
# |
Jul 1st 2019, 13:15 |
dereuromark |
i wonder if the php74 type safety fixes this strange behavior, as this will kill some apps if they internally reassign those to typed properties |
# |
Jul 1st 2019, 13:14 |
admad |
@ndm https://www.php.net/manual/en/language.types.array.php still shows numeric and non-string keys being cast to int. I would expect such a significant change to be well documented |
# |
Jul 1st 2019, 13:10 |
mdotobie |
I actually didn’t know that @ndm. Luckily that isn’t something I do. I never really understood why it was useful anyway. |
# |
Jul 1st 2019, 13:10 |
ndm |
I'd have to look it up |
# |
Jul 1st 2019, 13:10 |
admad |
@ndm that's new to me. Must be 7.3 not 7.2 |
# |
Jul 1st 2019, 13:05 |
ndm |
@mdotobie Correct... it should be noted though, that as of PHP 7.2 (IIRC) it's not possible anymore create arrays with integer string indices. |
# |
Jul 1st 2019, 12:53 |
inoas |
what was the way to teach cakephps orm group by max etc? |
# |
Jul 1st 2019, 12:48 |
mdotobie |
So by that logic @ndm I assume `{s}` will match `'abc'` and `'123'` but not 123 |
# |
Jul 1st 2019, 12:44 |
ndm |
@mdotobie The cookbook is a little unclear/misleading, `{n}` will match numeric keys, which includes numeric strings, ie it will match `123` and `'123'`, but not `'123abc'`. |
# |
Jul 1st 2019, 12:38 |
mdotobie |
okay. I will look a bit deeper. It was more out of curiosity. I use Hash quite a bit and just wanted to get a better sense of how it works. |
# |
Jul 1st 2019, 12:37 |
mdotobie |
I think I understand the docs mention that `{s}` will match numeric strings. If `{n}` only did indexed arrays and `{s}` did associative arrays and `{*}` did both I would get it. But I’m not sure I follow. |
# |
Jul 1st 2019, 12:36 |
admad |
maybe the docs are wrong :slightly_smiling_face: |
# |
Jul 1st 2019, 12:36 |
admad |
check the test cases |
# |
Jul 1st 2019, 12:36 |
admad |
then maybe i am mistaken |