Skip to content
Browse files

Removed trailing whitespace, unwanted tabs/spaces and so on...

Now, we will take care of that as well as file permissions.
  • Loading branch information...
1 parent 68f1695 commit aaff75da01a719de4e3d261c13df42625049fba4 @willdurand willdurand committed Aug 11, 2011
Showing with 2,593 additions and 2,593 deletions.
  1. +11 −11 WHATS_NEW
  2. +6 −6 docs/behavior/alternative_coding_standards.txt
  3. +1 −1 docs/behavior/i18n.txt
  4. +5 −5 docs/behavior/nested_set.txt
  5. +4 −4 docs/behavior/query_cache.txt
  6. +4 −4 docs/behavior/sluggable.txt
  7. +1 −1 docs/behavior/soft_delete.txt
  8. +9 −9 docs/behavior/sortable.txt
  9. +1 −1 docs/behavior/versionable.txt
  10. +1 −1 docs/build.xml
  11. +3 −3 docs/cookbook/Advanced-Column-Types.txt
  12. +4 −4 docs/cookbook/Customizing-Build.txt
  13. +1 −1 docs/cookbook/DBDesigner.txt
  14. +1 −1 docs/cookbook/Existing-Database.txt
  15. +1 −1 docs/cookbook/Master-Slave.txt
  16. +10 −10 docs/cookbook/Multi-Component.txt
  17. +4 −4 docs/cookbook/Namespaces.txt
  18. +1 −1 docs/cookbook/Nested-Set.txt
  19. +6 −6 docs/cookbook/Runtime-Introspection.txt
  20. +1 −1 docs/cookbook/Using-SQL-Schemas.txt
  21. +51 −51 docs/cookbook/Writing-Behavior.txt
  22. +1 −1 docs/guide/01-Installation.txt
  23. +4 −4 docs/guide/02-BuildTime.txt
  24. +3 −3 docs/guide/03-Basic-CRUD.txt
  25. +9 −9 docs/guide/04-Relationships.txt
  26. +2 −2 docs/guide/05-Validators.txt
  27. +2 −2 docs/guide/06-Transactions.txt
  28. +8 −8 docs/guide/07-Behaviors.txt
  29. +1 −1 docs/guide/08-Logging.txt
  30. +4 −4 docs/guide/09-Inheritance.txt
  31. +7 −7 docs/guide/10-Migrations.txt
  32. +6 −6 docs/reference/ActiveRecord.txt
  33. +16 −16 docs/reference/Buildtime-Configuration.txt
  34. +28 −28 docs/reference/ModelCriteria.txt
  35. +2 −2 docs/reference/Runtime-Configuration.txt
  36. +5 −5 docs/reference/Schema.txt
  37. +9 −9 generator/bin/propel-gen
  38. +5 −5 generator/build-propel.xml
  39. +17 −17 generator/build.properties-sample
  40. +17 −17 generator/build.xml
  41. +14 −14 generator/build.xml-local
  42. +2 −2 generator/default.properties
  43. +10 −10 generator/lib/behavior/AlternativeCodingStandardsBehavior.php
  44. +3 −3 generator/lib/behavior/AutoAddPkBehavior.php
  45. +7 −7 generator/lib/behavior/TimestampableBehavior.php
  46. +12 −12 generator/lib/behavior/aggregate_column/AggregateColumnBehavior.php
  47. +15 −15 generator/lib/behavior/aggregate_column/AggregateColumnRelationBehavior.php
  48. +1 −1 generator/lib/behavior/aggregate_column/templates/objectCompute.php
  49. +1 −1 generator/lib/behavior/aggregate_column/templates/objectUpdate.php
  50. +12 −12 generator/lib/behavior/concrete_inheritance/ConcreteInheritanceBehavior.php
  51. +7 −7 generator/lib/behavior/concrete_inheritance/ConcreteInheritanceParentBehavior.php
  52. +17 −17 generator/lib/behavior/i18n/I18nBehavior.php
  53. +9 −9 generator/lib/behavior/i18n/I18nBehaviorObjectBuilderModifier.php
  54. +2 −2 generator/lib/behavior/i18n/I18nBehaviorPeerBuilderModifier.php
  55. +4 −4 generator/lib/behavior/i18n/I18nBehaviorQueryBuilderModifier.php
  56. +1 −1 generator/lib/behavior/i18n/templates/objectGetCurrentTranslation.php
  57. +1 −1 generator/lib/behavior/i18n/templates/objectGetTranslation.php
  58. +1 −1 generator/lib/behavior/i18n/templates/objectSetLocale.php
  59. +1 −1 generator/lib/behavior/i18n/templates/objectSetTranslation.php
  60. +1 −1 generator/lib/behavior/i18n/templates/objectTranslatedColumnGetter.php
  61. +2 −2 generator/lib/behavior/i18n/templates/objectTranslatedColumnSetter.php
  62. +1 −1 generator/lib/behavior/i18n/templates/queryJoinI18n.php
  63. +1 −1 generator/lib/behavior/i18n/templates/queryJoinWithI18n.php
  64. +1 −1 generator/lib/behavior/i18n/templates/queryUseI18nQuery.php
  65. +5 −5 generator/lib/behavior/nestedset/NestedSetBehavior.php
  66. +73 −73 generator/lib/behavior/nestedset/NestedSetBehaviorObjectBuilderModifier.php
  67. +22 −22 generator/lib/behavior/nestedset/NestedSetBehaviorPeerBuilderModifier.php
  68. +10 −10 generator/lib/behavior/nestedset/NestedSetBehaviorQueryBuilderModifier.php
  69. +14 −14 generator/lib/behavior/query_cache/QueryCacheBehavior.php
  70. +15 −15 generator/lib/behavior/sluggable/SluggableBehavior.php
  71. +3 −3 generator/lib/behavior/sortable/SortableBehavior.php
  72. +22 −22 generator/lib/behavior/sortable/SortableBehaviorObjectBuilderModifier.php
  73. +20 −20 generator/lib/behavior/sortable/SortableBehaviorPeerBuilderModifier.php
  74. +14 −14 generator/lib/behavior/sortable/SortableBehaviorQueryBuilderModifier.php
  75. +12 −12 generator/lib/behavior/versionable/VersionableBehavior.php
  76. +15 −15 generator/lib/behavior/versionable/VersionableBehaviorObjectBuilderModifier.php
  77. +4 −4 generator/lib/behavior/versionable/VersionableBehaviorPeerBuilderModifier.php
  78. +9 −9 generator/lib/behavior/versionable/VersionableBehaviorQueryBuilderModifier.php
  79. +13 −13 generator/lib/builder/DataModelBuilder.php
  80. +1 −1 generator/lib/builder/om/ExtensionQueryBuilder.php
  81. +2 −2 generator/lib/builder/om/ExtensionQueryInheritanceBuilder.php
  82. +21 −21 generator/lib/builder/om/OMBuilder.php
  83. +1 −1 generator/lib/builder/om/ObjectBuilder.php
  84. +2 −2 generator/lib/builder/om/PHP5NestedSetPeerBuilder.php
  85. +5 −5 generator/lib/builder/om/PHP5NodeBuilder.php
  86. +3 −3 generator/lib/builder/om/PHP5NodePeerBuilder.php
  87. +12 −12 generator/lib/builder/om/PHP5ObjectBuilder.php
  88. +12 −12 generator/lib/builder/om/PHP5ObjectNoCollectionBuilder.php
  89. +41 −41 generator/lib/builder/om/PHP5PeerBuilder.php
  90. +4 −4 generator/lib/builder/om/PHP5TableMapBuilder.php
  91. +6 −6 generator/lib/builder/om/PeerBuilder.php
  92. +1,267 −1,267 generator/lib/builder/om/QueryBuilder.php
  93. +10 −10 generator/lib/builder/om/QueryInheritanceBuilder.php
  94. +6 −6 generator/lib/builder/util/PropelStringReader.php
  95. +7 −7 generator/lib/builder/util/PropelTemplate.php
  96. +7 −7 generator/lib/builder/util/StandardEnglishPluralizer.php
  97. +6 −6 generator/lib/builder/util/XmlToAppData.php
  98. +7 −7 generator/lib/config/GeneratorConfig.php
  99. +1 −1 generator/lib/config/GeneratorConfigInterface.php
  100. +21 −21 generator/lib/config/QuickGeneratorConfig.php
  101. +14 −14 generator/lib/model/AppData.php
  102. +24 −24 generator/lib/model/Behavior.php
  103. +25 −25 generator/lib/model/Column.php
  104. +2 −2 generator/lib/model/ColumnDefaultValue.php
  105. +17 −17 generator/lib/model/Database.php
  106. +9 −9 generator/lib/model/ForeignKey.php
  107. +3 −3 generator/lib/model/Index.php
  108. +1 −1 generator/lib/model/NameFactory.php
  109. +5 −5 generator/lib/model/NameGenerator.php
  110. +4 −4 generator/lib/model/PhpNameGenerator.php
  111. +2 −2 generator/lib/model/PropelTypes.php
  112. +1 −1 generator/lib/model/ScopedElement.php
  113. +33 −33 generator/lib/model/Table.php
  114. +1 −1 generator/lib/model/VendorInfo.php
  115. +3 −3 generator/lib/model/XMLElement.php
  116. +5 −5 generator/lib/model/diff/PropelColumnComparator.php
  117. +12 −12 generator/lib/model/diff/PropelColumnDiff.php
  118. +10 −10 generator/lib/model/diff/PropelDatabaseComparator.php
  119. +8 −8 generator/lib/model/diff/PropelDatabaseDiff.php
  120. +6 −6 generator/lib/model/diff/PropelForeignKeyComparator.php
  121. +3 −3 generator/lib/model/diff/PropelIndexComparator.php
  122. +20 −20 generator/lib/model/diff/PropelTableComparator.php
  123. +13 −13 generator/lib/model/diff/PropelTableDiff.php
  124. +41 −41 generator/lib/platform/DefaultPlatform.php
  125. +16 −16 generator/lib/platform/MysqlPlatform.php
  126. +21 −21 generator/lib/platform/PgsqlPlatform.php
  127. +3 −3 generator/lib/platform/PropelPlatformInterface.php
  128. +5 −5 generator/lib/platform/SqlitePlatform.php
  129. +6 −6 generator/lib/reverse/BaseSchemaParser.php
  130. +15 −15 generator/lib/reverse/mysql/MysqlSchemaParser.php
  131. +23 −23 generator/lib/reverse/oracle/OracleSchemaParser.php
  132. +2 −2 generator/lib/reverse/pgsql/PgsqlSchemaParser.php
  133. +1 −1 generator/lib/reverse/sqlite/SqliteSchemaParser.php
  134. +10 −10 generator/lib/task/AbstractPropelDataModelTask.php
  135. +6 −6 generator/lib/task/BasePropelMigrationTask.php
  136. +19 −19 generator/lib/task/PropelConvertConfTask.php
  137. +8 −8 generator/lib/task/PropelMigrationDownTask.php
  138. +5 −5 generator/lib/task/PropelMigrationStatusTask.php
  139. +4 −4 generator/lib/task/PropelMigrationTask.php
  140. +6 −6 generator/lib/task/PropelMigrationUpTask.php
  141. +8 −8 generator/lib/task/PropelOMTask.php
  142. +9 −9 generator/lib/task/PropelSQLDiffTask.php
  143. +9 −9 generator/lib/task/PropelSQLExec.php
  144. +5 −5 generator/lib/task/PropelSQLTask.php
  145. +3 −3 generator/lib/task/PropelSchemaReverseTask.php
  146. +18 −18 generator/lib/util/PropelPHPParser.php
  147. +17 −17 generator/lib/util/PropelQuickBuilder.php
  148. +19 −19 generator/lib/util/PropelSQLParser.php
  149. +2 −2 generator/pear/BuildPropelGenPEARPackageTask.php
