> Another question. Is there something in the zend framework where:
> when I
> want to delete something it checks if the value is used in another
> table,
> and don't delete it when it is.
>
> e.g. table with articles. Every articles is connected with a
> category. when
> I try to delete a category, it 'll check if that id is used in the
> table
> articles. If used, it 'll not delete it. If not used, the category
> can be
> deleted.
This is best handled by a foreign key constraint with the ON DELETE
RESTRICT modifier. You must use a storage engine that supports
foreign key constraints. MyISAM cannot do this, but InnoDB can.
There's no way to do this atomically in client-side code.
Regards,
Bill Karwin
没有评论:
发表评论