Skip to content
Browse files

- Changed project layout

- Included propel as submodule
- Created test environment, first tests
- Bugfixes for the written tests
  • Loading branch information...
1 parent 838b2dc commit cbb20431176dddd5ff99469c1801f3fcd796d67b @gossi committed Oct 3, 2011
Showing with 46 additions and 17,612 deletions.
  1. +7 −4 .buildpath
  2. +2 −2 .settings/org.eclipse.php.core.prefs
  3. +2 −7 {src → }/generator/ListenerBehavior.php
  4. +2 −0 {src → }/generator/ListenerCollectionBehavior.php
  5. 0 {src → }/generator/ListenerTable.php
  6. +7 −12 {src → }/generator/templates/ListenerCollection.php
  7. +25 −25 {src → }/generator/templates/ObjectListener.php
  8. +1 −0 lib/.gitignore
  9. +0 −38 lib/propel-1.6.1/CHANGELOG
  10. +0 −4 lib/propel-1.6.1/INSTALL
  11. +0 −19 lib/propel-1.6.1/LICENSE
  12. +0 −755 lib/propel-1.6.1/WHATS_NEW
  13. +0 −70 lib/propel-1.6.1/generator/bin/propel-gen
  14. +0 −32 lib/propel-1.6.1/generator/bin/propel-gen.bat
  15. +0 −623 lib/propel-1.6.1/generator/build-propel.xml
  16. +0 −190 lib/propel-1.6.1/generator/build.properties-sample
  17. +0 −238 lib/propel-1.6.1/generator/build.xml
  18. +0 −120 lib/propel-1.6.1/generator/build.xml-local
  19. +0 −290 lib/propel-1.6.1/generator/default.properties
  20. +0 −133 lib/propel-1.6.1/generator/lib/behavior/AlternativeCodingStandardsBehavior.php
  21. +0 −53 lib/propel-1.6.1/generator/lib/behavior/AutoAddPkBehavior.php
  22. +0 −487 lib/propel-1.6.1/generator/lib/behavior/SoftDeleteBehavior.php
  23. +0 −176 lib/propel-1.6.1/generator/lib/behavior/TimestampableBehavior.php
  24. +0 −133 lib/propel-1.6.1/generator/lib/behavior/aggregate_column/AggregateColumnBehavior.php
  25. +0 −164 lib/propel-1.6.1/generator/lib/behavior/aggregate_column/AggregateColumnRelationBehavior.php
  26. +0 −17 lib/propel-1.6.1/generator/lib/behavior/aggregate_column/templates/objectCompute.php
  27. +0 −11 lib/propel-1.6.1/generator/lib/behavior/aggregate_column/templates/objectUpdate.php
  28. +0 −16 lib/propel-1.6.1/generator/lib/behavior/aggregate_column/templates/objectUpdateRelated.php
  29. +0 −20 lib/propel-1.6.1/generator/lib/behavior/aggregate_column/templates/queryFindRelated.php
  30. +0 −8 lib/propel-1.6.1/generator/lib/behavior/aggregate_column/templates/queryUpdateRelated.php
  31. +0 −244 lib/propel-1.6.1/generator/lib/behavior/concrete_inheritance/ConcreteInheritanceBehavior.php
  32. +0 −89 lib/propel-1.6.1/generator/lib/behavior/concrete_inheritance/ConcreteInheritanceParentBehavior.php
  33. +0 −269 lib/propel-1.6.1/generator/lib/behavior/i18n/I18nBehavior.php
  34. +0 −208 lib/propel-1.6.1/generator/lib/behavior/i18n/I18nBehaviorObjectBuilderModifier.php
  35. +0 −37 lib/propel-1.6.1/generator/lib/behavior/i18n/I18nBehaviorPeerBuilderModifier.php
  36. +0 −74 lib/propel-1.6.1/generator/lib/behavior/i18n/I18nBehaviorQueryBuilderModifier.php
  37. +0 −12 lib/propel-1.6.1/generator/lib/behavior/i18n/templates/objectAttributes.php
  38. +0 −2 lib/propel-1.6.1/generator/lib/behavior/i18n/templates/objectClearReferences.php
  39. +0 −12 lib/propel-1.6.1/generator/lib/behavior/i18n/templates/objectGetCurrentTranslation.php
  40. +0 −10 lib/propel-1.6.1/generator/lib/behavior/i18n/templates/objectGetLocale.php
  41. +0 −11 lib/propel-1.6.1/generator/lib/behavior/i18n/templates/objectGetLocaleAlias.php
  42. +0 −34 lib/propel-1.6.1/generator/lib/behavior/i18n/templates/objectGetTranslation.php
  43. +0 −5 lib/propel-1.6.1/generator/lib/behavior/i18n/templates/objectPostDelete.php
  44. +0 −28 lib/propel-1.6.1/generator/lib/behavior/i18n/templates/objectRemoveTranslation.php
  45. +0 −14 lib/propel-1.6.1/generator/lib/behavior/i18n/templates/objectSetLocale.php
  46. +0 −13 lib/propel-1.6.1/generator/lib/behavior/i18n/templates/objectSetLocaleAlias.php
  47. +0 −17 lib/propel-1.6.1/generator/lib/behavior/i18n/templates/objectSetTranslation.php
  48. +0 −5 lib/propel-1.6.1/generator/lib/behavior/i18n/templates/objectTranslatedColumnGetter.php
  49. +0 −7 lib/propel-1.6.1/generator/lib/behavior/i18n/templates/objectTranslatedColumnSetter.php
  50. +0 −17 lib/propel-1.6.1/generator/lib/behavior/i18n/templates/queryJoinI18n.php
  51. +0 −18 lib/propel-1.6.1/generator/lib/behavior/i18n/templates/queryJoinWithI18n.php
  52. +0 −18 lib/propel-1.6.1/generator/lib/behavior/i18n/templates/queryUseI18nQuery.php
  53. +0 −99 lib/propel-1.6.1/generator/lib/behavior/nestedset/NestedSetBehavior.php
  54. +0 −1,591 lib/propel-1.6.1/generator/lib/behavior/nestedset/NestedSetBehaviorObjectBuilderModifier.php
  55. +0 −560 lib/propel-1.6.1/generator/lib/behavior/nestedset/NestedSetBehaviorPeerBuilderModifier.php
  56. +0 −379 lib/propel-1.6.1/generator/lib/behavior/nestedset/NestedSetBehaviorQueryBuilderModifier.php
  57. +0 −264 lib/propel-1.6.1/generator/lib/behavior/query_cache/QueryCacheBehavior.php
  58. +0 −332 lib/propel-1.6.1/generator/lib/behavior/sluggable/SluggableBehavior.php
  59. +0 −83 lib/propel-1.6.1/generator/lib/behavior/sortable/SortableBehavior.php
  60. +0 −636 lib/propel-1.6.1/generator/lib/behavior/sortable/SortableBehaviorObjectBuilderModifier.php
  61. +0 −367 lib/propel-1.6.1/generator/lib/behavior/sortable/SortableBehaviorPeerBuilderModifier.php
  62. +0 −285 lib/propel-1.6.1/generator/lib/behavior/sortable/SortableBehaviorQueryBuilderModifier.php
  63. +0 −250 lib/propel-1.6.1/generator/lib/behavior/versionable/VersionableBehavior.php
  64. +0 −514 lib/propel-1.6.1/generator/lib/behavior/versionable/VersionableBehaviorObjectBuilderModifier.php
  65. +0 −79 lib/propel-1.6.1/generator/lib/behavior/versionable/VersionableBehaviorPeerBuilderModifier.php
  66. +0 −120 lib/propel-1.6.1/generator/lib/behavior/versionable/VersionableBehaviorQueryBuilderModifier.php
  67. +0 −622 lib/propel-1.6.1/generator/lib/builder/DataModelBuilder.php
  68. +0 −120 lib/propel-1.6.1/generator/lib/builder/om/ClassTools.php
  69. +0 −139 lib/propel-1.6.1/generator/lib/builder/om/ExtensionQueryBuilder.php
  70. +0 −147 lib/propel-1.6.1/generator/lib/builder/om/ExtensionQueryInheritanceBuilder.php
  71. +0 −533 lib/propel-1.6.1/generator/lib/builder/om/OMBuilder.php
  72. +0 −206 lib/propel-1.6.1/generator/lib/builder/om/ObjectBuilder.php
  73. +0 −108 lib/propel-1.6.1/generator/lib/builder/om/PHP5ExtensionNodeBuilder.php
  74. +0 −109 lib/propel-1.6.1/generator/lib/builder/om/PHP5ExtensionNodePeerBuilder.php
  75. +0 −130 lib/propel-1.6.1/generator/lib/builder/om/PHP5ExtensionObjectBuilder.php
  76. +0 −133 lib/propel-1.6.1/generator/lib/builder/om/PHP5ExtensionPeerBuilder.php
  77. +0 −105 lib/propel-1.6.1/generator/lib/builder/om/PHP5InterfaceBuilder.php
  78. +0 −198 lib/propel-1.6.1/generator/lib/builder/om/PHP5MultiExtendObjectBuilder.php
  79. +0 −1,136 lib/propel-1.6.1/generator/lib/builder/om/PHP5NestedSetBuilder.php
  80. +0 −1,724 lib/propel-1.6.1/generator/lib/builder/om/PHP5NestedSetPeerBuilder.php
  81. +0 −1,101 lib/propel-1.6.1/generator/lib/builder/om/PHP5NodeBuilder.php
  82. +0 −751 lib/propel-1.6.1/generator/lib/builder/om/PHP5NodePeerBuilder.php
