# |
Nov 30th 2017, 12:16 |
spriz |
then you update the entity, and use ->save() |
# |
Nov 30th 2017, 12:16 |
spriz |
you can get the id by using ->id on the entity? |
# |
Nov 30th 2017, 12:15 |
h.mavisakalian |
I want to get the ID of an existing record and update that record |
# |
Nov 30th 2017, 12:15 |
h.mavisakalian |
:slightly_smiling_face: |
# |
Nov 30th 2017, 12:14 |
spriz |
what are you trying to do? |
# |
Nov 30th 2017, 12:14 |
spriz |
it makes no sense to turn it into array and then retrieve the exact same entity again :P |
# |
Nov 30th 2017, 12:14 |
obinoob |
h.mavisakalian I'm sure there are better ways: https://book.cakephp.org/3.0/en/orm/retrieving-data-and-resultsets.html#getting-a-single-entity-by-primary-key |
# |
Nov 30th 2017, 12:14 |
spriz |
@h.mavisakalian you’re fetching the same thing twice here, eh? |
# |
Nov 30th 2017, 12:12 |
h.mavisakalian |
$postUpdate = $postsTable->find()->where([ ‘instaid’ => $post[‘id’] ]); $postUpdate = $postUpdate->toArray();$postUpdate = $postsTable->get($postUpdate[0][‘id’]); |
# |
Nov 30th 2017, 12:12 |
h.mavisakalian |
But just tell me if there is no shorter way to do this |
# |
Nov 30th 2017, 12:12 |
h.mavisakalian |
See what I came out with |
# |
Nov 30th 2017, 12:12 |
h.mavisakalian |
Ok |
# |
Nov 30th 2017, 12:10 |
obinoob |
ksandeep_: really? https://gist.github.com/obinoob/8d833962e3a167143b38a5f5697209c9/revisions |
# |
Nov 30th 2017, 12:09 |
ksandeep_ |
i found no change in data after change 'addresses' to 'addresses'[0] |
# |
Nov 30th 2017, 12:07 |
obinoob |
ksandeep_: however the address still not getting saved, this seems very awkward I would say |
# |
Nov 30th 2017, 12:05 |
obinoob |
ksandeep_: https://gist.github.com/obinoob/8d833962e3a167143b38a5f5697209c9 |
# |
Nov 30th 2017, 12:05 |
ksandeep_ |
show the data |
# |
Nov 30th 2017, 12:04 |
obinoob |
ksandeep_: by changing 'addresses' to 'addresses'[0] suddenly the object gets filled but the key now gets 'a'?!? |
# |
Nov 30th 2017, 11:59 |
obinoob |
ksandeep_: https://gist.github.com/obinoob/8d833962e3a167143b38a5f5697209c9 |
# |
Nov 30th 2017, 11:56 |
ksandeep_ |
change 'addresses' to 'addresses'[0] at line 26 and revert |
# |
Nov 30th 2017, 11:54 |
obinoob |
h.mavisakalian: read this https://book.cakephp.org/3.0/en/orm.html#database-access-orm |
# |
Nov 30th 2017, 11:53 |
obinoob |
ksandeep_: https://gist.github.com/obinoob/8d833962e3a167143b38a5f5697209c9 |
# |
Nov 30th 2017, 11:50 |
ksandeep_ |
ok then put debug($client) at 37 and share data |
# |
Nov 30th 2017, 11:50 |
h.mavisakalian |
Anyone ? |
# |
Nov 30th 2017, 11:49 |
obinoob |
ksandeep_: i've reduced the amount of associations in order to simplify |
# |
Nov 30th 2017, 11:49 |
obinoob |
ksandeep_: this is the updated controller https://gist.github.com/obinoob/80b2ebcd4d5906e3f3b0fee214bb47dc |
# |
Nov 30th 2017, 11:48 |
ksandeep_ |
https://gist.github.com/obinoob/d16ed6d38dc1c3edc9937843485d623a |
# |
Nov 30th 2017, 11:48 |
obinoob |
ksandeep_: sorry I'm not seeing $clients anywhere... |
# |
Nov 30th 2017, 11:47 |
rajaslack |
@admad how to use epilog() |
# |
Nov 30th 2017, 11:46 |
ksandeep_ |
Your object include Associated data or not |
# |
Nov 30th 2017, 11:45 |
ksandeep_ |
share debug data from $clients at line32 |
# |
Nov 30th 2017, 11:44 |
obinoob |
ksandeep_: clients controller: https://gist.github.com/obinoob/80b2ebcd4d5906e3f3b0fee214bb47dc |
# |
Nov 30th 2017, 11:44 |
obinoob |
ksandeep_: address table: https://gist.github.com/obinoob/46ca79a8dcdda54ca07695b2b8e6d1e3 |
# |
Nov 30th 2017, 11:43 |
obinoob |
ksandeep_: client table: https://gist.github.com/obinoob/7d52bd0fbc89533c50f20cb544323e0d |
# |
Nov 30th 2017, 11:43 |
h.mavisakalian |
I am running version 3.5 |
# |
Nov 30th 2017, 11:43 |
h.mavisakalian |
now I want to get the ID of that record so I can Retrieve and update it |
# |
Nov 30th 2017, 11:43 |
obinoob |
ksandeep_: address entity: https://gist.github.com/obinoob/44029d2f2bffd2906a2280b3a9a3752b |
# |
Nov 30th 2017, 11:43 |
obinoob |
ksandeep_: client entity: https://gist.github.com/obinoob/83e8efd6e6e4f29dc709076068dd2870 |
# |
Nov 30th 2017, 11:43 |
h.mavisakalian |
lets say you check if a record exists… with ->exists() |
# |
Nov 30th 2017, 11:42 |
h.mavisakalian |
How do you get the ID of an existing record ? |
# |
Nov 30th 2017, 11:42 |
h.mavisakalian |
Have a question |