Hi!
Here is my table:
CREATE TABLE t_site_establishment_allocation
(
f_site_id character varying(255) NOT NULL,
f_establishment_id serial NOT NULL,
CONSTRAINT t_site_establishment_allocation_f_establishment_id_fkey FOREIGN KEY (f_establishment_id)
REFERENCES t_site_establishment (f_establishment_id) MATCH SIMPLE
ON UPDATE CASCADE ON DELETE CASCADE,
CONSTRAINT t_site_establishment_allocation_f_site_id_fkey FOREIGN KEY (f_site_id)
REFERENCES t_site (f_site_id) MATCH SIMPLE
ON UPDATE CASCADE ON DELETE CASCADE
)
Now, I want to execute some code on delete.
I have an ajax function sending to this controller:
public function actionUnallocate()
{
$establishmentAssociation = t_site_establishment_allocation::model()->findByPk(array('f_establishment_id' => $_GET['establishment_id'], 'f_site_id' => $_GET['site_id']));
$establishmentAssociation->delete();
}
On that case, I have an error “Column name must be either a string or an array”. I don’t understand why…
So I have changed my code with this:
public function actionUnallocate()
{
t_site_establishment_allocation::model()->deleteAll('f_establishment_id=:establishmentId AND f_site_id=:siteId',array(':establishmentId'=>$_GET['establishment_id'], ':siteId'=>$_GET['site_id']));
}
This code works, but apparently my function afterdelete is not executed… Is that because I use a deleteAll?
Thanks!