Sorry, we could not display the entire diff because it was too big.
View
11 .buildpath
@@ -1,8 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<buildpath>
- <buildpathentry kind="src" path="src"/>
+ <buildpathentry kind="src" path="test/fixtures/listener-behavior/build/classes"/>
+ <buildpathentry kind="src" path="runtime"/>
+ <buildpathentry kind="src" path="lib/propel-1.6.2/runtime/lib"/>
+ <buildpathentry external="true" kind="lib" path="/usr/local/Cellar/php/5.3.6/lib/php/PHPUnit"/>
<buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/>
- <buildpathentry kind="src" path="lib/propel-1.6.1/generator/lib"/>
- <buildpathentry kind="src" path="lib/propel-1.6.1/runtime/lib"/>
- <buildpathentry kind="src" path="build/propel"/>
+ <buildpathentry kind="src" path="generator"/>
+ <buildpathentry kind="src" path="lib/propel-1.6.2/generator/lib"/>
+ <buildpathentry kind="src" path="test/listener-behavior"/>
</buildpath>
View
4 .settings/org.eclipse.php.core.prefs
@@ -1,5 +1,5 @@
-#Fri Jul 15 22:15:26 CEST 2011
+#Mon Oct 03 17:45:45 CEST 2011
eclipse.preferences.version=1
-include_path=0;/propel-listener-behavior/src\u00050;/propel-listener-behavior/build/propel\u00050;/propel-listener-behavior/lib/propel-1.6.1/generator/lib\u00050;/propel-listener-behavior/lib/propel-1.6.1/runtime/lib
+include_path=0;/propel-listener-behavior/generator\u00050;/propel-listener-behavior/test/fixtures/listener-behavior/build/classes\u00050;/propel-listener-behavior/lib/propel-1.6.2/generator/lib\u00050;/propel-listener-behavior/runtime\u00050;/propel-listener-behavior/lib/propel-1.6.2/runtime/lib\u00050;/propel-listener-behavior/test/listener-behavior\u00051;/usr/local/Cellar/php/5.3.6/lib/php/PHPUnit
phpVersion=php5.3
use_asp_tags_as_php=false
View
9 src/generator/ListenerBehavior.php → generator/ListenerBehavior.php
@@ -55,10 +55,6 @@ private function createListenerTable()
$callback->setSize(100);
$params = new Column('json_params');
-
- // arrays don't work properly, see ticket: http://www.propelorm.org/ticket/1482
- // use text and json_encode and json_decode as workaround
-// $params->getDomain()->copy($db->getPlatform()->getDomainForType(PropelTypes::PHP_ARRAY));
$params->getDomain()->copy($db->getPlatform()->getDomainForType(PropelTypes::LONGVARCHAR));
$event = new Column('event');
@@ -128,8 +124,7 @@ public function preInsert()
public function postInsert()
{
- return '$this->notifyListener(\'postInsert\');
-$this->saveEnqueuedListeners();';
+ return '$this->notifyListener(\'postInsert\');';
}
public function preSave()
@@ -139,7 +134,7 @@ public function preSave()
public function postSave()
{
- return '$this->notifyListener(\'postSave\');';
+ return '$this->notifyListener(\'postSave\');'."\n".'$this->saveEnqueuedListeners();';
}
public function preUpdate()
View
2 src/generator/ListenerCollectionBehavior.php → generator/ListenerCollectionBehavior.php
@@ -1,5 +1,7 @@
<?php
+require_once 'ListenerTable.php';
+
class ListenerCollectionBehavior extends Behavior
{
public function objectMethods()
View
0 src/generator/ListenerTable.php → generator/ListenerTable.php
File renamed without changes.
View
19 ...enerator/templates/ListenerCollection.php → generator/templates/ListenerCollection.php
@@ -25,7 +25,7 @@ private static function implode_recursive($glue, $pieces)
* @param mixed $listener information about the listener
* @param String $event the event at which the listener fires
*/
-public static function getListenerInfo($listener, $target, $refId = null)
+public static function getListenerConfig($listener, $target, $refId = null)
{
$default = array(
'on' => null,
@@ -36,8 +36,8 @@ public static function getListenerInfo($listener, $target, $refId = null)
'ref_id' => $refId,
);
- if ($listener instanceof ListenerInfo) {
- $listener = $listener->getListenerInfo();
+ if ($listener instanceof ListenerConfigInterface) {
+ $listener = $listener->getListenerConfig();
} else if (is_string($listener) && function_exists($listener)) {
$listener = array('callback' => $listener);
} else if (is_string($listener) && class_exists($listener)) {
@@ -94,7 +94,7 @@ public static function addListenerToRuntime(<?php echo $listenerName; ?> $l) {
}
if (!in_array($l, self::$globalListeners[$l->getTarget()][$l->getEvent()])) {
- self::$globalListeners[$l->getTarget()][$l->getEvent()][] = $l;
+ self::$globalListeners[$l->getTarget()][$l->getEvent()][$l->getId()] = $l;
}
}
@@ -105,13 +105,8 @@ public static function addListenerToRuntime(<?php echo $listenerName; ?> $l) {
* @param <?php echo $listenerName; ?> $l
*/
public static function removeListenerFromRuntime(<?php echo $listenerName; ?> $l) {
- try {
- self::getGlobalListeners();
- $key = array_search($l, self::$globalListeners[$l->getTarget()][$l->getEvent()]);
- if ($key) {
- unset(self::$globalListeners[$l->getTarget()][$l->getEvent()][$key]);
- }
- } catch (Exception $e) {}
+ self::getGlobalListeners();
+ unset(self::$globalListeners[$l->getTarget()][$l->getEvent()][$l->getId()]);
}
/**
@@ -150,7 +145,7 @@ public function setParams($v)
* Adds a listener to the static collection, to keep the collection in sync during runtime.
*/
public function postInsert(PropelPDO $con = null) {
- if ($this->target == '') {
+ if ($this->target == '') {
self::addListenerToRuntime($this);
}
}
View
50 src/generator/templates/ObjectListener.php → generator/templates/ObjectListener.php
@@ -1,37 +1,32 @@
/**
-* Stores dynamic listeners
+* Stores local listeners
* @type array
*/
private $listeners = null;
/**
-* Stores dynamic listeners queue
+* Stores local listeners queue
* @type array
*/
private $listenerQueue = null;
/**
* Saves a listener in the database
*
-* @param mixed $listener information about the listener
+* @param mixed $listener listener-config
+* @param int $refId reference id for binding a local listener to a tupel
*/
private static function saveListener($listener, $refId = null)
{
- $listener = <?php echo $listenerName; ?>::getListenerInfo($listener, get_called_class(), $refId);
-
- // prepare for saving
- $todb = array();
- foreach (array_keys($listener) as $key) {
- $todb[ucfirst($key)] = $listener[$key];
- }
-
+ $listener = <?php echo $listenerName; ?>::getListenerConfig($listener, get_called_class(), $refId);
+
// save listener
$l = <?php echo $listenerName; ?>Query::create()->findOneById($listener['id']);
if (is_null($l)) {
$l = new <?php echo $listenerName; ?>();
- $l->fromArray($todb);
- if (array_key_exists('Params', $todb)) {
- $l->setParams($todb['Params']);
+ $l->fromArray($listener, BasePeer::TYPE_FIELDNAME);
+ if (array_key_exists('params', $listener)) {
+ $l->setParams($listener['params']);
}
$l->save();
}
@@ -42,7 +37,7 @@ private static function saveListener($listener, $refId = null)
/**
* Adds a global listener to the collection
*
-* @param mixed $listener information about the listener
+* @param mixed $listener listener-config
*/
public static function addGlobalListener($listener)
{
@@ -52,7 +47,7 @@ public static function addGlobalListener($listener)
/**
* Adds a local listener to the collection
*
-* @param mixed $listener information about the listener
+* @param mixed $listener listener-config
*/
public function addListener($listener)
{
@@ -61,7 +56,12 @@ public function addListener($listener)
}
if (is_array($this->getPrimaryKey())) {
- throw new PropelException('Cannot add dynamic listener on an object with a composite primary key');
+ throw new PropelException('Cannot add local listener on an object with a composite primary key');
+ }
+
+ // pre fill $this->listeners. So new listeners won't be saved here once the object isn't saved itself
+ if (is_null($this->listeners)) {
+ $this->getListeners();
}
// enqueue listener, if this is new
@@ -74,19 +74,18 @@ public function addListener($listener)
// anyway save it
else {
- $listeners = $this->getListeners();
$this->listeners[] = self::saveListener($listener, $this->getPrimaryKey());
}
}
/**
* Removes a global listener from the collection
*
-* @param mixed $listener information about the listener
+* @param mixed $listener listener-config
*/
public static function removeGlobalListener($listener)
{
- $listener = $this->getListenerInfo($listener, get_called_class());
+ $listener = <?php echo $listenerName; ?>::getListenerConfig($listener, get_called_class());
$l = <?php echo $listenerName; ?>Query::create()->findOneById($listener['id']);
@@ -99,10 +98,10 @@ public static function removeGlobalListener($listener)
/**
* Removes a local listener from the collection
*
-* @param mixed $listener information about the listener
+* @param mixed $listener listener-config
*/
public function removeListener($listener) {
- $listener = $this->getListenerInfo($listener, get_class($this));
+ $listener = <?php echo $listenerName; ?>::getListenerConfig($listener, get_class($this), $this->getPrimaryKey());
$l = <?php echo $listenerName; ?>Query::create()->findOneById($listener['id']);
@@ -135,7 +134,7 @@ private function notifyListener($event) {
$listeners = array_merge($listeners, $allListeners[<?php echo $listenerName; ?>::ALL]);
}
- // grab dynamic listeners
+ // grab local listeners
$listeners = array_merge($listeners, $this->getListeners());
if (count($listeners)) {
@@ -164,7 +163,7 @@ private function notifyListener($event) {
}
/**
-* Returns the dynamic listeners
+* Returns the local listeners
*
* @return array
*/
@@ -185,8 +184,9 @@ private function saveEnqueuedListeners() {
if (is_array($this->listenerQueue)) {
$this->getListeners();
foreach ($this->listenerQueue as $l) {
- $this->listeners = array_merge($this->listeners, self::saveListener($l, $this->getPrimaryKey()));
+ $this->listeners[] = self::saveListener($l, $this->getPrimaryKey());
}
+ $this->listenerQueue = null;
}
}
View
1 lib/.gitignore
@@ -0,0 +1 @@
+/propel
View
38 lib/propel-1.6.1/CHANGELOG
@@ -1,38 +0,0 @@
-= Changelog Of The Propel 1.6 Branch =
-
-== 2011-06-14: Version 1.6.1 ==
-
- * [2318] Fixed handling of custom sqlType in migrations (closes #1348)
- * [2317] fixed `PropelObjectCollection::populateRelation()` when using classPrefix or namespaces (based on a patch by mattleff) (closes #1402)
- * [2316] Made `PropelObjectCollection::populateRelation()` initialize empty collections on entities having no related entity in a one-to-many relationship (closes #1182)
- * [2315] Added all supported MySQL table options (closes #1447)
- * [2314] Fixed phpDoc of generated ActiveRecord getter and setter methods for nested set models
- * [2313] Fixed autoloading of namespaced models when using `useQuery()` (closes #1444)
- * [2312] Fixed formatting issues in generated TableMap classes
- * [2311] Fixed location of FKeys in PostgreSQL migrations (closes #1411)
- * [2310] Fixed handling of empty string values on boolean columns for ActiveRecord mutator and ActiveQuery filter (closes #1437)
- * [2309] fixed inconsistent EOL types in builder classes (closes #1436)
- * [2308] fixed inconsistent EOL types in builder classes (closes #1436)
- * [2307] Fixed "Nesting level too deep" error when similar schemas are used (patch from gepo) (closes #1426)
- * [2306] Improved runtime/exception phpDoc formatting (patch by kupokomapa) (closes #1429)
- * [2305] Improved runtime/logger phpDoc formatting (patch by kupokomapa) (closes #1428)
- * [2304] Improved runtime/connection phpDoc blocks (based on a patch by kupokomapa) (closes #1425)
- * [2303] Added `ModelCriteria::getSelect()` (closes #1412)
- * [2302] Added `PropelOnDemandCollection::toArray()` (closes #1415)
- * [2301] Fixed subquery bug with select (closes #1417)
- * [2300] Added test to prove subquery bug with select (refs #1417)
- * [2299] Fixed `PropelObjectCollection` and `PropelArrayCollection` would throw a fatal error when calling save() in conjunction with readOnly entities (closes #1422)
- * [2298] Improved runtime/config phpDoc blocks (patch by kupokomapa) (closes #1424)
- * [2297] Improved runtime/collections phpDoc blocks (based on a patch by kupokomapa) (closes #1423)
- * [2296] Fixed coding standards in DBAdapter (closes #1421)
- * [2295] Improved runtime/adapter phpDoc blocks (patch by kupokomapa) (refs #1421)
- * [2294] Fixed soft delete via Peer class executes a wrong query (closes #1405)
- * [2293] Fixed `forceDelete()` enables soft delete behavior even when disabled (closes #1404)
- * [2292] Fixed tests under PHP 5.2 (closes #1388)
- * [2291] Fixed minor formatting issue in generated Peer class
- * [2290] Fixed generated column filters for enum columns when passed an arry (closes #1381)
- * [2289] Fixed strict standards error in soft delete behavior (closes #1398)
- * [2288] Added missing `findRoots()` method to nested_set behavior with scope (closes #1397)
- * [2287] Fixed bad binding with SQLSRV adapter (refs #1199) (closes #1400)
- * [2286] Fixed DATE column with defaultValue of 0000-00-00 generates fatal (closes #1389)
- * [2285] Fixed typo in README
View
4 lib/propel-1.6.1/INSTALL
@@ -1,4 +0,0 @@
-I N S T A L L I N G P R O P E L
-==================================
-
-See docs/guide/01-Installation.txt for detailed installation instructions.
View
19 lib/propel-1.6.1/LICENSE
@@ -1,19 +0,0 @@
-Copyright (c) 2005-2010 Hans Lellelid, David Zuelke, Francois Zaninotto
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
View
755 lib/propel-1.6.1/WHATS_NEW
@@ -1,755 +0,0 @@
-= What's new in Propel 1.6? =
-
-[[PageOutline]]
-
-Propel 1.6 is a new backwards compatible iteration of the Propel 1.x branch. As usual, don't forget to rebuild your model once you upgrade to this new version.
-
-== Migrations ==
-
-How do you manage changes to your database as the Model evolves and the schema changes? Calling the `sql` and `insert-sql` task each time the schema is updated has one dreadful drawback: it erases all the data in the database.
-
-Starting with Propel 1.6, the `sql`-`insert-sql` sequence is replaced by the `diff`-`migrate` sequence:
-
-{{{
-> propel-gen diff
-
-[propel-sql-diff] Reading databases structure...
-[propel-sql-diff] 1 tables imported from databases.
-[propel-sql-diff] Loading XML schema files...
-[propel-sql-diff] 2 tables found in 1 schema file.
-[propel-sql-diff] Comparing models...
-[propel-sql-diff] Structure of database was modified: 1 added table, 1 modified table
-[propel-sql-diff] "PropelMigration_1286484196.php" file successfully created in /path/to/project/build/migrations
-[propel-sql-diff] Please review the generated SQL statements, and add data migration code if necessary.
-[propel-sql-diff] Once the migration class is valid, call the "migrate" task to execute it.
-
-> propel-gen migrate
-
-[propel-migration] Executing migration PropelMigration_1286484196 up
-[propel-migration] 4 of 4 SQL statements executed successfully on datasource "bookstore"
-[propel-migration] Migration complete. No further migration to execute.
-}}}
-
-`diff` compares the schema to the database, and generates a class with all the required `ALTER TABLE` and `CREATE TABLE` statements to update the database structure. This migration class then feeds the `migrate` task, which connects to the database and executes the migrations - with no data loss.
-
-Migrations are a fantastic way to work on complex projects with always evolving models ; they are also a great tool for team work, since migration classes can be shared among all developers. That way, when a developer adds a table to the model, a second developer just needs to run the related migration to have the table added to the table.
-
-Propel migrations can also be executed incrementally - the new `up` and `down` tasks are there for that. And when you're lost in migration, call the `status` task to chack which migrations were already executed, and which ones should be executed to update the database structure.
-
-The Propel guide offers [wiki:Documentation/1.6/Migrations an entire chapter on Migrations] to explain how to use them and how they work.
-
-Migrations only work on MySQL and PostgreSQL for now. On other platforms, you should continue to use `sql` and `insert-sql`.
-
-== New Behaviors ==
-
-Propel 1.6 ships with more core behaviors than ever.
-
-=== Versionable behavior ===
-
-Once enabled on a table, the `versionable` behavior will store a copy of the !ActiveRecord object in a separate table each time it is saved. This allows to keep track of the changes made on an object, whether to review modifications, or revert to a previous state.
-
-The classic Wiki example is a good illustration of the utility of the `versionable` behavior:
-
-{{{
-#!xml
-<table name="wiki_page">
- <column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" />
- <column name="title" type="VARCHAR" required="true" />
- <column name="body" type="LONGVARCHAR" />
- <behavior name="versionable" />
-</table>
-}}}
-
-After rebuild, the `WikiPage` model has versioning abilities:
-
-{{{
-#!php
-<?php
-$page = new WikiPage();
-
-// automatic version increment
-$page->setTitle('Propel');
-$page->setBody('Propel is a CRM built in PHP');
-$page->save();
-echo $page->getVersion(); // 1
-$page->setBody('Propel is an ORM built in PHP5');
-$page->save();
-echo $page->getVersion(); // 2
-
-// reverting to a previous version
-$page->toVersion(1);
-echo $page->getBody(); // 'Propel is a CRM built in PHP'
-// saving a previous version creates a new one
-$page->save();
-echo $page->getVersion(); // 3
-
-// checking differences between versions
-print_r($page->compareVersions(1, 2));
-// array(
-// 'Body' => array(1 => 'Propel is a CRM built in PHP', 2 => 'Propel is an ORM built in PHP5'),
-// );
-
-// deleting an object also deletes all its versions
-$page->delete();
-}}}
-
-The `versionable` behavior offers audit log functionality, so you can track who made a modification, when, and why:
-
-{{{
-#!php
-<?php
-$page = new WikiPage();
-$page->setTitle('PEAR');
-$page->setBody('PEAR is a framework and distribution system for reusable PHP components');
-$page->setVersionCreatedBy('John Doe');
-$page->setVersionComment('First draft');
-$page->save();
-// do more modifications...
-
-// list all modifications
-foreach ($page->getAllVersions() as $pageVersion) {
- echo sprintf("'%s', Version %d, updated by %s on %s (%s)\n",
- $pageVersion->getTitle(),
- $pageVersion->getVersion(),
- $pageVersion->getVersionCreatedBy(),
- $pageVersion->getVersionCreatedAt(),
- $pageVersion->getVersionComment(),
- );
-}
-// 'PEAR', Version 1, updated by John Doe on 2010-12-21 22:53:02 (First draft)
-// 'PEAR', Version 2, updated by ...
-}}}
-
-If it was just for that, the `versionable` behavior would already be awesome. Versioning is a very common feature, and there is no doubt that this behavior will replace lots of boilerplate code. Consider the fact that it's very configurable, [wiki:Documentation/1.6/Behaviors/versionable fully documented], and unit tested, and there is no reason to develop your own versioning layer.
-
-But there is more. The `versionable` behavior also works on relationships. If the `WikiPage` has one `Category`, and if the `Category` model also uses the `versionable` behavior, then each time a `WikiPage` is saved, it saves the version of the related `Category` it is related to, and it is able to restore it:
-
-{{{
-#!php
-<?php
-$category = new Category();
-$category->setName('Libraries');
-$page = new WikiPage();
-$page->setTitle('PEAR');
-$page->setBody('PEAR is a framework and distribution system for reusable PHP components');
-$page->setCategory($category);
-$page->save(); // version 1
-
-$page->setTitle('PEAR - PHP Extension and Application Repository');
-$page->save(); // version 2
-
-$category->setName('PHP Libraries');
-$page->save(); // version 3
-
-$page->toVersion(1);
-echo $page->getTitle(); // 'PEAR'
-echo $page->getCategory()->getName(); // 'Libraries'
-$page->toVersion(3);
-echo $page->getTitle(); // 'PEAR - PHP Extension and Application Repository'
-echo $page->getCategory()->getName(); // 'PHP Libraries'
-}}}
-
-Now the versioning is not limited to a single class anymore. You can even design a fully versionable '''application''' - it all depends on your imagination.
-
-=== I18n behavior ===
-
-The `i18n` behavior provides support for internationalization on the model. Using this behavior, the text columns of an !ActiveRecord object can have several translations.
-
-This is useful in multilingual applications, such as an e-commerce website selling home appliances across the world. This website should keep the name and description of each item separated from the other details, and keep one version for each supported language.
-
-Starting with Propel 1.6, this is possible by adding a simple `<behavior>` tag to the table that needs internationalization:
-
-{{{
-#!xml
-<table name="item">
- <column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" />
- <column name="name" type="VARCHAR" required="true" />
- <column name="description" type="LONGVARCHAR" />
- <column name="price" type="FLOAT" />
- <column name="is_in_store" type="BOOLEAN" />
- <behavior name="i18n">
- <parameter name="i18n_columns" value="name, description" />
- </behavior>
-</table>
-}}}
-
-In this example, the `name` and `description` columns are moved to a new table, called `item_i18n`, which shares a many-to-one relationship with Item - one Item has many Item translations. But all this happens in the background; for the end user, everything happens as if there were only one main `Item` object:
-
-{{{
-#!php
-<?php
-$item = new Item();
-$item->setPrice('12.99');
-$item->setName('Microwave oven');
-$item->save();
-}}}
-
-This creates one record in the `item` table with the price, and another in the `item_i18n` table with the English (default language) translation for the name. Of course, you can add more translations:
-
-{{{
-#!php
-<?php
-$item->setLocale('fr_FR');
-$item->setName('Four micro-ondes');
-$item->setLocale('es_ES');
-$item->setName('Microondas');
-$item->save();
-}}}
-
-This works both for setting AND for getting internationalized columns:
-
-{{{
-#!php
-<?php
-$item->setLocale('en_EN');
-echo $item->getName(); //'Microwave oven'
-$item->setLocale('fr_FR');
-echo $item->getName(); // 'Four micro-ondes'
-}}}
-
-'''Tip''': The big advantage of Propel behaviors is that they use code generation. Even though it's only a proxy method to the `ItemI18n` class, `Item::getName()` has all the phpDoc required to make your IDE happy.
-
-This new behavior also adds special capabiliies to the Query objects. The most interesting allows you to execute less queries when you need to query for an Item and one of its translations - which is common to display a list of items in the locale of the user:
-
-{{{
-#!php
-<?php
-$items = ItemQuery::create()->find(); // one query to retrieve all items
-$locale = 'en_EN';
-foreach ($items as $item) {
- echo $item->getPrice();
- $item->setLocale($locale);
- echo $item->getName(); // one query to retrieve the English translation
-}
-}}}
-
-This code snippet requires 1+n queries, n being the number of items. But just add one more method call to the query, and the SQL query count drops to 1:
-
-{{{
-#!php
-<?php
-$items = ItemQuery::create()
- ->joinWithI18n('en_EN')
- ->find(); // one query to retrieve both all items and their translations
-foreach ($items as $item) {
- echo $item->getPrice();
- echo $item->getName(); // no additional query
-}
-}}}
-
-In addition to hydrating translations, `joinWithI18n()` sets the correct locale on results, so you don't need to call `setLocale()` for each result.
-
-'''Tip''': `joinWithI18n()` adds a left join with two conditions. That means that the query returns all items, including those with no translation. If you need to return only objects having translations, add `Criteria::INNER_JOIN` as second parameter to `joinWithI18n()`.
-
-Last but not least, Propel's `i18n` behavior is a drop-in replacement for symfony's `i18n` behavior. That means that with a couple more parameters, the locale can be accessed using `setCulture()`, and the `i18n_columns` parameter can be omitted if you explicit the `i18n` table.
-
-Just like the `versionable` behavior, the `i18n` behavior is thoroughly unit-tested and [wiki:Documentation/1.6/Behaviors/i18n fully documented].
-
-== XML/YAML/JSON/CSV Parsing and Dumping ==
-
-ActiveRecord and Collection objects now have the ability to be converted to and from a string, using any of the XML, YAML, JSON, and CSV formats.
-
-The syntax is very intuitive: ActiveRecord and collection objects now offer a `toXML()` and a `fromXML()` method (same for YAML, JSON, and CSV). Here are a few examples:
-
-{{{
-#!php
-<?php
-// dump a collection to YAML
-$books = BookQuery::create()
- ->orderByTitle()
- ->joinWith('Author')
- ->find();
-echo $books->toYAML();
-// Book_1:
-// Id: 123
-// Title: Pride and Prejudice
-// AuthorId: 456
-// Author:
-// Id: 456
-// FirstName: Jane
-// LastName: Austen
-// Book_2:
-// Id: 789
-// Title: War and Peace
-// AuthorId: 147
-// Author:
-// Id: 147
-// FirstName: Leo
-// LastName: Tolstoi
-
-// parse an XML string into an object
-$bookString = <<<EOF
-<?xml version="1.0" encoding="UTF-8"?>
-<data>
- <Id>9012</Id>
- <Title><![CDATA[Don Juan]]></Title>
- <ISBN><![CDATA[0140422161]]></ISBN>
- <Price>12.99</Price>
- <PublisherId>1234</PublisherId>
- <AuthorId>5678</AuthorId>
-</data>
-EOF;
-$book = new Book();
-$book->fromXML($bookString);
-echo $book->getTitle(); // Don Juan
-}}}
-
-== Model Objects String Representation ==
-
-Taking advantage of the dumping abilities just introduced, all ActiveRecord objects now have a string representation based on a YAML dump of their properties:
-
-{{{
-#!php
-<?php
-$author = new Author();
-$author->setFirstName('Leo');
-$author->setLastName('Tolstoi');
-echo $author;
-// Id: null
-// FirstName: Leo
-// LastName: Tolstoi
-// Email: null
-// Age: null
-}}}
-
-'''Tip''': Tables with a column using the `isPrimaryString` attribute still output the value of a single column as string representation.
-
-`PropelCollection` objects also take advantage from this possibility:
-
-{{{
-#!php
-<?php
-$authors = AuthorQuery::create()
- ->orderByLastName()
- ->find();
-echo $authors;
-// Author_0:
-// Id: 456
-// FirstName: Jane
-// LastName: Austen
-// Email: null
-// Age: null
-// Author_1:
-// Id: 147
-// FirstName: Leo
-// LastName: Tolstoi
-// Email: null
-// Age: null
-}}}
-
-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">
- <column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" />
- <column name="name" required="true" type="VARCHAR" size="128" />
-</table>
-}}}
-
-{{{
-#!php
-<?php
-$publisher = new Publisher();
-$publisher->setName('Penguin');
-echo $publisher;
-// <?xml version="1.0" encoding="UTF-8"?>
-// <data>
-// <Id></Id>
-// <Name><![CDATA[Peguin]]></Name>
-// </data>
-}}}
-
-== Easier OR in Queries ==
-
-Combining two generated filters with a logical `OR` used to be impossible in previous Propel versions - the alternative was to use `orWhere()` or `combine()`, but that meant losing all the smart defaults of generated filters.
-
-Propel 1.6 introduces a new method for Query objects: `_or()`. It just specifies that the next condition will be combined with a logical `OR` rather than an `AND`.
-
-{{{
-#!php
-<?php
-// Basic usage: _or() as a drop-in replacement for orWhere()
-$books = BookQuery::create()
- ->where('Book.Title = ?', 'War And Peace')
- ->_or()
- ->where('Book.Title LIKE ?', 'War%')
- ->find();
-// SELECT * FROM book WHERE book.TITLE = 'War And Peace' OR book.TITLE LIKE 'War%'
-
-// _or() also works on generated filters:
-$books = BookQuery::create()
- ->filterByTitle('War And Peace')
- ->_or()
- ->filterByTitle('War%')
- ->find();
-// SELECT * FROM book WHERE book.TITLE = 'War And Peace' OR book.TITLE LIKE 'War%'
-
-// _or() also works on embedded queries
-$books = BookQuery::create()
- ->filterByTitle('War and Peace')
- ->_or()
- ->useAuthorQuery()
- ->filterByName('Leo Tolstoi')
- ->endUse()
- ->find();
-// SELECT book.* from book
-// INNER JOIN author ON book.AUTHOR_ID = author.ID
-// WHERE book.TITLE = 'War and Peace'
-// OR author.NAME = 'Leo Tolstoi'
-}}}
-
-This new method is implemented in the `Criteria` class, so it also works for the old-style queries (using `add()` for conditions).
-
-'''Tip''': Since `ModelCriteria::orWhere()` is a synonym for `->_or()->where()`, it is now deprecated.
-
-== Multiple Buildtime Connections ==
-
-Propel 1.5 used the `build.properties` for buildtime connection settings. This had one major drawback: it used to be impossible to deal with several connections at buildtime, let alone several RDBMS.
-
-In Propel 1.6, you can write your buildtime connection settings in a `buildtime-conf.xml` file. The format is the same as the `runtime-conf.xml` file, so a good starting point is to copy the runtime conf, and change the settings for users wit hgreater privileges.
-
-Here is an example buildtime configuration file that defines a MySQL and a SQLite connection:
-
-{{{
-#!xml
-<?xml version="1.0"?>
-<config>
- <propel>
- <datasources default="bookstore">
- <datasource id="bookstore">
- <adapter>mysql</adapter>
- <connection>
- <dsn>mysql:host=localhost;dbname=bookstore</dsn>
- <user>testuser</user>
- <password>password</password>
- </connection>
- </datasource>
- <datasource id="cms">
- <adapter>sqlite</adapter>
- <connection>
- <dsn>sqlite:/opt/databases/mydb.sq3</dsn>
- </connection>
- </datasource>
- </datasources>
- </propel>
-</config>
-}}}
-
-Now that Propel can deal with database vendors at buildtime more accurately, the generated classes offer more optimizations for the database they rely one. Incidentally, that means that you should rebuild your model if you use different database vendors. Thats includes cases when your developement and production environments use different vendors.
-
-== Support For SQL Schemas ==
-
-For complex models showing a large number of tables, database administrators often like to group tables into "SQL schemas", which are namespaces in the SQL server. Starting with Propel 1.6, it is now possible to assign tables to SQL schemas using the `schema` attribute in the `<database>` of the `<table>` tag:
-
-{{{
-#!xml
-<database name="my_connection">
- <table name="book" schema="bookstore">
- <column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" />
- <column name="title" type="VARCHAR" required="true" />
- <column name="author_id" type="INTGER" />
- <foreign-key foreignTable="author" foreignSchema="people" onDelete="setnull" onUpdate="cascade">
- <reference local="author_id" foreign="id" />
- </foreign-key>
- </table>
- <table name="author" schema="people">
- <column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" />
- <column name="name" type="VARCHAR" required="true" />
- </table>
-</database>
-}}}
-
-'''Tip''': This feature is only available in PostgreSQL, MSSQL, and MySQL. The `schema` attribute is simply ignored in Oracle and SQLite.
-
-Propel also supports foreign keys between tables assigned to two different schemas. For MySQL, where "SQL schema" is a synonym for "database", this allows for cross-database queries.
-
-The Propel documentation contains a new tutorial about the SQL schema attributes and usage, called [wiki:Documentation/1.6/Using-SQL-Schemas Using SQL Schemas].
-
-== Foreign Key Filters Now Accept a Collection ==
-
-The generated `filterByRelationName()` methods in the model queries now accept a `PropelCollection` as argument. This will allow you to keep using objects and avoid dealing with foreign keys completely:
-
-{{{
-#!php
-<?php
-// get young authors
-$authors = AuthorQuery::create()
- ->filterByAge(array('max' => 35))
- ->find(); // $authors is a PropelObjectCollection
-// get all books by young authors
-$books = BookQuery::create()
- ->filterByAuthor($authors) // <= That's new
- ->find();
-}}}
-
-== Join With Several Conditions ==
-
-Creating a Join with more than one connection is now very easy. Just call `ModelCriteria::addJoinCondition($joinName, $condition)` after a `ModelCriteria::join()` to add further conditions to a join:
-
-{{{
-#!php
-<?php
-$authors = AuthorQuery::create()
- ->join('Author.Book')
- ->addJoinCondition('Book', 'Book.Title IS NOT NULL')
- ->find();
-// SELECT * FROM author
-// INNER JOIN book ON (author.ID=book.AUTHOR_ID AND book.TITLE IS NOT NULL);
-}}}
-
-If you need to bind a variable to the condition, set the variable as last parameter of the `addJoinCondition()` call. Propel correctly binds the value using PDO:
-
-{{{
-#!php
-<?php
-$authors = AuthorQuery::create()
- ->join('Author.Book')
- ->addJoinCondition('Book', 'Book.Title LIKE ?', 'War%')
- ->find();
-// SELECT * FROM author
-// INNER JOIN book ON (author.ID=book.AUTHOR_ID AND book.TITLE LIKE 'War%');
-}}}
-
-'''Tip''': `Criteria::addMultipleJoin()`, which allowed the same feature to some extent in previous versions, is now deprecated, since it was vulnerable in SQL injection attacks.
-
-== Model-Only Relationships ==
-
-Propel models can share relationships even though the underlying tables aren't linked by a foreign key. This ability may be of great use when using Propel on top of a legacy database.
-
-For example, a `review` table designed for a MyISAM database engine is linked to a `book` table by a simple `book_id` column:
-
-{{{
-#!xml
-<table name="review">
- <column name="review_id" type="INTEGER" primaryKey="true" required="true"/>
- <column name="reviewer" type="VARCHAR" size="50" required="true"/>
- <column name="book_id" required="true" type="INTEGER"/>
-</table>
-}}}
-
-To enable a model-only relationship, add a `<foreign-key>` tag using the `skipSql` attribute, as follows:
-
-{{{
-#!xml
-<table name="review">
- <column name="review_id" type="INTEGER" primaryKey="true" required="true"/>
- <column name="reviewer" type="VARCHAR" size="50" required="true"/>
- <column name="book_id" required="true" type="INTEGER"/>
- <!-- Model-only relationship -->
- <foreign-key foreignTable="book" onDelete="CASCADE" skipSql="true">
- <reference local="book_id" foreign="id"/>
- </foreign-key>
-</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.
-
-== Advanced Column Types ==
-
-Propel 1.6 introduces a new set of column types. The database-agnostic implementation allows these column types to work on all supported RDBMS.
-
-=== ENUM Columns ===
-
-Although stored in the database as integers, ENUM columns let users manipulate a set of predefined values, without worrying about their storage.
-
-{{{
-#!xml
-<table name="book">
- ...
- <column name="style" type="ENUM" valueSet="novel, essay, poetry" />
-</table>
-}}}
-
-{{{
-#!php
-<?php
-// The ActiveRecord setter and getter let users use any value from the valueSet
-$book = new Book();
-$book->setStyle('novel');
-echo $book->getStyle(); // novel
-// Trying to set a value not in the valueSet throws an exception
-
-// Each value in an ENUM column has a related constant in the Peer class
-// Your IDE with code completion should love this
-echo BookPeer::STYLE_NOVEL; // 'novel'
-echo BookPeer::STYLE_ESSAY; // 'essay'
-echo BookPeer::STYLE_POETRY; // 'poetry'
-// The Peer class also gives access to list of available values
-print_r(BookPeer::getValueSet(BookPeer::STYLE)); // array('novel', 'essay', 'poetry')
-
-// ENUM columns are also searchable, using the generated filterByXXX() method
-// or other ModelCritera methods (like where(), orWhere(), condition())
-$books = BookQuery::create()
- ->filterByStyle('novel')
- ->find();
-}}}
-
-=== OBJECT Columns ===
-
-An `OBJECT` column can store PHP objects (mostly Value Objects) in the database. The column setter serializes the object, which is later stored to the database as a string. The column getter unserializes the string and returns the object. Therefore, for the end user, the column contains an object.
-
-{{{
-#!php
-<?php
-class GeographicCoordinates
-{
- public $latitude, $longitude;
-
- public function __construct($latitude, $longitude)
- {
- $this->latitude = $latitude;
- $this->longitude = $longitude;
- }
-
- public function isInNorthernHemisphere()
- {
- return $this->latitude > 0;
- }
-}
-
-// The 'house' table has a 'coordinates' column of type OBJECT
-$house = new House();
-$house->setCoordinates(new GeographicCoordinates(48.8527, 2.3510));
-echo $house->getCoordinates()->isInNorthernHemisphere(); // true
-$house->save();
-}}}
-
-Not only do `OBJECT` columns benefit from these smart getter and setter in the generated Active Record class, they are also searchable using the generated `filterByXXX()` method in the query class:
-
-{{{
-#!php
-<?php
-$house = HouseQuery::create()
- ->filterByCoordinates(new GeographicCoordinates(48.8527, 2.3510))
- ->find();
-}}}
-
-Propel looks in the database for a serialized version of the object passed as parameter of the `filterByXXX()` method.
-
-=== ARRAY Columns ===
-
-An `ARRAY` column can store a simple PHP array in the database (nested arrays and associative arrays are not accepted). The column setter serializes the array, which is later stored to the database as a string. The column getter unserializes the string and returns the array. Therefore, for the end user, the column contains an array.
-
-{{{
-#!php
-<?php
-// The 'book' table has a 'tags' column of type ARRAY
-$book = new Book();
-$book->setTags(array('novel', 'russian'));
-print_r($book->getTags()); // array('novel', 'russian')
-
-// If the column name is plural, Propel also generates hasXXX(), addXXX(),
-// and removeXXX() methods, where XXX is the singular column name
-echo $book->hasTag('novel'); // true
-$book->addTag('romantic');
-print_r($book->getTags()); // array('novel', 'russian', 'romantic')
-$book->removeTag('russian');
-print_r($book->getTags()); // array('novel', 'romantic')
-}}}
-
-Propel doesn't use `serialize()` to transform the array into a string. Instead, it uses a special serialization function, that makes it possible to search for values of `ARRAY` columns.
-
-{{{
-#!php
-<?php
-// Search books that contain all the specified tags
-$books = BookQuery::create()
- ->filterByTags(array('novel', 'russian'), Criteria::CONTAINS_ALL)
- ->find();
-
-// Search books that contain at least one of the specified tags
-$books = BookQuery::create()
- ->filterByTags(array('novel', 'russian'), Criteria::CONTAINS_SOME)
- ->find();
-
-// Search books that don't contain any of the specified tags
-$books = BookQuery::create()
- ->filterByTags(array('novel', 'russian'), Criteria::CONTAINS_NONE)
- ->find();
-
-// If the column name is plural, Propel also generates singular filter methods
-// expecting a scalar parameter instead of an array
-$books = BookQuery::create()
- ->filterByTag('russian')
- ->find();
-}}}
-
-'''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()`, `orWhere()`, and `condition()`) allow conditions on `ENUM`, `OBJECT`, and `ARRAY` columns. `Criteria` alone (through `add()`, `addAnd()`, and `addOr()`) does not support conditions on such columns.
-
-== Table Subqueries (a.k.a "Inline Views") ==
-
-SQL supports table subqueries to solve complex cases that a single query can't solve, or to optimize slow queries with several joins. For instance, to find the latest book written by every author in SQL, it usually takes a query like the following:
-
-{{{
-#!sql
-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
-FROM
-(
- 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
-WHERE lastBook.PRICE < 20
-}}}
-
-To achieve this query using Propel, call the new `addSelectQuery()` method to use a first query as the source for the SELECT part of a second query:
-
-{{{
-$latestBooks = BookQuery::create()
- ->withColumn('MAX(Book.CreatedAt)')
- ->groupBy('Book.AuthorId');
-$latestCheapBooks = BookQuery::create()
- ->useSelectQuery($latestBooks, 'lastBook')
- ->where('lastBook.Price < ?', 20)
- ->find();
-}}}
-
-You could use two queries or a WHERE IN to achieve the same result, but it wouldn't be as effective.
-
-Inline views are used a lot in Oracle, so this addition should make Propel even more Oracle-friendly.
-
-== Better Pluralizer ==
-
-Have you ever considered Propel as a lame English speaker? Due to its poor pluralizer, Propel used to be unable to create proper getter methods in one-to-many relationships when dealing with foreign objects named 'Child', 'Category', 'Wife', or 'Sheep'.
-
-Starting with Propel 1.6, Propel adds a new pluralizer class named `StandardEnglishPluralizer`, which should take care of most of the irregular plural forms of your domain class names. This new pluralizer is disabled by default for backwards compatibility reasons, but it's very easy to turn it on in your `build.properties` file:
-
-{{{
-#!ini
-propel.builder.pluralizer.class = builder.util.StandardEnglishPluralizer
-}}}
-
-Rebuild your model, and voila: ActiveRecord objects can now retrieve foreign objects using `getChildren()`, `getCategories()`, `getWives()`, and... `getSheep()`.
-
-== New Reference Chapter in the Documentation: Active Record ==
-
-There wasn't any one-stop place to read about the abilities of the generated Active Record objects in the Propel documentation. Since Propel 1.6, the new [wiki:Documentation/1.6/ActiveRecord Active Record reference] makes it easier to learn the usage of Propel models using code examples.
-
-== Miscellaneous ==
-
- * The runtime performance was tweaked on various places. Small boosts may be visible when logging is enabled, and on large batch processes.
- * A new `dbd2propel` task allows to convert [http://www.fabforce.net/dbdesigner4/ DBDesigner 4] models to a Propel schema in an easier way than the previous PHP script located under the `contrib/` folder. See the new [wiki:Documentation/1.6/DBDesigner DBDesigner2Propel chapter] for details.
- * By the way, the `contrib/` directory was removed from the core - it was not maintained anymore. Previous versions can be found in the 1.5 branch.
- * `ModelCriteria::keepQuery()` is now ON by default. This will remove bad surprises when doing a `count()` before a `find()`, and has a very limited impact on performance. You should not need to manually call `keepQuery()` anymore.
- * `ModelCriteria::with()` is now a little smarter, and therefore reduces even more the query count when hydrating one-to-many relationships.
- * Runtime Exceptions now look better in PHP 5.3, since Propel takes advantage of exception linking
- * Read queries (issued by Query termination methods `findPk()`, `find()`, `findOne()`, and `count()`) now don't create a transaction by default. Write queries still do.
- * The !ActiveRecord and !ActiveQuery APIs have been harmonized to provide similar parameter conversion for temporal and boolean columns in generated setters and filters. For instance, you can now set a boolean column to 'yes', or filter a temporal column on the 'now' string. The phpDoc blocks of generated setters and filters were rewritten to reflect these changes, so check the generated classes for details.
- * The generated `toArray()` method for !ActiveRecord objects can now include collections, without risk of infinite recursion. Therefore `$author->toArray()` also outputs the collection of Books by the author. The dumping abilities introduced in 1.6 take advantage of this feature.
- * `PropelModelPager` now behaves more like a `PropelCollection`, thanks to the addition of `isFirst()`, `isLast()`, `isOdd()`, and `isEven()` methods. That means that it's easier to replace a `find()` by a `paginate()` as termination method for a query if there is a complex formatting.
- * Despite all that you may have read about PHP 5.3's garbage collector, memory leaks still exist on some particular circular references. Propel generates a `clearAllReferences()` method on all !ActiveRecord classes, and this method has been improved in Propel 1.6 to handle the existing leaks. Use it when you iterate on large collections of objects, or where the memory is limited.
- * For each database, Behaviors are now added to a priority queue. This allows to execute some behaviors before others, and to solve conflicts between behaviors. See [wiki:Documentation/1.6/Writing-Behavior#SpecifyingaPriorityForBehaviorExecution How to Write a Behavior].
- * Behaviors can now modify existing methods even if no hook is called in the builders, thanks to a new service class called `PropelPHPParser`. This class can remove a method, replace a method by another one, or add a new method before or after an existing one. See the [wiki:Documentation/1.6/Behaviors#ReplacingorRemovingExistingMethods Behavior Documentation] for details.
- * Propel now supports tablespace definition on Oracle tables using custom `<vendor>` tags. See the [wiki:Documentation/1.6/Schema#AddingVendorInfo Schema reference] for details.
- * The built-in [wiki:Documentation/1.6/Runtime-Introspection Runtime Introspection] classes are now a little smarter: `TableMap` objects have the knowledge of the primary string column.
View
70 lib/propel-1.6.1/generator/bin/propel-gen
@@ -1,70 +0,0 @@
-#!/bin/sh
-# Shell wrapper for Propel generator
-# $Id$
-#
-# This script will do the following:
-# - check for PHING_COMMAND env, if found, use it.
-# - if not found assume php is on the path
-# - check for PROPEL_GEN_HOME env, if found use it
-# - if not look for it
-
-if [ -z "$PROPEL_GEN_HOME" ] ; then
-
- # try to find Propel
- if [ -d /opt/propel/generator ] ; then
- PROPEL_GEN_HOME=/opt/propel/generator
- fi
-
- if [ -d "${HOME}/opt/propel/generator" ] ; then
- PROPEL_GEN_HOME="${HOME}/opt/propel/generator"
- fi
-
- if [ -d "/usr/local/propel/generator" ] ; then
- PROPEL_GEN_HOME="/usr/local/propel/generator"
- fi
-
- if [ -d "${HOME}/usr/propel/generator" ] ; then
- PROPEL_GEN_HOME="${HOME}/usr/propel/generator"
- fi
-
- ## resolve links - the script name may be a link to phing's home
- PRG="$0"
- progname=`basename "$0"`
- saveddir=`pwd`
-
- # need this for relative symlinks
- dirname_prg=`dirname "$PRG"`
- cd "$dirname_prg"
-
- while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
- done
-
- cd "$saveddir"
-
- PROPEL_GEN_HOME=`dirname "$PRG"`/..
-
- # make it fully qualified
- PROPEL_GEN_HOME=`cd "$PROPEL_GEN_HOME" && pwd`
-
- # make it available in PHP via getenv("PROPEL_GEN_HOME")
- export PROPEL_GEN_HOME
-
-fi
-
-if [ -z "$PHING_COMMAND" ] ; then
- # echo "WARNING: PHING_COMMAND environment not set. (Assuming phing on PATH)"
- export PHING_COMMAND="phing"
-fi
-
-if [ $# = 1 ] ; then
- $PHING_COMMAND -f $PROPEL_GEN_HOME/build.xml -Dusing.propel-gen=true -Dproject.dir=$saveddir $*
-else
- $PHING_COMMAND -f $PROPEL_GEN_HOME/build.xml -Dusing.propel-gen=true -Dproject.dir=$*
-fi
View
32 lib/propel-1.6.1/generator/bin/propel-gen.bat
@@ -1,32 +0,0 @@
-@echo off
-
-rem *********************************************************************
-rem ** The Propel generator convenience script for Windows based systems
-rem ** $Id$
-rem *********************************************************************
-
-rem This script will do the following:
-rem - check for PHING_COMMAND env, if found, use it.
-rem - if not found detect php, if found use it, otherwise err and terminate
-rem - check for PROPEL_GEN_HOME env, if found use it
-rem - if not found error and leave
-
-if "%OS%"=="Windows_NT" @setlocal
-
-rem %~dp0 is expanded pathname of the current script under NT
-set DEFAULT_PROPEL_GEN_HOME=%~dp0..
-
-if "%PROPEL_GEN_HOME%" == "" set PROPEL_GEN_HOME=%DEFAULT_PROPEL_GEN_HOME%
-set DEFAULT_PROPEL_GEN_HOME=
-
-if "%PHING_COMMAND%" == "" set PHING_COMMAND=phing.bat
-
-set nbArgs=0
-for %%x in (%*) do Set /A nbArgs+=1
-if %nbArgs% leq 1 (
- %PHING_COMMAND% -f "%PROPEL_GEN_HOME%\build.xml" -Dusing.propel-gen=true -Dproject.dir="%CD%" %*
-) else (
- %PHING_COMMAND% -f "%PROPEL_GEN_HOME%\build.xml" -Dusing.propel-gen=true -Dproject.dir=%*
-)
-
-if "%OS%"=="Windows_NT" @endlocal
View
623 lib/propel-1.6.1/generator/build-propel.xml
@@ -1,623 +0,0 @@
-<project name="propel" default="main">
-
- <!--
- Note - You should not have to edit this file.
-
- Instead, if calling build-propel.xml directly, edit the build.properties
- that is in the same directory. If calling build-propel.xml via another
- build file, you can also use the build.properties in the same directory,
- or set the property propel.contextProperties to the file
- to use in place of build.properties (e.g. project.properties).
- -->
-
- <property name="build.properties" value="build.properties"/>
- <property name="propel.contextProperties" value="./${build.properties}"/>
- <property name="propel.home" value="."/>
-
- <available file="${propel.home}/build.properties" property="globalBuildPopertiesExists"/>
-
- <if>
- <and>
- <isset property="globalBuildPopertiesExists"/>
- </and>
- <then>
- <property file="${propel.home}/build.properties"/>
- </then>
- </if>
-
- <!--
- The default.properties file will map old properties to the new ones along
- with setting the corret defaults.
- -->
- <property file="${propel.home}/default.properties"/>
-
- <!--
- Do forward declarations of all of our tasks to
- centralize them and clean up the targets.
- -->
-
- <path id="propelclasses">
- <pathelement dir="${propel.home}/lib/"/>
- <pathelement dir="${propel.project.dir}/"/>
- </path>
-
- <taskdef
- name="propel-om"
- classname="task.PropelOMTask" classpathRef="propelclasses"/>
- <taskdef
- name="propel-data-dump"
- classname="task.PropelDataDumpTask" classpathRef="propelclasses"/>
- <taskdef
- name="propel-data-sql"
- classname="task.PropelDataSQLTask" classpathRef="propelclasses"/>
- <taskdef
- name="propel-schema-reverse"
- classname="task.PropelSchemaReverseTask" classpathRef="propelclasses"/>
- <taskdef
- name="propel-sql"
- classname="task.PropelSQLTask" classpathRef="propelclasses"/>
- <taskdef
- name="propel-sql-diff"
- classname="task.PropelSQLDiffTask" classpathRef="propelclasses"/>
- <taskdef
- name="propel-migration-status"
- classname="task.PropelMigrationStatusTask" classpathRef="propelclasses"/>
- <taskdef
- name="propel-migration-up"
- classname="task.PropelMigrationUpTask" classpathRef="propelclasses"/>
- <taskdef
- name="propel-migration-down"
- classname="task.PropelMigrationDownTask" classpathRef="propelclasses"/>
- <taskdef
- name="propel-migration"
- classname="task.PropelMigrationTask" classpathRef="propelclasses"/>
- <taskdef
- name="propel-sql-exec"
- classname="task.PropelSQLExec" classpathRef="propelclasses"/>
- <taskdef
- name="propel-graphviz"
- classname="task.PropelGraphvizTask" classpathRef="propelclasses"/>
- <taskdef
- name="propel-convert-conf"
- classname="task.PropelConvertConfTask" classpathRef="propelclasses"/>
-
- <!-- ================================================================ -->
- <!-- M A I N T A R G E T -->
- <!-- ================================================================ -->
- <!-- This default target will run all the targets that generate -->
- <!-- source. You will probably only run this target once then -->
- <!-- call individual targets as necessary to update your sources -->
- <!-- when you change your XML schema. -->
- <!-- ================================================================ -->
-
- <target
- name="main"
- depends="mysqli-check"
- description="==> generates sql + om classes">
-
- <phingcall target="sql"/>
- <phingcall target="om"/>
- <phingcall target="convert-conf"/>
- </target>
-
- <!-- ================================================================ -->
- <!-- C H E C K R U N O N L Y O N S C H E M A C H A N G E -->
- <!-- ================================================================ -->
- <!-- Maps the propel.runOnlyOnSchemaChange to -->
- <!-- propel.internal.runOnlyOnSchemaChange -->
- <!-- ================================================================ -->
-
- <target name="check-run-only-on-schema-change">
- <condition property="propel.internal.runOnlyOnSchemaChange">
- <equals arg1="${propel.runOnlyOnSchemaChange}" arg2="true"/>
- </condition>
- </target>
-
- <!-- ================================================================ -->
- <!-- G E N E R A T E P R O J E C T S Q L -->
- <!-- ================================================================ -->
- <!-- Generate the SQL for your project, These are in addition -->
- <!-- to the base Turbine tables! The tables you require for your -->
- <!-- project should be specified in project-schema.xml. -->
- <!-- ================================================================ -->
-
- <target
- name="sql-check"
- depends="check-run-only-on-schema-change"
- if="propel.internal.runOnlyOnSchemaChange">
- <uptodate
- property="propel.internal.sql.uptodate"
- targetfile="${propel.sql.dir}/${propel.schema.default.basename}.sql">
- <srcfiles dir="${propel.schema.dir}" includes="**/${propel.schema.default.basename}.xml" />
- </uptodate>
- </target>
-
- <!-- temporary target to check whether postgres is being used with identifier quoting ON.
- If so, a warning is issued, since identifier quoting is only paritally implemented & this point. -->
- <target name="pgsql-quoting-check">
- <if>
- <and>
- <equals arg1="${propel.database}" arg2="pgsql"/>
- <equals arg1="${propel.disableIdentifierQuoting}" arg2=""/>
- </and>
- <then>
- <warn>ATTENTION: It appears you are using PostgreSQL and you have identifier-quoting turned on.</warn>
- <warn>It is suggested that you disable identifier quoting when using PostgreSQL -- especially if you</warn>
- <warn>have case-sensitive columns in your database.</warn>
- <warn></warn>
- <warn>To disable identifier quoting, add the following property to your build.properties (or specify</warn>
- <warn>it using -D on commandline):</warn>
- <warn></warn>
- <warn>propel.disableIdentifierQuoting=true</warn>
- <warn></warn>
- <warn>You can ignore this warning if you understand the issues related to case-sensitivity and Propel's</warn>
- <warn>DDL-only implementation of identifier quoting.</warn>
- </then>
- </if>
- </target>
-
- <!-- temporary target to check whether mysqli is being used
- If so, a warning is issued, since this is deprecated -->
- <target name="mysqli-check">
- <if>
- <and>
- <equals arg1="${propel.database}" arg2="mysqli"/>
- </and>
- <then>
- <warn>ATTENTION: It appears you are using the mysqli driver.</warn>
- <warn></warn>
- <warn>This driver is no longer supported by Propel because Propel now uses PDO for database connections.</warn>
- <warn>Please use mysqli driver instead.</warn>
- <fail>Use 'mysql' instead of 'mysqli' for your propel.database property.</fail>
- </then>
- </if>
- </target>
-
- <target
- name="sql"
- depends="sql-check,pgsql-quoting-check,mysqli-check"
- unless="propel.internal.sql.uptodate"
- description="==> generates the SQL for your project">
-
- <echo message="+------------------------------------------+"/>
- <echo message="| |"/>
- <echo message="| Generating SQL for YOUR Propel project! |"/>
- <echo message="| |"/>
- <echo message="+------------------------------------------+"/>
-
- <phingcall target="sql-template"/>
-
- </target>
-
- <target name="sql-template">
- <propel-sql
- validate="${propel.schema.validate}"
- xsd="${propel.schema.xsd.file}"
- xsl="${propel.schema.xsl.file}"
- outputDirectory="${propel.sql.dir}"
- sqldbmap="${propel.sql.dir}/sqldb.map"
- targetDatabase="${propel.database}"
- packageObjectModel="${propel.packageObjectModel}"
- url="${propel.database.url}"
- userId="${propel.database.user}"
- password="${propel.database.password}">
- <mapper type="glob" from="${propel.sql.mapper.from}" to="${propel.sql.mapper.to}"/>
- <schemafileset dir="${propel.schema.dir}"
- includes="${propel.schema.sql.includes}"
- excludes="${propel.schema.sql.excludes}"
- />
- </propel-sql>
- </target>
-
- <!-- ================================================================ -->
- <!-- C R E A T E T A R G E T D A T A B A S E -->
- <!-- ================================================================ -->
- <!-- Create the target database by executing a generated script -->
- <!-- that is capable of performing the task. -->
- <!-- ================================================================ -->
-
- <target name="create-db-check">
- <condition property="propel.internal.manualCreation">
- <equals arg1="${propel.database.manualCreation}" arg2="true"/>
- </condition>
- </target>
-
- <target
- name="create-db"
- unless="propel.internal.manualCreation"
- depends="create-db-check,mysqli-check"
- description="==> generates the target database">
-
- <fail message="create-db target temporarily disabled, while we replace creole components."/>
-
- <!--
- <echo message="Executing the create-db.sql script ..."/>
-
- <sql
- autocommit="true"
- driver="${propel.database.driver}"
- onerror="continue"
- src="${propel.sql.dir}/create-db.sql"
- url="${propel.database.createUrl}"
- />
- -->
- </target>
-
- <!-- ================================================================ -->
- <!-- I N S E R T S I N G L E S Q L F I L E S -->
- <!-- ================================================================ -->
-
- <target
- name="insert-sql"
- description="==> inserts the generated sql ">
-
- <propel-sql-exec
- autocommit="true"
- onerror="continue"
- sqldbmap="${propel.sql.dir}/sqldb.map"
- srcDir="${propel.sql.dir}"
- url="${propel.database.buildUrl}"
- userId="${propel.database.user}"
- password="${propel.database.password}"
- />
- </target>
-
- <!-- ================================================================ -->
- <!-- N E W R E V E R S E T O X M L -->
- <!-- ================================================================ -->
-
- <target
- name="reverse"
- description="==> generate xml schema from reverse-engineered database (new)">
-
- <echo message="+-----------------------------------------------+"/>
- <echo message="| |"/>
- <echo message="| Generating XML from PDO connection ! |"/>
- <echo message="| |"/>
- <echo message="+-----------------------------------------------+"/>
-
- <propel-schema-reverse
- databaseName="${propel.project}"
- dbSchema="${propel.database.schema}"
- dbEncoding="${propel.database.encoding}"
- url="${propel.database.buildUrl}"
- userId="${propel.database.user}"
- password="${propel.database.password}"
- outputFile="${propel.schema.dir}/${propel.default.schema.basename}.xml"
- samePhpName="${propel.samePhpName}"
- addVendorInfo="${propel.addVendorInfo}"
- addValidators="${propel.addValidators}"
- />
-
- </target>
-
- <!-- ================================================================ -->
- <!-- M I G R A T I O N T A S K S -->
- <!-- ================================================================ -->
-
- <target
- name="sql-diff"
- depends="sql-check,pgsql-quoting-check,mysqli-check"
- unless="propel.internal.sql.uptodate"
- description="==> generates a SQL diff for your project">
-
- <echo message="+----------------------------------------------+"/>
- <echo message="| |"/>
- <echo message="| Generating SQL diff between the XML schemas |"/>
- <echo message="| and the current database structure. |"/>
- <echo message="| |"/>
- <echo message="+----------------------------------------------+"/>
-
- <phingcall target="sql-diff-template"/>
- </target>
-
- <target name="sql-diff-template">
- <propel-sql-diff
- validate="${propel.schema.validate}"
- xsd="${propel.schema.xsd.file}"
- xsl="${propel.schema.xsl.file}"
- outputDirectory="${propel.migration.dir}"
- targetDatabase="${propel.database}"
- packageObjectModel="${propel.packageObjectModel}"
- databaseName="${propel.project}"
- url="${propel.database.url}"
- userId="${propel.database.user}"
- password="${propel.database.password}"
- editorCmd="${propel.migration.editor}"
- caseInsensitive="${propel.migration.caseInsensitive}">
- <mapper type="glob" from="${propel.sql.mapper.from}" to="${propel.sql.mapper.to}"/>
- <schemafileset dir="${propel.schema.dir}"
- includes="${propel.schema.sql.includes}"
- excludes="${propel.schema.sql.excludes}"
- />
- </propel-sql-diff>
- </target>
-
- <target
- name="migration-status"
- depends="sql-check,pgsql-quoting-check,mysqli-check"
- unless="propel.internal.sql.uptodate"
- description="Lists the migrations left to be executed">
-
- <echo message="+----------------------------------------------+"/>
- <echo message="| |"/>
- <echo message="| Look for Migration classes and lists |"/>
- <echo message="| the ones not yet executed. |"/>
- <echo message="| |"/>
- <echo message="+----------------------------------------------+"/>
-
- <phingcall target="migration-status-template"/>
- </target>
-
- <target name="migration-status-template">
- <propel-migration-status
- migrationTable="${propel.migration.table}"
- outputDirectory="${propel.migration.dir}">
- </propel-migration-status>
- </target>
-
- <target
- name="migration-up"
- depends="sql-check,pgsql-quoting-check,mysqli-check"
- unless="propel.internal.sql.uptodate"
- description="Execute the next migration">
-
- <echo message="+----------------------------------------------+"/>
- <echo message="| |"/>
- <echo message="| Look for next Migration class |"/>
- <echo message="| and execute it |"/>
- <echo message="| |"/>
- <echo message="+----------------------------------------------+"/>
-
- <phingcall target="migration-up-template"/>
- </target>
-
- <target name="migration-up-template">
- <propel-migration-up
- migrationTable="${propel.migration.table}"
- outputDirectory="${propel.migration.dir}">
- </propel-migration-up>
- </target>
-
- <target
- name="migration-down"
- depends="sql-check,pgsql-quoting-check,mysqli-check"
- unless="propel.internal.sql.uptodate"
- description="Execute the next migration">
-
- <echo message="+----------------------------------------------+"/>
- <echo message="| |"/>
- <echo message="| Look for previous Migration class |"/>
- <echo message="| and execute it |"/>
- <echo message="| |"/>
- <echo message="+----------------------------------------------+"/>
-
- <phingcall target="migration-down-template"/>
- </target>
-
- <target name="migration-down-template">
- <propel-migration-down
- migrationTable="${propel.migration.table}"
- outputDirectory="${propel.migration.dir}">
- </propel-migration-down>
- </target>
-
- <target
- name="migration"
- depends="sql-check,pgsql-quoting-check,mysqli-check"
- unless="propel.internal.sql.uptodate"
- description="Execute the next migration">
-
- <echo message="+----------------------------------------------+"/>
- <echo message="| |"/>
- <echo message="| Look for next Migration class |"/>
- <echo message="| and execute it |"/>
- <echo message="| |"/>
- <echo message="+----------------------------------------------+"/>
-
- <phingcall target="migration-template"/>
- </target>
-
- <target name="migration-template">
- <propel-migration
- migrationTable="${propel.migration.table}"
- outputDirectory="${propel.migration.dir}">
- </propel-migration>
- </target>
-
- <!-- ================================================================ -->
- <!-- Generate SQL from XML data file -->
- <!-- ================================================================ -->
-
- <target
- name="datasql"
- description="==> generates sql from data xml">
-
- <echo message="+-----------------------------------------------+"/>
- <echo message="| |"/>
- <echo message="| Generating SQL from data XML ! |"/>
- <echo message="| |"/>
- <echo message="+-----------------------------------------------+"/>
-
- <propel-data-sql
- validate="${propel.schema.validate}"
- xsd="${propel.schema.xsd.file}"
- xsl="${propel.schema.xsl.file}"
- outputDirectory="${propel.sql.dir}"
- sqldbmap="${propel.sql.dir}/sqldb.map"
- dbEncoding="${propel.database.encoding}"
- targetDatabase="${propel.database}"
- datadbmap="${propel.schema.dir}/datadb.map"
- srcDir="${propel.schema.dir}">
- <mapper type="glob" from="${propel.datasql.mapper.from}" to="${propel.datasql.mapper.to}"/>
- <schemafileset dir="${propel.schema.dir}"
- includes="${propel.schema.datadtd.includes}"
- excludes="${propel.schema.datadtd.excludes}"
- />
- </propel-data-sql>
- </target>
-
- <!-- ================================================================ -->
- <!-- Dump data from database into xml file -->
- <!-- ================================================================ -->
-
- <target
- name="datadump"
- description="==> dump data from database into xml file">
-
- <echo message="+-----------------------------------------------+"/>
- <echo message="| |"/>
- <echo message="| Dumping the data from database into XML |"/>
- <echo message="| |"/>
- <echo message="+-----------------------------------------------+"/>
-
- <propel-data-dump
- validate="${propel.schema.validate}"
- xsd="${propel.schema.xsd.file}"
- xsl="${propel.schema.xsl.file}"
- targetDatabase="${propel.database}"
- datadbmap="${propel.schema.dir}/datadb.map"
- databaseDriver="${propel.database.driver}"
- dbEncoding="${propel.database.encoding}"
- databaseUrl="${propel.database.url}"
- databaseUser="${propel.database.user}"
- databasePassword="${propel.database.password}"
- outputDirectory="${propel.schema.dir}">
- <mapper type="glob" from="${propel.datadump.mapper.from}" to="${propel.datadump.mapper.to}"/>
- <schemafileset dir="${propel.schema.dir}"
- includes="${propel.schema.datadtd.includes}"
- excludes="${propel.schema.datadtd.excludes}"
- />
- </propel-data-dump>
- </target>
-
- <!-- ================================================================ -->
- <!-- G E N E R A T E P R O J E C T P E E R B A S E D O M -->
- <!-- ================================================================ -->
- <!-- Generate the Peer-based object model for your project. -->
- <!-- These are in addition to the base Propel OM! -->
- <!-- ================================================================ -->
-
- <target
- name="om-check"
- depends="check-run-only-on-schema-change"
- if="propel.internal.runOnlyOnSchemaChange">
- <uptodate
- property="propel.internal.om.uptodate"
- targetfile="${propel.php.dir}/report.${propel.project}.om.generation">
- <srcfiles dir="${propel.schema.dir}" includes="**/${propel.schema.om.includes}.xml" />
- </uptodate>
- </target>
-
- <target
- name="om"
- depends="om-check,mysqli-check"
- unless="propel.internal.om.uptodate"
- description="==> generates the Peer-based object model for your project">
-
- <echo message="+------------------------------------------+"/>
- <echo message="| |"/>
- <echo message="| Generating Peer-based Object Model for |"/>
- <echo message="| YOUR Propel project! |"/>
- <echo message="| |"/>
- <echo message="+------------------------------------------+"/>
-
- <phingcall target="om-template"/>
- <!--<phingcall target="om-tar"/>-->
- </target>
-
- <target name="om-template">
- <propel-om
- validate="${propel.schema.validate}"
- xsd="${propel.schema.xsd.file}"
- xsl="${propel.schema.xsl.file}"
- outputDirectory="${propel.php.dir}"
- targetDatabase="${propel.database}"
- targetPackage="${propel.targetPackage}"
- targetPlatform="${propel.targetPlatform}"
- packageObjectModel="${propel.packageObjectModel}">
- <schemafileset dir="${propel.schema.dir}"
- includes="${propel.schema.om.includes}"
- excludes="${propel.schema.om.excludes}"
- />
- </propel-om>
- </target>
-
- <!-- ================================================================== -->
- <!-- X M L R U N T I M E C O N F T O P H P A R R A Y -->
- <!-- ================================================================== -->
-
- <target
- name="convert-conf"
- description="==> converts properties file to PHP array">
-
- <echo message="+------------------------------------------+"/>
- <echo message="| |"/>
- <echo message="| Converting runtime config file to an |"/>
- <echo message="| array dump for improved performance. |"/>
- <echo message="| |"/>
- <echo message="+------------------------------------------+"/>
-
- <propel-convert-conf
- targetDatabase="${propel.database}"
- xsd="${propel.schema.xsd.file}"
- xsl="${propel.schema.xsl.file}"
- xmlConfFile="${propel.conf.dir}/${propel.runtime.conf.file}"
- outputDirectory="${propel.phpconf.dir}"
- outputFile="${propel.runtime.phpconf.file}"
- outputClassmapFile="${propel.runtime.phpconf-classmap.file}"
- packageObjectModel="${propel.packageObjectModel}">
- <schemafileset dir="${propel.schema.dir}"
- includes="${propel.schema.sql.includes}"
- excludes="${propel.schema.sql.excludes}"
- />
- </propel-convert-conf>
-
- </target>
-
- <target
- name="dbd2propel"
- description="==> generates a Propel XML schema from a DBDesigner 4 XML schema">
-
- <echo message="+------------------------------------------+"/>
- <echo message="| |"/>
- <echo message="| Generating Propel XML Schema |"/>
- <echo message="| Based on DB4Designer export |"/>
- <echo message="| |"/>
- <echo message="+------------------------------------------+"/>
-
- <xslt todir="${propel.schema.dir}" style="${propel.dbd2propel.xsl.file}" >
- <fileset dir="${propel.dbd2propel.dir}">
- <include name="${propel.dbd2propel.includes}" />
- </fileset>
- <mapper type="regexp" from="^(.*)\.xml$" to="\1.schema.xml"/>
- </xslt>
- </target>
-
- <target
- name="graphviz"
- depends="sql-check"
- description="==> generates Graphviz file for your project">
-
- <echo message="+------------------------------------------+"/>
- <echo message="| |"/>
- <echo message="| Generating Graphiz for YOUR Propel |"/>
- <echo message="| project! |"/>
- <echo message="| |"/>
- <echo message="+------------------------------------------+"/>
-
- <propel-graphviz
- outputDirectory="${propel.graph.dir}"
- targetDatabase="${propel.database}"
- sqldbmap="${propel.sql.dir}/sqldb.map"
- packageObjectModel="${propel.packageObjectModel}">
- <mapper type="glob" from="${propel.sql.mapper.from}" to="${propel.sql.mapper.to}"/>
- <schemafileset dir="${propel.schema.dir}"
- includes="${propel.schema.sql.includes}"
- excludes="${propel.schema.sql.excludes}"
- />
- </propel-graphviz>
- </target>
-
-
-</project>
View
190 lib/propel-1.6.1/generator/build.properties-sample
@@ -1,190 +0,0 @@
-# -------------------------------------------------------------------
-#
-# P R O P E L C O N F I G U R A T I O N F I L E
-#
-# -------------------------------------------------------------------
-# This file contains some example properties. Ideally properties
-# should be specified in the project-specific build.properties file;
-# however, this file can be used to specify non-default properties
-# that you would like to use accross all of your Propel projects.
-# -------------------------------------------------------------------
-#
-
-propel.home = .
-
-# -------------------------------------------------------------------
-#
-# P R O J E C T
-#
-# -------------------------------------------------------------------
-# This is the name of your Propel project. The name of your Propel
-# project is used (by default) to determine where the generator will
-# find needed configuration files and will place resuilting build
-# files. E.g. if your project is named 'killerapp', Propel will
-# look here for schema.xml and runtime-conf.xml files:
-#
-# projects/killerapp/
-#
-# -------------------------------------------------------------------
-
-# You can set this here, but it's preferrable to set this in a
-# project-specific build.properties file.
-#
-# propel.project = bookstore
-
-# -------------------------------------------------------------------
-#
-# T A R G E T D A T A B A S E
-#
-# -------------------------------------------------------------------
-# This is the target database, only considered when generating
-# the SQL for your Propel project. Your possible choices are:
-#
-# mssql, mysql, oracle, pgsql, sqlite
-# -------------------------------------------------------------------
-
-# You can set this here, but it's preferrable to set this in a
-# project-specific build.properties file.
-#
-# propel.database = mysql
-
-# -------------------------------------------------------------------
-#
-# O B J E C T M O D E L I N F O R M A T I O N
-#
-# -------------------------------------------------------------------
-# These settings will allow you to customize the way your
-# Peer-based object model is created.
-# -------------------------------------------------------------------
-# addGenericAccessors
-# If true, Propel adds methods to get database fields by name/position.
-#
-# addGenericMutators
-# If true, Propel adds methods to set database fields by name/position.
-#
-# addSaveMethod
-# If true, Propel adds tracking code to determine how to save objects.
-#
-# addTimeStamp
-# If true, Propel true puts time stamps in phpdoc of generated om files.
-#
-# basePrefix
-# A string to pre-pend to the file names of base data and peer objects.
-#
-# complexObjectModel
-# If true, Propel generates data objects with collection support and
-# methods to easily retreive foreign key relationships.
-#
-# targetPackage
-# Sets the PHP "package" the om files will generated to, e.g.
-# "com.company.project.om".
-#
-# targetPlatform
-# Sets whether Propel is building classes for php5 (default)
-# or php4 (experimental).
-#
-# packageObjectModel
-# Sets whether Propel is packaging ObjectModel fro several
-# [package].schema.xml files. The <database package="packageName">
-# attribute has to be set then. (warning: this is experimental!)
-#
-# -------------------------------------------------------------------
-
-# classes will be put in (and included from) this directory
-# e.g. if package is "bookstore" then om will expect include('bookstore/Book.php'); to work.
-# use dot-path notation -- e.g. my.bookstore -> my/bookstore.
-#
-propel.targetPackage = ${propel.project}
-
-propel.addGenericAccessors = false
-propel.addGenericMutators = false
-propel.addSaveMethod = true
-propel.addTimeStamp = true
-propel.basePrefix = Base
-propel.complexObjectModel = true
-propel.targetPlatform = php5
-propel.packageObjectModel = false
-
-# -------------------------------------------------------------------
-#
-# D B C O N N E C T I O N S E T T I N G S
-#
-# -------------------------------------------------------------------
-# PDO connection settings. These connection settings are used by
-# build tagets that perform database operations (e.g. 'insert-sql',
-# 'reverse').
-#
-# You can set them here, but it's preferrable to set these properties
-# in a project-specific build.properties file.
-#
-
-# If you want to use a custom driver, specify it below, otherwise
-# leave it blank or comment it out to use Creole stock driver.
-#
-# propel.database.driver = creole.drivers.sqlite.SQLiteConnection
-
-# Note that if you do not wish to specify the database (e.g. if you
-# are using multiple databses) you can use the @DB@ token which
-# will be replaced with a database at runtime.
-#
-# propel.database.url = mysql:host=$host;dbname=$database
-
-# For MySQL or Oracle, you also need to specify username & password
-# propel.database.user = [db username]
-# propel.database.password = [db password]
-
-# Use the URL below to specify a DSN to used to create the database.
-# Note that this URL should not contain the database name, as you will
-# get an error if the database does not exist.
-# (This does not apply to SQLite since the databse is automatically created
-# when the connection is made -- if it does not already exist.)
-#
-# propel.database.createUrl = mysql:host=$host;dbname=$database
-
-
-# -------------------------------------------------------------------
-#
-# D A T A B A S E TO X M L
-#
-# -------------------------------------------------------------------
-#
-# samePhpName
-# If true, the reverse task will set the phpName attribute for the
-# tables and columns to be the same as SQL name.
-#
-# addVendorInfo
-# If true, the reverse task will add vendor specific information
-# to the database schema
-#
-# addValidators
-# List of Validators that the reverse task may add to the schema
-# based on database constraints.
-# Allowed tokens are:
-# none add no validators
-# all add all validators
-# maxlength add maxlengths for string type columns
-# maxvalue add maxvalue for numeric columns
-# type add notmatch validators for numeric columns
-# required add required validators for required columns
-# unique add unique validators for unique indexes
-# You can cherry-pick allowed validators by using a comma-separated value, e.g
-# maxvalue,type,required
-#
-# -------------------------------------------------------------------
-
-# propel.samePhpName = false
-# propel.addVendorInfo=true
-# propel.addValidators=none
-
-
-# -------------------------------------------------------------------
-#
-# D A T A B A S E B U I L D C O N F I G
-#
-# -------------------------------------------------------------------
-# Some databases provide some configuration options that can be set
-# in this script.
-#
-# === MySQL
-# propel.mysql.tableType
-# Use this property to set the table type of generated tables (e.g. InnoDB, MyISAM).
View
238 lib/propel-1.6.1/generator/build.xml
@@ -1,238 +0,0 @@
-<!--
- Use this file to faciliate easy per-project building.
-
- Simply create a build.properties file in your project directory,
- for example ./projects/bookstore/build.properties, that contains
- any needed (i.e. to override) values for that project.
-
- Call this build script and specify the name of the project and
- (optionally) the name of the target you wish to execute (default is
- 'main' target) of build-propel.xml.
-
- Normal use:
- $> phing -Dproject=bookstore
-
- Specific target:
- $> phing -Dproject=bookstore -Dtarget=insert-sql
-
--->
-<project name="propel-project-builder" default="main">
-
-<!-- in case ${project.dir} was specified on command line, we set the project.dir
- property here. If it wasn't set, then this will be bogus, but it will
- be overridden by the "set-project-dir" target. -->
-<resolvepath propertyName="propel.project.dir" file="${project.dir}" dir="${application.startdir}"/>
-
-<!-- set a default target if none provided -->
-<property name="target" value="main"/>
-
-<!-- Set a default name for the build.properties file.
- This allows for overriding the name of the build.properties file; however,
- Propel still expects to find the file in the ${propel.project.dir}.
- -->
-<property name="build.properties" value="build.properties"/>
-
-<target name="check-buildprops-exists">
- <available file="${propel.project.dir}/${build.properties}" property="projBuildPopertiesExists"/>
-</target>
-
-<target name="check-buildprops" unless="projBuildPopertiesExists" depends="check-buildprops-exists">
- <echo message="====================================================="/>
- <echo message="Could not open ${build.properties} file:"/>
- <echo message=" ${propel.project.dir}${build.properties}"/>
- <echo message=" "/>
- <echo message="Make sure that '${propel.project.dir}' is a valid path"/>
- <echo message="and that it contains a ${build.properties} file."/>
- <echo message="====================================================="/>
-
- <fail message="Missing configuration file (see description above)."/>
-</target>
-
-<target name="check-project-or-dir-set">
- <condition property="projectOrDirSet">
- <or>
- <isset property="project"/>
- <isset property="project.dir"/>
- </or>
- </condition>
-</target>
-
-<target name="check-buildprops-for-propel-gen" if="using.propel-gen" unless="projBuildPopertiesExists" depends="check-buildprops-exists">
- <echo message="=========================================================="/>
- <echo message=" Welcome to Propel!"/>
- <echo message=" "/>
- <echo message="The propel-gen script requires a ${build.properties} file"/>
- <echo message="to run. Either you didn't create one already, or this file"/>
- <echo message="is not where the propel-gen script is looking for it."/>
- <echo message=" "/>
- <echo message="Expected ${build.properties} file location is:"/>
- <echo message=" ${propel.project.dir}${build.properties}"/>
- <echo message=" "/>
- <echo message="The propel-gen script expects the name of a task to execute:"/>
- <echo message=" "/>
- <echo message="$&gt; propel-gen [taskname]"/>
- <echo message=" "/>
- <echo message="If you call the script from another directory than the one where"/>
- <echo message="where the ${build.properties} file is, set the path to this"/>
- <echo message="file as first argument of the script:"/>
- <echo message=" "/>
- <echo message="$&gt; propel-gen /path/to/projectdir [taskname]"/>
- <echo message=" "/>
- <echo message="Available tasknames are:"/>
- <echo message=" om"/>
- <echo message=" convert-conf"/>
- <echo message=" sql"/>
- <echo message=" insert-sql"/>
- <echo message=" diff"/>
- <echo message=" status"/>
- <echo message=" migrate"/>
- <echo message=" up"/>
- <echo message=" down"/>
- <echo message=" reverse"/>
- <echo message=" ... and a few others."/>
- <echo message="But you should start by creating a schema."/>
- <echo message="=========================================================="/>
- <fail message="No project directory specified."/>
-</target>
-
-<target name="check-project-set" unless="projectOrDirSet" depends="check-project-or-dir-set">
- <echo message="====================================================="/>
- <echo message="Project not specified. You must enter a project name. "/>
- <echo message="In the future you can enter it on the command line: "/>
- <echo message=" "/>
- <echo message="-Dproject=bookstore"/>
- <echo message=" "/>
- <echo message="This will attempt to find your project directory in"/>
- <echo message="the default directory (./projects/bookstore)."/>
- <echo message=" "/>
- <echo message="You can also avoid this message and specicfy a custom "/>
- <echo message="directory, using the project.dir property:"/>
- <echo message=" "/>
- <echo message="-Dproject.dir=/path/to/bookstore"/>
- <echo message="====================================================="/>
- <input propertyname="project" promptChar=":">Project name</input>
- <property name="propel.project" value="${project}" override="true"/>
-</target>
-
-<target name="set-project-dir" unless="project.dir" depends="check-project-set">
- <echo>No project.dir was specified, using default path: ./projects/${project}</echo>
- <property name="propel.project.dir" value="./projects/${project}" override="true"/>
-</target>
-
-<target name="configure" depends="set-project-dir,check-buildprops-for-propel-gen,check-buildprops">
- <if>
- <isset property="additional.properties"/>
- <then>
- <echo>Processing additional properties file: ${additional.properties}</echo>
- <resolvepath propertyName="additional.properties.resolved" file="${additional.properties}" dir="${application.startdir}"/>
- <property file="${additional.properties.resolved}"/>
- </then>
- </if>
- <echo msg="Loading project-specific props from ${propel.project.dir}/${build.properties}"/>
- <property file="${propel.project.dir}/${build.properties}"/>
-</target>
-
-<target name="main" depends="configure" description="The main target. Includes project-specific build.properties and calls the build-propel.xml script">
-
- <phing phingfile="./build-propel.xml" target="${target}"/>
-
-</target>
-
-<!--
- Convenience mappings to build-propel.xml main targets
-
- This makes it possible to use this buildfile w/o needing to specify
- target as a property, e.g.:
-
- $> phing -Dproject=bookstore insert-sql
-
- The main reason for this is just consistency w/ old build-propel.xml file
- (primarily for documentation & user confusion avoidance reasons). There are relatively
- few & infrequently changing main targets of build-propel.xml, so it's a non-
- issue as far as maintenance is concerned.
--->
-
-<target name="convert-conf" depends="configure">
- <phing phingfile="build-propel.xml" target="convert-conf"/>
-</target>
-
-<target name="create-db" depends="configure">
- <phing phingfile="build-propel.xml" target="create-db"/>