Log message #4188740

# At Username Text
# Jun 7th 2019, 04:27 conehead Why would you? As a string?
# Jun 7th 2019, 04:27 liaogz82 check with you guys, how do you save date time in milliseconds in cakephp?
# Jun 7th 2019, 04:21 liaogz82 oh god no! I go and add it in now
# Jun 7th 2019, 04:17 conehead Did you add the `associated` key? ``` $entity = $articles->newEntity($this->request->getData(), [ 'associated' => [ 'Tags', 'Comments' => ['associated' => ['Users']] ] ]); ```
# Jun 7th 2019, 04:13 liaogz82 this part, should I change `worker_section_type` to `WorkerSectionType`??
# Jun 7th 2019, 04:12 slackebot "worker_overtime": [{ "code":"5S", "description":"AUDIT 5S", "amount":"1000", "remark":"PAJAK(5S)" }] } ```
# Jun 7th 2019, 04:12 liaogz82 ``` "worker_section_type":{ "section_id":1, "worker_gaji": [{ "code":"PM_3U", "description":"MI 3 UDANG", "amount":"20", "remark":"PAJAK(1 BAG)" }], "worker_tambahan": [{ "code":"FULL_2U", "description":"F/HARIAN >100 BAGS 2 UDG", "amount":"10", "remark":"PAJAK(BAG)" }],
# Jun 7th 2019, 04:11 liaogz82 but it does have many to many relationships
# Jun 7th 2019, 04:11 liaogz82 no I just save one, not many
# Jun 7th 2019, 04:10 conehead Guess you are looking for `saveMany()` https://book.cakephp.org/3.0/en/orm/saving-data.html#saving-multiple-entities
# Jun 7th 2019, 03:54 kgb.acct.personal https://book.cakephp.org/3.0/en/orm/saving-data.html#saving-with-associations
# Jun 7th 2019, 03:53 kgb.acct.personal Too bad. Looks like saveAll is not in Cake3 anymore. You can use just save() or saveMany()
# Jun 7th 2019, 03:47 liaogz82 sorry I misinterpret what you say
# Jun 7th 2019, 03:47 liaogz82 this is it
# Jun 7th 2019, 03:47 liaogz82 ``` public function add() { $worker = $this->Workers->newEntity(); $success = false; if ($this->request->is('post')) { $worker = $this->Workers->patchEntity($worker, $this->request->getData()); if ($this->Workers->saveAll($worker)) { $success = true; } $this->set([ 'success' => $success, '_serialize' => ['success'] ]); } } ```
# Jun 7th 2019, 03:39 kgb.acct.personal You're supposed to use your model table to call saveAll()
# Jun 7th 2019, 03:38 kgb.acct.personal I mean the statement where you call saveAll()
# Jun 7th 2019, 03:36 liaogz82 this is the data i want to save
# Jun 7th 2019, 03:36 slackebot "phone_number":"019-8998571" } ```
# Jun 7th 2019, 03:36 slackebot "worker_overtime": [{ "code":"5S", "description":"AUDIT 5S", "amount":"1000", "remark":"PAJAK(5S)" }] }, "date_of_birth":1555862400000, "date_join":1555862400000, "ic_number":"831108-12-6180", "epf_number":"21783801", "income_tax_number":"N/A", "socso_number":"831108126180", "document":"NI", "citizen_id":1, "race_id":1, "religion_id":1, "bank_number":"4-6944323-23", "is_vip":0, "date_resign":1555862400000,
# Jun 7th 2019, 03:36 liaogz82 ``` { "name":"JIAH BINTI NUNO", "location_id": 1, "job_description":"PEKERJA AM(PACKING MEE)", "gender":"F", "payment_type":"D", "worker_section_type":{ "section_id":1, "worker_gaji": [{ "code":"PM_3U", "description":"MI 3 UDANG", "amount":"20", "remark":"PAJAK(1 BAG)" }], "worker_tambahan": [{ "code":"FULL_2U", "description":"F/HARIAN >100 BAGS 2 UDG", "amount":"10", "remark":"PAJAK(BAG)" }],
# 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)