# |
Jul 1st 2019, 15:30 |
niel512 |
why is the T quoted? |
# |
Jul 1st 2019, 15:26 |
kyleweishaupt |
Does anyone know an easy adjustment to have Cake 3.8 validate datetimes in UTC coming from moment.js? I can't seem to get my custom DateTimeType to handle `YYYY-MM-DD'T'HH:MM:ss.uZ`. I keep getting the "Provided value is invalid" but can't seem to get it right. |
# |
Jul 1st 2019, 15:06 |
ndm |
@barry.chapman What's special about SAML requests? |
# |
Jul 1st 2019, 14:54 |
barry.chapman |
anyone know how to generate a saml request in cake? |
# |
Jul 1st 2019, 14:09 |
slackebot |
$newsletter_id); }) |
# |
Jul 1st 2019, 14:09 |
ndm |
``` ->where(function (\Cake\Database\Expression\QueryExpression $exp) use ($newsletter_id) { return $exp->eq('MD5(CONCAT("newsletter-", Newsletters.id))', $newsletter_id); }) ``` ``` ->where(function (\Cake\Database\Expression\QueryExpression $exp, \Cake\ORM\Query $query) use ($newsletter_id) { $func = $query->func()->md5( [$query->func()->concat(['newsletter-', 'Newsletters.id' => 'identifier'])] ); return $exp->eq($func, |
# |
Jul 1st 2019, 14:08 |
ndm |
eh, sorry, I ment expressions, not functions @david, but you could use the functions builder in conjunction with expressions of course |
# |
Jul 1st 2019, 14:00 |
ndm |
You need to use either the functions builder, or bindings |
# |
Jul 1st 2019, 14:00 |
david |
cakephp convert queries from OriginalCase to "everylowercase" |
# |
Jul 1st 2019, 13:59 |
david |
I am having issues with concat and LowerCase table names... |
# |
Jul 1st 2019, 13:48 |
ndm |
@ionas I can't quite wrap my head around that snippet... but `innerJoinWith()` is for associations, in order to join a subquery, you'd have to use `innerJoin()` or `join()`... an example of what data you have, and what you want to retrieve might help. Are trying to pull of some kind of "greatest n per group" query? |
# |
Jul 1st 2019, 13:47 |
dereuromark |
I had the bug that tags have been saved multiple times, with a count of 1 each. instead of proper reusing. So no, I didnt find another solution, this one works now. |
# |
Jul 1st 2019, 13:46 |
ricksaccous |
that prob won't work for what you're trying to do i suppose |
# |
Jul 1st 2019, 13:46 |
ricksaccous |
@dereuromark save and replace strategy? lol |
# |
Jul 1st 2019, 13:44 |
dereuromark |
admad: the problem is specifically patchEntity and uniqueness only for existing in DB ( https://github.com/dereuromark/cakephp-tags/pull/28/files#diff-33b2925318abc4cc41b83442ae327efbR170 ) it would need to do uniqueness check also on already patched data, not sure if someone already coded sth here. |
# |
Jul 1st 2019, 13:43 |
ndm |
*wouldn't |
# |
Jul 1st 2019, 13:43 |
david |
how would you do this WHERE clause in the CakePHP Way? $newsletter = $this->Newsletters->find() ->where(['MD5(CONCAT("newsletter-", Newsletters.id)) =' => $newsletter_id]) ->first(); |
# |
Jul 1st 2019, 13:43 |
ndm |
@ionas it really depends on what exactly you are trying to do... but you probably would use `IN`, but `ON`, like `JOIN (SELECT ...) AS sub ON sub.id = parent.id` |
# |
Jul 1st 2019, 13:43 |
inoas |
https://gist.github.com/inoas/9195c4526642fd68dc72506e607ac576 |
# |
Jul 1st 2019, 13:42 |
inoas |
because for me it doesnt |
# |
Jul 1st 2019, 13:42 |
inoas |
do you have a very small working snipplet |
# |
Jul 1st 2019, 13:40 |
inoas |
ndm you mean using IN against a subquery within a join? |
# |
Jul 1st 2019, 13:40 |
dereuromark |
admad: that aint working in this case. it creates duplicates. |
# |
Jul 1st 2019, 13:40 |
ndm |
@ionas it should |
# |
Jul 1st 2019, 13:39 |
inoas |
ndm limit in innerjoin should work? |
# |
Jul 1st 2019, 13:35 |
admad |
best it's best to do your stop in beforeMarshal and let normal patching process work |
# |
Jul 1st 2019, 13:34 |
admad |
to avoid having them updated |
# |
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? |