# |
Dec 3rd 2019, 14:43 |
ckjksl |
Sorry, I have a question about caching query results: https://book.cakephp.org/3/en/orm/query-builder.html#caching-query-results |
# |
Dec 3rd 2019, 14:40 |
scuadra |
if I have further issues I'll ask again for help :slightly_smiling_face: |
# |
Dec 3rd 2019, 14:39 |
scuadra |
thank you @dereuromark |
# |
Dec 3rd 2019, 14:39 |
scuadra |
all right |
# |
Dec 3rd 2019, 14:38 |
dereuromark |
yes, it is exactly the same from the outside. |
# |
Dec 3rd 2019, 14:36 |
scuadra |
Hello. I want to migrate a shell from Cake 2.x to 3.x. But I see that since version 3.6.0 shells are deprecated and I should use Console Commands. My Cake version is 3.7. So is it possible to run Console Command as cronjob in the same (or similar) way like shells? |
# |
Dec 3rd 2019, 13:10 |
javier.villanueva |
Now I have this... in the patched information |
# |
Dec 3rd 2019, 12:56 |
gianmarxgagliardi |
@neon1024 always the usual mistake even with the changes you suggested |
# |
Dec 3rd 2019, 12:54 |
david |
thank you @javier.villanueva |
# |
Dec 3rd 2019, 12:52 |
javier.villanueva |
But is better that you wait an expert opinion lol |
# |
Dec 3rd 2019, 12:51 |
javier.villanueva |
related_farms |
# |
Dec 3rd 2019, 12:51 |
javier.villanueva |
I think that is better create a Conect Model |
# |
Dec 3rd 2019, 12:51 |
david |
:slightly_smiling_face: |
# |
Dec 3rd 2019, 12:51 |
javier.villanueva |
mmmm |
# |
Dec 3rd 2019, 12:50 |
javier.villanueva |
changing foreing keys |
# |
Dec 3rd 2019, 12:50 |
javier.villanueva |
I think |
# |
Dec 3rd 2019, 12:50 |
javier.villanueva |
yes you need to add two belongsToMany assocs |
# |
Dec 3rd 2019, 12:49 |
david |
yes, that would be the default BTM way. But if I edit the city2_id I need to be related in a bidirectional way |
# |
Dec 3rd 2019, 12:48 |
javier.villanueva |
use too 'className' => 'Cities' |
# |
Dec 3rd 2019, 12:47 |
javier.villanueva |
(not checked) |
# |
Dec 3rd 2019, 12:47 |
javier.villanueva |
$this->belongsToMany('NearCities', [ 'foreignKey' => 'city1_id', 'targetForeignKey' => 'city2_id', 'joinTable' => 'cities_cities' ]); |
# |
Dec 3rd 2019, 12:45 |
javier.villanueva |
yes you can |
# |
Dec 3rd 2019, 12:44 |
david |
I have a "cities" which are near (or not) some of them to others. "cities_near" is a join table with "city1_id" and "city2_id". When a city is near to one, that one is near to the other. Can I do that in a smart way with belongsToMany? |
# |
Dec 3rd 2019, 12:30 |
javier.villanueva |
not is correct.... i check |
# |
Dec 3rd 2019, 12:29 |
javier.villanueva |
https://pastebin.com/4sp9YnWM |
# |
Dec 3rd 2019, 12:28 |
javier.villanueva |
the patched information looks ok |
# |
Dec 3rd 2019, 12:24 |
neon1024 |
I think you meant to use `'foreignKey' => 'dog_id', 'targetForeignKey' => 'id'` |
# |
Dec 3rd 2019, 12:24 |
neon1024 |
@gianmarxgagliardi Because you’ve set an incorrect foreignKey I think. :point_right: https://book.cakephp.org/3/en/orm/associations.html#belongsto-associations |
# |
Dec 3rd 2019, 12:20 |
javier.villanueva |
i will try |
# |
Dec 3rd 2019, 12:20 |
javier.villanueva |
ok |
# |
Dec 3rd 2019, 12:19 |
neon1024 |
@javier.villanueva You might need to include the tables in the `associated` options key for `patchEntity` too if they don’t marshall properly |
# |
Dec 3rd 2019, 12:18 |
javier.villanueva |
uhm ok |
# |
Dec 3rd 2019, 12:17 |
neon1024 |
..which people on IRC can’t even read |
# |
Dec 3rd 2019, 12:17 |
neon1024 |
Could you pastebin perhaps? Rather than filling the whole channel with code? |
# |
Dec 3rd 2019, 12:17 |
neon1024 |
I would also dump the resulting entity after `patchEntity` to make sure it’s marhsalled prop… |
# |
Dec 3rd 2019, 12:17 |
slackebot |
index() { $result = $this->DogsCats->find('all')->contain(['Dogs','Cats']); $this->set('farms',$result); } }``` |
# |
Dec 3rd 2019, 12:17 |
slackebot |
]); $this->belongsTo('Cats', [ 'foreignKey' => 'id', 'joinType'=>'INNER', ]); } }``` Controller/DogsCats ```<?php namespace App\Controller; class DogsCatsController extends AppController { public function initialize() { parent::initialize(); $this->loadComponent('Paginator'); $this->loadComponent('Flash'); // Include the FlashComponent } public function |
# |
Dec 3rd 2019, 12:17 |
slackebot |
'foreignKey'=>'cat_id' ]); } }``` Model/Table/DogsCats ```<?php use App\Model\Entity\DogCat; use Cake\ORM\Table; use Cake\ORM\Query; use Cake\ORM\RulesChecker; use Cake\ORM\Validation\Validator; class DogsCatsTable extends Table { public function initialize(array $config) { $this->addBehavior('Timestamp'); $this->belongsTo('Dogs', [ 'foreignKey' => 'id', 'joinType'=>'INNER', |
# |
Dec 3rd 2019, 12:17 |
slackebot |
$this->addBehavior('Timestamp'); $this->hasMany('DogsCats',[ 'foreignKey'=>'dog_id' ]); } }``` Model/Table/Cats ```<?php use App\Model\Entity\Cat; use Cake\ORM\Table; use Cake\ORM\Query; use Cake\ORM\RulesChecker; use Cake\ORM\Validation\Validator; class CatsTable extends Table { public function initialize(array $config) { $this->addBehavior('Timestamp'); $this->hasMany('DogsCats',[ |
# |
Dec 3rd 2019, 12:17 |
gianmarxgagliardi |
from this error I don't understand why I read in the documentation but I couldn't solve The Dogs association is not defined on DogsCats. InvalidArgumentException ```Model/Table/Dogs <?php use App\Model\Entity\Dog; use Cake\ORM\Table; use Cake\ORM\Query; use Cake\ORM\RulesChecker; use Cake\ORM\Validation\Validator; class DogsTable extends Table { public function initialize(array $config) { |
# |
Dec 3rd 2019, 12:17 |
javier.villanueva |
mm |