I am using the following code:
MyClass::model()->deleteAllByAttributes(array('phone_number'=>':phone_number'), '', array(':phone_number'=>$phoneNumber));
And I am getting the following error:
CDbException
SQLSTATE[HY093]: Invalid parameter number: number of bound variables
does not match number of tokens. The SQL statement executed was:
DELETE FROM `my_class` WHERE `my_class`.`phone_number`=:yp0
(E:\xampp\htdocs\yii\db\CDbCommand.php:354)
I believe you don’t need to bind the attributes in the
attributesarray (as infindAllByAttributes()too). The values in theparamsarray are bound to values in theconditionstring, not theattributesarray, so I believe the following should work for you (and be sanitized):Alternatively, you could use:
Which would have the same effect… But then you might as well use
deleteAll():