Changeset 4332
- Timestamp:
- 05/02/08 14:29:33 (14 months ago)
- Location:
- branches/0.11
- Files:
-
- 7 modified
-
lib/Doctrine.php (modified) (1 diff)
-
lib/Doctrine/Data/Import.php (modified) (2 diffs)
-
lib/Doctrine/Hydrator/RecordDriver.php (modified) (3 diffs)
-
lib/Doctrine/Manager.php (modified) (26 diffs)
-
lib/Doctrine/Record.php (modified) (1 diff)
-
lib/Doctrine/Search/Query.php (modified) (1 diff)
-
tests/Ticket/736TestCase.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/0.11/lib/Doctrine.php
r4317 r4332 951 951 * Get the Doctrine_Table object for the passed model 952 952 * 953 * @param string $ tableName954 * @return void 955 */ 956 public static function getTable($ tableName)957 { 958 return Doctrine_Manager:: table($tableName);953 * @param string $componentName 954 * @return void 955 */ 956 public static function getTable($componentName) 957 { 958 return Doctrine_Manager::getInstance()->getConnectionForComponent($componentName)->getTable($componentName); 959 959 } 960 960 -
branches/0.11/lib/Doctrine/Data/Import.php
r4301 r4332 300 300 protected function _loadNestedSetData($model, $nestedSetData, $parent = null) 301 301 { 302 $manager = Doctrine_Manager::getInstance();303 304 302 foreach($nestedSetData AS $rowKey => $nestedSet) { 305 303 $children = array(); … … 315 313 316 314 if( ! $parent) { 317 $manager->getTable($model)->getTree()->createRoot($record);315 Doctrine::getTable($model)->getTree()->createRoot($record); 318 316 } else { 319 317 $parent->getNode()->addChild($record); -
branches/0.11/lib/Doctrine/Hydrator/RecordDriver.php
r4087 r4332 106 106 $component = $this->_getClassNameToReturn($data, $component); 107 107 if ( ! isset($this->_tables[$component])) { 108 $this->_tables[$component] = Doctrine _Manager::getInstance()->getTable($component);108 $this->_tables[$component] = Doctrine::getTable($component); 109 109 $this->_tables[$component]->setAttribute(Doctrine::ATTR_LOAD_REFERENCES, false); 110 110 } … … 144 144 { 145 145 if ( ! isset($this->_tables[$component])) { 146 $this->_tables[$component] = Doctrine _Manager::getInstance()->getTable($component);146 $this->_tables[$component] = Doctrine::getTable($component); 147 147 $this->_tables[$component]->setAttribute(Doctrine::ATTR_LOAD_REFERENCES, false); 148 148 } … … 153 153 154 154 foreach ($subclasses as $subclass) { 155 $table = Doctrine _Manager::getInstance()->getTable($subclass);155 $table = Doctrine::getTable($subclass); 156 156 $inheritanceMap = $table->getOption('inheritanceMap'); 157 157 list($key, $value) = each($inheritanceMap); -
branches/0.11/lib/Doctrine/Manager.php
r4331 r4332 56 56 57 57 /** 58 * @var string $root root directory59 */60 protected $_root;61 62 /**63 58 * @var Doctrine_Query_Registry the query registry 64 59 */ … … 72 67 private function __construct() 73 68 { 74 $this->_root = dirname(__FILE__);75 76 69 Doctrine_Locator_Injectable::initNullObject(new Doctrine_Null); 77 70 } … … 122 115 123 116 /** 124 * returns the root directory of Doctrine 125 * 126 * @return string 127 */ 128 final public function getRoot() 129 { 130 return $this->_root; 131 } 132 133 /** 134 * getInstance 135 * returns an instance of this class 117 * Returns an instance of this class 136 118 * (this class uses the singleton pattern) 137 119 * … … 148 130 149 131 /** 150 * getQueryRegistry 151 * 152 * lazy-initializes the query registry object and returns it 132 * Lazy-initializes the query registry object and returns it 153 133 * 154 134 * @return Doctrine_Query_Registry … … 163 143 164 144 /** 165 * setQueryRegistry 166 * sets the query registry 145 * Sets the query registry 167 146 * 168 147 * @return Doctrine_Manager this object … … 176 155 177 156 /** 178 * fetch 179 * fetches data using the provided queryKey and 180 * the associated query in the query registry 181 * 182 * if no query for given queryKey is being found a 183 * Doctrine_Query_Registry exception is being thrown 184 * 185 * @param string $queryKey the query key 186 * @param array $params prepared statement params (if any) 187 * @return mixed the fetched data 188 */ 189 public function find($queryKey, $params = array(), $hydrationMode = Doctrine::HYDRATE_RECORD) 190 { 191 return Doctrine_Manager::getInstance() 192 ->getQueryRegistry() 193 ->get($queryKey) 194 ->execute($params, $hydrationMode); 195 } 196 197 /** 198 * fetchOne 199 * fetches data using the provided queryKey and 200 * the associated query in the query registry 201 * 202 * if no query for given queryKey is being found a 203 * Doctrine_Query_Registry exception is being thrown 204 * 205 * @param string $queryKey the query key 206 * @param array $params prepared statement params (if any) 207 * @return mixed the fetched data 208 */ 209 public function findOne($queryKey, $params = array(), $hydrationMode = Doctrine::HYDRATE_RECORD) 210 { 211 return Doctrine_Manager::getInstance() 212 ->getQueryRegistry() 213 ->get($queryKey) 214 ->fetchOne($params, $hydrationMode); 215 } 216 217 /** 218 * connection 219 * 220 * if the adapter parameter is set this method acts as 157 * Open a new connection. If the adapter parameter is set this method acts as 221 158 * a short cut for Doctrine_Manager::getInstance()->openConnection($adapter, $name); 222 159 * … … 239 176 240 177 /** 241 * openConnection 242 * opens a new connection and saves it to Doctrine_Manager->connections 178 * Opens a new connection and saves it to Doctrine_Manager->connections 243 179 * 244 180 * @param PDO|Doctrine_Adapter_Interface $adapter database driver … … 331 267 332 268 /** 333 * parsePdoDsn269 * Parse a pdo style dsn in to an array of parts 334 270 * 335 271 * @param array $dsn An array of dsn information … … 369 305 370 306 /** 371 * buildDsnPartsArray 372 * 307 * Build the blank dsn parts array used with parseDsn() 308 * 309 * @see parseDsn() 373 310 * @param string $dsn 374 311 * @return array $parts 375 312 */ 376 p ublic functionbuildDsnPartsArray($dsn)313 protected function _buildDsnPartsArray($dsn) 377 314 { 378 315 // fix sqlite dsn so that it will parse correctly … … 400 337 401 338 /** 402 * parseDsn339 * Parse a Doctrine style dsn string in to an array of parts 403 340 * 404 341 * @param string $dsn … … 408 345 public function parseDsn($dsn) 409 346 { 410 $parts = $this-> buildDsnPartsArray($dsn);347 $parts = $this->_buildDsnPartsArray($dsn); 411 348 412 349 switch ($parts['scheme']) { … … 479 416 480 417 /** 481 * getConnection 418 * Get the connection instance for the passed name 419 * 482 420 * @param integer $index 483 421 * @return object Doctrine_Connection … … 494 432 495 433 /** 496 * getConnectionName434 * Get the name of the passed connection instance 497 435 * 498 436 * @param Doctrine_Connection $conn connection object to be searched for … … 505 443 506 444 /** 507 * bindComponent 508 * binds given component to given connection 445 * Binds given component to given connection 509 446 * this means that when ever the given component uses a connection 510 447 * it will be using the bound connection instead of the current connection … … 520 457 521 458 /** 522 * getConnectionForComponent459 * Get the connection instance for the specified component 523 460 * 524 461 * @param string $componentName … … 537 474 538 475 /** 539 * hasConnectionForComponent476 * Check if a component is bound to a connection 540 477 * 541 478 * @param string $componentName … … 548 485 549 486 /** 550 * getTable 551 * this is the same as Doctrine_Connection::getTable() except 552 * that it works seamlessly in multi-server/connection environment 553 * 554 * @see Doctrine_Connection::getTable() 555 * @param string $componentName 556 * @return Doctrine_Table 557 */ 558 public function getTable($componentName) 559 { 560 return $this->getConnectionForComponent($componentName)->getTable($componentName); 561 } 562 563 /** 564 * table 565 * this is the same as Doctrine_Connection::getTable() except 566 * that it works seamlessly in multi-server/connection environment 567 * 568 * @see Doctrine_Connection::getTable() 569 * @param string $componentName 570 * @return Doctrine_Table 571 */ 572 public static function table($componentName) 573 { 574 $manager = Doctrine_Manager::getInstance(); 575 return $manager->getConnectionForComponent($componentName)->getTable($componentName); 576 } 577 578 /** 579 * closes the connection 487 * Closes the specified connection 580 488 * 581 489 * @param Doctrine_Connection $connection … … 597 505 598 506 /** 599 * getConnections 600 * returns all opened connections 507 * Returns all opened connections 601 508 * 602 509 * @return array … … 608 515 609 516 /** 610 * setCurrentConnection 611 * sets the current connection to $key 517 * Sets the current connection to $key 612 518 * 613 519 * @param mixed $key the connection key … … 625 531 626 532 /** 627 * contains 628 * whether or not the manager contains specified connection 533 * Whether or not the manager contains specified connection 629 534 * 630 535 * @param mixed $key the connection key … … 637 542 638 543 /** 639 * count 640 * returns the number of opened connections 544 * Returns the number of opened connections 641 545 * 642 546 * @return integer … … 648 552 649 553 /** 650 * getIterator 651 * returns an ArrayIterator that iterates through all connections 554 * Returns an ArrayIterator that iterates through all connections 652 555 * 653 556 * @return ArrayIterator … … 659 562 660 563 /** 661 * getCurrentConnection 662 * returns the current connection 564 * Get the current connection instance 663 565 * 664 566 * @throws Doctrine_Connection_Exception if there are no open connections … … 675 577 676 578 /** 677 * createDatabases 678 * 679 * Creates databases for connections 579 * Creates databases for all existing connections 680 580 * 681 581 * @param string $specifiedConnections Array of connections you wish to create the database for … … 703 603 704 604 /** 705 * dropDatabases 706 * 707 * Drops databases for connections 605 * Drops databases for all existing connections 708 606 * 709 607 * @param string $specifiedConnections Array of connections you wish to drop the database for … … 731 629 732 630 /** 733 * __toString 734 * returns a string representation of this object 631 * Returns a string representation of this object 735 632 * 736 633 * @return string -
branches/0.11/lib/Doctrine/Record.php
r4320 r4332 157 157 // get the table of this class 158 158 $class = get_class($this); 159 $this->_table = Doctrine _Manager::getInstance()->getTable($class);159 $this->_table = Doctrine::getTable($class); 160 160 $exists = false; 161 161 } -
branches/0.11/lib/Doctrine/Search/Query.php
r3884 r4332 55 55 { 56 56 if (is_string($table)) { 57 $table = Doctrine _Manager::table($table);57 $table = Doctrine::getTable($table); 58 58 } else { 59 59 if ( ! $table instanceof Doctrine_Table) { -
branches/0.11/tests/Ticket/736TestCase.php
r3884 r4332 34 34 public function testForHydrationOverwrintingLocalInstancesWhenItShouldnt() 35 35 { 36 $module = Doctrine _Manager::getInstance()->getTable("T736_Module")->find(1);36 $module = Doctrine::getTable("T736_Module")->find(1); 37 37 $module->moduledata->content = "foo"; 38 38 $module->moduledata->save(); … … 85 85 { 86 86 $contents = $event->data; 87 $delegate = Doctrine _Manager::getInstance()->getTable("T736_ModuleDelegate")->find($contents["moduledelegateid"], ($contents instanceof Doctrine_Record) ? Doctrine::HYDRATE_RECORD :Doctrine::HYDRATE_ARRAY );87 $delegate = Doctrine::getTable("T736_ModuleDelegate")->find($contents["moduledelegateid"], ($contents instanceof Doctrine_Record) ? Doctrine::HYDRATE_RECORD :Doctrine::HYDRATE_ARRAY ); 88 88 if ($contents instanceof Doctrine_Record) 89 89 {