Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8407985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:31:23+00:00 2026-06-09T23:31:23+00:00

i am using doctrine’s SoftDelete and upon deletion i would like to SofDelete the

  • 0

i am using doctrine’s SoftDelete and upon deletion i would like to SofDelete the related records.

here is the Schema file i am using.

detect_relations: true
User:
  actAs:
    Timestampable:
    SoftDelete:
    Sluggable:
      unique: true
      fields: [name]
      canUpdate: true
  tableName: user
  columns:
    name:
      type: string(50)
      notnull: true
    email:
      type: string(50)
      notnull: true
      unique: true
    password:
      type: string(50)
      notnull: true
    business_id: integer
  relations:
    Business:
      cascade: [delete]
Business:
  actAs:
    Timestampable:
    SoftDelete:
    Sluggable:
      unique: true
      fields: [name]
      canUpdate: true
  tableName: business
  columns:
    name:
      type: string(50)
      notnull: true
    website: string(100)
    address: string(100)

when i try to SoftDelete user it does not delete related record from business table (i.e it does not update the deleted_at flag in the business table). only the deleted_at flag from the user table is updated.

the DQL i am using is.

$q = Doctrine_Query::create()
    ->delete('Model_User u')
    ->where('u.id = ?', $id);
$q ->execute();

where am i going wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T23:31:24+00:00Added an answer on June 9, 2026 at 11:31 pm

    After searching around for some time, i finally found the solution by myself. hope this helps someone with the same problem as mine.

    here are few of the conditions for application level delete cascade to work.

    • Unlike the save() operations the delete() cascading needs to be turned on explicitly

    apart from defining cascade: [delete] in your Schema, it is important to note that you need to explicitly define the relations too.
    if you are depending on detect_relations: true for you to generate all the relations this won’t work for application level delete cascade. (atleast it didn’t work for me, after manually defining the relations it worked though).

    • Application level cascading save() and delete() does not apply when doing DQL update and delete statements, only when calling save() and
      delete() on your objects.

    doctrine documentation is not clear about this. i had to refer symfony documentation for this to understand. doctrine documentation only says.

    The following describes the generic procedure when you delete a record
    through $record->delete():

    for me to understand it was quite confusing. but after going through symfony’s documentation of doctrine i was clear about how to do it. so instead of deleting through DQL. i had to use this.

    $user = Doctrine_Core::getTable('User')->find(1)
    $user->delete();
    

    and Booom, it works. 🙂

    P.S: here is the link to symfony documentation in case if anyone wants to refer.

    http://www.symfony-project.org/doctrine/1_2/en/04-Schema-Files#chapter_04_sub_application_level

    and here is the link to a post which clarifies my doubt which is not of any use though 🙂

    https://groups.google.com/forum/?fromgroups#!topic/doctrine-user/POq6ybO01lg%5B1-25%5D

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Doctrine with Symfony2. My config.yml file looks something like this:- Doctrine
I am using Doctrine 1.2 in my project. The schema.yml file contains: Campaign: tableName:
I am using Doctrine 2 with Codeigniter 2 and I would like to Doctrine
I'm using Doctrine 2, and would like this ORM to auto flush() the EntityManager
Im using Doctrine and i dont quite understand this code here: $this->hasColumn('id', 'integer', 8,
I'm using Doctrine ODM with MongoDB. I have a product model like this: namespace
when using doctrine i stumble upon these 2 words: accessor and mutator. are these
Is there any way, when using Doctrine, to create a table like another? I
I'm using Doctrine 1.2. I'd like to execute a Doctrine_Query that, instead of returning
Using Doctrine , I am trying to delete records in a single table based

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.