Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/260.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
Php Yii:按相关表的默认排序模型_Php_Yii - Fatal编程技术网

Php Yii:按相关表的默认排序模型

Php Yii:按相关表的默认排序模型,php,yii,Php,Yii,我有三张桌子,宠物,物种和家。家里有多种宠物,每种都有一种。这些物种可以在家里混合 有没有可能在房子上使用findByPk,然后按物种和名称对相关宠物进行分类 Hendersons -------------- Cat "Hairball" Cat "Princess" Dog "Ace" Dog "Killer" 这对某些人来说可能是显而易见的,但我找不到答案。在Carlos的帮助下,以下是家庭模式的功能代码: 'pets' => array(self::MANY_MANY, 'Pet

我有三张桌子,宠物,物种和家。家里有多种宠物,每种都有一种。这些物种可以在家里混合

有没有可能在房子上使用findByPk,然后按物种和名称对相关宠物进行分类

Hendersons
--------------
Cat "Hairball"
Cat "Princess"
Dog "Ace"
Dog "Killer"

这对某些人来说可能是显而易见的,但我找不到答案。

在Carlos的帮助下,以下是家庭模式的功能代码:

'pets' => array(self::MANY_MANY, 'Pets', 'home_id',
                'order'=>'species.name ASC',
                'with'=>'species')

很简单。谢谢,卡洛斯。

是的,你们可以用它。就这样。谢谢你为什么不把它作为答案呢?因为我有功能代码,我想把它附加到问题上,但我不想窃取你的互联网点。别担心,展示这个