ich hab ein Problem mit den Active Records
in SQL würde die abfrage so aussehen:
SELECT *, SUM(newPM) AS unRead FROM (
SELECT t.conID, user_id, lastread, sender, subject, sendTime, IF(lastread < sendTime, 1, 0) AS newPM FROM `pm_conversation` AS t LEFT JOIN pm_messages AS z ON t.conID = z.conID ORDER BY sendTime DESC
) AS temp
GROUP BY conID
ORDER BY sendTime DESC
Table 1:
* This is the model class for table "pm_conversation".
*
* The followings are the available columns in table 'pm_conversation':
* @property integer $conID
* @property integer $user_id
* @property string $lastread
Table 2:
* This is the model class for table "pm_messages".
*
* The followings are the available columns in table 'pm_messages':
* @property string $pmID
* @property integer $sender
* @property string $subject
* @property string $message
* @property string $sendTime
* @property integer $conID
nur wie mach ich dass nun mit den Active Records??
die ganzen Conversations bekomm ich mit
Yii::app()->getModule(‘user’)->user()->conversations