-1

I have a long query that I need to parameterize in yii1.1. Can anybody help with it?

$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();
niac
  • 33
  • 2
  • 17
kritika555
  • 183
  • 1
  • 4
  • 15

1 Answers1

0

refer to this stackoverflow question here Either way you can use the bind param option. Check out the documentation for more information here. A sample from the docs is show below.

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