# |
Jan 23rd 2017, 00:40 |
dereuromark |
looks almost like my queue plugin code :slightly_smiling_face: |
# |
Jan 23rd 2017, 00:39 |
dereuromark |
check the generated query (debug kit) |
# |
Jan 23rd 2017, 00:39 |
mdotobie |
Hello. I have a strange situation. I am using the Query Builder to create an SQL query in CakePHP3(3.3.9) and the Cake is returning a row that shouldn’t be in the result set, but if I run the generated SQL against the database it behaves as expected |
# |
Jan 22nd 2017, 23:38 |
savant |
@bigdaddygee what are the relations between the tables? |
# |
Jan 22nd 2017, 21:03 |
bigdaddygee |
I get this SQL (I've replaced all field name by *...) SELECT * FROM alerts Alerts INNER JOIN users Users ON Users.id = (Alerts.user_id) WHERE (Users.digestType = :c0 AND AlertCategories.sub_category_id in (:c1,:c2,:c3)) |
# |
Jan 22nd 2017, 21:02 |
bigdaddygee |
Hum, i'm facing a problem and I understand why it happen, but can't figure how to fix it right now... I'm using contain to require some tables that are related to my queried one and I want to filter theses results where they meet some predefined id. I expected an inner join from the query builder to occur, but instead it create other sql request so I can't filter into it's telling me unknown column name :| |
# |
Jan 22nd 2017, 20:45 |
GutaFish |
is possible to get from tash which shell command called it ? Or. How I could disable welcome message from task? |
# |
Jan 22nd 2017, 20:39 |
bigdaddygee |
they are handled by Cake itself |
# |
Jan 22nd 2017, 20:39 |
bigdaddygee |
You should not take care of modified or created |
# |
Jan 22nd 2017, 19:57 |
siran |
... maybe .... though I doubt it, since I was doing an unset($row['modified']) before the save() |
# |
Jan 22nd 2017, 19:56 |
siran |
that can solve the issue |
# |
Jan 22nd 2017, 19:56 |
siran |
maybe I could put 'modified' in the accesible fields... |
# |
Jan 22nd 2017, 19:54 |
siran |
slackebot: part of the problem was with my $row, but still I'd like to prevent cake from doing an update where the only field changing is the modifies field |
# |
Jan 22nd 2017, 19:32 |
bigdaddygee |
and compare it with what you have on $row |
# |
Jan 22nd 2017, 19:32 |
bigdaddygee |
create an array from your get on line 8 |
# |
Jan 22nd 2017, 19:27 |
siran |
slackebot: it might be something on the data... need some time to check |
# |
Jan 22nd 2017, 19:26 |
siran |
slackebot: also I don't know what two arrays you want to 'diff' |
# |
Jan 22nd 2017, 19:26 |
siran |
slackebot: I unset'ed modifiedandcreated fields that came in $row... but stilll |
# |
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 ? |