Log message #4197650

# At Username Text
# Aug 13th 2019, 09:12 neon1024 `$newSubQuery = $this->Examples->find()`
# Aug 13th 2019, 09:05 val @admad any example?
# Aug 13th 2019, 08:51 admad Create a separate query instance for the sub query
# Aug 13th 2019, 08:42 val So that the alias would be applied only to that subquery.
# Aug 13th 2019, 08:41 val Hi, what is the safe way to construct a subquery with custom aliases in 3.x?
# Aug 13th 2019, 07:36 neon1024 Hey @jotpe
# Aug 13th 2019, 07:34 jotpe Morning all
# Aug 13th 2019, 06:34 xuanvu442 @admad Thanks bro
# Aug 13th 2019, 05:58 admad @xuanvu442 in cake 3 you can use `bin/cake routes` in CLI to get list of all connected routes, i don't remember if 2.x has the same command
# Aug 13th 2019, 05:10 xuanvu442 Hi everyone! I’ve a small question, hope guys help me. How do I get all the HTTP Request Method available on my project (cakephp 2.x)? Plz see the image!
# Aug 13th 2019, 03:18 challgren Do you have any guide you followed for using AWS?
# Aug 13th 2019, 03:17 claudio Yeah I also checked the code, and looking at AWS it does seem like we don't have cookie stickness enabled, so that might explain the issue. Going to check for the impact in enabling it and then might be the path we take forward. Thanks for the tips :slightly_smiling_face:
# Aug 13th 2019, 03:10 challgren is the webroot different?
# Aug 13th 2019, 03:05 challgren Digging into the code it looks cookie based
# Aug 13th 2019, 02:56 claudio Yeah it's worth the shot, just going to drop a line on the forum to, maybe someone else has some ideas I can try before changing the live server to use database sessions. Thanks for the feedback @challgren
# Aug 13th 2019, 02:54 challgren Id root around in the CsrfComponent and see what its doing there to set it and verify it
# Aug 13th 2019, 02:54 challgren Im not 100% honestly
# Aug 13th 2019, 02:53 claudio component
# Aug 13th 2019, 02:53 challgren Are you using the component or middleware?
# Aug 13th 2019, 02:53 claudio @challgren I actually thought the issue could be there, but testing locally, I did delete the tmp/sessions folder and I didn't get any token mismatch exceptions, I did notice some pages were acting up because the session had gone away, but not the csrf in particular. It's worth the try but I wanted to be sure before trying it out. Anything else worth checking?
# Aug 13th 2019, 02:51 challgren might want a central cache location for your session since it auto scales
# Aug 13th 2019, 02:51 claudio 'Session' => [ 'defaults' => 'cake', 'timeout' => 480 ...
# Aug 13th 2019, 02:49 challgren How are you storing your cookies?
# Aug 13th 2019, 02:49 claudio Hi everyone. My current Cake website is hosted in AWS and it allows for auto scaling, works perfectly but recently having migrated to a newer version of cake, we started using the Csrf component ( Not the middleware ) but when the when the server auto scales I sometimes get a token mismatch exception, any way to fix this issue? Thanks
# Aug 13th 2019, 02:34 latenal @challgren, thanks. It worked. But while I was doing it, I realized that it works as well if I interchange the func and value as `$entityId => 'json_extract(`data`, “$.user_id”)’`
# Aug 13th 2019, 02:13 challgren Youd have to use a query function https://book.cakephp.org/3.0/en/orm/query-builder.html#custom-functions
# Aug 13th 2019, 01:55 slackebot1 ignored). How do I fix it?
# Aug 13th 2019, 01:55 latenal I have a simple query ``` $query = $this->Logs ->find() ->select(['Logs.id', 'Logs.action', 'Logs.ip', 'Logs.created']); $conditions = [ 'OR' => [ 'user_id' => $entityId, "JSON_EXTRACT(`data`, '$.user_id') =" => $entityId ] ]; $query = $query->where($conditions); ``` When I run it I get only 1 value (`JSON_EXTRACT` seems to be
# Aug 12th 2019, 22:12 slackebot1 and it's in the middle of the night, so that's all I have for now, you get the idea :slightly_smiling_face:
# Aug 12th 2019, 22:12 ndm @scuadra And here's a quick and dirty example for `belongsToMany` for DBMS' that do support window functions: https://gist.github.com/ndm2/b417e3fa683a972e295dc0e24ef515e3. That might not be the best way to do it, like, there's a redundant `IN` condition, I'm not sure how well this will work with additional conditions on the association, using `FROM` instead of a `JOIN` for the ranked data might be better, etc, but after all it's just an example,
# Aug 12th 2019, 21:58 ricksaccous @latenal thanks, the rule idea helped, my code is less convoluted now
# Aug 12th 2019, 21:03 slackebot1 $retailTable->find() ->where(['product_id' => $entity->id]) ->count(); return $retail + $wholesale > 0 || !$entity->visible; }, 'visible', [ 'message' => 'Fill in the inventory first', 'errorField' => 'visible' ]); ```
# Aug 12th 2019, 21:03 latenal Here it is: ``` <?php // Check minimum qty $rules->add(function ($entity, $options) { $wholesaleTable = TableRegistry::getTableLocator()->get('ProductWholesalePrices'); $wholesale = $wholesaleTable->find() ->where(['product_id' => $entity->id]) ->count(); $retailTable = TableRegistry::getTableLocator()->get('ProductRetailPrices'); $retail =
# Aug 12th 2019, 21:01 latenal I am looking for a code sample..
# Aug 12th 2019, 21:00 ricksaccous rather than whatever i'm doing
# Aug 12th 2019, 21:00 ricksaccous hmm that might be a decent idea actually
# Aug 12th 2019, 20:59 latenal I’ve done it in `buildRules`
# Aug 12th 2019, 20:31 ricksaccous hmmmm
# Aug 12th 2019, 20:31 ricksaccous i mean evaluate conditionally
# Aug 12th 2019, 20:30 ricksaccous the entity doesn't seem to be passed into "context"
# Aug 12th 2019, 20:30 ricksaccous rather than the request data