1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Siam
- * Date: 2020/2/27
- * Time: 10:01
- */
- namespace EasySwoole\ORM\Tests\models;
- use EasySwoole\Mysqli\QueryBuilder;
- use EasySwoole\ORM\AbstractModel;
- class Users extends AbstractModel
- {
- protected $tableName='users';
- public function roles()
- {
- return $this->belongsToMany(Roles::class, 'user_role');
- }
- public function roles_join()
- {
- return $this->belongsToMany(Roles::class, 'user_role', 'user_id', 'user_id');
- }
- public function roles_different_field()
- {
- return $this->belongsToMany(Roles::class, 'user_role_different_field', 'u_id', 'r_id');
- }
- public function roles_different_field_call()
- {
- return $this->belongsToMany(Roles::class, 'user_role_different_field', 'u_id', 'r_id', function(QueryBuilder $builder){
- // 是目标表
- $builder->fields("role_id");
- });
- }
- }
|