SQL查询到yii 1.1参数化查询

wmtdaxz3  于 2022-11-09  发布在  其他
关注(0)|答案(1)|浏览(196)

我有一个很长的查询,我需要在yii1.1中参数化。有人能帮我吗?

$command = Yii::app()->db->createCommand("UPDATE visit
                    LEFT JOIN card_generated ON card_generated.id = visit.card
                    SET visit_status = " . VisitStatus::CLOSED . ",card_status =" . CardStatus::NOT_RETURNED . "
                    WHERE CURRENT_DATE > date_out AND visit_status = " . VisitStatus::ACTIVE . "
                   AND card_status = " . CardStatus::ACTIVE . " and (card_type= " . CardType::SAME_DAY_VISITOR . " OR card_type=" . CardType::TEMPORARY_ASIC . ")")->execute();
zbdgwd5y

zbdgwd5y1#

请参考stackoverflow问题here无论哪种方式,您都可以使用bind param选项。请在此处查看文档以获取更多信息。文档中的一个示例如下所示。

$user = Yii::app()->db->createCommand()
    ->select('username, password')
    ->from('tbl_user')
    ->where('id=:id', array(':id'=>1))
    ->queryRow();

相关问题