# |
Jul 3rd 2019, 18:57 |
brian493 |
awesome thanks for your help. I'm a laravel dev and I spend all day in that framework |
# |
Jul 3rd 2019, 18:57 |
cnizzardini |
:+1: |
# |
Jul 3rd 2019, 18:57 |
brian493 |
cool, it dumped 540 rows into my table, this is working |
# |
Jul 3rd 2019, 18:56 |
cnizzardini |
i didn't psuedo code too well there |
# |
Jul 3rd 2019, 18:56 |
brian493 |
syntax is a little weird heh |
# |
Jul 3rd 2019, 18:56 |
cnizzardini |
thats what i meant |
# |
Jul 3rd 2019, 18:56 |
cnizzardini |
yeah |
# |
Jul 3rd 2019, 18:56 |
slackebot |
'quantity' => $quantityItem['quantity'] ] ]); } ``` |
# |
Jul 3rd 2019, 18:56 |
brian493 |
``` $this->StoreQuantity->create(); $this->StoreQuantity->save([ 'StoreQuantity' => [ 'store_id' => $quantityItem['id'], 'store_name' => $quantityItem['name'], |
# |
Jul 3rd 2019, 18:56 |
brian493 |
ah ! I got it |
# |
Jul 3rd 2019, 18:56 |
cnizzardini |
try reversing them? |
# |
Jul 3rd 2019, 18:55 |
brian493 |
that's what I tried before I came in here looking for help :slightly_smiling_face: |
# |
Jul 3rd 2019, 18:55 |
cnizzardini |
$storeQuantity->save($yourArrayOfData); |
# |
Jul 3rd 2019, 18:55 |
cnizzardini |
$this->StoreQuantity->create() |
# |
Jul 3rd 2019, 18:55 |
cnizzardini |
try |
# |
Jul 3rd 2019, 18:54 |
brian493 |
this is my function, I'm calling it as a console command for a scheduled task I'm setting up |
# |
Jul 3rd 2019, 18:54 |
slackebot |
'quantity' => $quantityItem['quantity'] ] ]); $storeQuantity->save(); } } } } ``` |
# |
Jul 3rd 2019, 18:54 |
slackebot |
if ($quantityItems) { foreach ($quantityItems as $quantityItem) { $this->StoreQuantity->create([ 'StoreQuantity' => [ 'store_id' => $quantityItem['id'], 'store_name' => $quantityItem['name'], |
# |
Jul 3rd 2019, 18:54 |
brian493 |
``` public function updateStoreQuantityCache() { $this->Artwork = ClassRegistry::init('Artwork'); $this->StoreQuantity = ClassRegistry::init('StoreQuantity'); $artworks = $this->Artwork->find('all', ['recursive' => 0]); foreach ($artworks as $artwork) { $quantityItems = $this->getStoreQuantities($artwork['Artwork']['id']); |
# |
Jul 3rd 2019, 18:54 |
cnizzardini |
a snippet that is |
# |
Jul 3rd 2019, 18:54 |
cnizzardini |
paste your code |
# |
Jul 3rd 2019, 18:53 |
brian493 |
I am passing my data to the save() call |
# |
Jul 3rd 2019, 18:53 |
brian493 |
oh I think I see what I'm doing wrong |
# |
Jul 3rd 2019, 18:53 |
cnizzardini |
read those, see if it helps |
# |
Jul 3rd 2019, 18:52 |
cnizzardini |
https://api.cakephp.org/2.7/class-Model.html#_save |
# |
Jul 3rd 2019, 18:52 |
cnizzardini |
https://api.cakephp.org/2.7/class-Model.html#_create |
# |
Jul 3rd 2019, 18:52 |
cnizzardini |
its supposed to return an array |
# |
Jul 3rd 2019, 18:51 |
cnizzardini |
This https://api.cakephp.org/2.7/class-Model.html ???? |
# |
Jul 3rd 2019, 18:50 |
brian493 |
which is what I would expect |
# |
Jul 3rd 2019, 18:50 |
brian493 |
it's an instance of my model as far as I can tell |
# |
Jul 3rd 2019, 18:50 |
cnizzardini |
well dump the object, what is it |
# |
Jul 3rd 2019, 18:48 |
brian493 |
it's like I'm getting results back from create() instead of it creating an object |
# |
Jul 3rd 2019, 18:48 |
brian493 |
looks like a model object or collection... not really totally sure what I'm looking at |
# |
Jul 3rd 2019, 18:47 |
cnizzardini |
init, that is |
# |
Jul 3rd 2019, 18:47 |
cnizzardini |
what object is it returning? |
# |
Jul 3rd 2019, 18:47 |
brian493 |
no create() is on the object that init returns |
# |
Jul 3rd 2019, 18:47 |
cnizzardini |
Calling init is returning an array? |
# |
Jul 3rd 2019, 18:47 |
cnizzardini |
Yeah, that is what I am seeing "Loads a class, registers the object in the registry and returns instance of the object. ClassRegistry::init() is used as a factory for models, and handle correct injecting of settings, that assist in testing." |
# |
Jul 3rd 2019, 18:46 |
brian493 |
for some reason create() isn't returning the object I would expect |
# |
Jul 3rd 2019, 18:45 |
brian493 |
docs just say call create() and then save([data in here]) but since I'm getting an array returned from create() that obviously won't work |
# |
Jul 3rd 2019, 18:45 |
cnizzardini |
its been a while since I worked in cake 2 |