public $q;//注册数据库1是A库,2是B库
    public $name;//账号
    public function rules()
    { 
       // echo $this->uniques();
       // echo $this->q;
        return [ 
            
            ['name', 'unique', 'targetClass' =>'app\models\User2', 'message' => '账号已被注册'],
            //['name', 'unique', 'targetClass' =>$this->uniques(), 'message' => '账号已被注册'],
            //['name', 'unique', 'targetClass' =>(q==1?app\models\User:app\models\User2), 'message' => '账号已被注册'],        ];
    }
    
    
        public function uniques(){
        if ($this->q==1){
            $a='app\models\User';
        }elseif ($this->q==2){
            $a='app\models\User';
        }
         return $a;
    }打印方法返回的内容也不行,打印成员变量也报错我应该怎么取$this->q的值,
就是想实现不同数据库之间的帐号唯一验证 'targetClass' =>'app\models\User2'这句话 'targetClass' =>'app\models\User2'根据传来的参数做出不同的改变,要么 'targetClass' =>'app\models\User2'
要么 'targetClass' =>'app\models\User‘’现就是在那个方法里面echo $this->q 直接就error了,根本不能取值判断。不知道咋取,求大大指点下