Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.2.0
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      WIndows 7
      Wamp (PHP Version 5.3.0 mysqlnd 5.0.5-dev - 081106 - $Revision: 1.3.2.27 $ )

      Description

      I made a DQL delete query.

      $q = Doctrine_Query::create()
      ->delete()
      ->from('termRelationship tr')
      ->innerJoin('tr.termTaxonomy tt')
      ->innerJoin('tr.Post p')
      ->where('p.id = ?', '1')
      ->andWhere('tt.taxonomy = ?','category');

      //GENERATED SQL OF THE DQL
      DELETE FROM term_relationship INNER JOIN term_taxonomy t2 ON t.term_taxonomy_id = t2.id INNER JOIN post p ON t.object_id = p.id WHERE (id = '1' AND taxonomy = 'category')

      But this query is incorrect

      The query must be( alias are not present beetween DELETE and FROM and for the FROM table)

      DELETE tr FROM term_relationship tr INNER JOIN term_taxonomy t2 ON tr.term_taxonomy_id = t2.id INNER JOIN post p ON tr.object_id = p.id WHERE (p.id = '1' AND t2.taxonomy = 'category')

      With this request all is good in pphmyadmin.

        Activity

        jerome created issue -
        Hide
        Jonathan H. Wage added a comment -

        Joins are not supported on update and delete queries because it is not supported on all dbms. It won't be implemented in Doctrine 1 or Doctrine 2. You can however get the same affect by using subqueries.

        Show
        Jonathan H. Wage added a comment - Joins are not supported on update and delete queries because it is not supported on all dbms. It won't be implemented in Doctrine 1 or Doctrine 2. You can however get the same affect by using subqueries.
        Jonathan H. Wage made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Won't Fix [ 2 ]
        Hide
        James Bench added a comment - - edited

        You can't delete from a table when it's in a subquery in MySQL (I'm using Doctrine 2).

        DELETE FROM tblA a WHERE a.id NOT IN(SELECT a2.id FROM tblA a2 JOIN a2.tblB b WHERE b.value = :value)
        
        Show
        James Bench added a comment - - edited You can't delete from a table when it's in a subquery in MySQL (I'm using Doctrine 2). DELETE FROM tblA a WHERE a.id NOT IN(SELECT a2.id FROM tblA a2 JOIN a2.tblB b WHERE b.value = :value)

        This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

        • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DC-646, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            jerome
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: