On 2 Mrz. 2009, 19:25, mscdex <[email protected]> wrote:
> On Mar 2, 7:20 am, krishan <[email protected]> wrote:
>
> I usually do this sort of checking in the model validation or in the
> delete controller action before the deletion is attempted. Something
> like a find('count') or similar method to tocheckif the ID of the
> record to be deleted exists in a FK in some other table or record. You
> might also try the model's 'del' method which has a 'cascade' option
> (http://book.cakephp.org/view/690/del).
Hello in addition to the topic above,
i have the same problem and this suggestion sounds nice for me!
I'd like to check if the ID of the record to be deleted exists in a
foreign key in some other table (i have to check all associated
tables) or record.
Could someone help me to build an example for this?
[code of my updated delete fuction in appController]
function delete($id)
{
# check (with find('count') or something else) if the
ID of the record to be deleted exists in a foreign key in some other
table #
if ( # the record is "not used" # )
{
$this->{$this->modelClass}->del($id);
$this->Session->setFlash('delete (id: '.$id.') works!');
}
else
{
$this->Session->setFlash('Could not be deleted
because of ...');
}
$this->redirect(array ('action' => 'index'));
}
[/code]
Could someone help me please? Thanks!
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
To unsubscribe from this group, send email to
cake-php+unsubscribegooglegroups.com or reply to this email with the words
"REMOVE ME" as the subject.