Hi,
I’m trying to delete a row from a table but I get an error: Call to a member function delete() on a non-object
This is the code:
$userId = Yii::app()->user->getId();
//get the correct record
$criteria = new CDbCriteria;
$criteria->compare('property_id',$propertyId);
$criteria->compare('user_id',$userId);
$criteria->limit = 1;
$rowToRemove = PropertyUserAssignment::model()->findAll($criteria);
//print_r($rowToRemove);
$rowToRemove->delete();
When I print_r $rowToRemove it shows the correct record, so I’m assuming the model is being returned correctly, what am I missing?
Thanks in advance.