Sorry, we could not display the entire diff because too many files (360) changed.
View
22 WHATS_NEW
@@ -70,7 +70,7 @@ $page = new WikiPage();
// automatic version increment
$page->setTitle('Propel');
$page->setBody('Propel is a CRM built in PHP');
-$page->save();
+$page->save();
echo $page->getVersion(); // 1
$page->setBody('Propel is an ORM built in PHP5');
$page->save();
@@ -338,7 +338,7 @@ echo $authors;
}}}
If you want to use another format for the default string representation instead of YAML, you can set the `defaultStringFormat` attribute to any of the supported formats in either the `<database>` or the `<table>` elements in the XML schema:
-
+
{{{
#!xml
<table name="publisher" defaultStringFormat="XML">
@@ -543,7 +543,7 @@ To enable a model-only relationship, add a `<foreign-key>` tag using the `skipSq
</table>
}}}
-Such a foreign key is not translated into SQL when Propel builds the table creation or table migration code. It can be seen as a "virtual foreign key". However, on the PHP side, the `Book` model actually has a one-to-many relationship with the `Review` model. The generated !ActiveRecord and !ActiveQuery classes take advantage of this relationship to offer smart getters and filters.
+Such a foreign key is not translated into SQL when Propel builds the table creation or table migration code. It can be seen as a "virtual foreign key". However, on the PHP side, the `Book` model actually has a one-to-many relationship with the `Review` model. The generated !ActiveRecord and !ActiveQuery classes take advantage of this relationship to offer smart getters and filters.
== Advanced Column Types ==
@@ -595,13 +595,13 @@ An `OBJECT` column can store PHP objects (mostly Value Objects) in the database.
class GeographicCoordinates
{
public $latitude, $longitude;
-
+
public function __construct($latitude, $longitude)
{
$this->latitude = $latitude;
$this->longitude = $longitude;
}
-
+
public function isInNorthernHemisphere()
{
return $this->latitude > 0;
@@ -685,21 +685,21 @@ SQL supports table subqueries to solve complex cases that a single query can't s
{{{
#!sql
-SELECT book.ID, book.TITLE, book.AUTHOR_ID, book.PRICE, book.CREATED_AT, MAX(book.CREATED_AT)
-FROM book
+SELECT book.ID, book.TITLE, book.AUTHOR_ID, book.PRICE, book.CREATED_AT, MAX(book.CREATED_AT)
+FROM book
GROUP BY book.AUTHOR_ID
}}}
Now if you want only the cheapest latest books with a single query, you need a subquery:
{{{
#!sql
-SELECT lastBook.ID, lastBook.TITLE, lastBook.AUTHOR_ID, lastBook.PRICE, lastBook.CREATED_AT
+SELECT lastBook.ID, lastBook.TITLE, lastBook.AUTHOR_ID, lastBook.PRICE, lastBook.CREATED_AT
FROM
(
- SELECT book.ID, book.TITLE, book.AUTHOR_ID, book.PRICE, book.CREATED_AT, MAX(book.CREATED_AT)
- FROM book
+ SELECT book.ID, book.TITLE, book.AUTHOR_ID, book.PRICE, book.CREATED_AT, MAX(book.CREATED_AT)
+ FROM book
GROUP BY book.AUTHOR_ID
-) AS lastBook
+) AS lastBook
WHERE lastBook.PRICE < 20
}}}
View
12 docs/behavior/alternative_coding_standards.txt
@@ -24,7 +24,7 @@ Rebuild your model, and you're ready to go. The code of the model classes now us
// in om/BaseBook.php
/**
* Set the value of [title] column.
- *
+ *
* @param string $v new value
* @return Table4 The current object (for fluent API support)
*/
@@ -34,21 +34,21 @@ Rebuild your model, and you're ready to go. The code of the model classes now us
{
$v = (string) $v;
}
-
+
if ($this->title !== $v)
{
$this->title = $v;
$this->modifiedColumns[] = BookPeer::TITLE;
}
-
+
return $this;
}
-
-// instead of
+
+// instead of
/**
* Set the value of [title] column.
- *
+ *
* @param string $v new value
* @return Table4 The current object (for fluent API support)
*/
View
2 docs/behavior/i18n.txt
@@ -166,7 +166,7 @@ $items = ItemQuery::create()
== Symfony Compatibility ==
-This behavior is entirely compatible with the i18n behavior for symfony. That means that it can generate `setCulture()` and `getCulture()` methods as aliases to `setLocale()` and `getLocale()`, provided that you add a `locale_alias` parameter. That also means that if you add the behavior to a table without translated columns, and that the translation table is present in the schema, the behavior recognizes them.
+This behavior is entirely compatible with the i18n behavior for symfony. That means that it can generate `setCulture()` and `getCulture()` methods as aliases to `setLocale()` and `getLocale()`, provided that you add a `locale_alias` parameter. That also means that if you add the behavior to a table without translated columns, and that the translation table is present in the schema, the behavior recognizes them.
So the following schema is exactly equivalent to the first one in this tutorial:
View
10 docs/behavior/nested_set.txt
@@ -2,7 +2,7 @@
[[PageOutline]]
-The `nested_set` behavior allows a model to become a tree structure, and provides numerous methods to traverse the tree in an efficient way.
+The `nested_set` behavior allows a model to become a tree structure, and provides numerous methods to traverse the tree in an efficient way.
Many applications need to store hierarchical data in the model. For instance, a forum stores a tree of messages for each discussion. A CMS sees sections and subsections as a navigation tree. In a business organization chart, each person is a leaf of the organization tree. [http://en.wikipedia.org/wiki/Nested_set_model Nested sets] are the best way to store such hierachical data in a relational database and manipulate it. The name "nested sets" describes the algorithm used to store the position of a model in the tree ; it is also known as "modified preorder tree traversal".
@@ -18,7 +18,7 @@ In the `schema.xml`, use the `<behavior>` tag to add the `nested_set` behavior t
</table>
}}}
-Rebuild your model, insert the table creation sql again, and you're ready to go. The model now has the ability to be inserted into a tree structure, as follows:
+Rebuild your model, insert the table creation sql again, and you're ready to go. The model now has the ability to be inserted into a tree structure, as follows:
{{{
#!php
@@ -105,12 +105,12 @@ $s2->moveToFirstChildOf($s4);
| \
$s4:Business $s3:Europe
|
-$s2:World
+$s2:World
*/
}}}
You can delete the descendants of a node using `deleteDescendants()`:
-
+
{{{
#!php
<?php
@@ -193,7 +193,7 @@ foreach ($root->getIterator() as $node) {
}
}}}
-The iterator parses the tree in a recursive way by retrieving the children of every node. This can be quite effective on very large trees, since the iterator hydrates only a few objects at a time.
+The iterator parses the tree in a recursive way by retrieving the children of every node. This can be quite effective on very large trees, since the iterator hydrates only a few objects at a time.
Beware, though, that the iterator executes many queries to parse a tree. On smaller trees, prefer the `getBranch()` method to execute only one query, and hydrate all records at once:
View
8 docs/behavior/query_cache.txt
@@ -69,17 +69,17 @@ class BookQuery extends BaseBookQuery
{
return $this->getCacheBackend()->test($key);
}
-
+
public function cacheFetch($key)
{
return $this->getCacheBackend()->load($key);
}
-
+
public function cacheStore($key, $value)
{
return $this->getCacheBackend()->save($key, $value);
}
-
+
protected function getCacheBackend()
{
if (self::$cacheBackend === null) {
@@ -98,7 +98,7 @@ class BookQuery extends BaseBookQuery
);
self::$cacheBackend = Zend_Cache::factory('Core', 'Memcached', $frontendOptions, $backendOptions);
}
-
+
return self::$cacheBackend;
}
}
View
8 docs/behavior/sluggable.txt
@@ -114,22 +114,22 @@ The slug is generated by the object when it is saved, via the `createSlug()` met
protected function createSlug()
{
// create the slug based on the `slug_pattern` and the object properties
- $slug = $this->createRawSlug();
+ $slug = $this->createRawSlug();
// truncate the slug to accomodate the size of the slug column
$slug = $this->limitSlugSize($slug);
// add an incremental index to make sure the slug is unique
$slug = $this->makeSlugUnique($slug);
-
+
return $slug;
}
protected function createRawSlug()
{
// here comes the string composition code, generated according to `slug_pattern`
$slug = 'posts/' . $this->cleanupSlugPart($this->getTitle());
- // cleanupSlugPart() cleans up the slug part
+ // cleanupSlugPart() cleans up the slug part
// based on the `replace_pattern` and `replacement` parameters
-
+
return $slug;
}
}}}
View
2 docs/behavior/soft_delete.txt
@@ -55,7 +55,7 @@ echo $book->getTitle(); // 'War And Peace'
Note that `find()` and other selection methods automatically re-enable the `soft_delete` filter, so `disableSoftDelete()` is really a single shot method. You can also enable the query alteration manually by calling the `enableSoftDelete()` method on Query objects.
-'''Tip''': `ModelCriteria::paginate()` executes two queries, so `disableSoftDelete()` doesn't work in this case. Prefer `includeDeleted()` in queries using `paginate()`.
+'''Tip''': `ModelCriteria::paginate()` executes two queries, so `disableSoftDelete()` doesn't work in this case. Prefer `includeDeleted()` in queries using `paginate()`.
If you want to recover a deleted object, use the `unDelete()` method:
View
18 docs/behavior/sortable.txt
@@ -2,7 +2,7 @@
[[PageOutline]]
-The `sortable` behavior allows a model to become an ordered list, and provides numerous methods to traverse this list in an efficient way.
+The `sortable` behavior allows a model to become an ordered list, and provides numerous methods to traverse this list in an efficient way.
== Basic Usage ==
@@ -16,7 +16,7 @@ In the `schema.xml`, use the `<behavior>` tag to add the `sortable` behavior to
</table>
}}}
-Rebuild your model, insert the table creation sql again, and you're ready to go. The model now has the ability to be inserted into an ordered list, as follows:
+Rebuild your model, insert the table creation sql again, and you're ready to go. The model now has the ability to be inserted into an ordered list, as follows:
{{{
#!php
@@ -47,7 +47,7 @@ $secondTask = $firstTask->getNext(); // $t2
$lastTask = $secondTask->getNext(); // $t3
$secondTask = $lastTask->getPrevious(); // $t2
-$allTasks = TaskQuery::create()->findList();
+$allTasks = TaskQuery::create()->findList();
// => collection($t1, $t2, $t3)
$allTasksInReverseOrder = TaskQuery::create()->orderByRank('desc')->find();
// => collection($t3, $t2, $t2)
@@ -70,13 +70,13 @@ You can move an object in the list using any of the `moveUp()`, `moveDown()`, `m
{{{
#!php
<?php
-// The list is 1 - Wash the dishes, 2 - Do the laundry, 3 - Rest a little
+// The list is 1 - Wash the dishes, 2 - Do the laundry, 3 - Rest a little
$t2->moveToTop();
// The list is now 1 - Do the laundry, 2 - Wash the dishes, 3 - Rest a little
$t2->moveToBottom();
// The list is now 1 - Wash the dishes, 2 - Rest a little, 3 - Do the laundry
$t2->moveUp();
-// The list is 1 - Wash the dishes, 2 - Do the laundry, 3 - Rest a little
+// The list is 1 - Wash the dishes, 2 - Do the laundry, 3 - Rest a little
$t2->swapWith($t1);
// The list is now 1 - Do the laundry, 2 - Wash the dishes, 3 - Rest a little
$t2->moveToRank(3);
@@ -85,16 +85,16 @@ $t2->moveToRank(2);
}}}
By default, new objects are added at the bottom of the list. But you can also insert them at a specific position, using any of the `insertAtTop(), `insertAtBottom()`, and `insertAtRank()` methods. Note that the `insertAtXXX` methods don't save the object:
-
+
{{{
#!php
<?php
-// The list is 1 - Wash the dishes, 2 - Do the laundry, 3 - Rest a little
+// The list is 1 - Wash the dishes, 2 - Do the laundry, 3 - Rest a little
$t4 = new Task();
$t4->setTitle('Clean windows');
$t4->insertAtRank(2);
$t4->save();
-// The list is now 1 - Wash the dishes, 2 - Clean Windows, 3 - Do the laundry, 4 - Rest a little
+// The list is now 1 - Wash the dishes, 2 - Clean Windows, 3 - Do the laundry, 4 - Rest a little
}}}
Whenever you `delete()` an object, the ranks are rearranged to fill the gap:
@@ -103,7 +103,7 @@ Whenever you `delete()` an object, the ranks are rearranged to fill the gap:
#!php
<?php
$t4->delete();
-// The list is now 1 - Wash the dishes, 2 - Do the laundry, 3 - Rest a little
+// The list is now 1 - Wash the dishes, 2 - Do the laundry, 3 - Rest a little
}}}
'''Tip''': You can remove an object from the list without necessarily deleting it by calling `removeFromList()`. Don't forget to `save()` it afterwards so that the other objects in the lists are rearranged to fill the gap.
View
2 docs/behavior/versionable.txt
@@ -29,7 +29,7 @@ $book = new Book();
// automatic version increment
$book->setTitle('War and Peas');
-$book->save();
+$book->save();
echo $book->getVersion(); // 1
$book->setTitle('War and Peace');
$book->save();
View
2 docs/build.xml
@@ -7,7 +7,7 @@
<phingcall target="phpdoc-runtime"/>
<phingcall target="phpdoc-generator"/>
</target>
-
+
<target name="phpdoc-runtime" description="build runtime docs">
<phpdoc title="Propel Runtime" destdir="api/runtime" sourcecode="yes" output="HTML:Smarty:PHP">
<fileset dir="${runtime.dir}/lib">
View
6 docs/cookbook/Advanced-Column-Types.txt
@@ -110,13 +110,13 @@ Propel offers an `OBJECT` column type to store PHP objects in the database. The
class GeographicCoordinates
{
public $latitude, $longitude;
-
+
public function __construct($latitude, $longitude)
{
$this->latitude = $latitude;
$this->longitude = $longitude;
}
-
+
public function isInNorthernHemisphere()
{
return $this->latitude > 0;
@@ -198,4 +198,4 @@ $books = BookQuery::create()
'''Tip''': Filters on array columns translate to SQL as LIKE conditions. That means that the resulting query often requires a full table scan, and is not suited for large tables.
-'''Warning''': Only generated Query classes (through generated `filterByXXX()` methods) and `ModelCriteria` (through `where()`, and `condition()`) allow conditions on `ENUM`, `OBJECT`, and `ARRAY` columns. `Criteria` alone (through `add()`, `addAnd()`, and `addOr()`) does not support conditions on such columns.
+'''Warning''': Only generated Query classes (through generated `filterByXXX()` methods) and `ModelCriteria` (through `where()`, and `condition()`) allow conditions on `ENUM`, `OBJECT`, and `ARRAY` columns. `Criteria` alone (through `add()`, `addAnd()`, and `addOr()`) does not support conditions on such columns.
View
8 docs/cookbook/Customizing-Build.txt
@@ -83,7 +83,7 @@ Or, for maximum re-usability, you can create a ''<path>'' object, and then refer
<path id="propelclasses">
<pathelement dir="/path/to/propel-generator/classes"/>
</path>
-
+
<taskdef
name="propel-om"
classname="propel.phing.PropelOMTask"
@@ -112,7 +112,7 @@ Now that we've seen the essential elements of our custom build file, it's time t
{{{
<?xml version="1.0">
<project name="propel" default="om">
-
+
<!-- set properties we use later -->
<property name="propelgen.home" value="/path/to/propel-generator"/>
<property name="out.dir" value="/var/www/bookstore"/>
@@ -121,13 +121,13 @@ Now that we've seen the essential elements of our custom build file, it's time t
<path id="propelclasses">
<pathelement dir="${propelgen.home}/classes"/>
</path>
-
+
<taskdef
name="propel-om"
classname="propel.phing.PropelOMTask"
classpathRef="propelclasses"/>
-
+
<!-- this [default] target performs the work -->
<target name="om" description="build propel om">
<propel-om
View
2 docs/cookbook/DBDesigner.txt
@@ -35,4 +35,4 @@ propel.dbd2propel.dir = ${propel.project.dir}/dbd
propel.dbd2propel.includes = *.xml
# XSLT used to transform DBDesigner files to Propel schemas
propel.dbd2propel.xsl.file = ${propel.home}/resources/xsl/dbd2propel.xsl
-}}}
+}}}
View
2 docs/cookbook/Existing-Database.txt
@@ -25,7 +25,7 @@ propel.database = mysql
# This must be a PDO DSN
propel.database.url = mysql:dbname=legacyapp
propel.database.user = root
-# propel.database.password =
+# propel.database.password =
}}}
1. Run the `reverse` task to generate the `schema.xml`:
{{{
View
2 docs/cookbook/Master-Slave.txt
@@ -1,6 +1,6 @@
= Replication =
-Propel can be used in a master-slave replication environment. These environments are set up to improve the performance of web applications by dispatching the database-load to multiple database-servers. While a single master database is responsible for all write-queries, multiple slave-databases handle the read-queries. The slaves are synchronised with the master by a fast binary log (depending on the database).
+Propel can be used in a master-slave replication environment. These environments are set up to improve the performance of web applications by dispatching the database-load to multiple database-servers. While a single master database is responsible for all write-queries, multiple slave-databases handle the read-queries. The slaves are synchronised with the master by a fast binary log (depending on the database).
== Configuring Propel for Replication ==
View
20 docs/cookbook/Multi-Component.txt
@@ -7,7 +7,7 @@ Propel comes along with packaging capabilities that allow you to more easily int
You can use as many `schema.xml` files as you want. Schema files have to be named `(*.)schema.xml`, so names like `schema.xml`, `package1.schema.xml`, `core.package1.schema.xml` are all acceptable. These files ''have'' to be located in your project directory.
Each schema file has to contain a `<database>` element with a `name` attribute. This name references the connection settings to be used for this database (and configured in the `runtime-conf.xml`), so separated schemas can share a common database name.
-
+
Whenever you call a propel build taks, Propel will consider all these schema files and build the classes (or the SQL) for all the tables.
== Understanding Packages ==
@@ -26,7 +26,7 @@ propel.targetPackage = my_project
}}}
By default, all the tables of all the schemas in the project use this package. However, you can override the package for a given `<database>` by setting its `package` attribute:
-
+
{{{
#!xml
<!-- in author.schema.xml -->
@@ -55,7 +55,7 @@ In this example, thanks to the `package` attribute, the tables are grouped into
'''Warning''': If you separate tables related by a foreign key into separate packages (like `book` and `author` in this example), you must enable the `packageObjectModel` build property to let Propel consider other packages for relations.
You can also override the `package` attribute at the `<table>` element level.
-
+
{{{
#!xml
<!-- in author.schema.xml -->
@@ -84,11 +84,11 @@ This ends up in the following package:
Notice that tables can end up in separated packages even though they belong to the same schema file.
-'''Tip''': You can use dots in a package name to add more package levels.
+'''Tip''': You can use dots in a package name to add more package levels.
=== Packages and Generated Model Files ===
-The `package` attribute of a table translates to the directory in which Propel generates the Model classes for this table.
+The `package` attribute of a table translates to the directory in which Propel generates the Model classes for this table.
For instance, if no `package` attribute is defined at the database of table level, Propel places all classes according to the `propel.targetPackage` from the `build.properties`:
@@ -109,7 +109,7 @@ build/
ReviewQuery.php
}}}
-You can further tweak the location where Propel puts the created files by changing the `propel.output.dir` build property. By default this property is set to:
+You can further tweak the location where Propel puts the created files by changing the `propel.output.dir` build property. By default this property is set to:
{{{
#!ini
@@ -180,7 +180,7 @@ build/
}}}
If you specialize the `package` for each `<database>` element, Propel uses it for SQL files:
-
+
{{{
build/
sql/
@@ -198,7 +198,7 @@ build/
review.schema.sql // contains CREATE TABLE review
}}}
-== Understanding The packageObjectModel Build Property ==
+== Understanding The packageObjectModel Build Property ==
The `propel.packageObjectModel` build property enables the "packaged" build process. This modifies the build tasks behavior by joining `<database>` elements of the same name - but keeping their packages separate. That allows to split a large schema into several files, regardless of foreign key dependencies, since Propel will join all schemas using the same database name.
@@ -219,7 +219,7 @@ In the bookstore-packaged example you'll find the following schema files:
* review.schema.xml
* log.schema.xml
-Each schema file has to contain a `<database>` tag that has its `package` attribute set to the package name where ''all'' of the tables in this schema file/database belong to.
+Each schema file has to contain a `<database>` tag that has its `package` attribute set to the package name where ''all'' of the tables in this schema file/database belong to.
For example, in the bookstore-packaged example the `author.schema.xml` contains the following `<database>` tag:
@@ -287,7 +287,7 @@ Then, have a look at the `build/sql/` directory: you will see that for each pack
* core.publisher.schema.sql
* core.review.schema.sql
* util.log.schema.sql
-
+
These files contain the CREATE TABLE SQL statements necessary for each package.
When you now run the insert-sql task by typing:
View
8 docs/cookbook/Namespaces.txt
@@ -49,8 +49,8 @@ Here is an example schema using namespaces:
</database>
}}}
-The `<database>` element defines a `namespace` attribute. The `book` and `author` tables inherit their namespace from the database, therefore the generated classes for these tables will be `\Bookstore\Book` and `\Bookstore\Author`.
-
+The `<database>` element defines a `namespace` attribute. The `book` and `author` tables inherit their namespace from the database, therefore the generated classes for these tables will be `\Bookstore\Book` and `\Bookstore\Author`.
+
The `publisher` table defines a `namespace` attribute on ots own, which ''extends'' the database namespace. That means that the generated class will be `\Bookstore\Book\Publisher`.
As for the `user` table, it defines an absolute namespace (starting with a backslash), which ''overrides'' the database namespace. The generated class for the `user` table will be `Admin\User`.
@@ -111,10 +111,10 @@ echo get_class($book->getPublisher());
== Using Namespaces As A Directory Structure ==
In a schema, you can define a `package` attribute on a `<database>` or a `<table>` tag to generate model classes in a subdirectory (see [wiki:Documentation/1.6/Multi-Component]). If you use namespaces to autoload your classes based on a SplClassAutoloader (see http://groups.google.com/group/php-standards), then you may find yourself repeating the `namespace` data in the `package` attribute:
-
+
{{{
#!xml
-<database name="bookstore" defaultIdMethod="native"
+<database name="bookstore" defaultIdMethod="native"
namespace="Foo/Bar" package="Foo.Bar">
}}}
View
2 docs/cookbook/Nested-Set.txt
@@ -164,7 +164,7 @@ foreach($it as $m) {
}}}
=== Tree traversal ===
-!NestetSet implementation use the [http://somabo.de/talks/200504_php_quebec_spl_for_the_masses.pdf SPL RecursiveIterator] as suggested by soenke
+!NestetSet implementation use the [http://somabo.de/talks/200504_php_quebec_spl_for_the_masses.pdf SPL RecursiveIterator] as suggested by soenke
== !NestedSet known broken behaviour ==
View
12 docs/cookbook/Runtime-Introspection.txt
@@ -12,7 +12,7 @@ To retrieve a table map for a table, use the `getTableMap()` static method of th
{{{
#!php
-<?php
+<?php
$bookTable = BookPeer::getTableMap();
}}}
@@ -22,7 +22,7 @@ A `TableMap` object carries the same information as the schema. Check the follow
{{{
#!php
-<?php
+<?php
echo $bookTable->getName(); // 'table'
echo $bookTable->getPhpName(); // 'Table'
echo $bookTable->getPackage(); // 'bookstore'
@@ -32,7 +32,7 @@ echo $bookTable->isUseIdGenerator(); // true
Tip: A TableMap object also references the `DatabaseMap` that contains it. From the database map, you can also retrieve other table maps using the table name or the table phpName:
{{{
#!php
-<?php
+<?php
$dbMap = $bookTable->getDatabaseMap();
$authorTable = $dbMap->getTable('author');
$authorTable = $dbMap->getTablebyPhpName('Author');
@@ -42,7 +42,7 @@ To introspect the columns of a table, use any of the `getColumns()`, `getPrimary
{{{
#!php
-<?php
+<?php
$bookColumns = $bookTable->getColumns();
foreach ($bookColumns as $column) {
echo $column->getName();
@@ -53,14 +53,14 @@ Alternatively, if you know a column name, you can retrieve the corresponding Col
{{{
#!php
-<?php
+<?php
$bookTitleColumn = $bookTable->getColumn('title');
}}}
The `DatabaseMap` object offers a shortcut to every `ColumnMap` object if you know the fully qualified column name:
{{{
#!php
-<?php
+<?php
$bookTitleColumn = $dbMap->getColumn('book.TITLE');
}}}
View
2 docs/cookbook/Using-SQL-Schemas.txt
@@ -21,7 +21,7 @@ In a XML schema, you can assign all the tables included into a `<database>` tag
'''Tip''': On RDBMS that do not support SQL schemas (Oracle, SQLite), the `schema` attribute is ignored.
You can also assign a table to a given schema individually ; this overrides the `schema` of the parent `<database>`:
-
+
{{{
#!xml
<table name="book" schema="bookstore1">
View
102 docs/cookbook/Writing-Behavior.txt
@@ -2,14 +2,14 @@
[[PageOutline]]
-Behaviors are a good way to reuse code across models without requiring inheritance (a.k.a. horizontal reuse). This step-by-step tutorial explains how to port model code to a behavior, focusing on a simple example.
+Behaviors are a good way to reuse code across models without requiring inheritance (a.k.a. horizontal reuse). This step-by-step tutorial explains how to port model code to a behavior, focusing on a simple example.
In the tutorial "[http://propel.posterous.com/getting-to-know-propel-15-keeping-an-aggregat Keeping an Aggregate Column up-to-date]", posted in the [http://propel.posterous.com/ Propel blog], the `TotalNbVotes` property of a `PollQuestion` object was updated each time a related `PollAnswer` object was saved, edited, or deleted. This "aggregate column" behavior was implemented by hand using hooks in the model classes. To make it truly reusable, the custom model code needs to be refactored and moved to a Behavior class.
-
+
== Boostrapping A Behavior ==
-
+
A behavior is a class that can alter the generated classes for a table of your model. It must only extend the [browser:branches/1.6/generator/lib/model/Behavior.php `Behavior`] class and implement special "hook" methods. Here is the class skeleton to start with for the `aggregate_column` behavior:
-
+
{{{
#!php
<?php
@@ -21,16 +21,16 @@ class AggregateColumnBehavior extends Behavior
);
}
}}}
-
+
Save this class in a file called `AggregateColumnBehavior.php`, and set the path for the class file in the project `build.properties` (just replace directory separators with dots). Remember that the `build.properties` paths are relative to the include path:
-
+
{{{
#!ini
propel.behavior.aggregate_column.class = path.to.AggregateColumnBehavior
}}}
-
+
Test the behavior by adding it to a table of your model, for instance to a `poll_question` table:
-
+
{{{
#!xml
<database name="poll" defaultIdMethod="native">
@@ -43,9 +43,9 @@ Test the behavior by adding it to a table of your model, for instance to a `poll
</table>
</database>
}}}
-
+
Rebuild your model, and check the generated `PollQuestionTableMap` class under the `map` subdirectory of your build class directory. This class carries the structure metadata for the `PollQuestion` ActiveRecord class at runtime. The class should feature a `getBehaviors()` method as follows, proving that the behavior was correctly applied:
-
+
{{{
#!php
<?php
@@ -61,11 +61,11 @@ class PollQuestionTableMap extends TableMap
} // getBehaviors()
}
}}}
-
+
== Adding A Column ==
-
+
The behavior works, but it still does nothing at all. Let's make it useful by allowing it to add a column. In the `AggregateColumnBehavior` class, just implement the `modifyTable()` method with the following code:
-
+
{{{
#!php
<?php
@@ -78,7 +78,7 @@ class AggregateColumnBehavior extends Behavior
$table = $this->getTable();
if (!$columnName = $this->getParameter('name')) {
throw new InvalidArgumentException(sprintf(
- 'You must define a \'name\' parameter for the \'aggregate_column\' behavior in the \'%s\' table',
+ 'You must define a \'name\' parameter for the \'aggregate_column\' behavior in the \'%s\' table',
$table->getName()
));
}
@@ -92,13 +92,13 @@ class AggregateColumnBehavior extends Behavior
}
}
}}}
-
+
This method shows that a behavior class has access to the `<parameters>` defined for it in the `schema.xml` through the `getParameter()` command. Behaviors can also always access the `Table` object attached to them, by calling `getTable()`. A `Table` can check if a column exists and add a new one easily. The `Table` class is one of the numerous generator classes that serve to describe the object model at buildtime, together with `Column`, `ForeignKey`, `Index`, and a lot more classes. You can find all the buildtime model classes under the [browser:branches/1.6/generator/lib/model generator/lib/model] directory.
'''Tip''': Don't mix up the ''runtime'' database model (`DatabaseMap`, `TableMap`, `ColumnMap`, `ValidatorMap`, `RelationMap`) with the ''buildtime'' database model (`Database`, `Table`, `Column`, `Validator`, etc.). The buildtime model is very detailed, in order to ease the work of the builders that write the ActiveRecord and Query classes. On the other hand, the runtime model is optimized for speed, and carries minimal information to allow correct hydration and binding at runtime. Behaviors use the buildtime object model, because they are run at buildtime, so they have access to the most powerful model.
Now rebuild the model and the SQL, and sure enough, the new column is there. `BasePollQuestion` offers a `getTotalNbVotes()` and a `setTotalNbVotes()` method, and the table creation SQL now includes the additional `total_nb_votes` column:
-
+
{{{
#!sql
DROP TABLE IF EXISTS poll_question;
@@ -110,27 +110,27 @@ CREATE TABLE poll_question
PRIMARY KEY (id)
)Type=InnoDB;
}}}
-
-'''Tip''': The behavior only adds the column if it's not present (`!$table->containsColumn($columnName)`). So if a user needs to customize the column type, or any other attribute, he can include a `<column>` tag in the table with the same name as defined in the behavior, and the `modifyTable()` will then skip the column addition.
-
+
+'''Tip''': The behavior only adds the column if it's not present (`!$table->containsColumn($columnName)`). So if a user needs to customize the column type, or any other attribute, he can include a `<column>` tag in the table with the same name as defined in the behavior, and the `modifyTable()` will then skip the column addition.
+
== Adding A Method To The ActiveRecord Class ==
-
+
In the previous post, a method of the ActiveRecord class was in charge of updating the `total_nb_votes` column. A behavior can easily add such methods by implementing the `objectMethods()` method:
-
+
{{{
#!php
<?php
class AggregateColumnBehavior extends Behavior
-{
+{
// ...
-
+
public function objectMethods()
{
$script = '';
$script .= $this->addUpdateAggregateColumn();
return $script;
}
-
+
protected function addUpdateAggregateColumn()
{
$sql = sprintf('SELECT %s FROM %s WHERE %s = ?',
@@ -160,11 +160,11 @@ public function update{$columnPhpName}(PropelPDO \$con)
}
}
}}}
-
-The ActiveRecord class builder expects a string in return to the call to `Behavior::objectMethods()`, and appends this string to the generated code of the ActiveRecord class. Don't bother about indentation: builder classes know how to properly indent a string returned by a behavior. A good rule of thumb is to create one behavior method for each added method, to provide better readability.
-
+
+The ActiveRecord class builder expects a string in return to the call to `Behavior::objectMethods()`, and appends this string to the generated code of the ActiveRecord class. Don't bother about indentation: builder classes know how to properly indent a string returned by a behavior. A good rule of thumb is to create one behavior method for each added method, to provide better readability.
+
Of course, the schema must be modified to supply the necessary parameters to the behavior:
-
+
{{{
#!xml
<database name="poll" defaultIdMethod="native">
@@ -190,16 +190,16 @@ Of course, the schema must be modified to supply the necessary parameters to the
</table>
</database>
}}}
-
+
Now if you rebuild the model, you will see the new `updateTotalNbVotes()` method in the generated `BasePollQuestion` class:
-
+
{{{
#!php
<?php
class BasePollQuestion extends BaseObject
{
// ...
-
+
/**
* Updates the aggregate column total_nb_votes
*
@@ -215,22 +215,22 @@ class BasePollQuestion extends BaseObject
}
}
}}}
-
+
Behaviors offer similar hook methods to allow the addition of methods to the query classes (`queryMethods()`) and to the peer classes (`peerMethods()`). And if you need to add attributes, just implement one of the `objectAttributes()`, `queryAttributes()`, or `peerAttributes()` methods.
== Using a Template For Generated Code ==
-The behavior's `addUpdateAggregateColumn()` method is somehow hard to read, because of the large string containing the PHP code canvas for the added method. Propel behaviors can take advantage of Propel's simple templating system to use an external file as template for the code to insert.
+The behavior's `addUpdateAggregateColumn()` method is somehow hard to read, because of the large string containing the PHP code canvas for the added method. Propel behaviors can take advantage of Propel's simple templating system to use an external file as template for the code to insert.
Let's refactor the `addUpdateAggregateColumn()` method to take advantage of this feature:
{{{
#!php
<?php
class AggregateColumnBehavior extends Behavior
-{
+{
// ...
-
+
protected function addUpdateAggregateColumn()
{
$sql = sprintf('SELECT %s FROM %s WHERE %s = ?',
@@ -250,7 +250,7 @@ class AggregateColumnBehavior extends Behavior
}
}}}
-The method no longer returns a string created by hand, but a ''rendered template''. Propel templates are simple PHP files executed in a sandbox - they have only access to the variables declared as second argument of the `renderTemplate()` call.
+The method no longer returns a string created by hand, but a ''rendered template''. Propel templates are simple PHP files executed in a sandbox - they have only access to the variables declared as second argument of the `renderTemplate()` call.
Now create a `templates/` directory in the same directory as the `AggregateColumnBehavior` class file, and add in a `objectUpdateAggregate.php` file with the following code:
@@ -274,11 +274,11 @@ public function update<?php echo $columnPhpName ?>(PropelPDO $con)
No need to escape dollar signs anymore: this syntax allows for a cleaner separation, and is very convenient for large behaviors.
== Adding Another Behavior From A Behavior ==
-
+
This is where it's getting tricky. In the [http://propel.posterous.com/getting-to-know-propel-15-keeping-an-aggregat blog post] describing the column aggregation technique, the calls to the `updateTotalNbVotes()` method come from the `postSave()` and `postDelete()` hooks of the `PollAnswer` class. But the current behavior is applied to the `poll_question` table, how can it modify the code of a class based on another table?
The short answer is: it can't. To modify the classes built for the `poll_answer` table, a behavior must be registered on the `poll_answer` table. But a behavior is just like a column or a foreign key: it has an object counterpart in the buildtime database model. So the trick here is to modify the `AggregateColumnBehavior::modifyTable()` method to ''add a new behavior'' to the foreign table. This second behavior will be in charge of implementing the `postSave()` and `postDelete()` hooks of the `PollAnswer` class.
-
+
{{{
#!php
<?php
@@ -289,7 +289,7 @@ class AggregateColumnBehavior extends Behavior
public function modifyTable()
{
// ...
-
+
// add a behavior to the foreign table to autoupdate the aggregate column
$foreignTable = $table->getDatabase()->getTable($this->getParameter('foreign_table'));
if (!$foreignTable->hasBehavior('concrete_inheritance_parent')) {
@@ -309,7 +309,7 @@ class AggregateColumnBehavior extends Behavior
}
}
}}}
-
+
In practice, everything now happens as if the `poll_answer` had its own behavior:
{{{
@@ -325,15 +325,15 @@ In practice, everything now happens as if the `poll_answer` had its own behavior
</table>
</database>
}}}
-
+
Adding a behavior to a `Table` instance, as well as adding a `Parameter` to a `Behavior` instance, is quite straightforward. And since the second behavior class file is required in the `modifyTable()` method, there is no need to add a path for it in the `build.properties`.
-
+
== Adding Code For Model Hooks ==
-
+
The new `AggregateColumnRelationBehavior` is yet to write. It must implement a call to `PollQuestion::updateTotalNbVotes()` in the `postSave()` and `postDelete()` hooks.
Adding code to hooks from a behavior is just like adding methods: add a method with the right hook name returning a code string, and the code will get appended at the right place. Unsurprisingly, the behavior hook methods for `postSave()` and `postDelete()` are called `postSave()` and `postDelete()`:
-
+
{{{
#!php
<?php
@@ -353,12 +353,12 @@ class AggregateColumnBehavior extends Behavior
$foreignColumnPhpName = $foreignColumn->getPhpName();
return "\$this->updateRelated{$foreignColumnPhpName}(\$con)";
}
-
+
public function postDelete()
{
return $this->postSave();
}
-
+
public function objectMethods()
{
$script = '';
@@ -389,18 +389,18 @@ protected function updateRelated{$foreignColumnPhpName}(PropelPDO \$con)
}
}
}}}
-
+
The `postSave()` and `postDelete()` behavior hooks will not add code to the ActiveRecord `postSave()` and `postDelete()` methods - to allow users to further implement these methods - but instead it adds code directly to the `save()` and `delete()` methods, inside a transaction. Check the generated `BasePollAnswer` class for the added code in these methods:
-
+
{{{
#!php
<?php
// aggregate_column_relation behavior
$this->updateRelatedTotalNbVotes($con);
}}}
-
+
You will also see the new `updateRelatedTotalNbVotes()` method added by `AggregateColumnBehavior::objectMethods()`:
-
+
{{{
#!php
<?php
@@ -438,7 +438,7 @@ class BehaviorB extends Behavior
}}}
== What's Left ==
-
+
These are the basics of behavior writing: implement one of the methods documented in the [wiki:Documentation/1.6/Behaviors#WritingaBehavior behaviors chapter] of the Propel guide, and return strings containing the code to be added to the ActiveRecord, Query, and Peer classes. In addition to the behavior code, you should always write unit tests - all the behaviors bundled with Propel have full unit test coverage. And to make your behavior usable by others, documentation is highly recommended. Once again, Propel core behaviors are fully documented, to let users understand the behavior usage without having to peek into the code.
As for the `AggregateColumnBehavior`, the job is not finished. The [http://propel.posterous.com/getting-to-know-propel-15-keeping-an-aggregat blog post] emphasized the need for hooks in the Query class, and these are not yet implemented in the above code. Besides, the post kept quiet about one use case that left the aggregate column not up to date (when a question is detached from a poll without deleting it). Lastly, the parameters required for this behavior are currently a bit verbose, especially concerning the need to define the foreign table and the foreign key - this could be simplified thanks to the knowledge of the object model that behaviors have.
View
2 docs/guide/01-Installation.txt
@@ -10,7 +10,7 @@ Propel runs on most PHP platforms. It just requires:
* [http://www.php.net/ PHP 5.2.4] or newer, with the DOM (libxml2) module enabled
* A supported database (MySQL, MS SQL Server, PostgreSQL, SQLite, Oracle)
-
+
'''Tip''': Propel uses the PDO and SPL components, which are bundled and enabled by default in PHP5.
== Project-Local Installation ==
View
8 docs/guide/02-BuildTime.txt
@@ -12,7 +12,7 @@ To illustrate Propel's build abilities, this chapter uses the data structure of
== Describing Your Database as XML Schema ==
-Propel generates PHP classes based on a ''relational'' description of your data model. This "schema" uses XML to describe tables, columns and relationships. The schema syntax closely follows the actual structure of the database.
+Propel generates PHP classes based on a ''relational'' description of your data model. This "schema" uses XML to describe tables, columns and relationships. The schema syntax closely follows the actual structure of the database.
Create a `bookstore` directory. This will be the root of the bookstore project.
@@ -274,7 +274,7 @@ The database and PHP classes are now ready to be used. But they don't know yet h
=== Writing The XML Runtime Configuration ===
-Create a file called `runtime-conf.xml` at the root of the `bookstore` project, using the following content:
+Create a file called `runtime-conf.xml` at the root of the `bookstore` project, using the following content:
{{{
#!xml
<?xml version="1.0" encoding="UTF-8"?>
@@ -305,7 +305,7 @@ Create a file called `runtime-conf.xml` at the root of the `bookstore` project,
Notice how the `id` attribute of the `<datasource>` tag matches the connection name defined in the `<database>` tag of the `schema.xml`. This is how Propel maps a database description to a connection.
Replace the `<adapter>` and the `<connection>` settings wit hthe ones of your database.
-
+
See the [wiki:Documentation/1.6/RuntimeConfiguration runtime configuration reference] for a more detailed explanation of this file.
'''Tip''': If you uncomment the `<log>` section, Propel will attempt to instantiate the `Log` class (from the [http://pear.php.net/package/Log/ PEAR Log] package) with the specified parameters and use that to log queries. Propel's statement logging happens at the DEBUG level (7); errors and warnings are logged at the appropriate (non-debug) level.
@@ -325,7 +325,7 @@ The resulting file can be found under `build/conf/bookstore-conf.php`, where "bo
{{{
> cd /path/to/bookstore
-> propel-gen
+> propel-gen
}}}
== Setting Up Propel ==
View
6 docs/guide/03-Basic-CRUD.txt
@@ -2,7 +2,7 @@
[[PageOutline]]
-In this chapter, you will learn how to perform basic C.R.U.D. (Create, Retrieve, Update, Delete) operations on your database using Propel.
+In this chapter, you will learn how to perform basic C.R.U.D. (Create, Retrieve, Update, Delete) operations on your database using Propel.
== Creating Rows ==
@@ -80,7 +80,7 @@ This issues a simple SELECT SQL query. For instance, for MySQL:
{{{
#!sql
-SELECT author.id, author.first_name, author.last_name
+SELECT author.id, author.first_name, author.last_name
FROM `author`
WHERE author.id = 1
LIMIT 1;
@@ -283,7 +283,7 @@ $links = $pager->getLinks(5); // array of page numbers around the current page;
== Collections And On-Demand Hydration ==
The `find()` method of generated Model Query objects returns a `PropelCollection` object. You can use this object just like an array of model objects, iterate over it using `foreach`, access the objects by key, etc.
-
+
{{{
#!php
<?php
View
18 docs/guide/04-Relationships.txt
@@ -2,7 +2,7 @@
[[PageOutline]]
-The definition of foreign keys in your schema allows Propel to add smart methods to the generated model and query objects. In practice, these generated methods mean that you will never actually have to deal with primary and foreign keys yourself. It makes the task of dealing with relations extremely straightforward.
+The definition of foreign keys in your schema allows Propel to add smart methods to the generated model and query objects. In practice, these generated methods mean that you will never actually have to deal with primary and foreign keys yourself. It makes the task of dealing with relations extremely straightforward.
== Inserting A Related Row ==
@@ -44,7 +44,7 @@ $author->addBook($book);
$author->save();
}}}
-The result is the same in the database - the `author_id` column of the `book` row is correctly set to the `id` of the `author` row.
+The result is the same in the database - the `author_id` column of the `book` row is correctly set to the `id` of the `author` row.
== Save Cascade ==
@@ -84,7 +84,7 @@ Just like the related object setters, Propel generates a getter for every relati
#!php
<?php
$book = BookQuery()::create()->findPk(1);
-$author = $book->getAuthor();
+$author = $book->getAuthor();
echo $author->getFirstName(); // 'Leo'
}}}
@@ -93,7 +93,7 @@ Since a relationship can also be seen from the other end, Propel allows the fore
{{{
#!php
<?php
-$author = AuthorQuery::create()->findPk(1);
+$author = AuthorQuery::create()->findPk(1);
$books = $author->getBooks();
foreach ($books as $book) {
echo $book->getTitle();
@@ -124,7 +124,7 @@ If you need to find objects related to a model object that you already have, you
{{{
#!php
<?php
-$author = AuthorQuery::create()->findPk(1);
+$author = AuthorQuery::create()->findPk(1);
$books = BookQuery::create()
->filterByAuthor($author)
->orderByTitle()
@@ -143,8 +143,8 @@ To illustrate this, let's see how to write the following SQL query with the Prop
{{{
#!sql
-SELECT book.*
-FROM book INNER JOIN author ON book.AUTHOR_ID = author.ID
+SELECT book.*
+FROM book INNER JOIN author ON book.AUTHOR_ID = author.ID
WHERE book.ISBN = '0140444173' AND author.FIRST_NAME = 'Leo'
ORDER BY book.TITLE ASC
LIMIT 10;
@@ -165,7 +165,7 @@ $books = BookQuery::create()
->find();
}}}
-Propel knows the columns to use in the `ON` clause from the definition of foreign keys in the schema. The ability to use methods of a related Query object allows you to keep your model logic where it belongs.
+Propel knows the columns to use in the `ON` clause from the definition of foreign keys in the schema. The ability to use methods of a related Query object allows you to keep your model logic where it belongs.
Of course, you can embed several queries to issue a query of any complexity level:
@@ -417,4 +417,4 @@ To enable a model-only relationship, add a `<foreign-key>` tag using the `skipSq
</table>
}}}
-Such a foreign key is not translated into SQL when Propel builds the table creation or table migration code. It can be seen as a "virtual foreign key". However, on the PHP side, the `Book` model actually has a one-to-many relationship with the `Review` model. The generated !ActiveRecord and !ActiveQuery classes take advantage of this relationship to offer smart getters and filters.
+Such a foreign key is not translated into SQL when Propel builds the table creation or table migration code. It can be seen as a "virtual foreign key". However, on the PHP side, the `Book` model actually has a one-to-many relationship with the `Review` model. The generated !ActiveRecord and !ActiveQuery classes take advantage of this relationship to offer smart getters and filters.
View
4 docs/guide/05-Validators.txt
@@ -5,7 +5,7 @@
Validators help you to validate an input before perstisting it to the database. In Propel, validators are rules describing what type of data a column accepts. Validators are referenced in the `schema.xml` file, using `<validator>` tags.
Validators are applied at the PHP level, they are not created as constraints on the database itself. That means that if you also use another language to work with the database, the validator rules will not be enforced.
-You can also apply multiple rule entries per validator entry in the schema.xml file.
+You can also apply multiple rule entries per validator entry in the schema.xml file.
== Overview ==
@@ -224,7 +224,7 @@ require_once 'propel/validator/BasicValidator.php';
/**
* A simple validator for email fields.
- *
+ *
* @package propel.validator
*/
class EmailValidator implements BasicValidator
View
4 docs/guide/06-Transactions.txt
@@ -276,11 +276,11 @@ $fromAccount->setValue($fromAccount->getValue() - $amount);
$fromAccount->save();
}}}
-However, it's a good practice to pass the connection explicitely, and for three reasons:
+However, it's a good practice to pass the connection explicitely, and for three reasons:
* Propel doesn't need to look for a connection object, and this results in a tiny boost in performance.
* You can use a specific connection, which is required in distributed (master/slave) environments, in order to distinguish read and write operations.
- * Most importantly, transactions are tied to a single connection. You can't enclose two queries using different connections in a single transaction. So it's very useful to identify the connection you want to use for every query, as Propel will throw an exception if you use the wrong connection.
+ * Most importantly, transactions are tied to a single connection. You can't enclose two queries using different connections in a single transaction. So it's very useful to identify the connection you want to use for every query, as Propel will throw an exception if you use the wrong connection.
== Limitations ==
View
16 docs/guide/07-Behaviors.txt
@@ -4,7 +4,7 @@
Behaviors are a great way to package model extensions for reusability. They are the powerful, versatile, fast, and help you organize your code in a better way.
-== Pre and Post Hooks For `save()` And `delete()` Methods ==
+== Pre and Post Hooks For `save()` And `delete()` Methods ==
The `save()` and `delete()` methods of your generated objects are easy to override. In fact, Propel looks for one of the following methods in your objects and executes them when needed:
@@ -255,7 +255,7 @@ class MyBehavior extends Behavior
protected $parameters = array(
'column_name' => 'foo',
);
-
+
public function modifyTable()
{
$table = $this->getTable();
@@ -267,7 +267,7 @@ class MyBehavior extends Behavior
'type' => 'INTEGER',
));
}
- }
+ }
}
}}}
@@ -318,7 +318,7 @@ peerFilter(&$script) // do whatever you want with the generated code, passed as
=== Adding New Classes ===
-Behaviors can add entirely new classes based on the data model. To build a new class, a behavior must provide an array of builder class names (in return to `getAdditionalBuilders()`) and the builder classes themselves.
+Behaviors can add entirely new classes based on the data model. To build a new class, a behavior must provide an array of builder class names (in return to `getAdditionalBuilders()`) and the builder classes themselves.
For instance, to add an empty child class for the ActiveRecord class, create the following behavior:
@@ -345,7 +345,7 @@ class AddChildBehaviorBuilder extends OMBuilder
{
return $this->getStubObjectBuilder()->getUnprefixedClassname() . 'Child';
}
-
+
protected function addClassOpen(&$script)
{
$table = $this->getTable();
@@ -408,12 +408,12 @@ public function findPk(\$key, \$con = null)
";
$table = $this->getTable();
$newFindPkMethod = sprintf($newFindPkMethod, $table->getName(), $table->getPhpName(), $table->getPhpName());
- $parser = new PropelPHPParser($script);
- $parser->replaceMethod('findPk', $newFindPkMethod);
+ $parser = new PropelPHPParser($script);
+ $parser->replaceMethod('findPk', $newFindPkMethod);
$script = $parser->getCode();
}
}
-}}}
+}}}
The `PropelPHPParser` class provides the following utility methods:
{{{
View
2 docs/guide/08-Logging.txt
@@ -202,7 +202,7 @@ Tip: There is also a bundled `MojaviLogAdapter` class which allows you to use a
== Debugging Database Activity ==
By default, Propel uses `PropelPDO` for database connections. This class, which extends PHP's `PDO`, offers a debug mode to keep track of all the database activity, including all the executed queries.
-
+
=== Enabling The Debug Mode ===
The debug mode is disabled by default, but you can enable it at runtime as follows:
View
8 docs/guide/09-Inheritance.txt
@@ -31,7 +31,7 @@ Once you rebuild your model, Propel generated all three model classes (`Book`, `
'''Tip''': An inherited class can extend another inherited class. That mean that you can add a `Manga` kind of book that extends `Comic` instead of `Book`.
-'''Tip''': If you define an `<inheritance>` tag with no `extends` attribute, as in the example above, it must use the table `phpName` as its `class` attribute.
+'''Tip''': If you define an `<inheritance>` tag with no `extends` attribute, as in the example above, it must use the table `phpName` as its `class` attribute.
=== Using Inherited Objects ===
@@ -195,7 +195,7 @@ Since the columns of the main table are copied to the child tables, this schema
</behavior>
<column name="resource_link" type="VARCHAR" size="100"/>
</table>
-}}}
+}}}
'''Tip''': The `concrete_inheritance` behavior copies columns, foreign keys, indices and validators.
@@ -264,7 +264,7 @@ By default, every time you save an `Article` or a `Video` object, Propel saves a
{{{
#!php
-<?php
+<?php
$conts = ContentQuery::create()->find();
foreach ($conts as $content) {
echo $content->getTitle() . "(". $content->getCategoryName() ")/n";
@@ -318,7 +318,7 @@ The `hasChildObject()` and `getChildObject()` methods are automatically added by
</behavior>
<column name="body" type="VARCHAR" size="100"/>
</table>
-// results in
+// results in
<table name="article">
<column name="body" type="VARCHAR" size="100"/>
<column name="id" type="INTEGER" primaryKey="true" autoIncrement="true"/>
View
14 docs/guide/10-Migrations.txt
@@ -14,7 +14,7 @@ The workflow of Propel migrations is very simple:
1. Call the `diff` task to create a migration class containing the SQL statements altering the database structure
1. Review the migration class Propel just generated, and add data migration code if necessary
1. Execute the migration using the `migrate` task.
-
+
Here is a concrete example. On a new bookstore project, a developer creates an XML schema with a single `book` table:
{{{
@@ -55,7 +55,7 @@ It is recommended to review the generated migration class to check the generated
*/
class PropelMigration_1286483354
{
-
+
public function getUpSQL()
{
return array('bookstore' => '
@@ -220,7 +220,7 @@ For these situations, Propel provides the `status` task. It simply lists the mig
[propel-migration-status] Checking Database Versions...
[propel-migration-status] Listing Migration files...
[propel-migration-status] 1 migration needs to be executed:
-[propel-migration-status] PropelMigration_1286484196
+[propel-migration-status] PropelMigration_1286484196
[propel-migration-status] Call the "migrate" task to execute it
}}}
@@ -235,7 +235,7 @@ For these situations, Propel provides the `status` task. It simply lists the mig
[propel-migration-status] 2 valid migration classes found in "/Users/francois/propel/1.6/test/fixtures/migration/build/migrations"
[propel-migration-status] 1 migration needs to be executed:
[propel-migration-status] > PropelMigration_1286483354 (executed)
-[propel-migration-status] PropelMigration_1286484196
+[propel-migration-status] PropelMigration_1286484196
[propel-migration-status] Call the "migrate" task to execute it
}}}
@@ -316,7 +316,7 @@ ALTER TABLE `book` ADD
public function postUp($manager)
{
- // post-migration code
+ // post-migration code
$sql = "INSERT INTO author (first_name,last_name) values('Leo','Tolstoi')";
$pdo = $manager->getPdoConnection('bookstore');
$stmt = $pdo->prepare($sql);
@@ -340,7 +340,7 @@ Propel::init('/path/to/build/conf/bookstore-conf.php');
class PropelMigration_1286483354
{
-
+
public function postUp($manager)
{
// add the post-migration code here
@@ -350,7 +350,7 @@ class PropelMigration_1286483354
$author->setLastname('Tolstoi');
$author->save($pdo);
}
-
+
public function getUpSQL()
{
// ...
View
12 docs/reference/ActiveRecord.txt
@@ -51,7 +51,7 @@ The best way to learn what a generated Active Record class can do is to inspect
<table name="books">
<!-- generates the following Active Record class: Books (not good) !-->
-<!-- You can customize the name of an Active Record class in PHP
+<!-- You can customize the name of an Active Record class in PHP
by setting the phpName attribute in the <table> tag !-->
<table name="foo_books" phpName="Book" />
<!-- generates the following Active Record class: Book !-->
@@ -151,7 +151,7 @@ To use a custom name for these methods, set the `phpName` attribute in the `<col
<!-- getTitle(), setTitle() !-->
}}}
-'''Tip''': Calling the setter on an autoincremented PK will throw an exception as soon as you try to save the object. You can allow PK inserts on such columns by setting the `allowPkInsert` attribute to `true` in the `<table>` tag of the XML schema.
+'''Tip''': Calling the setter on an autoincremented PK will throw an exception as soon as you try to save the object. You can allow PK inserts on such columns by setting the `allowPkInsert` attribute to `true` in the `<table>` tag of the XML schema.
'''Tip''': Calling a getter doesn't issue any database query, except for lazy-loaded columns.
@@ -195,7 +195,7 @@ $book->delete();
// All persistence methods accept a connection object
$con = Propel::getConnection(BookPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
$book->delete($con);
-}}}
+}}}
== Relationship Getters and Setters ==
@@ -423,13 +423,13 @@ echo $house->getCoordinates()->isInNorthernHemisphere(); // true
class GeographicCoordinates
{
public $latitude, $longitude;
-
+
public function __construct($latitude, $longitude)
{
$this->latitude = $latitude;
$this->longitude = $longitude;
}
-
+
public function isInNorthernHemisphere()
{
return $this->latitude > 0;
@@ -748,6 +748,6 @@ $book2 = book1->copy(); // creates a copy of an Active Record instance
echo $book1->equals($book2); // compares two ActiveRecord instances
}}}
-== Conclusion ==
+== Conclusion ==
Active Record classes are not only an object-oriented tool to execute SQL queries in a database-independent way. They provide a lot of features to streamline day-to-day work with persisted objects. They can also be seen as a persistence ability that can be added to any PHP object.
View
32 docs/reference/Buildtime-Configuration.txt
@@ -36,12 +36,12 @@ You can also specify properties on the command line when you invoke Propel. The
{{{
#!ini
-# The name of your project.
+# The name of your project.
# This affects names of generated files, etc.
propel.project = /Your-Project-Name/
# The package to use for the generated classes.
-# This affects the value of the @package phpdoc tag, and it also affects
+# This affects the value of the @package phpdoc tag, and it also affects
# the directory that the classes are placed in. By default this will be
# the same as the project. Note that the target package (and thus the target
# directory for generated classes) can be overridden in each `<database>` and
@@ -70,7 +70,7 @@ propel.schema.autoPrefix = true|{false}
# Whether to validate the XML schema using the XSD file.
# The default XSD file is located under `generator/resources/xsd/database.xsd`
-# and you can use a custom XSD file by changing the `propel.schema.xsd.file`
+# and you can use a custom XSD file by changing the `propel.schema.xsd.file`
# property.
propel.schema.validate = {true}|false
@@ -107,14 +107,14 @@ propel.database.user = {empty}|string
propel.database.password = {empty}|string
# The database PDO connection settings at builtime for reverse engineer
-# or data dump. The default is to use the database connection defined by the
+# or data dump. The default is to use the database connection defined by the
# `propel.database.url` property.
propel.database.buildUrl = {propel.database.url}/string
# The database PDO connection settings at builtime for creating a database.
-# The default is to use the database connection defined by the
+# The default is to use the database connection defined by the
# `propel.database.url` property.
-# Propel is unable to create databases for some vendors because they do not
+# Propel is unable to create databases for some vendors because they do not
# provide a SQL method for creation; therefore, it is usually recommended that
# you actually create your database by hand.
propel.database.createUrl = {propel.database.url}/string
@@ -127,7 +127,7 @@ propel.database.schema = {empty}|string
# This can affect things such as transforming charsets when exporting to XML, etc.
propel.database.encoding = {empty}|string
-# Add a prefix to all the table names in the database.
+# Add a prefix to all the table names in the database.
# This does not affect the tables phpName.
# This setting can be overridden on a per-database basis in the schema.
propel.tablePrefix = {empty}|string
@@ -143,11 +143,11 @@ propel.tablePrefix = {empty}|string
propel.samePhpName = true|{false}
# Whether to add the vendor info. This is currently only used for MySQL, but
-# does provide additional information (such as full-text indexes) which can
+# does provide additional information (such as full-text indexes) which can
# affect the generation of the DDL from the schema.
propel.addVendorInfo = true|{false}
-# Which Propel validators to add to the generated schema,
+# Which Propel validators to add to the generated schema,
# based on the database constraints.
propel.addValidators = {none}|maxvalue|type|required|unique|all
# You can cherry-pick allowed validators by using a comma-separated value, e.g
@@ -158,7 +158,7 @@ propel.addValidators = maxvalue,type,required
{{{
#!ini
-# Whether to add generic getter/setter methods.
+# Whether to add generic getter/setter methods.
# Generic accessors are `getByName()`, `getByPosition(), ` and `toArray()`.
propel.addGenericAccessors = {true}|false
# Generic mutators are `setByName()`, `setByPosition()`, and `fromArray()`.
@@ -169,11 +169,11 @@ propel.addGenericMutators = {true}|false
# will be committed too often with just a date change.
propel.addTimeStamp = true|{false}
-# Whether to add `validate()` method to your classes.
+# Whether to add `validate()` method to your classes.
# Set to false if you don't use Propel validation.
propel.addValidateMethod = {true}|false
-# Whether to add `require` statements on the generated stub classes.
+# Whether to add `require` statements on the generated stub classes.
# Propel uses autoloading for OM classes, and doesn't insert require statements
# by default. If you don't want to use autoloading, set this to true.
propel.addIncludes = true|{false}
@@ -182,7 +182,7 @@ propel.addIncludes = true|{false}
# Set to false if you never use these hooks for a small speed boost.
propel.addHooks = {true}|false
-# The prefix to use for the base (super) classes that are generated.
+# The prefix to use for the base (super) classes that are generated.
propel.basePrefix = {Base}|string
# Some sort of "namespacing": All Propel classes with get the Prefix
@@ -203,14 +203,14 @@ propel.useLeftJoinsInDoJoinMethods = {true}|false
{{{
#!ini
-# Default table type.
+# Default table type.
# You can override this setting if you wish to default to another engine for
# all tables (for instance InnoDB, or HEAP). This setting can also be
# overridden on a per-table basis using the `<vendor>` element in the schema
# (see [wiki:Documentation/1.6/Schema#AddingVendorInfo]).
propel.mysql.tableType = {MyISAM}|string
-# Keyword used to specify the table engine in the CREATE SQL statement.
+# Keyword used to specify the table engine in the CREATE SQL statement.
# Defaults to 'ENGINE', users of MYSQL < 5 should use 'TYPE' instead.
propel.mysql.tableEngineKeyword = {ENGINE}|TYPE
}}}
@@ -230,7 +230,7 @@ propel.dateTimeClass = {DateTime}|string
# These are the default formats that will be used when fetching values from
# temporal columns in Propel. You can always specify these when calling the
-# methods directly, but for methods like getByName() it is nice to change
+# methods directly, but for methods like getByName() it is nice to change
# the defaults.
# To have these methods return DateTime objects instead, you should set these
# to empty values
View
56 docs/reference/ModelCriteria.txt
@@ -57,7 +57,7 @@ So Propel queries are a very powerful tool to write your queries in an object-or
== Generated Query Methods ==
-For each object, Propel creates a few methods in the generated query object.
+For each object, Propel creates a few methods in the generated query object.
=== Column Filter Methods ===
@@ -77,7 +77,7 @@ WHERE book.TITLE = :p1'; // :p1 => 'War And Peace'
}}}
* For string columns, `filterByXXX()` translates to a SQL `WHERE ... LIKE` if the value contains wildcards:
-
+
{{{
#!php
<?php
@@ -90,7 +90,7 @@ WHERE book.TITLE LIKE :p1'; // :p1 => 'War%'
}}}
* For numeric and temporal columns, `filterByXXX()` translates into an interval condition if the value is an associative array using 'min' and/or 'max' as keys:
-
+
{{{
#!php
<?php
@@ -103,7 +103,7 @@ WHERE book.ID >= :p1 AND book.ID <= :p2)'; // :p1 => 123, :p2 => 456
}}}
* For integer columns, `filterByXXX()` translates into a SQL `WHERE ... IN` if the value is an array:
-
+
{{{
#!php
<?php
@@ -116,7 +116,7 @@ WHERE book.AUTHOR_ID IN (:p1, :p2)'; // :p1 => 123, :p2 => 456
}}}
* For Boolean columns, `filterByXXX()` translates the value to a boolean using smart casting:
-
+
{{{
#!php
<?php
@@ -131,7 +131,7 @@ WHERE book.IS_PUBLISHED = :p1
}}}
* for Temporal columns, `filterByXXX()` accepts a string, a timestamp, or a DateTime value:
-
+
{{{
#!php
<?php
@@ -157,7 +157,7 @@ $books = BookQuery::create()
$query = 'SELECT book.* from `book`
WHERE book.STYLE = :p1; // :p1 => 0
}}}
-
+
* for Object columns, `filterByXXX()` accepts a PHP object
{{{
@@ -235,7 +235,7 @@ $books = BookQuery::create()
->filterByName('Leo Tolstoi')
->endUse()
->find();
-}}}
+}}}
`useAuthorQuery()` returns a new instance of `AuthorQuery` already joined with the current `BookQuery` instance. The next method is therefore called on a different object - that's why the `filterByName()` call is further indented in the code example. Finally, `endUse()` merges the conditions applied on the `AuthorQuery` to the `BookQuery`, and returns the original `BookQuery` object.
@@ -264,13 +264,13 @@ $books = BookQuery::create()
$query = 'SELECT book.* from book
LEFT JOIN author a ON book.AUTHOR_ID = a.ID
WHERE a.NAME = :p1'; // :p1 => 'Leo Tolstoi'
-}}}
+}}}
The `useXXXQuery()` methods allow for very complex queries. You can mix them, nest them, and reopen them to add more conditions.
== Inherited Methods ==
-The generated Query classes extend a core Propel class named `ModelCriteria`, which provides even more methods for building your queries.
+The generated Query classes extend a core Propel class named `ModelCriteria`, which provides even more methods for building your queries.
=== Finding An Object From Its Primary Key ===
@@ -307,7 +307,7 @@ $article = BookQuery::create()
{{{
#!php
<?php
-// The query recognizes method calls composed of `findOneBy` or `findBy`, and a column name.
+// The query recognizes method calls composed of `findOneBy` or `findBy`, and a column name.
$book = BookQuery::create()->findOneByTitle('War And Peace');
// same as
$book = BookQuery::create()
@@ -381,7 +381,7 @@ $nbDeletedBooks = BookQuery::create()
// Deleting a selection of Books
$nbDeletedBooks = BookQuery::create()
->filterByTitle('Pride And Prejudice')
- ->delete($con);
+ ->delete($con);
}}}
=== Updating Objects ===
@@ -520,7 +520,7 @@ echo $q->count(); // 1
== Relational API ==
-For more complex queries, you can use an alternative set of methods, closer to the relational logic of SQL, to make sure that Propel issues exactly the SQL query you need.
+For more complex queries, you can use an alternative set of methods, closer to the relational logic of SQL, to make sure that Propel issues exactly the SQL query you need.
This alternative API uses methods like `where()`, `join()` and `orderBy()` that translate directly to their SQL equivalent - `WHERE`, `JOIN`, etc. Here is an example:
@@ -677,7 +677,7 @@ $book = BookQuery::create()
->join('Book.Author')
->where('Author.Name = ?', 'Jane Austen')
->findOne();
- // SELECT book.* FROM book
+ // SELECT book.* FROM book
// INNER JOIN author ON book.AUTHOR_ID = author.ID
// WHERE author.NAME = 'Jane Austin'
// LIMIT 1;
@@ -713,13 +713,13 @@ $book = BookQuery::create()
// You can override the default join type for a given relationship
// By setting the joinType attribute of the foreign key element in the schema.xml
-// Add more conditions to an existing join
+// Add more conditions to an existing join
// by calling addJoinCondition($joinName, $clause, $value)
$book = BookQuery::create()
->joinAuthor()
->addJoinCondition('Author', 'Author.LastName <> ?', 'Austen')
->findOne();
- // SELECT book.* FROM book
+ // SELECT book.* FROM book
// INNER JOIN author ON (book.AUTHOR_ID = author.ID AND author.LAST_NAME <> 'Austen')
// LIMIT 1;
}}}
@@ -747,7 +747,7 @@ $books = BookQuery::create('b')
->orderBy('b.Title')
->find();
-// Table aliases are mostly useful to join the current table,
+// Table aliases are mostly useful to join the current table,
// or to handle multiple foreign keys on the same column
$employee = EmployeeQuery::create('e')
->innerJoin('e.Supervisor s')
@@ -928,21 +928,21 @@ SQL supports table subqueries (a.k.a "inline view" in Oracle) to solve complex c
{{{
#!sql
-SELECT book.ID, book.TITLE, book.AUTHOR_ID, book.PRICE, book.CREATED_AT, MAX(book.CREATED_AT)
-FROM book
+SELECT book.ID, book.TITLE, book.AUTHOR_ID, book.PRICE, book.CREATED_AT, MAX(book.CREATED_AT)
+FROM book
GROUP BY book.AUTHOR_ID
}}}
Now if you want only the cheapest latest books with a single query, you need a subquery:
{{{
#!sql
-SELECT lastBook.ID, lastBook.TITLE, lastBook.AUTHOR_ID, lastBook.PRICE, lastBook.CREATED_AT
+SELECT lastBook.ID, lastBook.TITLE, lastBook.AUTHOR_ID, lastBook.PRICE, lastBook.CREATED_AT
FROM
(
- SELECT book.ID, book.TITLE, book.AUTHOR_ID, book.PRICE, book.CREATED_AT, MAX(book.CREATED_AT)
- FROM book
+ SELECT book.ID, book.TITLE, book.AUTHOR_ID, book.PRICE, book.CREATED_AT, MAX(book.CREATED_AT)
+ FROM book
GROUP BY book.AUTHOR_ID
-) AS lastBook
+) AS lastBook
WHERE lastBook.PRICE < 20
}}}