Last active
November 20, 2015 10:53
-
-
Save aramis-it/9cbc75b132b0a2328e9a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class ExamplesUsersTable extends Table | |
{ | |
public function initialize(array $config) | |
{ | |
parent::initialize($config); | |
$this->table('examples_users'); | |
$this->displayField('id'); | |
$this->primaryKey('id'); | |
$this->addBehavior('Timestamp'); | |
$this->belongsTo('Examples', [ | |
'foreignKey' => 'example_id', | |
'joinType' => 'INNER' | |
]); | |
$this->belongsTo('Users', [ | |
'foreignKey' => 'user_id', | |
'joinType' => 'INNER' | |
]); | |
} | |
######################## | |
class ExamplesTable extends Table | |
{ | |
public function initialize(array $config) | |
{ | |
parent::initialize($config); | |
$this->table('examples'); | |
$this->displayField('id'); | |
$this->primaryKey('id'); | |
$this->addBehavior('Timestamp'); | |
$this->belongsTo('Users', [ | |
'foreignKey' => 'user_id', | |
'joinType' => 'INNER' | |
]); | |
$this->belongsTo('Relations', [ | |
'foreignKey' => 'relation_id', | |
'joinType' => 'INNER' | |
]); | |
$this->belongsToMany('VoteUsers', // changed Users to VoteUsers because conflict belongsTo Users | |
['className' => 'Users', | |
'foreignKey' => 'example_id', | |
'targetForeignKey' => 'user_id', | |
'joinTable' => 'examples_users' | |
]); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment