Changeset 5285
- Timestamp:
- 12/11/08 05:22:00 (7 months ago)
- Files:
-
- 1 modified
-
branches/1.1/UPGRADE_TO_1_1 (modified) (23 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/1.1/UPGRADE_TO_1_1
r5244 r5285 2 2 ====================== 3 3 4 This document details the changes made to Doctrine 1.1 to make it easier for you to upgrade your projects to use this version. 4 This document details the changes made to Doctrine 1.1 to make it easier for you 5 to upgrade your projects to use this version. 5 6 6 7 Doctrine Record 7 8 --------------- 8 9 9 [r5014](http://trac.doctrine-project.org/changeset/5014) - Added support for `FROM User u WHERE u.id IN ?` in the Doctrine_Query api. 10 10 [r5014](http://trac.doctrine-project.org/changeset/5014) - Added support for 11 `FROM User u WHERE u.id IN ?` in the Doctrine_Query api. 12 13 [php] 11 14 $q = Doctrine_Query::create() 12 15 ->from('User u') … … 14 17 $users = $q->execute(); 15 18 16 [r5019](http://trac.doctrine-project.org/changeset/5019) - `unlink()` and `link()` have been changed to not delete references until `save()` is called on the object. Also, fixed synchronizeWithArray() to synchronize many to many relationships. 17 19 [r5019](http://trac.doctrine-project.org/changeset/5019) - `unlink()` and 20 `link()` have been changed to not delete references until `save()` is called 21 on the object. Also, fixed synchronizeWithArray() to synchronize many to many 22 relationships. 23 24 [php] 18 25 // Does not link until save() 19 26 $user = Doctrine::getTable('User')->find(1); … … 37 44 $user->save(); 38 45 39 [r5034](http://trac.doctrine-project.org/changeset/5034) - You can now retrieve the old values of records through the getModified() function. By default it returns an array of fieldName => newValue but if you specify getModified(true) it will return the old values. 40 46 [r5034](http://trac.doctrine-project.org/changeset/5034) - You can now retrieve 47 the old values of records through the getModified() function. By default it 48 returns an array of fieldName => newValue but if you specify getModified(true) 49 it will return the old values. 50 51 [php] 41 52 $users = Doctrine::getTable('User')->findAll(); 42 53 $user = $users->getFirst(); … … 57 68 */ 58 69 59 [r5035](http://trac.doctrine-project.org/changeset/5035) - Added ability to use custom setters with fromArray() 60 70 [r5035](http://trac.doctrine-project.org/changeset/5035) - Added ability to use 71 custom setters with fromArray() 72 73 [php] 61 74 public function setTableDefinition() 62 75 { … … 76 89 --------------- 77 90 78 [r5027](http://trac.doctrine-project.org/changeset/5039) - Added support for setting default charset and collate for tables. 91 [r5027](http://trac.doctrine-project.org/changeset/5039) - Added support for 92 setting default charset and collate for tables. 79 93 80 94 Set globally on a Doctrine_Manager instance. 81 95 96 [php] 82 97 $manager->setCollate('utf8_unicode_ci'); 83 98 $manager->setCharset('utf8'); … … 85 100 The same can be set on the Doctrine_Connection and Doctrine_Record levels. 86 101 102 [php] 87 103 $connection->setCollate('utf8_unicode_ci'); 88 104 $connection->setCharset('utf8'); … … 94 110 } 95 111 96 [r5030](http://trac.doctrine-project.org/changeset/5039) - Added support for setting default options for columns and auto added identifier columns. 97 98 The following is now possible on Doctrine_Manager, Doctrine_Connection and Doctrine_Record. 99 100 $manager->setAttribute(Doctrine::ATTR_DEFAULT_COLUMN_OPTIONS, array('type' => 'string', 'length' => 255, 'notnull' => true)); 112 [r5030](http://trac.doctrine-project.org/changeset/5039) - Added support for 113 setting default options for columns and auto added identifier columns. 114 115 The following is now possible on Doctrine_Manager, Doctrine_Connection and 116 Doctrine_Record. 117 118 [php] 119 $manager->setAttribute(Doctrine::ATTR_DEFAULT_COLUMN_OPTIONS, 120 array('type' => 'string', 'length' => 255, 'notnull' => true)); 101 121 102 122 You can also customize the values that make up the auto added identifier column as well. 103 123 104 $manager->setAttribute(Doctrine::ATTR_DEFAULT_IDENTIFIER_OPTIONS, array('name' => '%s_id', 'type' => 'string', 'length' => 16)); // %s in the name is replaced with the table name. 105 106 [r5079](http://trac.doctrine-project.org/changeset/5079) - Added ability to retrieve the modified properties from the last transaction with the Doctrine_Record::getLastModified() method 107 124 [php] 125 // %s in the name is replaced with the table name. 126 $manager->setAttribute(Doctrine::ATTR_DEFAULT_IDENTIFIER_OPTIONS, 127 array('name' => '%s_id', 'type' => 'string', 'length' => 16)); 128 129 [r5079](http://trac.doctrine-project.org/changeset/5079) - Added ability to 130 retrieve the modified properties from the last transaction with the 131 Doctrine_Record::getLastModified() method 132 133 [php] 108 134 $user = new User(); 109 135 $user->username = 'jwage'; … … 111 137 $user->save(); 112 138 113 // getModified() returns the current modified properties and in this case now no propeties are modified. 139 // getModified() returns the current modified properties and in this case 140 now no propeties are modified. 114 141 print_r($user->getModified()); // array() 115 142 … … 120 147 -------------- 121 148 122 [r5031](http://trac.doctrine-project.org/changeset/5031) - A query can now be transformed from an update() or delete() to a select() or any combination. Run a query once to update a field then turn it to a select and execute it. 123 149 [r5031](http://trac.doctrine-project.org/changeset/5031) - A query can now be 150 transformed from an update() or delete() to a select() or any combination. Run a 151 query once to update a field then turn it to a select and execute it. 152 153 [php] 124 154 $q = Doctrine_Query::create() 125 155 ->update('User u') … … 132 162 $user = $q->fetchOne(); 133 163 134 [r5018](http://trac.doctrine-project.org/changeset/5018) - Added `Doctrine::ATTR_AUTO_FREE_QUERY_OBJECTS` for auto freeing query objects after execution 135 164 [r5018](http://trac.doctrine-project.org/changeset/5018) - Added 165 `Doctrine::ATTR_AUTO_FREE_QUERY_OBJECTS` for auto freeing query objects after 166 execution 167 168 [php] 136 169 $manager->setAttribute('auto_free_query_objects'); 137 170 $q = Doctrine_Query::create() … … 139 172 $users = $q->execute(); // $q->free() is triggered 140 173 141 [r5121](http://trac.doctrine-project.org/changeset/5121) - Added new Doctrine_Query_Abstract::getFlattenedParams() to replace Doctrine_Query_Abstract::getParams() and Doctrine_Query_Abstract::getParams() now returns the raw unmodified array of query parameters. 174 [r5121](http://trac.doctrine-project.org/changeset/5121) - Added new 175 Doctrine_Query_Abstract::getFlattenedParams() to replace 176 Doctrine_Query_Abstract::getParams() and Doctrine_Query_Abstract::getParams() 177 now returns the raw unmodified array of query parameters. 142 178 143 179 Doctrine Collection 144 180 ------------------- 145 181 146 [r5032](http://trac.doctrine-project.org/changeset/5032) - You can now convert a Doctrine_Collection in to a key value array made up of the values from the two specified columns. 147 182 [r5032](http://trac.doctrine-project.org/changeset/5032) - You can now convert 183 a Doctrine_Collection in to a key value array made up of the values from the two 184 specified columns. 185 186 [php] 148 187 $q = Doctrine_Query::create() 149 188 ->from('User u'); … … 169 208 ------------------- 170 209 171 [r5033](http://trac.doctrine-project.org/changeset/5033) - You can now specify a unique validator on a set of fields. The argument of the unique() function can either be an array of fields or an argument for each field. 172 210 [r5033](http://trac.doctrine-project.org/changeset/5033) - You can now specify a 211 unique validator on a set of fields. The argument of the unique() function can 212 either be an array of fields or an argument for each field. 213 214 [php] 173 215 public function setTableDefinition() 174 216 { … … 182 224 ---------------------- 183 225 184 In Doctrine 1.1 you now have the ability to register custom validators so that Doctrine is aware of them. You can also get the allowed validators. 226 In Doctrine 1.1 you now have the ability to register custom validators so that 227 Doctrine is aware of them. You can also get the allowed validators. 185 228 186 229 [php] … … 195 238 ---------------- 196 239 197 You now have the ability to configure the Email validator to not check the mx record of the e-mail address. 240 You now have the ability to configure the Email validator to not check the mx 241 record of the e-mail address. 198 242 199 243 [php] … … 211 255 ------------------ 212 256 213 [r5016](http://trac.doctrine-project.org/changeset/5016) - A performance change was made to the hydration process which should yield some improvements when hydrating large result sets. 257 [r5016](http://trac.doctrine-project.org/changeset/5016) - A performance change 258 was made to the hydration process which should yield some improvements when 259 hydrating large result sets. 214 260 215 261 Doctrine Schema Files 216 262 --------------------- 217 263 218 You are now able to pass extra attributes through the YAML schema parser to store any custom column information and you have access to it through the Doctrine_Table. 219 220 --- 264 You are now able to pass extra attributes through the YAML schema parser to 265 store any custom column information and you have access to it through the 266 Doctrine_Table. 267 268 [yml] 221 269 User: 222 270 columns: … … 236 284 Doctrine will now generate phpDoc property tags with the generated base classes. 237 285 238 ---286 [yml] 239 287 User: 240 288 columns: … … 252 300 Generates the following User and Phonenumber class 253 301 302 [php] 254 303 /** 304 * BaseUser 305 * 255 306 * This class has been auto-generated by the Doctrine ORM Framework 256 * 307 * 257 308 * @property string $username 258 309 * @property string $password 259 * @property $Phonenumbers 310 * @property Doctrine_Collection $Phonenumbers 311 * 312 * @package ##PACKAGE## 313 * @subpackage ##SUBPACKAGE## 314 * @author ##NAME## <##EMAIL##> 315 * @version SVN: $Id: Builder.php 5270 2008-12-05 20:47:43Z jwage $ 260 316 */ 261 317 abstract class BaseUser extends Doctrine_Record … … 276 332 277 333 /** 334 * BasePhonenumber 335 * 278 336 * This class has been auto-generated by the Doctrine ORM Framework 279 * 337 * 280 338 * @property integer $user_id 281 339 * @property string $phonenumber 282 * @property $User 340 * @property User $User 341 * 342 * @package ##PACKAGE## 343 * @subpackage ##SUBPACKAGE## 344 * @author ##NAME## <##EMAIL##> 345 * @version SVN: $Id: Builder.php 5270 2008-12-05 20:47:43Z jwage $ 283 346 */ 284 347 abstract class BasePhonenumber extends Doctrine_Record … … 301 364 -------------------- 302 365 303 [r5084](http://trac.doctrine-project.org/changeset/5084) - As of Doctrine 1.1 you are now able to reference relationships defined on the versioned model from the {CLASS}Version auto generated model. 304 366 [r5084](http://trac.doctrine-project.org/changeset/5084) - As of Doctrine 1.1 367 you are now able to reference relationships defined on the versioned model 368 from the {CLASS}Version auto generated model. 369 370 [php] 305 371 // These relationships are defined on the User model but they 306 372 // are copied to the UserVersion model when it is generated. … … 311 377 ->leftJoin('u.Groups g'); 312 378 313 [r5097](http://trac.doctrine-project.org/changeset/5097) - Added ability to disable automatic deleting of versions when a record is deleted 314 379 [r5097](http://trac.doctrine-project.org/changeset/5097) - Added ability to 380 disable automatic deleting of versions when a record is deleted 381 382 [php] 315 383 $this->actAs('Versionable', array('deleteVersions' => false)); 316 384 385 [yml] 317 386 actAs: 318 387 Versionable: 319 388 deleteVersions: false 320 389 321 [r5098](http://trac.doctrine-project.org/changeset/5098) - Added ability to define custom accessors/mutators for a Doctrine record 322 390 [r5098](http://trac.doctrine-project.org/changeset/5098) - Added ability to 391 define custom accessors/mutators for a Doctrine record 392 393 [php] 323 394 public function setTableDefinition() 324 395 { … … 342 413 } 343 414 344 [r5220](http://trac.doctrine-project.org/changeset/5220) - Added ability to define foreign key constraint format to be used when generating tables on database 345 346 Doctrine_Manager::getInstance()->setAttribute(Doctrine::ATTR_FKNAME_FORMAT, '%localtbl_%localcol_%reftbl_%refcol_%i'); // Default is %localtbl_%localcol_%reftbl_%refcol 347 348 [r5236](http://trac.doctrine-project.org/changeset/5236) - Added ability to alias record listeners 349 415 [r5236](http://trac.doctrine-project.org/changeset/5236) - Added ability to 416 alias record listeners 417 418 [php] 350 419 $this->addListener(new My_Listener_FooListener($this->_options), 'FooListener'); 351 420 352 YAML: 353 354 - No aliasing and no options usage: 355 356 Foo: 357 columns: 358 bar: string(50) 359 listeners: [My_Listener_FooListener] 360 361 - No aliasing and using options 362 363 Foo: 364 columns: 365 bar: string(50) 366 listeners: 367 My_Listener_FooListener: 368 useOptions: true 369 370 - Using alias definition 371 372 Foo: 373 columns: 374 bar: string(50) 375 listeners: 376 FooListener: 377 class: My_Listener_FooListener 378 useOptions: true 379 380 381 [r5236](http://trac.doctrine-project.org/changeset/5236) - Added ability to enable/disable record listeners 382 383 - Possibility to remove all listeners of all record listeners 384 385 Doctrine::getTable('Foo')->getRecordListener()->setOption('disabled', true); 386 387 - Possibility to remove some listeners of all record listeners 388 389 Doctrine::getTable('Foo')->getRecordListener()->setOption('disabled', array('preSerialize', 'postHydrate')); 390 391 - Possibility to remove all listeners of a single record listener 392 393 Doctrine::getTable('Foo')->getRecordListener()->get('FooListener')->setOption('disabled', true); 394 395 - Possibility to remove some listeners of a single record listener 396 397 Doctrine::getTable('Foo')->getRecordListener()->get('FooListener')->setOption('disabled', array('preSave', 'postInsert')); 398 399 [r5241](http://trac.doctrine-project.org/changeset/5240) - Added ability to work with mapped values as if they were part of the record. It is useful to store transient data into record (this data is not persisted to database). 400 401 class Foo extends Doctrine_Record { 402 public function setTableDefinition() { 403 $this->mapValue('name'); 404 } 405 406 // ... 407 } 421 No aliasing and no options usage: 422 423 [yml] 424 Foo: 425 columns: 426 bar: string(50) 427 listeners: [My_Listener_FooListener] 428 429 No aliasing and using options 430 431 [yml] 432 Foo: 433 columns: 434 bar: string(50) 435 listeners: 436 My_Listener_FooListener: 437 useOptions: true 438 439 Using alias definition 440 441 [yml] 442 Foo: 443 columns: 444 bar: string(50) 445 listeners: 446 FooListener: 447 class: My_Listener_FooListener 448 useOptions: true 449 450 [r5236](http://trac.doctrine-project.org/changeset/5236) - Added ability to 451 enable/disable record listeners 452 453 Possibility to remove all listeners of all record listeners 454 455 [php] 456 Doctrine::getTable('Foo')->getRecordListener()->setOption('disabled', true); 457 458 Possibility to remove some listeners of all record listeners 459 460 [php] 461 Doctrine::getTable('Foo')->getRecordListener()->setOption('disabled', 462 array('preSerialize', 'postHydrate')); 463 464 Possibility to remove all listeners of a single record listener 465 466 [php] 467 Doctrine::getTable('Foo')->getRecordListener()->get('FooListener') 468 ->setOption('disabled', true); 469 470 Possibility to remove some listeners of a single record listener 471 472 [php] 473 Doctrine::getTable('Foo')->getRecordListener()->get('FooListener') 474 ->setOption('disabled', array('preSave', 'postInsert')); 475 476 [r5241](http://trac.doctrine-project.org/changeset/5240) - Added ability to 477 work with mapped values as if they were part of the record. It is useful to 478 store transient data into record (this data is not persisted to database). 479 480 [php] 481 class Foo extends Doctrine_Record { 482 public function setTableDefinition() { 483 $this->mapValue('name'); 484 } 485 486 // ... 487 } 408 488 409 489 $foo = new Foo(); … … 418 498 In Doctrine 1.1 we have made a few changes to migrations. 419 499 420 * Generated migration classes are prefixed with a timestamp instead of a incremented integer. 421 * Added possibility for automation of up/down methods. 422 * Re-ordered arguments for addColumn() so that type is first before length. 423 * Added `Doctrine_Migration_Diff` tool. 500 * Generated migration classes are prefixed with a timestamp instead of a 501 incremented integer. 502 * Added possibility for automation of up/down methods. 503 * Re-ordered arguments for addColumn() so that type is first before length. 504 * Added `Doctrine_Migration_Diff` tool. 505 506 Here is an example of how you can automate the opposite up or down of a migration 507 api method. 424 508 425 509 [php] … … 429 513 } 430 514 431 The above example will create the column when $direction == up and will remove the column when $direction == down. 515 The above example will create the column when $direction == up and will remove 516 the column when $direction == down. 517 518 SoftDelete 519 ---------- 520 521 In Doctrine 1.1 the SoftDelete behavior was changed slightly to store a `deleted_at` 522 timestamp to indicate a deleted record rather than a `deleted` boolean flag. 523 524 You will need to modify your existing database schema and rename the `deleted` 525 column to `deleted_at` and modify the type to be a timestamp.