# |
Jun 7th 2019, 03:35 |
liaogz82 |
this is the api call |
# |
Jun 7th 2019, 03:35 |
liaogz82 |
``` { "message": "Unknown method \"saveAll\"", "url": "/workers/add.json", "code": 500, "file": "/var/www/html/vendor/cakephp/cakephp/src/ORM/Table.php", "line": 2512 } ``` |
# |
Jun 7th 2019, 03:31 |
kgb.acct.personal |
Can you post the whole syntax? |
# |
Jun 7th 2019, 03:28 |
liaogz82 |
where could this gone wrong? |
# |
Jun 7th 2019, 03:28 |
liaogz82 |
Hi guys I am using cakephp 3.6 and it keep giving this error `Unknown method "saveAll"` |
# |
Jun 6th 2019, 20:22 |
ckjksl |
but no worries, i'll figure it out. Thanks for the ideas! |
# |
Jun 6th 2019, 20:22 |
ckjksl |
the problem with randomized ID is that they need to be associated to the tag. |
# |
Jun 6th 2019, 20:21 |
jeremyharris |
many ways to solve it ¯\_(ツ)_/¯ |
# |
Jun 6th 2019, 20:20 |
ricksaccous |
oh well |
# |
Jun 6th 2019, 20:20 |
ricksaccous |
which makes that unfeasable |
# |
Jun 6th 2019, 20:20 |
ricksaccous |
that's why i said closest, butttt, he also needs a subset of ids anyway |
# |
Jun 6th 2019, 20:20 |
jeremyharris |
hence the fetch idea above |
# |
Jun 6th 2019, 20:20 |
jeremyharris |
maybe, but there’s no guarantee those IDs exist (e.g. 1- 5, what if 2 was deleted) |
# |
Jun 6th 2019, 20:19 |
ricksaccous |
or maybe he can count get a randomized [1, something between the count] and then find the closest id to that if that's a thing |
# |
Jun 6th 2019, 20:19 |
jeremyharris |
first make sure you know what is slow before you start trying to optimize |
# |
Jun 6th 2019, 20:19 |
jeremyharris |
yes I think you’ll need to figure out something better hahah |
# |
Jun 6th 2019, 20:19 |
ckjksl |
but ... 20s page render time is sad for local 1 user |
# |
Jun 6th 2019, 20:19 |
ckjksl |
so i'm not worried about the database getting hammered |
# |
Jun 6th 2019, 20:19 |
ckjksl |
lol. i have a wee bit of leeway because it's a local app and only 1 user at a time |
# |
Jun 6th 2019, 20:18 |
jeremyharris |
might work well for 2k rows, might not for 1 billion :P where as rand in the query might work better for 1 billion over 2k (though I doubt it) |
# |
Jun 6th 2019, 20:17 |
jeremyharris |
it’ll be up to you to figure out the most optimized way to do this depending on your data. for example, you can fetch all IDs only, don’t hydrate, get a random one within PHP, and do a quick SELECT on it |
# |
Jun 6th 2019, 20:17 |
ckjksl |
lol okay, i'll try that |
# |
Jun 6th 2019, 20:16 |
jeremyharris |
if contain doesn’t work with rand/limit, you can always make a new query for the random result and slap it on the entity :) |
# |
Jun 6th 2019, 20:16 |
ckjksl |
but 2500 tags with associated assets is a 20 second page load :( |
# |
Jun 6th 2019, 20:15 |
ckjksl |
for me, $q->order('random()') returns all associated data randomized. |
# |
Jun 6th 2019, 20:15 |
jeremyharris |
perhaps try a subquery instead? |
# |
Jun 6th 2019, 20:15 |
ricksaccous |
and he can't first() in a contain() |
# |
Jun 6th 2019, 20:15 |
ricksaccous |
i didn't type that out right |
# |
Jun 6th 2019, 20:14 |
ricksaccous |
yeah that's what i gathered, but it seems limit on order->rand() returns nothing |
# |
Jun 6th 2019, 20:14 |
jeremyharris |
I think what lorenzo meant by that comment in the SO post is that rand doesn’t perform well regardless of how you try to optimize it at the query |
# |
Jun 6th 2019, 20:13 |
jeremyharris |
grabbing them all and randomizing within PHP isn’t great, because all that data needs to come back from the database and get turned into PHP objects, which could be memory intensive |
# |
Jun 6th 2019, 20:12 |
ricksaccous |
oh it does? |
# |
Jun 6th 2019, 20:12 |
ricksaccous |
or closest to the randomized id |
# |
Jun 6th 2019, 20:12 |
jeremyharris |
limit works on rand |
# |
Jun 6th 2019, 20:12 |
ricksaccous |
just randomize the id and grab by the randomized id XD |
# |
Jun 6th 2019, 20:11 |
ckjksl |
yeah. So i guess i might as well grab all of them and splice them myself |
# |
Jun 6th 2019, 20:11 |
ricksaccous |
doesn't matter, it seems that limit won't work on rand() in general because rand() grabs all then splices them |
# |
Jun 6th 2019, 20:11 |
ricksaccous |
oh you mean in the example? |
# |
Jun 6th 2019, 20:05 |
ckjksl |
that's not even the associated data. it's the regular data. |
# |
Jun 6th 2019, 20:04 |
ckjksl |
wow. okay, maybe i'll just do that then -.- |
# |
Jun 6th 2019, 20:04 |
ricksaccous |
if you really need random might as well just grab them all then |