【发布时间】:2014-09-15 10:52:04
【问题描述】:
我有两个模型。它们是 DisnotificationUpdate 和 DisNotification。 DisnotificationUpdate 关系如下。
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'user' => array(self::BELONGS_TO, 'Login', 'userid'),
'notifi' => array(self::BELONGS_TO, 'Disnotification', 'notifi_id'),
);
}
属性如下。
public function attributeLabels()
{
return array(
'id' => 'ID',
'notifi_id' => 'Notifi',
'view' => 'View',
'userid' => 'Userid',
);
}
Disnotification 模型具有以下属性。
public function attributeLabels()
{
return array(
'id' => 'ID',
'notification' => 'Notification',
'owner' => 'Owner',
'workspace_id' => 'Workspace',
'postID' => 'Post',
'pDate' => 'P Date',
);
}
我想从 DisnotificationUpdate 中选择值,并在 DisNotification 中使用“pDate”按值排序。 我尝试如下。
$dataProvider=DisnotificationUpdate::model()->findAll(array(
'condition' => 'userid=:userid',
'order' => 'notifi.pDate ASC',
'limit'=>10,
'params' => array(':userid' => $myid)
));
但它给出了一个错误,“'order Clause'中的未知列'notifi.pDate'”。我做错了什么?谢谢。
【问题讨论】:
标签: php sql-order-by foreign-key-relationship yii