Log message #3977611

# At Username Text
# Jan 22nd 2017, 19:23 bigdaddygee http://php.net/manual/en/function.array-diff-assoc.php
# Jan 22nd 2017, 19:23 bigdaddygee Let's check it with
# Jan 22nd 2017, 19:21 bigdaddygee at line 8 you'll have to check if $row is different from what you receive in $entity
# Jan 22nd 2017, 19:20 siran slackebot: i updated it removing all non-important lines
# Jan 22nd 2017, 19:18 bigdaddygee let me check
# Jan 22nd 2017, 19:18 bigdaddygee np
# Jan 22nd 2017, 19:18 siran unfortunately I didn't know how to put php format
# Jan 22nd 2017, 19:18 siran https://gist.github.com/siran/feb1fb0d0c98d8211e35f6438c6fefe6
# Jan 22nd 2017, 19:17 siran i was there
# Jan 22nd 2017, 19:17 siran np
# Jan 22nd 2017, 19:16 bigdaddygee you do need a github account, if you don't paste it to pastebin.org but it's more clean on gist.
# Jan 22nd 2017, 19:15 bigdaddygee siran https://gist.github.com/
# Jan 22nd 2017, 19:15 bigdaddygee @admad I found ! :) I use newExpr()->add()
# Jan 22nd 2017, 19:15 siran slackebot: where do i make the gist?
# Jan 22nd 2017, 19:13 bigdaddygee Can you past the code on gist ?
# Jan 22nd 2017, 19:10 siran slackebot: so apparently the $data i'm saving is the same as the record, so the only thing changin is the 'modified' field
# Jan 22nd 2017, 19:09 siran slackebot: i do a find to see if the record exists, if it exists I patchEntity() with an array of values (that may or may not be the same as the one already in the table); if it doesn't exist I do a newEntity()
# Jan 22nd 2017, 19:09 siran i do a find to see if the record exists, if it exists I patchEntity() with an array of values (that may or may not be the same as the one already in the table); if it doesn't exist I do a newEntity()
# Jan 22nd 2017, 19:08 bigdaddygee I mean, in your code, do you know where this update is fired ?
# Jan 22nd 2017, 19:07 siran slackebot: I get: UPDATE mytable SET modified = '2017-01-22 18:57:35' WHERE id = '58062825'
# Jan 22nd 2017, 19:07 bigdaddygee Oh, and what's your save procedure right now ? (gist)
# Jan 22nd 2017, 19:06 siran slackebot: apparently im invoking save() on an entity without changes... so when I look the generated SQL (using debugkit) it is only updating the table's modified field
# Jan 22nd 2017, 19:05 bigdaddygee siran, can you explain a little bit more ?
# Jan 22nd 2017, 19:05 siran how can I avoid doing **updates where the only thing changing is the 'modified' field ?
# Jan 22nd 2017, 19:04 siran how can I avoid doing updated where the only thing changing is the 'modified' field ?
# Jan 22nd 2017, 19:03 siran hi y'all !
# Jan 22nd 2017, 18:56 bigdaddygee admad I trying to use concat right now I just found it, is it worth to try this way ?
# Jan 22nd 2017, 18:55 admad @bigdaddygee https://book.cakephp.org/3.0/en/orm/query-builder.html#using-sql-functions
# Jan 22nd 2017, 18:54 bigdaddygee I also tried $query = $this->Ads->find('all'); $query->where(['created >=' => $query->func()->now() .' - INTERVAL 1 HOUR'])->toArray(); but since i'm trying to concatenate a function and a string I receive an error... :|
# Jan 22nd 2017, 18:51 bigdaddygee Hi everybody, I'm trying to use MySQL function and constant in CakePHP ORM and i'm not exactly sure how to do it... Target SQL : SELECT * FROM ads WHERE created >= (NOW() - INTERVAL 1 hour) Actualy in CakePHP : $this->Ads->find('all')->where(['created >=' => Time::now() .' - INTERVAL 1 HOUR'])->toArray();
# Jan 22nd 2017, 17:55 hytromo Thanks guys, this `$visitHours = $this->ProfessorVisitHours->find()->where(['professor_id' => $id])->groupBy(function($prof){ return $prof->day; })->toArray();` worked
# Jan 22nd 2017, 17:49 thinkingmedia that stuff is a pain. When it doesn't work it's just an empty result.
# Jan 22nd 2017, 17:48 hmic good call!
# Jan 22nd 2017, 17:48 hmic ;-)
# Jan 22nd 2017, 17:48 thinkingmedia I would just debug what `groupBy` is getting. ``` $this->ProfessorVisitHours->find()->where(['professor_id' => $id])->groupBy(function($prof){ dd($prof); }); ```
# Jan 22nd 2017, 17:48 hmic sure, you need to supply the right path to group by to the collection, so check the data returned first and add the correct path to the groupBy, like thinkingmedia suggests
# Jan 22nd 2017, 17:47 thinkingmedia the groupBy will execute the query
# Jan 22nd 2017, 17:47 hmic like: find()->where()->all()->groupBy()
# Jan 22nd 2017, 17:46 hmic hytromo: maybe you need to execute the query first, then apply the collection function
# Jan 22nd 2017, 17:46 thinkingmedia try including the alias `->groupBy('ProfessorVisitorHours.day')`
# Jan 22nd 2017, 17:45 hytromo thinkingmedia, I know, I am talking about Collection's groupBy, not query's group ( https://book.cakephp.org/3.0/en/orm/query-builder.html#aggregates-group-and-having> VS <https://book.cakephp.org/3.0/en/core-libraries/collections.html#grouping-and-counting )