Log message #4099927

# At Username Text
# Nov 30th 2017, 13:33 obinoob regarding to my issue does anyone knows why hasMany association if failing to updated associated entities? I think this is somehow a required fk issue...
# Nov 30th 2017, 13:27 obinoob h.mavisakalian np if it helped is what matters ;)
# Nov 30th 2017, 13:13 h.mavisakalian His method worked
# Nov 30th 2017, 13:13 h.mavisakalian @obinoob (IRC) thanks too
# Nov 30th 2017, 13:11 obinoob johnwayne not sure if it is of much help but take a read here https://book.cakephp.org/3.0/en/orm/query-builder.html#aggregates-group-and-having
# Nov 30th 2017, 13:04 h.mavisakalian Worked like a charm
# Nov 30th 2017, 13:04 h.mavisakalian @johnwayne Thanks man
# Nov 30th 2017, 13:00 johnwayne so you can use normal find, and at the end ->first() then you will get same datastructure like with get(...)
# Nov 30th 2017, 12:59 johnwayne $postUpdate = $postsTable->findByPostId($post[‘id’])->toArray();
# Nov 30th 2017, 12:58 h.mavisakalian get()
# Nov 30th 2017, 12:58 h.mavisakalian it only works when I use ->grt()
# Nov 30th 2017, 12:58 h.mavisakalian with entity it gives me the error I mentioned
# Nov 30th 2017, 12:58 h.mavisakalian then I can’t do this $postUpdate->likes = $post[‘likes’][‘count’]; $postsTable->save($postUpdate);
# Nov 30th 2017, 12:57 obinoob so use find and where whats the deal?
# Nov 30th 2017, 12:57 h.mavisakalian ->get() only works with a id (primary) which I don’t have at that point so I need to fetch it from the database
# Nov 30th 2017, 12:56 h.mavisakalian but its wrong… and even I can see that
# Nov 30th 2017, 12:56 h.mavisakalian It works this way…
# Nov 30th 2017, 12:56 h.mavisakalian $postUpdate = $postsTable->find()->where([ ‘postid’ => $post[‘id’] ]); $postUpdate = $postUpdate->toArray(); $postUpdate = $postsTable->get($postUpdate[0][‘id’]); $postUpdate->likes = $post[‘likes’][‘count’]; $postsTable->save($postUpdate);
# Nov 30th 2017, 12:55 h.mavisakalian look
# Nov 30th 2017, 12:55 obinoob h.mavisakalian so what do you want to achieve now? you need to be pragmatic when naming variables... it's makes your code readable I'm not very good with that either but that is very important
# Nov 30th 2017, 12:54 h.mavisakalian Sorry if this is frustrating for you all :slightly_smiling_face:
# Nov 30th 2017, 12:53 johnwayne How can I group query by month and year -> https://pastebin.com/QWcUF3AT
# Nov 30th 2017, 12:52 h.mavisakalian It works with get() when I fetch the data as you told me, get the ID from the array and then use get() with the ID
# Nov 30th 2017, 12:51 h.mavisakalian Yes I did…
# Nov 30th 2017, 12:51 h.mavisakalian $postUpdate = $postsTable->find()->where([ ‘postid’ => $post[‘id’] ]); $postUpdate->likes = $post[‘likes’][‘count’]; $postsTable->save($postUpdate);
# Nov 30th 2017, 12:51 obinoob if you're lacking any of those you can't use an Entity to CRUD
# Nov 30th 2017, 12:50 obinoob h.mavisakalian did you checked for Entity Class and Table Class as I told you to?
# Nov 30th 2017, 12:49 h.mavisakalian “Argument 1 passed to Cake\ORM\Table::save() must implement interface Cake\Datasource\EntityInterface, instance of Cake\ORM\Query given”
# Nov 30th 2017, 12:49 h.mavisakalian I did, but the save() function gives me an error when I save the entity
# Nov 30th 2017, 12:49 obinoob h.mavisakalian in your case $this->Posts->find()->where(['id' => $id]);
# Nov 30th 2017, 12:48 obinoob h.mavisakalian you can do $this->Posts->find(')->where(['district_id' => $district]);
# Nov 30th 2017, 12:46 obinoob h.mavisakalian because it is implemented in a smarter way
# Nov 30th 2017, 12:46 h.mavisakalian I just have the postId… which is custom from that JSON content
# Nov 30th 2017, 12:46 h.mavisakalian well thats the whole point )))) I dont have the id of that record at that point
# Nov 30th 2017, 12:45 h.mavisakalian also why doesn’t the ->get() method let you do something like ->get([‘postId’ => $post[‘id’]]) ?
# Nov 30th 2017, 12:45 obinoob actually I missed a slash -> url: '/clients/add/'+$('input#id').val()
# Nov 30th 2017, 12:44 obinoob if you're using ajax it's the same thing provide the id at -> url: '/clients/add'+$('input#id').val()
# Nov 30th 2017, 12:44 h.mavisakalian Yes, I know that. I was just wondering if I can fetch that record using that PostID and get the id from my database
# Nov 30th 2017, 12:43 obinoob h.mavisakalian you have read my small example right? so in order to supply the param id you need to put in in the url like this: http://domain/controller/action/param
# Nov 30th 2017, 12:43 h.mavisakalian so I can use get() to fetch that record and update it… with just a few lines
# Nov 30th 2017, 12:41 h.mavisakalian and update it with a entity