Answer the question
In order to leave comments, you need to log in
How to determine id in SQL query at specific iteration in yii1?
hello here is the request
$users = "1,2,3,4,5,6,7,8,9,10";
$criteria = new CDbCriteria();
$criteria->addCondition("src_id in ($users) or dst_id in ($users)");
$criteria->select = array
(
'date_format(time, "%H:%i") as time',
'date_format(date, "%d.%m.%Y") as date',
);
$criteria->join= 'JOIN table.user as user ON user.id=(case when (src_id <> (' . $user_id .')) then dst_id else src_id end)';
$builder = new CDbCommandBuilder(Yii::app()->db_site->getSchema());
$command = $builder->createFindCommand('message', $criteria);
$db = $command->queryAll();
$criteria->join= 'JOIN table.user as user ON user.id=(case when (src_id <> (' . $user_id .')) then dst_id else src_id end)';
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question