B
B
balex7772019-04-16 09:53:11
Yii
balex777, 2019-04-16 09:53:11

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();

Need something here
$criteria->join= 'JOIN table.user as user ON user.id=(case when (src_id <> (' . $user_id .')) then dst_id else src_id end)';

During the iteration, src_id must not be equal to src_id , that is, in the first iteration, src_id = 1, and so on. and it is necessary that this src_id value of a specific iteration gets into $user_id in order to compare it
Who knows how to implement it?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question