简体   繁体   中英

Yii escaping quotes in UpdateAll where clause

Is there a 'Yii' way of escaping quotes when updating or selecting by a textfield?

MyModel::model()->updateAll( array( 'status_id' => 1 ), 'name="' . $model->name . '"' );

If $model-name contains double quotes in this case it obviously breaks the statement. Is there a 'Yii' way of escaping this properly?

如果我没记错的话,那就是:

MyModel::model()->updateAll(array('status_id' => 1), 'name=:name', array(':name' => $model->name));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM