Problem With Delete()


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->limit = 1;


$rowToRemove = PropertyUserAssignment::model()->findAll($criteria);



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.

findAll() returns a list of AR… so your model is in $rowToRemove[0]

you can use find() instead to get only one model.

Thank you!