ここの情報は古いです。ご理解頂いた上でお取り扱いください。

Changeset 12914


Ignore:
Timestamp:
Sep 16, 2009, 7:40:56 PM (10 years ago)
Author:
fukamachi
Message:

distributed db - added a conditional branch to choose the table's db (distributed)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE3/branches/fukamachi/distributed_db/lib/util/opDoctrineQuery.class.php

    r12229 r12914  
    105105  }
    106106
    107   static public function chooseConnection($shouldGoToMaster = true, $queryType = self::SELECT)
     107  static public function chooseConnection($shouldGoToMaster = true, $queryType = self::SELECT, $from = null)
    108108  {
     109    if (null !== $from)
     110    {
     111      $manager = sfContext::getInstance()->getDatabaseManager();
     112      foreach ($manager->getNames() as $name)
     113      {
     114        $tables = $manager->getDatabase($name)->getParameter('tables', array());
     115        foreach ($tables as $table)
     116        {
     117          if (substr($from[0], 0, strlen($table)) === $table)
     118          {
     119            //TODO: return this db connection object
     120          }
     121        }
     122      }
     123    }
     124
    109125    if (!sfContext::hasInstance())
    110126    {
     
    122138  public function preQuery()
    123139  {
    124     $this->_conn = self::chooseConnection($this->shouldGoToMaster, $this->getType());
     140    $from = $this->_sqlParts['from'] ? $this->_sqlParts['from'] : $this->_dqlParts['from'];
     141    $this->_conn = self::chooseConnection($this->shouldGoToMaster, $this->getType(), $from);
    125142  }
    126143}
Note: See TracChangeset for help on using the changeset viewer.