Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
yii中的多对多关系返回空数组_Yii_Many To Many - Fatal编程技术网

yii中的多对多关系返回空数组

yii中的多对多关系返回空数组,yii,many-to-many,Yii,Many To Many,虽然我的表不是空的,但它返回空数组 class CryptoCurrency extends CActiveRecord { public function relations() { return array( 'currencies' => array(self::MANY_MANY, 'MiningPool', 'mining_pool_currencies(currency_id,mining_pool_id)')

虽然我的表不是空的,但它返回空数组

 class CryptoCurrency extends CActiveRecord
 {
     public function relations()
     {
         return array(
             'currencies' => array(self::MANY_MANY, 'MiningPool', 'mining_pool_currencies(currency_id,mining_pool_id)'),
         );
     }
 }
这是我的另一个型号

 class MiningPool extends CActiveRecord
 {
     public function relations()
     {
         return array(
             'currencies' => array(self::MANY_MANY, 'CryptoCurrency', 'mining_pool_currencies(mining_pool_id,currency_id)'),
         );
     }
 }
&这是我的管理员功能从控制器

 class MiningPoolController extends Controller
 {
     public function actionAdmin()
     {
         $model=new MiningPool('search');
         print_r($model->currencies);
         exit;
     }
 }
它给出了空数组。有人能告诉我怎么了吗?

一个MiningPool有很多货币是有道理的,但是CryptoCurrency类上的关系的名称不应该类似于pools吗


名字本身并不重要,但也许Yii会感到困惑,因为两个关系都有相同的名字?尝试将CryptoCurrency类中的关系名称改为pools之类的名称,看看会发生什么。

为了清晰起见,您是否省略了类的属性mining\u pool\u id和currency\u id,或者忘记将它们添加到类中?我更改了关系名称,但它仍然返回空数组。