Hi,
You can try something like this in your file
Lib/model/Arcivle.php to delete the attached media
class Article extends BaseArticle
{
...
public function delete ($con = null)
{
// retrieve the "media" from the media_id
$media = MediaPeer::retrieveByPk($this->getMediaId());
$media->delete();
$ret = parent::delete($con);
}
}
Olivier
> -----Original Message-----
> From: [email protected] [mailto:symfony-
> [EMAIL PROTECTED] On Behalf Of Thomas Rabaix
> Sent: Monday, May 12, 2008 1:30 PM
> To: [email protected]
> Subject: [symfony-users] Re: Propel : onDelete/casade and parent attached
> media
>
>
> Yes, its depends ...
>
> $article->delete() will never call $media->delete() at least in innodb
>
> Thomas
>
> On Mon, May 12, 2008 at 1:19 PM, Olivier LOYNET <[EMAIL PROTECTED]>
> wrote:
> >
> > Hi
> >
> > You have to override your 'delete' method in your lib/model/foo
> > and it's not depend on your database
> >
> > Like this...
> >
> >
> > class Foo extends BaseFoo
> > {
> >
> > public function delete ($con = null)
> > {
> > $photoDir = sfConfig::get('app_xxxxxx_dir');
> >
> > if (is_file($photoDir.'/'.$this->getFileName()))
> > {
> > unlink($photoDir.'/'.$this->getFileName());
> > }
> >
> > $ret = parent::delete($con);
> > }
> > }
> >
> > Olivier
> >
> >
> >
> >
> > > -----Original Message-----
> > > From: [email protected] [mailto:symfony-
> > > [EMAIL PROTECTED] On Behalf Of nico_bl1nd
> > > Sent: Monday, May 12, 2008 10:50 AM
> > > To: symfony users
> > > Subject: [symfony-users] Re: Propel : onDelete/casade and parent
> attached
> > > media
> > >
> > >
> > > This is quite automatic.
> > > I call the Article.delete method, then everything is done by "magic",
> > > thanks to the schema.yml onDelete:cascade parameter in the Media
> > > definition.
> > > I'm not sure to be clear.
> > >
> > > On 12 mai, 10:37, cleve <[EMAIL PROTECTED]> wrote:
> > > > Are you still calling the parent delete function after removing the
> > > > files?
> > > >
> > > > On May 12, 8:26 am, nico_bl1nd <[EMAIL PROTECTED]> wrote:
> > > >
> > > > > Hi everyone,
> > > >
> > > > > I'm working on two related tables : article/media.
> > > > > "onDelete: cascade" work like a charm. But I would the media
> files to
> > > > > be deleted to.
> > > > > Where should this part of the code be integrated ? I though it
> would
> > > > > in the Media.php/delete function, but it doesn't work.
> > > > > Any idea ?
> > > >
> > > > > thanks a lot.
> > > > > Nicolas
> > >
> >
> > >
> >
>
>
>
> --
> Thomas Rabaix
>
> Internet Consultant
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" 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/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---