Doctrine 1
  1. Doctrine 1
  2. DC-663

Doctrine_Table::createQuery creates a query with the default connection instead of the current connection

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2.1, 1.2.2, 1.2.3
    • Fix Version/s: 1.2.3
    • Component/s: Query
    • Labels:
      None
    • Environment:
      Ubuntu 9.10

      Description

      If we manually set a connection on the Doctrine_Table instance Doctrine silently ignores it when creating a Doctrine_Query instance through createQuery method

      $manager->setConnection($defaultConnection);

      $table = Doctrine::getTable('Users')->setConnection($newConnection);
      $table->createQuery(); // -> connection to $defaultConnection

      The code:

      public function createQuery($alias = '')
      {
      if ( ! empty($alias))

      { $alias = ' ' . trim($alias); }

      $class = $this->getAttribute(Doctrine_Core::ATTR_QUERY_CLASS);

      return Doctrine_Query::create(null, $class) <-- fix too quick for a patch -> return Doctrine_Query::create($this>_conn, $class)
      >from($this>getComponentName() . $alias);
      }

        Activity

        Hide
        Christoph Berg added a comment -

        When using Table classes generated with the latest Symfony 1.4 version (1.4.8) the table gets bound to a specific connection, but Doctrine still uses the default connection.

        Using the above mentioned quick fix - replacing $this->_conn with null - everything works as it should.

        Show
        Christoph Berg added a comment - When using Table classes generated with the latest Symfony 1.4 version (1.4.8) the table gets bound to a specific connection, but Doctrine still uses the default connection. Using the above mentioned quick fix - replacing $this->_conn with null - everything works as it should.

          People

          • Assignee:
            Guilherme Blanco
            Reporter:
            Costache Catalin
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: