Answer the question
In order to leave comments, you need to log in
Why does the selection from 2 tables not work?
I'm sitting for an hour and I can't make a selection from 2 tables in any way.
There are two tables. anime_short and anime_long.
anime_short
anime_long Foreign
key defined
for anime_long table:
ALTER TABLE `anime_long` ADD CONSTRAINT `anime_long_ibfk_1` FOREIGN KEY (`short_id`) REFERENCES `cakephp3_db`.`anime_short`(`id`) ON DELETE CASCADE ON UPDATE NO ACTION; anime_short
initialization function
public function initialize(array $config)
{
$this->table('anime_short');
$this->hasOne('anime_long');
$this->displayField('id');
$this->primaryKey('id');
}
public function initialize(array $config)
{
$this->table('anime_long');
$this->belongsTo('AnimeShort', [
'foreignKey' => 'short_id',
'joinType' => 'INNER'
]);
}
$this->loadModel('AnimeShort');
$a_s = $this->AnimeShort->get(108);
debug($a_s);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question