I've bin searching for days now without fixing this problem:
I am getting this error message:Error: SQLSTATE[42000]: Syntax error or access violation: 1066 Not unique table/alias: 'Posts'
And this is my initialize method in the PostTable class:
public function initialize(array $config)
{
parent::initialize($config);
$this->table('posts');
$this->displayField('post_id');
$this->primaryKey('post_id');
$this->addBehavior('timestamp');
$this->belongsTo('Posts', [
'foreignKey' => 'post_id',
'joinType' => 'INNER'
]);
$this->belongsTo('Users', [
'className' => 'Users',
'foreignKey' => 'fk_post_user_id', //<- foreignkey name are correct
'joinType' => 'INNER'
]);
$this->belongsTo('Pictures',[
'foreignKey' => 'fk_post_picture_id',
'joinType' => 'INNER'
]);
}
And this is my database:
i know the error has to do something with the foreignkeys of the posts
table, but i don't know what is wrong with the belongTo
in my initialize method.