Changeset 12914
- Timestamp:
- Sep 16, 2009, 7:40:56 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
OpenPNE3/branches/fukamachi/distributed_db/lib/util/opDoctrineQuery.class.php
r12229 r12914 105 105 } 106 106 107 static public function chooseConnection($shouldGoToMaster = true, $queryType = self::SELECT )107 static public function chooseConnection($shouldGoToMaster = true, $queryType = self::SELECT, $from = null) 108 108 { 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 109 125 if (!sfContext::hasInstance()) 110 126 { … … 122 138 public function preQuery() 123 139 { 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); 125 142 } 126 143 }
Note: See TracChangeset
for help on using the changeset viewer.