# |
Mar 19th 2019, 19:05 |
ricksaccous |
i would have just used sortConditions but they seem to be ignored |
# |
Mar 19th 2019, 19:00 |
ricksaccous |
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in /vagrant/nflf/httpdocs/vendor/cakephp/cakephp/src/Database/Query.php on line 352 |
# |
Mar 19th 2019, 18:59 |
ricksaccous |
when I'm trying to set up a hasOne relationship of the most recent record of a hasMany I'm getting exceeded memory limits |
# |
Mar 19th 2019, 18:34 |
ricksaccous |
no problem |
# |
Mar 19th 2019, 18:33 |
jnguyen |
thanks @ricksaccous |
# |
Mar 19th 2019, 18:33 |
jnguyen |
its just i had to make it plural on the calls too |
# |
Mar 19th 2019, 18:33 |
jnguyen |
ahhh okay that was it |
# |
Mar 19th 2019, 18:31 |
ricksaccous |
that will help you i think |
# |
Mar 19th 2019, 18:31 |
ricksaccous |
you can think of entities as just bags of data |
# |
Mar 19th 2019, 18:31 |
ricksaccous |
and you use the table class to create and patch new entities |
# |
Mar 19th 2019, 18:31 |
ricksaccous |
can be kind of confusing |
# |
Mar 19th 2019, 18:31 |
ricksaccous |
loadModel() corresponds to the table class not to the entity |
# |
Mar 19th 2019, 18:31 |
ricksaccous |
yeah |
# |
Mar 19th 2019, 18:31 |
ricksaccous |
you just need to add an s in your controller |
# |
Mar 19th 2019, 18:31 |
jnguyen |
ah okk |
# |
Mar 19th 2019, 18:30 |
ricksaccous |
etc etc |
# |
Mar 19th 2019, 18:30 |
ricksaccous |
$healthRecord = $this->HealthRecords->newEntity(); |
# |
Mar 19th 2019, 18:30 |
ricksaccous |
$this->loadModel('HealthRecords); |
# |
Mar 19th 2019, 18:30 |
jnguyen |
its being called within another controller |
# |
Mar 19th 2019, 18:30 |
ricksaccous |
you are calling it wrong |
# |
Mar 19th 2019, 18:30 |
slackebot2 |
dd($HealthRecord); //$this->HealthRecord->save($healthRecord); }``` |
# |
Mar 19th 2019, 18:30 |
jnguyen |
```public function test() { $this->loadModel('HealthRecord'); $HealthRecord =$this->HealthRecord->newEntity(); $data = [ 'user_id' => $this->Auth->user('id'), 'type' => 'test', 'entry' => ['test' => '1'], 'meta' => json_encode(['test' => '1']), ]; $HealthRecord = $this->HealthRecord->patchEntity($HealthRecord,$data); |
# |
Mar 19th 2019, 18:30 |
jnguyen |
it isnt |
# |
Mar 19th 2019, 18:29 |
ricksaccous |
this code isn't in a plugin is it? |
# |
Mar 19th 2019, 18:29 |
jnguyen |
ah |
# |
Mar 19th 2019, 18:29 |
ricksaccous |
in the controller |
# |
Mar 19th 2019, 18:29 |
ricksaccous |
i mean |
# |
Mar 19th 2019, 18:29 |
jnguyen |
health_records |
# |
Mar 19th 2019, 18:29 |
ricksaccous |
so how are you calling the table? |
# |
Mar 19th 2019, 18:28 |
ricksaccous |
oh okay |
# |
Mar 19th 2019, 18:28 |
jnguyen |
and yeah I did use migrations to create the table |
# |
Mar 19th 2019, 18:28 |
jnguyen |
my mistake it was HealthRecordsTable.php |
# |
Mar 19th 2019, 18:22 |
ricksaccous |
@jnguyen also maybe use migrations in this project, after you get more of a hang of things |
# |
Mar 19th 2019, 18:21 |
ricksaccous |
based on conventions |
# |
Mar 19th 2019, 18:21 |
ricksaccous |
so HealthRecordsTable.php is what the table class should be called |
# |
Mar 19th 2019, 18:20 |
ricksaccous |
it's always Table.php |
# |
Mar 19th 2019, 18:20 |
ricksaccous |
baked that* |
# |
Mar 19th 2019, 18:20 |
ricksaccous |
it should not have backed that |
# |
Mar 19th 2019, 18:20 |
ricksaccous |
not Tables.php |
# |
Mar 19th 2019, 18:20 |
ricksaccous |
HealthRecordsTable.php |
# |
Mar 19th 2019, 18:20 |
ricksaccous |
it should have been called |