From 876973a8cb0e09c0118911db9e16a1d1bd5a3a28 Mon Sep 17 00:00:00 2001
From: hansbrix NOT, !
-
- Logical NOT. Evaluates to 1 if the
- operand is 0, to 0 if
- the operand is non-zero, and NOT NULL
- returns NULL.
-
- The last example produces 1 because the
- expression evaluates the same way as
- (!1)+1.
-
- Logical AND. Evaluates to 1 if all
- operands are non-zero and not NULL, to
- 0 if one or more operands are
- 0, otherwise NULL is
- returned.
-
-Doctrine_Db_Profiler can be enabled by adding it as an eventlistener for Doctrine_Db.
-
-");
-?>
+
+Doctrine_Db_Profiler is an eventlistener for Doctrine_Db. It provides flexible query profiling. Besides the sql strings
+the query profiles include elapsed time to run the queries. This allows inspection of the queries that have been performed without the
+need for adding extra debugging code to model classes.
+
+
+
+Doctrine_Db_Profiler can be enabled by adding it as an eventlistener for Doctrine_Db.
+
+
+
+
+
+?>
diff --git a/manual/docs/Advanced components - Evenlisteners - AccessorInvoker.php b/manual/docs/Advanced components - Evenlisteners - AccessorInvoker.php
index 6ae287d87..450276d8f 100644
--- a/manual/docs/Advanced components - Evenlisteners - AccessorInvoker.php
+++ b/manual/docs/Advanced components - Evenlisteners - AccessorInvoker.php
@@ -1,34 +1,34 @@
-
-
-class User {
- public function setTableDefinition() {
- $this->hasColumn("name", "string", 200);
- $this->hasColumn("password", "string", 32);
- }
- public function setPassword($password) {
- return md5($password);
- }
- public function getName($name) {
- return strtoupper($name);
- }
-}
-
-$user = new User();
-
-$user->name = 'someone';
-
-print $user->name; // someone
-
-$user->password = '123';
-
-print $user->password; // 123
-
-$user->setAttribute(Doctrine::ATTR_LISTENER, new Doctrine_EventListener_AccessorInvoker());
-
-print $user->name; // SOMEONE
-
-$user->password = '123';
-
-print $user->password; // 202cb962ac59075b964b07152d234b70
-
+
+
+class User {
+ public function setTableDefinition() {
+ $this->hasColumn("name", "string", 200);
+ $this->hasColumn("password", "string", 32);
+ }
+ public function setPassword($password) {
+ return md5($password);
+ }
+ public function getName($name) {
+ return strtoupper($name);
+ }
+}
+
+$user = new User();
+
+$user->name = 'someone';
+
+print $user->name; // someone
+
+$user->password = '123';
+
+print $user->password; // 123
+
+$user->setAttribute(Doctrine::ATTR_LISTENER, new Doctrine_EventListener_AccessorInvoker());
+
+print $user->name; // SOMEONE
+
+$user->password = '123';
+
+print $user->password; // 202cb962ac59075b964b07152d234b70
+
diff --git a/manual/docs/Advanced components - Eventlisteners - Creating new listener.php b/manual/docs/Advanced components - Eventlisteners - Creating new listener.php
index da9bec4b7..2324c9d24 100644
--- a/manual/docs/Advanced components - Eventlisteners - Creating new listener.php
+++ b/manual/docs/Advanced components - Eventlisteners - Creating new listener.php
@@ -1,36 +1,36 @@
-Creating a new listener is very easy. You can set the listener in global, connection or factory level.
+Creating a new listener is very easy. You can set the listener in global, connection or factory level.
-
-class MyListener extends Doctrine_EventListener {
- public function onLoad(Doctrine_Record $record) {
- print $record->getTable()->getComponentName()." just got loaded!";
- }
- public function onSave(Doctrine_Record $record) {
- print "saved data access object!";
- }
-}
-class MyListener2 extends Doctrine_EventListener {
- public function onPreUpdate() {
- try {
- $record->set("updated",time());
- } catch(InvalidKeyException $e) {
- }
- }
-}
-
-
-// setting global listener
-$manager = Doctrine_Manager::getInstance();
-
-$manager->setAttribute(Doctrine::ATTR_LISTENER,new MyListener());
-
-// setting connection level listener
-$conn = $manager->openConnection($dbh);
-
-$conn->setAttribute(Doctrine::ATTR_LISTENER,new MyListener2());
-
-// setting factory level listener
-$table = $conn->getTable("User");
-
-$table->setAttribute(Doctrine::ATTR_LISTENER,new MyListener());
-
+
+class MyListener extends Doctrine_EventListener {
+ public function onLoad(Doctrine_Record $record) {
+ print $record->getTable()->getComponentName()." just got loaded!";
+ }
+ public function onSave(Doctrine_Record $record) {
+ print "saved data access object!";
+ }
+}
+class MyListener2 extends Doctrine_EventListener {
+ public function onPreUpdate() {
+ try {
+ $record->set("updated",time());
+ } catch(InvalidKeyException $e) {
+ }
+ }
+}
+
+
+// setting global listener
+$manager = Doctrine_Manager::getInstance();
+
+$manager->setAttribute(Doctrine::ATTR_LISTENER,new MyListener());
+
+// setting connection level listener
+$conn = $manager->openConnection($dbh);
+
+$conn->setAttribute(Doctrine::ATTR_LISTENER,new MyListener2());
+
+// setting factory level listener
+$table = $conn->getTable("User");
+
+$table->setAttribute(Doctrine::ATTR_LISTENER,new MyListener());
+
diff --git a/manual/docs/Advanced components - Eventlisteners - List of events.php b/manual/docs/Advanced components - Eventlisteners - List of events.php
index 3ef2d9f29..881d43347 100644
--- a/manual/docs/Advanced components - Eventlisteners - List of events.php
+++ b/manual/docs/Advanced components - Eventlisteners - List of events.php
@@ -1,47 +1,47 @@
-Here is a list of availible events and their parameters:
+Here is a list of availible events and their parameters:
-
-interface Doctrine_EventListener_Interface {
-
- public function onLoad(Doctrine_Record $record);
- public function onPreLoad(Doctrine_Record $record);
-
- public function onUpdate(Doctrine_Record $record);
- public function onPreUpdate(Doctrine_Record $record);
-
- public function onCreate(Doctrine_Record $record);
- public function onPreCreate(Doctrine_Record $record);
-
- public function onSave(Doctrine_Record $record);
- public function onPreSave(Doctrine_Record $record);
-
- public function onInsert(Doctrine_Record $record);
- public function onPreInsert(Doctrine_Record $record);
-
- public function onDelete(Doctrine_Record $record);
- public function onPreDelete(Doctrine_Record $record);
-
- public function onEvict(Doctrine_Record $record);
- public function onPreEvict(Doctrine_Record $record);
-
- public function onSleep(Doctrine_Record $record);
-
- public function onWakeUp(Doctrine_Record $record);
-
- public function onClose(Doctrine_Connection $connection);
- public function onPreClose(Doctrine_Connection $connection);
-
- public function onOpen(Doctrine_Connection $connection);
-
- public function onTransactionCommit(Doctrine_Connection $connection);
- public function onPreTransactionCommit(Doctrine_Connection $connection);
-
- public function onTransactionRollback(Doctrine_Connection $connection);
- public function onPreTransactionRollback(Doctrine_Connection $connection);
-
- public function onTransactionBegin(Doctrine_Connection $connection);
- public function onPreTransactionBegin(Doctrine_Connection $connection);
-
- public function onCollectionDelete(Doctrine_Collection $collection);
- public function onPreCollectionDelete(Doctrine_Collection $collection);
-}
+
+interface Doctrine_EventListener_Interface {
+
+ public function onLoad(Doctrine_Record $record);
+ public function onPreLoad(Doctrine_Record $record);
+
+ public function onUpdate(Doctrine_Record $record);
+ public function onPreUpdate(Doctrine_Record $record);
+
+ public function onCreate(Doctrine_Record $record);
+ public function onPreCreate(Doctrine_Record $record);
+
+ public function onSave(Doctrine_Record $record);
+ public function onPreSave(Doctrine_Record $record);
+
+ public function onInsert(Doctrine_Record $record);
+ public function onPreInsert(Doctrine_Record $record);
+
+ public function onDelete(Doctrine_Record $record);
+ public function onPreDelete(Doctrine_Record $record);
+
+ public function onEvict(Doctrine_Record $record);
+ public function onPreEvict(Doctrine_Record $record);
+
+ public function onSleep(Doctrine_Record $record);
+
+ public function onWakeUp(Doctrine_Record $record);
+
+ public function onClose(Doctrine_Connection $connection);
+ public function onPreClose(Doctrine_Connection $connection);
+
+ public function onOpen(Doctrine_Connection $connection);
+
+ public function onTransactionCommit(Doctrine_Connection $connection);
+ public function onPreTransactionCommit(Doctrine_Connection $connection);
+
+ public function onTransactionRollback(Doctrine_Connection $connection);
+ public function onPreTransactionRollback(Doctrine_Connection $connection);
+
+ public function onTransactionBegin(Doctrine_Connection $connection);
+ public function onPreTransactionBegin(Doctrine_Connection $connection);
+
+ public function onCollectionDelete(Doctrine_Collection $collection);
+ public function onPreCollectionDelete(Doctrine_Collection $collection);
+}
diff --git a/manual/docs/Advanced components - Eventlisteners - Listening events.php b/manual/docs/Advanced components - Eventlisteners - Listening events.php
index be619e48b..b15b8d5a8 100644
--- a/manual/docs/Advanced components - Eventlisteners - Listening events.php
+++ b/manual/docs/Advanced components - Eventlisteners - Listening events.php
@@ -1,14 +1,14 @@
-
-$table = $conn->getTable("User");
-
-$table->setEventListener(new MyListener2());
-
-// retrieve user whose primary key is 2
-$user = $table->find(2);
-
-$user->name = "John Locke";
-
-// update event will be listened and current time will be assigned to the field 'updated'
-$user->save();
-
+
+$table = $conn->getTable("User");
+
+$table->setEventListener(new MyListener2());
+
+// retrieve user whose primary key is 2
+$user = $table->find(2);
+
+$user->name = "John Locke";
+
+// update event will be listened and current time will be assigned to the field 'updated'
+$user->save();
+
diff --git a/manual/docs/Advanced components - Hook - Introduction.php b/manual/docs/Advanced components - Hook - Introduction.php
index b6f9a4314..11c0f6e9f 100644
--- a/manual/docs/Advanced components - Hook - Introduction.php
+++ b/manual/docs/Advanced components - Hook - Introduction.php
@@ -1,4 +1,4 @@
-Many web applications have different kinds of lists. The lists may contain data from multiple components (= database tables) and
-they may have actions such as paging, sorting and setting conditions. Doctrine_Hook helps building these lists. It has a simple API for
-building search criteria forms as well as building a DQL query from the 'hooked' parameters.
+Many web applications have different kinds of lists. The lists may contain data from multiple components (= database tables) and
+they may have actions such as paging, sorting and setting conditions. Doctrine_Hook helps building these lists. It has a simple API for
+building search criteria forms as well as building a DQL query from the 'hooked' parameters.
diff --git a/manual/docs/Advanced components - Hook - Parameter hooking.php b/manual/docs/Advanced components - Hook - Parameter hooking.php
index c899f011d..01cb62a8b 100644
--- a/manual/docs/Advanced components - Hook - Parameter hooking.php
+++ b/manual/docs/Advanced components - Hook - Parameter hooking.php
@@ -1,4 +1,4 @@
-
-$hook = new Doctrine_Hook($table, $fields);
-
+
+$hook = new Doctrine_Hook($table, $fields);
+
diff --git a/manual/docs/Advanced components - Locking Manager - Examples.php b/manual/docs/Advanced components - Locking Manager - Examples.php
index 44ccf1903..02333ba89 100644
--- a/manual/docs/Advanced components - Locking Manager - Examples.php
+++ b/manual/docs/Advanced components - Locking Manager - Examples.php
@@ -1,63 +1,63 @@
-The following code snippet demonstrates the use of Doctrine's pessimistic offline locking capabilities.
+The following code snippet demonstrates the use of Doctrine's pessimistic offline locking capabilities.
-At the page where the lock is requested...
-
-
-// Get a locking manager instance
-$lockingMngr = new Doctrine_Locking_Manager_Pessimistic();
-
-try
-{
- // Ensure that old locks which timed out are released
- // before we try to acquire our lock
- // 300 seconds = 5 minutes timeout
- $lockingMngr->releaseAgedLocks(300);
-
- // Try to get the lock on a record
- $gotLock = $lockingMngr->getLock(
- // The record to lock. This can be any Doctrine_Record
- $myRecordToLock,
- // The unique identifier of the user who is trying to get the lock
- 'Bart Simpson'
- );
-
- if($gotLock)
- {
- echo "Got lock!";
- // ... proceed
- }
- else
- {
- echo "Sorry, someone else is currently working on this record";
- }
-}
-catch(Doctrine_Locking_Exception $dle)
-{
- echo $dle->getMessage();
- // handle the error
-}
-
-
-
-At the page where the transaction finishes...
-
-// Get a locking manager instance
-$lockingMngr = new Doctrine_Locking_Manager_Pessimistic();
-
-try
-{
- if($lockingMngr->releaseLock($myRecordToUnlock, 'Bart Simpson'))
- {
- echo "Lock released";
- }
- else
- {
- echo "Record was not locked. No locks released.";
- }
-}
-catch(Doctrine_Locking_Exception $dle)
-{
- echo $dle->getMessage();
- // handle the error
-}
-
+At the page where the lock is requested...
+
+
+// Get a locking manager instance
+$lockingMngr = new Doctrine_Locking_Manager_Pessimistic();
+
+try
+{
+ // Ensure that old locks which timed out are released
+ // before we try to acquire our lock
+ // 300 seconds = 5 minutes timeout
+ $lockingMngr->releaseAgedLocks(300);
+
+ // Try to get the lock on a record
+ $gotLock = $lockingMngr->getLock(
+ // The record to lock. This can be any Doctrine_Record
+ $myRecordToLock,
+ // The unique identifier of the user who is trying to get the lock
+ 'Bart Simpson'
+ );
+
+ if($gotLock)
+ {
+ echo "Got lock!";
+ // ... proceed
+ }
+ else
+ {
+ echo "Sorry, someone else is currently working on this record";
+ }
+}
+catch(Doctrine_Locking_Exception $dle)
+{
+ echo $dle->getMessage();
+ // handle the error
+}
+
+
+
+At the page where the transaction finishes...
+
+// Get a locking manager instance
+$lockingMngr = new Doctrine_Locking_Manager_Pessimistic();
+
+try
+{
+ if($lockingMngr->releaseLock($myRecordToUnlock, 'Bart Simpson'))
+ {
+ echo "Lock released";
+ }
+ else
+ {
+ echo "Record was not locked. No locks released.";
+ }
+}
+catch(Doctrine_Locking_Exception $dle)
+{
+ echo $dle->getMessage();
+ // handle the error
+}
+
diff --git a/manual/docs/Advanced components - Locking Manager - Introduction.php b/manual/docs/Advanced components - Locking Manager - Introduction.php
index 99f934c75..e5f23a56c 100644
--- a/manual/docs/Advanced components - Locking Manager - Introduction.php
+++ b/manual/docs/Advanced components - Locking Manager - Introduction.php
@@ -1,24 +1,35 @@
-[Note: The term 'Transaction' doesnt refer to database transactions here but to the general meaning of this term]
-[Note: This component is in Alpha State]
-
-Locking is a mechanism to control concurrency. The two most well known locking strategies
-are optimistic and pessimistic locking. The following is a short description of these
-two strategies from which only pessimistic locking is currently supported by Doctrine.
-
-Optimistic Locking:
-The state/version of the object(s) is noted when the transaction begins.
-When the transaction finishes the noted state/version of the participating objects is compared
-to the current state/version. When the states/versions differ the objects have been modified
-by another transaction and the current transaction should fail.
-This approach is called 'optimistic' because it is assumed that it is unlikely that several users
-will participate in transactions on the same objects at the same time.
-
-Pessimistic Locking:
-The objects that need to participate in the transaction are locked at the moment
-the user starts the transaction. No other user can start a transaction that operates on these objects
-while the locks are active. This ensures that the user who starts the transaction can be sure that
-noone else modifies the same objects until he has finished his work.
-
-Doctrine's pessimistic offline locking capabilities can be used to control concurrency during actions or procedures
-that take several HTTP request and response cycles and/or a lot of time to complete.
+[**Note**: The term 'Transaction' doesnt refer to database transactions here but to the general meaning of this term]
+
+[**Note**: This component is in **Alpha State**]
+
+
+
+Locking is a mechanism to control concurrency. The two most well known locking strategies
+are optimistic and pessimistic locking. The following is a short description of these
+two strategies from which only pessimistic locking is currently supported by Doctrine.
+
+
+
+**Optimistic Locking:**
+
+The state/version of the object(s) is noted when the transaction begins.
+When the transaction finishes the noted state/version of the participating objects is compared
+to the current state/version. When the states/versions differ the objects have been modified
+by another transaction and the current transaction should fail.
+This approach is called 'optimistic' because it is assumed that it is unlikely that several users
+will participate in transactions on the same objects at the same time.
+
+
+
+**Pessimistic Locking:**
+
+The objects that need to participate in the transaction are locked at the moment
+the user starts the transaction. No other user can start a transaction that operates on these objects
+while the locks are active. This ensures that the user who starts the transaction can be sure that
+noone else modifies the same objects until he has finished his work.
+
+
+
+Doctrine's pessimistic offline locking capabilities can be used to control concurrency during actions or procedures
+that take several HTTP request and response cycles and/or a lot of time to complete.
diff --git a/manual/docs/Advanced components - Locking Manager - Maintainer.php b/manual/docs/Advanced components - Locking Manager - Maintainer.php
index 9d242f34e..43d6b676e 100644
--- a/manual/docs/Advanced components - Locking Manager - Maintainer.php
+++ b/manual/docs/Advanced components - Locking Manager - Maintainer.php
@@ -1,2 +1,3 @@
-Roman Borschel - romanb at #doctrine (freenode)
+Roman Borschel - romanb at #doctrine (freenode)
+
Don't hesitate to contact me if you have questions, ideas, ect.
diff --git a/manual/docs/Advanced components - Locking Manager - Planned.php b/manual/docs/Advanced components - Locking Manager - Planned.php
index d995f70bb..1f37ddab2 100644
--- a/manual/docs/Advanced components - Locking Manager - Planned.php
+++ b/manual/docs/Advanced components - Locking Manager - Planned.php
@@ -1,2 +1,2 @@
-- Possibility to release locks of a specific Record type (i.e. releasing all locks on 'User'
+- Possibility to release locks of a specific Record type (i.e. releasing all locks on 'User'
objects).
diff --git a/manual/docs/Advanced components - Locking Manager - Technical Details.php b/manual/docs/Advanced components - Locking Manager - Technical Details.php
index 57efaa9fe..b886529d1 100644
--- a/manual/docs/Advanced components - Locking Manager - Technical Details.php
+++ b/manual/docs/Advanced components - Locking Manager - Technical Details.php
@@ -1,6 +1,6 @@
-The pessimistic offline locking manager stores the locks in the database (therefore 'offline').
-The required locking table is automatically created when you try to instantiate an instance
-of the manager and the ATTR_CREATE_TABLES is set to TRUE.
-This behaviour may change in the future to provide a centralised and consistent table creation
-procedure for installation purposes.
+The pessimistic offline locking manager stores the locks in the database (therefore 'offline').
+The required locking table is automatically created when you try to instantiate an instance
+of the manager and the ATTR_CREATE_TABLES is set to TRUE.
+This behaviour may change in the future to provide a centralised and consistent table creation
+procedure for installation purposes.
diff --git a/manual/docs/Advanced components - Validators - Introduction.php b/manual/docs/Advanced components - Validators - Introduction.php
index 6be899668..26c8d993b 100644
--- a/manual/docs/Advanced components - Validators - Introduction.php
+++ b/manual/docs/Advanced components - Validators - Introduction.php
@@ -3,21 +3,27 @@ You can think of this validation as a gateway that needs to be passed right befo
persistent data store. The definition of these business rules takes place at the record level, that means
in your active record model classes (classes derived from Doctrine_Record).
The first thing you need to do to be able to use this kind of validation is to enable it globally.
-This is done through the Doctrine_Manager (see the code below).
-
-Once you enabled validation, you'll get a bunch of validations automatically:
-
+This is done through the Doctrine_Manager (see the code below).
+
+
+
+Once you enabled validation, you'll get a bunch of validations automatically:
+
+
+
- Data type validations: All values assigned to columns are checked for the right type. That means
if you specified a column of your record as type 'integer', Doctrine will validate that
any values assigned to that column are of this type. This kind of type validation tries to
be as smart as possible since PHP is a loosely typed language. For example 2 as well as "7"
are both valid integers whilst "3f" is not. Type validations occur on every column (since every
-column definition needs a type).
+column definition needs a type).
+
+
- Length validation: As the name implies, all values assigned to columns are validated to make
sure that the value does not exceed the maximum length.
-
-// turning on validation
-
-Doctrine_Manager::getInstance()->setAttribute(Doctrine::ATTR_VLD, true);
-
+
+// turning on validation
+
+Doctrine_Manager::getInstance()->setAttribute(Doctrine::ATTR_VLD, true);
+
diff --git a/manual/docs/Advanced components - Validators - List of predefined validators.php b/manual/docs/Advanced components - Validators - List of predefined validators.php
index af30adc69..72c27e511 100644
--- a/manual/docs/Advanced components - Validators - List of predefined validators.php
+++ b/manual/docs/Advanced components - Validators - List of predefined validators.php
@@ -1,14 +1,14 @@
-Here is a list of predefined validators. You cannot use these names for your custom validators.
-
-|| **name** || **arguments** || **task** ||
-|| email || || Check if value is valid email.||
-|| notblank || || Check if value is not blank.||
-|| notnull || || Check if value is not null.||
-|| country || || Check if valid is valid country code.||
-|| ip || || Checks if value is valid IP (internet protocol) address.||
-|| htmlcolor || || Checks if value is valid html color.||
-|| nospace || || Check if value has no space chars. ||
-|| range || [min,max] || Checks if value is in range specified by arguments.||
-|| unique || || Checks if value is unique in its database table. ||
-|| regexp || [expression] || Check if valie matches a given regexp. ||
+Here is a list of predefined validators. You cannot use these names for your custom validators.
+
+|| **name** || **arguments** || **task** ||
+|| email || || Check if value is valid email.||
+|| notblank || || Check if value is not blank.||
+|| notnull || || Check if value is not null.||
+|| country || || Check if valid is valid country code.||
+|| ip || || Checks if value is valid IP (internet protocol) address.||
+|| htmlcolor || || Checks if value is valid html color.||
+|| nospace || || Check if value has no space chars. ||
+|| range || [min,max] || Checks if value is in range specified by arguments.||
+|| unique || || Checks if value is unique in its database table. ||
+|| regexp || [expression] || Check if valie matches a given regexp. ||
diff --git a/manual/docs/Advanced components - Validators - More Validation.php b/manual/docs/Advanced components - Validators - More Validation.php
index fa2783c1f..cd15b8bab 100644
--- a/manual/docs/Advanced components - Validators - More Validation.php
+++ b/manual/docs/Advanced components - Validators - More Validation.php
@@ -1,31 +1,46 @@
The type and length validations are handy but most of the time they're not enough. Therefore
-Doctrine provides some mechanisms that can be used to validate your data in more detail.
-
+Doctrine provides some mechanisms that can be used to validate your data in more detail.
+
+
+
Validators: Validators are an easy way to specify further validations. Doctrine has a lot of predefined
validators that are frequently needed such as email, country, ip, range and regexp validators. You
find a full list of available validators at the bottom of this page. You can specify which validators
apply to which column through the 4th argument of the hasColumn() method.
If that is still not enough and you need some specialized validation that is not yet available as
-a predefined validator you have three options:
-
-- You can write the validator on your own.
-- You can propose your need for a new validator to a Doctrine developer.
-- You can use validation hooks.
-
+a predefined validator you have three options:
+
+
+
+- You can write the validator on your own.
+
+- You can propose your need for a new validator to a Doctrine developer.
+
+- You can use validation hooks.
+
+
+
The first two options are advisable if it is likely that the validation is of general use
and is potentially applicable in many situations. In that case it is a good idea to implement
-a new validator. However if the validation is special it is better to use hooks provided by Doctrine:
-
-- validate() (Executed every time the record gets validated)
-- validateOnInsert() (Executed when the record is new and gets validated)
-- validateOnUpdate() (Executed when the record is not new and gets validated)
-
+a new validator. However if the validation is special it is better to use hooks provided by Doctrine:
+
+
+
+- validate() (Executed every time the record gets validated)
+
+- validateOnInsert() (Executed when the record is new and gets validated)
+
+- validateOnUpdate() (Executed when the record is not new and gets validated)
+
+
+
If you need a special validation in your active record
you can simply override one of these methods in your active record class (a descendant of Doctrine_Record).
Within thess methods you can use all the power of PHP to validate your fields. When a field
doesnt pass your validation you can then add errors to the record's error stack.
The following code snippet shows an example of how to define validators together with custom
-validation:
+validation:
+
class User extends Doctrine_Record {
diff --git a/manual/docs/Advanced components - Validators - Valid or Not Valid.php b/manual/docs/Advanced components - Validators - Valid or Not Valid.php
index 4b08396e8..dc68f14d7 100644
--- a/manual/docs/Advanced components - Validators - Valid or Not Valid.php
+++ b/manual/docs/Advanced components - Validators - Valid or Not Valid.php
@@ -1,7 +1,10 @@
Now that you know how to specify your business rules in your models, it is time to look at how to
-deal with these rules in the rest of your application.
-
-Implicit validation:
+deal with these rules in the rest of your application.
+
+
+
+Implicit validation:
+
Whenever a record is going to be saved to the persistent data store (i.e. through calling $record->save())
the full validation procedure is executed. If errors occur during that process an exception of the type
Doctrine_Validator_Exception will be thrown. You can catch that exception and analyze the errors by
@@ -10,15 +13,20 @@ an ordinary array with references to all records that did not pass validation. Y
further explore the errors of each record by analyzing the error stack of each record.
The error stack of a record can be obtained with the instance method Doctrine_Record::getErrorStack().
Each error stack is an instance of the class Doctrine_Validator_ErrorStack. The error stack
-provides an easy to use interface to inspect the errors.
-
-Explicit validation:
+provides an easy to use interface to inspect the errors.
+
+
+
+Explicit validation:
+
You can explicitly trigger the validation for any record at any time. For this purpose Doctrine_Record
provides the instance method Doctrine_Record::isValid(). This method returns a boolean value indicating
the result of the validation. If the method returns FALSE, you can inspect the error stack in the same
way as seen above except that no exception is thrown, so you simply obtain
-the error stack of the record that didnt pass validation through Doctrine_Record::getErrorStack().
-
+the error stack of the record that didnt pass validation through Doctrine_Record::getErrorStack().
+
+
+
The following code snippet shows an example of handling implicit validation which caused a Doctrine_Validator_Exception.
diff --git a/manual/docs/Advanced components - View - Intoduction.php b/manual/docs/Advanced components - View - Intoduction.php
index da4e96544..cf7c6391c 100644
--- a/manual/docs/Advanced components - View - Intoduction.php
+++ b/manual/docs/Advanced components - View - Intoduction.php
@@ -1,3 +1,3 @@
-Database views can greatly increase the performance of complex queries. You can think of them as
-cached queries. Doctrine_View provides integration between database views and DQL queries.
+Database views can greatly increase the performance of complex queries. You can think of them as
+cached queries. Doctrine_View provides integration between database views and DQL queries.
diff --git a/manual/docs/Advanced components - View - Managing views.php b/manual/docs/Advanced components - View - Managing views.php
index f9e0d5359..647aec997 100644
--- a/manual/docs/Advanced components - View - Managing views.php
+++ b/manual/docs/Advanced components - View - Managing views.php
@@ -1,16 +1,16 @@
-
-$conn = Doctrine_Manager::getInstance()
- ->openConnection(new PDO("dsn","username","password"));
-
-$query = new Doctrine_Query($conn);
-$query->from('User.Phonenumber')->limit(20);
-
-$view = new Doctrine_View($query, 'MyView');
-
-// creating a database view
-$view->create();
-
-// dropping the view from the database
-$view->drop();
-
+
+$conn = Doctrine_Manager::getInstance()
+ ->openConnection(new PDO("dsn","username","password"));
+
+$query = new Doctrine_Query($conn);
+$query->from('User.Phonenumber')->limit(20);
+
+$view = new Doctrine_View($query, 'MyView');
+
+// creating a database view
+$view->create();
+
+// dropping the view from the database
+$view->drop();
+
diff --git a/manual/docs/Advanced components - View - Using views.php b/manual/docs/Advanced components - View - Using views.php
index 346a45435..676bfc206 100644
--- a/manual/docs/Advanced components - View - Using views.php
+++ b/manual/docs/Advanced components - View - Using views.php
@@ -1,15 +1,15 @@
-
-
-$conn = Doctrine_Manager::getInstance()
- ->openConnection(new PDO("dsn","username","password"));
-
-$query = new Doctrine_Query($conn);
-$query->from('User.Phonenumber')->limit(20);
-
-// hook the query into appropriate view
-$view = new Doctrine_View($query, 'MyView');
-
-// now fetch the data from the view
-$coll = $view->execute();
-
+
+
+$conn = Doctrine_Manager::getInstance()
+ ->openConnection(new PDO("dsn","username","password"));
+
+$query = new Doctrine_Query($conn);
+$query->from('User.Phonenumber')->limit(20);
+
+// hook the query into appropriate view
+$view = new Doctrine_View($query, 'MyView');
+
+// now fetch the data from the view
+$coll = $view->execute();
+
diff --git a/manual/docs/Cache - Configuration.php b/manual/docs/Cache - Configuration.php
index 12b5d869b..bcdb4d39f 100644
--- a/manual/docs/Cache - Configuration.php
+++ b/manual/docs/Cache - Configuration.php
@@ -1,26 +1,26 @@
-There are couple of availible Cache attributes on Doctrine:
-
-
+There are couple of availible Cache attributes on Doctrine:
+
+ * Doctrine::ATTR_CACHE_SIZE
+
+ * Defines which cache container Doctrine uses
+ * Possible values: Doctrine::CACHE_* (for example Doctrine::CACHE_FILE)
+
+ * Doctrine::ATTR_CACHE_DIR
+
+ * cache directory where .cache files are saved
+ * the default cache dir is %ROOT%/cachedir, where
+ %ROOT% is automatically converted to doctrine root dir
+
+ * Doctrine::ATTR_CACHE_SLAM
+
+ * On very busy servers whenever you start the server or modify files you can create a race of many processes all trying to cache the same file at the same time. This option sets the percentage of processes that will skip trying to cache an uncached file. Or think of it as the probability of a single process to skip caching. For example, setting apc.slam_defense to 75 would mean that there is a 75% chance that the process will not cache an uncached file. So, the higher the setting the greater the defense against cache slams. Setting this to 0 disables this feature
+
+ * Doctrine::ATTR_CACHE_SIZE
+
+ * Cache size attribute
+
+ * Doctrine::ATTR_CACHE_TTL
+
+ * How often the cache is cleaned
+
+
diff --git a/manual/docs/Cache - Overview.php b/manual/docs/Cache - Overview.php
index cd3ad0866..a909a7d52 100644
--- a/manual/docs/Cache - Overview.php
+++ b/manual/docs/Cache - Overview.php
@@ -1,40 +1,49 @@
-Doctrine has very comprehensive and fast caching solution.
-Its cache is always up-to-date.
-In order to achieve this doctrine does the following things:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-1. Every Doctrine_Table has its own cache directory. The default is cache/componentname/. All the cache files are saved into that directory.
-The format of each cache file is [primarykey].cache.
-
-2. When retrieving records from the database doctrine always tries to hit the cache first.
-
-3. If a record (Doctrine_Record) is retrieved from database or inserted into database it will be saved into cache.
-
-4. When a Data Access Object is deleted or updated it will be deleted from the cache
-
-Now one might wonder that this kind of solution won't work since eventually the cache will be a copy of database!
-So doctrine does the following things to ensure the cache won't get too big:
-
-
-
-
-
-
-
-1. Every time a cache file is accessed the id of that record will be added into the $fetched property of Doctrine_Cache
-
-2. At the end of each script the Doctrine_Cache destructor will write all these primary keys at the end of a stats.cache file
-
-3. Doctrine does propabalistic cache cleaning. The default interval is 200 page loads (= 200 constructed Doctrine_Managers). Basically this means
-that the average number of page loads between cache cleans is 200.
-
-4. On every cache clean stats.cache files are being read and the least accessed cache files
-(cache files that have the smallest id occurance in the stats file) are then deleted.
-For example if the cache size is set to 200 and the number of files in cache is 300, then 100 least accessed files are being deleted.
-Doctrine also clears every stats.cache file.
-
-
-So for every 199 fast page loads there is one page load which suffers a little overhead from the cache cleaning operation.
+Doctrine has very comprehensive and fast caching solution.
+Its cache is **always up-to-date**.
+In order to achieve this doctrine does the following things:
+
+
+
+|| 1. Every Doctrine_Table has its own cache directory. The default is cache/componentname/. All the cache files are saved into that directory.
+The format of each cache file is [primarykey].cache.
+
+
+
+2. When retrieving records from the database doctrine always tries to hit the cache first.
+
+
+
+3. If a record (Doctrine_Record) is retrieved from database or inserted into database it will be saved into cache.
+
+
+
+4. When a Data Access Object is deleted or updated it will be deleted from the cache ||
+
+
+
+Now one might wonder that this kind of solution won't work since eventually the cache will be a copy of database!
+So doctrine does the following things to ensure the cache won't get too big:
+
+
+
+|| 1. Every time a cache file is accessed the id of that record will be added into the $fetched property of Doctrine_Cache
+
+
+
+2. At the end of each script the Doctrine_Cache destructor will write all these primary keys at the end of a stats.cache file
+
+
+
+3. Doctrine does propabalistic cache cleaning. The default interval is 200 page loads (= 200 constructed Doctrine_Managers). Basically this means
+that the average number of page loads between cache cleans is 200.
+
+
+
+4. On every cache clean stats.cache files are being read and the least accessed cache files
+(cache files that have the smallest id occurance in the stats file) are then deleted.
+For example if the cache size is set to 200 and the number of files in cache is 300, then 100 least accessed files are being deleted.
+Doctrine also clears every stats.cache file. ||
+
+
+
+So for every 199 fast page loads there is one page load which suffers a little overhead from the cache cleaning operation.
diff --git a/manual/docs/Caching - Availible options.php b/manual/docs/Caching - Availible options.php
index a59fb9816..a640a9459 100644
--- a/manual/docs/Caching - Availible options.php
+++ b/manual/docs/Caching - Availible options.php
@@ -1,12 +1,18 @@
-Doctrine_Cache offers many options for performance fine-tuning:
-
-
-Option that defines the propability of which
-a query is getting cached.
-
-
-Option that defines the propability the actual cleaning will occur
-when calling Doctrine_Cache::clean();
-
-
+Doctrine_Cache offers many options for performance fine-tuning:
+
+* savePropability
+
+Option that defines the propability of which
+a query is getting cached.
+
+
+
+* cleanPropability
+
+Option that defines the propability the actual cleaning will occur
+when calling Doctrine_Cache::clean();
+
+
+
+* statsPropability
+
diff --git a/manual/docs/Caching - Introduction.php b/manual/docs/Caching - Introduction.php
index 127e6e208..4c2ebe3bf 100644
--- a/manual/docs/Caching - Introduction.php
+++ b/manual/docs/Caching - Introduction.php
@@ -1,45 +1,63 @@
-
-Doctrine_Cache offers an intuitive and easy-to-use query caching solution. It provides the following things:
-
-
-
-
-
-
-
-
-
-
-Doctrine_Cache hooks into Doctrine_Db eventlistener system allowing pluggable caching.
-It evaluates queries and puts SELECT statements in cache. The caching is based on propabalistics. For example
-if savePropability = 0.1 there is a 10% chance that a query gets cached.
-
-Now eventually the cache would grow very big, hence Doctrine uses propabalistic cache cleaning.
-When calling Doctrine_Cache::clean() with cleanPropability = 0.25 there is a 25% chance of the clean operation being invoked.
-What the cleaning does is that it first reads all the queries in the stats file and sorts them by the number of times occurred.
-Then if the size is set to 100 it means the cleaning operation will leave 100 most issued queries in cache and delete all other cache entries.
-
-
-
-
-Initializing a new cache instance:
-
-addListener(\$cache);
-?>");
-?>
-
-Now you know how to set up the query cache. In the next chapter you'll learn how to tweak the cache in order to get maximum performance.
-
+
+Doctrine_Cache offers an intuitive and easy-to-use query caching solution. It provides the following things:
+
+ * Multiple cache backends to choose from (including Memcached, APC and Sqlite)
+
+
+
+
+ * Manual tuning and/or self-optimization. Doctrine_Cache knows how to optimize itself, yet it leaves user
+ full freedom of whether or not he/she wants to take advantage of this feature.
+
+
+
+
+ * Advanced options for fine-tuning. Doctrine_Cache has many options for fine-tuning performance.
+
+
+
+
+ * Cache hooks itself directly into Doctrine_Db eventlistener system allowing it to be easily added on-demand.
+
+
+
+
+
+Doctrine_Cache hooks into Doctrine_Db eventlistener system allowing pluggable caching.
+It evaluates queries and puts SELECT statements in cache. The caching is based on propabalistics. For example
+if savePropability = 0.1 there is a 10% chance that a query gets cached.
+
+
+
+Now eventually the cache would grow very big, hence Doctrine uses propabalistic cache cleaning.
+When calling Doctrine_Cache::clean() with cleanPropability = 0.25 there is a 25% chance of the clean operation being invoked.
+What the cleaning does is that it first reads all the queries in the stats file and sorts them by the number of times occurred.
+Then if the size is set to 100 it means the cleaning operation will leave 100 most issued queries in cache and delete all other cache entries.
+
+
+
+
+
+
+
+
+Initializing a new cache instance:
+
+
+
+
+\$dbh = new Doctrine_Db('mysql:host=localhost;dbname=test', \$user, \$pass);
+
+\$cache = new Doctrine_Cache('memcache');
+
+// register it as a Doctrine_Db listener
+
+\$dbh->addListener(\$cache);
+?>
+
+
+
+Now you know how to set up the query cache. In the next chapter you'll learn how to tweak the cache in order to get maximum performance.
+
+
+
diff --git a/manual/docs/Coding standards - Coding Style - Arrays.php b/manual/docs/Coding standards - Coding Style - Arrays.php
index e41f40962..63b5c7973 100644
--- a/manual/docs/Coding standards - Coding Style - Arrays.php
+++ b/manual/docs/Coding standards - Coding Style - Arrays.php
@@ -1,28 +1,28 @@
-
-
-
-
-
-
-
-
-
-
-
-$sampleArray = array('Doctrine', 'ORM', 1, 2, 3);
-
-
-$sampleArray = array(1, 2, 3,
- $a, $b, $c,
- 56.44, $d, 500);
-
-
-$sampleArray = array('first' => 'firstValue',
- 'second' => 'secondValue');
-
+* Negative numbers are not permitted as indices.
+
+
+* An indexed array may be started with any non-negative number, however this is discouraged and it is recommended that all arrays have a base index of 0.
+
+
+* When declaring indexed arrays with the array construct, a trailing space must be added after each comma delimiter to improve readability.
+
+
+* It is also permitted to declare multiline indexed arrays using the "array" construct. In this case, each successive line must be padded with spaces.
+
+
+* When declaring associative arrays with the array construct, it is encouraged to break the statement into multiple lines. In this case, each successive line must be padded with whitespace such that both the keys and the values are aligned:
+
+
+
+$sampleArray = array('Doctrine', 'ORM', 1, 2, 3);
+
+
+$sampleArray = array(1, 2, 3,
+ $a, $b, $c,
+ 56.44, $d, 500);
+
+
+$sampleArray = array('first' => 'firstValue',
+ 'second' => 'secondValue');
+
diff --git a/manual/docs/Coding standards - Coding Style - Classes.php b/manual/docs/Coding standards - Coding Style - Classes.php
index 61c93a9df..f27eec354 100644
--- a/manual/docs/Coding standards - Coding Style - Classes.php
+++ b/manual/docs/Coding standards - Coding Style - Classes.php
@@ -1,30 +1,30 @@
-
-
-
-
-
-
-
-
-
-
-
-
-This is an example of an acceptable class declaration:
-
-
-
-/**
- * Documentation here
- */
-class Doctrine_SampleClass {
- // entire content of class
- // must be indented four spaces
-}
+* Classes must be named by following the naming conventions.
+
+
+* The brace is always written right after the class name (or interface declaration).
+
+
+* Every class must have a documentation block that conforms to the PHPDocumentor standard.
+
+
+* Any code within a class must be indented four spaces.
+
+
+* Only one class is permitted per PHP file.
+
+
+* Placing additional code in a class file is NOT permitted.
+
+This is an example of an acceptable class declaration:
+
+
+
+
+/**
+ * Documentation here
+ */
+class Doctrine_SampleClass {
+ // entire content of class
+ // must be indented four spaces
+}
diff --git a/manual/docs/Coding standards - Coding Style - Control statements.php b/manual/docs/Coding standards - Coding Style - Control statements.php
index 408e80089..bcc458d5c 100644
--- a/manual/docs/Coding standards - Coding Style - Control statements.php
+++ b/manual/docs/Coding standards - Coding Style - Control statements.php
@@ -1,76 +1,68 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-");
-?>
-
-
+
+
+* Control statements based on the if and elseif constructs must have a single space before the opening parenthesis of the conditional, and a single space after the closing parenthesis.
+
+
+* Within the conditional statements between the parentheses, operators must be separated by spaces for readability. Inner parentheses are encouraged to improve logical grouping of larger conditionals.
+
+
+* The opening brace is written on the same line as the conditional statement. The closing brace is always written on its own line. Any content within the braces must be indented four spaces.
+
+
+if (\$foo != 2) {
+ \$foo = 2;
+}
+
+* For "if" statements that include "elseif" or "else", the formatting must be as in these examples:
+
+
+if (\$foo != 1) {
+ \$foo = 1;
+} else {
+ \$foo = 3;
+}
+if (\$foo != 2) {
+ \$foo = 2;
+} elseif (\$foo == 1) {
+ \$foo = 3;
+} else {
+ \$foo = 11;
+}
+
+
+* PHP allows for these statements to be written without braces in some circumstances, the following format for if statements is also allowed:
+
+
+if (\$foo != 1)
+ \$foo = 1;
+else
+ \$foo = 3;
+
+if (\$foo != 2)
+ \$foo = 2;
+elseif (\$foo == 1)
+ \$foo = 3;
+else
+ \$foo = 11;
+
+
+* Control statements written with the "switch" construct must have a single space before the opening parenthesis of the conditional statement, and also a single space after the closing parenthesis.
+
+
+* All content within the "switch" statement must be indented four spaces. Content under each "case" statement must be indented an additional four spaces but the breaks must be at the same indentation level as the "case" statements.
+
+
+switch (\$case) {
+ case 1:
+ case 2:
+ break;
+ case 3:
+ break;
+ default:
+ break;
+}
+?>
+
+* The construct default may never be omitted from a switch statement.
+
diff --git a/manual/docs/Coding standards - Coding Style - Functions and methods.php b/manual/docs/Coding standards - Coding Style - Functions and methods.php
index 8b15661c0..0e687b65d 100644
--- a/manual/docs/Coding standards - Coding Style - Functions and methods.php
+++ b/manual/docs/Coding standards - Coding Style - Functions and methods.php
@@ -1,89 +1,89 @@
-
-
-* Methods must be named by following the naming conventions.
-
-
-* Methods must always declare their visibility by using one of the private, protected, or public constructs.
-
-
-* Like classes, the brace is always written right after the method name. There is no space between the function name and the opening parenthesis for the arguments.
-
-
-* Functions in the global scope are strongly discouraged.
-
-
-* This is an example of an acceptable function declaration in a class:
-
-
-
-/**
- * Documentation Block Here
- */
-class Foo {
- /**
- * Documentation Block Here
- */
- public function bar() {
- // entire content of function
- // must be indented four spaces
- }
-}
-
-* Passing by-reference is permitted in the function declaration only:
-
-
-/**
- * Documentation Block Here
- */
-class Foo {
- /**
- * Documentation Block Here
- */
- public function bar(&\$baz) {
- }
-}
-
-
-* Call-time pass by-reference is prohibited.
-
-
-* The return value must not be enclosed in parentheses. This can hinder readability and can also break code if a method is later changed to return by reference.
-
-
-/**
- * Documentation Block Here
- */
-class Foo {
- /**
- * WRONG
- */
- public function bar() {
- return(\$this->bar);
- }
- /**
- * RIGHT
- */
- public function bar() {
- return \$this->bar;
- }
-}
-
-* Function arguments are separated by a single trailing space after the comma delimiter. This is an example of an acceptable function call for a function that takes three arguments:
-
-
-threeArguments(1, 2, 3);
-?>
-
-* Call-time pass by-reference is prohibited. See the function declarations section for the proper way to pass function arguments by-reference.
-
-
-* For functions whose arguments permitted arrays, the function call may include the "array" construct and can be split into multiple lines to improve readability. In these cases, the standards for writing arrays still apply:
-
-
-threeArguments(array(1, 2, 3), 2, 3);
-
-threeArguments(array(1, 2, 3, 'Framework',
- 'Doctrine', 56.44, 500), 2, 3);
-?>
-
+
+
+* Methods must be named by following the naming conventions.
+
+
+* Methods must always declare their visibility by using one of the private, protected, or public constructs.
+
+
+* Like classes, the brace is always written right after the method name. There is no space between the function name and the opening parenthesis for the arguments.
+
+
+* Functions in the global scope are strongly discouraged.
+
+
+* This is an example of an acceptable function declaration in a class:
+
+
+
+/**
+ * Documentation Block Here
+ */
+class Foo {
+ /**
+ * Documentation Block Here
+ */
+ public function bar() {
+ // entire content of function
+ // must be indented four spaces
+ }
+}
+
+* Passing by-reference is permitted in the function declaration only:
+
+
+/**
+ * Documentation Block Here
+ */
+class Foo {
+ /**
+ * Documentation Block Here
+ */
+ public function bar(&\$baz) {
+ }
+}
+
+
+* Call-time pass by-reference is prohibited.
+
+
+* The return value must not be enclosed in parentheses. This can hinder readability and can also break code if a method is later changed to return by reference.
+
+
+/**
+ * Documentation Block Here
+ */
+class Foo {
+ /**
+ * WRONG
+ */
+ public function bar() {
+ return(\$this->bar);
+ }
+ /**
+ * RIGHT
+ */
+ public function bar() {
+ return \$this->bar;
+ }
+}
+
+* Function arguments are separated by a single trailing space after the comma delimiter. This is an example of an acceptable function call for a function that takes three arguments:
+
+
+threeArguments(1, 2, 3);
+?>
+
+* Call-time pass by-reference is prohibited. See the function declarations section for the proper way to pass function arguments by-reference.
+
+
+* For functions whose arguments permitted arrays, the function call may include the "array" construct and can be split into multiple lines to improve readability. In these cases, the standards for writing arrays still apply:
+
+
+threeArguments(array(1, 2, 3), 2, 3);
+
+threeArguments(array(1, 2, 3, 'Framework',
+ 'Doctrine', 56.44, 500), 2, 3);
+?>
+
diff --git a/manual/docs/Coding standards - Coding Style - Inline documentation.php b/manual/docs/Coding standards - Coding Style - Inline documentation.php
index cb02c60a4..3bf61d3e9 100644
--- a/manual/docs/Coding standards - Coding Style - Inline documentation.php
+++ b/manual/docs/Coding standards - Coding Style - Inline documentation.php
@@ -1,36 +1,36 @@
-Documentation Format
-
-
-
-Methods:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+Documentation Format
+
+* All documentation blocks ("docblocks") must be compatible with the phpDocumentor format. Describing the phpDocumentor format is beyond the scope of this document. For more information, visit: http://phpdoc.org/
+
+
+Methods:
+
+* Every method, must have a docblock that contains at a minimum:
+
+
+
+* A description of the function
+
+
+
+* All of the arguments
+
+
+
+* All of the possible return values
+
+
+
+
+* It is not necessary to use the "@access" tag because the access level is already known from the "public", "private", or "protected" construct used to declare the function.
+
+
+
+* If a function/method may throw an exception, use @throws:
+
+
+
+
+* @throws exceptionclass [description]
+
diff --git a/manual/docs/Coding standards - Coding Style - PHP code demarcation.php b/manual/docs/Coding standards - Coding Style - PHP code demarcation.php
index 0a66ad8ba..7212de016 100644
--- a/manual/docs/Coding standards - Coding Style - PHP code demarcation.php
+++ b/manual/docs/Coding standards - Coding Style - PHP code demarcation.php
@@ -1,5 +1,5 @@
-PHP code must always be delimited by the full-form, standard PHP tags ()
-
-Short tags are never allowed. For files containing only PHP code, the closing tag must always be omitted
-
+PHP code must always be delimited by the full-form, standard PHP tags ()
+
+Short tags are never allowed. For files containing only PHP code, the closing tag must always be omitted
+
diff --git a/manual/docs/Coding standards - Coding Style - Strings.php b/manual/docs/Coding standards - Coding Style - Strings.php
index 86fe80046..4a276d2e7 100644
--- a/manual/docs/Coding standards - Coding Style - Strings.php
+++ b/manual/docs/Coding standards - Coding Style - Strings.php
@@ -1,37 +1,37 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-// literal string
-$string = 'something';
-
-// string contains apostrophes
-$sql = "SELECT id, name FROM people WHERE name = 'Fred' OR name = 'Susan'";
-
-// variable substitution
-$greeting = "Hello $name, welcome back!";
-
-// concatenation
-$framework = 'Doctrine' . ' ORM ' . 'Framework';
-
-// concatenation line breaking
-
-$sql = "SELECT id, name FROM user "
- . "WHERE name = ? "
- . "ORDER BY name ASC";
+* When a string is literal (contains no variable substitutions), the apostrophe or "single quote" must always used to demarcate the string:
+
+
+* When a literal string itself contains apostrophes, it is permitted to demarcate the string with quotation marks or "double quotes". This is especially encouraged for SQL statements:
+
+
+* Variable substitution is permitted using the following form:
+
+
+
+* Strings may be concatenated using the "." operator. A space must always be added before and after the "." operator to improve readability:
+
+
+
+* When concatenating strings with the "." operator, it is permitted to break the statement into multiple lines to improve readability. In these cases, each successive line should be padded with whitespace such that the "."; operator is aligned under the "=" operator:
+
+
+
+
+// literal string
+$string = 'something';
+
+// string contains apostrophes
+$sql = "SELECT id, name FROM people WHERE name = 'Fred' OR name = 'Susan'";
+
+// variable substitution
+$greeting = "Hello $name, welcome back!";
+
+// concatenation
+$framework = 'Doctrine' . ' ORM ' . 'Framework';
+
+// concatenation line breaking
+
+$sql = "SELECT id, name FROM user "
+ . "WHERE name = ? "
+ . "ORDER BY name ASC";
diff --git a/manual/docs/Coding standards - Naming Conventions - Classes.php b/manual/docs/Coding standards - Naming Conventions - Classes.php
index e20a3f674..9986e5391 100644
--- a/manual/docs/Coding standards - Naming Conventions - Classes.php
+++ b/manual/docs/Coding standards - Naming Conventions - Classes.php
@@ -1,14 +1,14 @@
-
-
-
-
-
-
+
+* The Doctrine ORM Framework uses the same class naming convention as PEAR and Zend framework, where the names of the classes directly
+map to the directories in which they are stored. The root level directory of the Doctrine Framework is the "Doctrine/" directory,
+under which all classes are stored hierarchially.
+
+
+* Class names may only contain alphanumeric characters. Numbers are permitted in class names but are discouraged.
+Underscores are only permitted in place of the path separator, eg. the filename "Doctrine/Table/Exception.php" must map to the class name "Doctrine_Table_Exception".
+
+
+* If a class name is comprised of more than one word, the first letter of each new word must be capitalized. Successive capitalized letters
+are not allowed, e.g. a class "XML_Reader" is not allowed while "Xml_Reader" is acceptable.
+
diff --git a/manual/docs/Coding standards - Naming Conventions - Constants.php b/manual/docs/Coding standards - Naming Conventions - Constants.php
index 023ec3ab1..ae68ead82 100644
--- a/manual/docs/Coding standards - Naming Conventions - Constants.php
+++ b/manual/docs/Coding standards - Naming Conventions - Constants.php
@@ -1,17 +1,17 @@
-Following rules must apply to all constants used within Doctrine framework:
-
-
-
-
-
-
-
+Following rules must apply to all constants used within Doctrine framework:
-
-class Doctrine_SomeClass {
- const MY_CONSTANT = 'something';
-}
-print Doctrine_SomeClass::MY_CONSTANT;
-
+* Constants may contain both alphanumeric characters and the underscore.
+
+* Constants must always have all letters capitalized.
+
+* For readablity reasons, words in constant names must be separated by underscore characters. For example, ATTR_EXC_LOGGING is permitted but ATTR_EXCLOGGING is not.
+
+* Constants must be defined as class members by using the "const" construct. Defining constants in the global scope with "define" is NOT permitted.
+
+
+
+class Doctrine_SomeClass {
+ const MY_CONSTANT = 'something';
+}
+print Doctrine_SomeClass::MY_CONSTANT;
+
diff --git a/manual/docs/Coding standards - Naming Conventions - Filenames.php b/manual/docs/Coding standards - Naming Conventions - Filenames.php
index b5a2a11f3..263701db7 100644
--- a/manual/docs/Coding standards - Naming Conventions - Filenames.php
+++ b/manual/docs/Coding standards - Naming Conventions - Filenames.php
@@ -1,15 +1,20 @@
-
-
-
-
-
-
-Doctrine/Db.php
-
-Doctrine/Connection/Transaction.php
-
-
+
+* For all other files, only alphanumeric characters, underscores, and the dash character ("-") are permitted. Spaces are prohibited.
+
+
+
+* Any file that contains any PHP code must end with the extension ".php". These examples show the acceptable filenames for containing the class names from the examples in the section above:
+
+
+
+Doctrine/Db.php
+
+
+
+Doctrine/Connection/Transaction.php
+
+
+
+* File names must follow the mapping to class names described above.
+
diff --git a/manual/docs/Coding standards - Naming Conventions - Functions and methods.php b/manual/docs/Coding standards - Naming Conventions - Functions and methods.php
index 94399901e..ee79e07fd 100644
--- a/manual/docs/Coding standards - Naming Conventions - Functions and methods.php
+++ b/manual/docs/Coding standards - Naming Conventions - Functions and methods.php
@@ -1,21 +1,21 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
+
+* Interface classes must follow the same conventions as other classes (see above), however must end with the word "Interface"
+(unless the interface is approved not to contain it such as Doctrine_Overloadable). Some examples:
+
+
+
+
+Doctrine_Db_EventListener_Interface
+
+
+
+Doctrine_EventListener_Interface
+
+
diff --git a/manual/docs/Coding standards - Naming Conventions - Variables.php b/manual/docs/Coding standards - Naming Conventions - Variables.php
index 54b280794..102214560 100644
--- a/manual/docs/Coding standards - Naming Conventions - Variables.php
+++ b/manual/docs/Coding standards - Naming Conventions - Variables.php
@@ -1,30 +1,30 @@
-All variables must satisfy the following conditions:
-
-
-
-Doctrine_Db_EventListener_Interface
-
-Doctrine_EventListener_Interface
-
-
-
-
-
-
-
-
-
-
-
+All variables must satisfy the following conditions:
+
+
+* Variable names may only contain alphanumeric characters. Underscores are not permitted. Numbers are permitted in variable names but are discouraged.
+
+
+
+* Variable names must always start with a lowercase letter and follow the "camelCaps" capitalization convention.
+
+
+
+* Verbosity is encouraged. Variables should always be as verbose as practical. Terse variable names such as "$i" and "$n" are discouraged for anything other than the smallest loop contexts. If a loop contains more than 20 lines of code, the variables for the indices need to have more descriptive names.
+
+
+
+* Within the framework certain generic object variables should always use the following names:
+
+
+ * Doctrine_Connection -> //$conn//
+ * Doctrine_Collection -> //$coll//
+ * Doctrine_Manager -> //$manager//
+ * Doctrine_Query -> //$query//
+ * Doctrine_Db -> //$db//
+
+
+ There are cases when more descriptive names are more appropriate (for example when multiple objects of the same class are used in same context),
+ in that case it is allowed to use different names than the ones mentioned.
+
+
-
diff --git a/manual/docs/Coding standards - PHP File Formatting - General.php b/manual/docs/Coding standards - PHP File Formatting - General.php
index 73d61f660..a166c26fa 100644
--- a/manual/docs/Coding standards - PHP File Formatting - General.php
+++ b/manual/docs/Coding standards - PHP File Formatting - General.php
@@ -1,5 +1,7 @@
-For files that contain only PHP code, the closing tag ("?>") is never permitted. It is not required by PHP. Not including it prevents trailing whitespace from being accidentally injected into the output.
-
-
-
- There are cases when more descriptive names are more appropriate (for example when multiple objects of the same class are used in same context),
- in that case it is allowed to use different names than the ones mentioned.
-
-IMPORTANT: Inclusion of arbitrary binary data as permitted by __HALT_COMPILER() is prohibited from any Doctrine framework PHP file or files derived from them. Use of this feature is only permitted for special installation scripts.
-
+For files that contain only PHP code, the closing tag ("?>") is never permitted. It is not required by PHP. Not including it prevents trailing whitespace from being accidentally injected into the output.
+
+
+
+IMPORTANT: Inclusion of arbitrary binary data as permitted by __HALT_COMPILER() is prohibited from any Doctrine framework PHP file or files derived from them. Use of this feature is only permitted for special installation scripts.
+
diff --git a/manual/docs/Coding standards - PHP File Formatting - Indentation.php b/manual/docs/Coding standards - PHP File Formatting - Indentation.php
index 9e8070543..48089411d 100644
--- a/manual/docs/Coding standards - PHP File Formatting - Indentation.php
+++ b/manual/docs/Coding standards - PHP File Formatting - Indentation.php
@@ -1,2 +1,2 @@
-Use an indent of 4 spaces, with no tabs.
+Use an indent of 4 spaces, with no tabs.
diff --git a/manual/docs/Coding standards - PHP File Formatting - Line termination.php b/manual/docs/Coding standards - PHP File Formatting - Line termination.php
index d13c8fa17..810e3f209 100644
--- a/manual/docs/Coding standards - PHP File Formatting - Line termination.php
+++ b/manual/docs/Coding standards - PHP File Formatting - Line termination.php
@@ -1,11 +1,11 @@
-
-
-
-
-
-
-
+* Line termination is the standard way for Unix text files. Lines must end only with a linefeed (LF). Linefeeds are represented as ordinal 10, or hexadecimal 0x0A.
+
+
+* Do not use carriage returns (CR) like Macintosh computers (0x0D).
+
+
+* Do not use the carriage return/linefeed combination (CRLF) as Windows computers (0x0D, 0x0A).
+
+
+
diff --git a/manual/docs/Coding standards - PHP File Formatting - Maximum line length.php b/manual/docs/Coding standards - PHP File Formatting - Maximum line length.php
index a8a34b421..3d45cd32c 100644
--- a/manual/docs/Coding standards - PHP File Formatting - Maximum line length.php
+++ b/manual/docs/Coding standards - PHP File Formatting - Maximum line length.php
@@ -1,2 +1,2 @@
-The target line length is 80 characters, i.e. developers should aim keep code as close to the 80-column boundary as is practical. However, longer lines are acceptable. The maximum length of any line of PHP code is 120 characters.
+The target line length is 80 characters, i.e. developers should aim keep code as close to the 80-column boundary as is practical. However, longer lines are acceptable. The maximum length of any line of PHP code is 120 characters.
diff --git a/manual/docs/Coding standards - Testing - Writing tests.php b/manual/docs/Coding standards - Testing - Writing tests.php
index 6823a464b..5698664a0 100644
--- a/manual/docs/Coding standards - Testing - Writing tests.php
+++ b/manual/docs/Coding standards - Testing - Writing tests.php
@@ -1,34 +1,56 @@
-CLASSES
-
-
-
-For example Doctrine_Record_TestCase is a valid name since its referring to class named
-Doctrine_Record.
-
-Doctrine_Record_State_TestCase is also a valid name since its referring to testing the state aspect
-of the Doctrine_Record class.
-
-However something like Doctrine_PrimaryKey_TestCase is not valid since its way too generic.
-
-
-METHODS
-
-
-ASSERTIONS
-For example Doctrine_Export_Pgsql_TestCase::testCreateTableSupportsAutoincPks() is a valid test method name. Just by looking at it we know
-what it is testing. Also we can run agile documentation tool to get little up-to-date system information.
-
-NOTE: Commonly used testing method naming convention TestCase::test[methodName] is *NOT* allowed in Doctrine. So in this case
-Doctrine_Export_Pgsql_TestCase::testCreateTable() would not be allowed!
-
-
-
-
-class Customer extends Doctrine_Record {
- public function setUp() {
- // setup code goes here
- }
- public function setTableDefinition() {
- // table definition code goes here
- }
-
- public function getAvailibleProducts() {
- // some code
- }
- public function setName($name) {
- if($this->isValidName($name))
- $this->set("name",$name);
- }
- public function getName() {
- return $this->get("name");
- }
-}
-
+
+class Customer extends Doctrine_Record {
+ public function setUp() {
+ // setup code goes here
+ }
+ public function setTableDefinition() {
+ // table definition code goes here
+ }
+
+ public function getAvailibleProducts() {
+ // some code
+ }
+ public function setName($name) {
+ if($this->isValidName($name))
+ $this->set("name",$name);
+ }
+ public function getName() {
+ return $this->get("name");
+ }
+}
+
diff --git a/manual/docs/Configuration - Custom primary key column.php b/manual/docs/Configuration - Custom primary key column.php
index b5b1d3fc5..7cb9b3cde 100644
--- a/manual/docs/Configuration - Custom primary key column.php
+++ b/manual/docs/Configuration - Custom primary key column.php
@@ -1,10 +1,10 @@
-
-// custom primary key column name
-
-class Group extends Doctrine_Record {
- public function setUp() {
- $this->setPrimaryKeyColumn("group_id");
- }
-}
-
+
+// custom primary key column name
+
+class Group extends Doctrine_Record {
+ public function setUp() {
+ $this->setPrimaryKeyColumn("group_id");
+ }
+}
+
diff --git a/manual/docs/Configuration - Introduction.php b/manual/docs/Configuration - Introduction.php
index 32726fecb..35c67ae59 100644
--- a/manual/docs/Configuration - Introduction.php
+++ b/manual/docs/Configuration - Introduction.php
@@ -1,6 +1,6 @@
-
-$manager = Doctrine_Manager::getInstance();
-
-$manager->setAttribute(Doctrine::ATTR_LISTENER, new MyListener());
-
+
+$manager = Doctrine_Manager::getInstance();
+
+$manager->setAttribute(Doctrine::ATTR_LISTENER, new MyListener());
+
diff --git a/manual/docs/Configuration - Levels of configuration.php b/manual/docs/Configuration - Levels of configuration.php
index 7fee77891..864f04242 100644
--- a/manual/docs/Configuration - Levels of configuration.php
+++ b/manual/docs/Configuration - Levels of configuration.php
@@ -1,39 +1,41 @@
-Doctrine has a three-level configuration structure. You can set configuration attributes in global, connection and table level.
-If the same attribute is set on both lower level and upper level, the uppermost attribute will always be used. So for example
-if user first sets default fetchmode in global level to Doctrine::FETCH_BATCH and then sets 'example' table fetchmode to Doctrine::FETCH_LAZY,
-the lazy fetching strategy will be used whenever the records of 'example' table are being fetched.
-
-
-
- The attributes set in global level will affect every connection and every table in each connection.
-
-
- The attributes set in connection level will take effect on each table in that connection.
-
-
- The attributes set in table level will take effect only on that table.
-
+Doctrine has a three-level configuration structure. You can set configuration attributes in global, connection and table level.
+If the same attribute is set on both lower level and upper level, the uppermost attribute will always be used. So for example
+if user first sets default fetchmode in global level to Doctrine::FETCH_BATCH and then sets 'example' table fetchmode to Doctrine::FETCH_LAZY,
+the lazy fetching strategy will be used whenever the records of 'example' table are being fetched.
-
-// setting a global level attribute
-$manager = Doctrine_Manager::getInstance();
-
-$manager->setAttribute(Doctrine::ATTR_VLD, false);
-
-// setting a connection level attribute
-// (overrides the global level attribute on this connection)
-
-$conn = $manager->openConnection(new PDO('dsn', 'username', 'pw'));
-
-$conn->setAttribute(Doctrine::ATTR_VLD, true);
-
-// setting a table level attribute
-// (overrides the connection/global level attribute on this table)
-
-$table = $conn->getTable('User');
-
-$table->setAttribute(Doctrine::ATTR_LISTENER, new UserListener());
-
+
+
+
+
+// setting a global level attribute
+$manager = Doctrine_Manager::getInstance();
+
+$manager->setAttribute(Doctrine::ATTR_VLD, false);
+
+// setting a connection level attribute
+// (overrides the global level attribute on this connection)
+
+$conn = $manager->openConnection(new PDO('dsn', 'username', 'pw'));
+
+$conn->setAttribute(Doctrine::ATTR_VLD, true);
+
+// setting a table level attribute
+// (overrides the connection/global level attribute on this table)
+
+$table = $conn->getTable('User');
+
+$table->setAttribute(Doctrine::ATTR_LISTENER, new UserListener());
+
diff --git a/manual/docs/Configuration - List of attributes.php b/manual/docs/Configuration - List of attributes.php
index f238ab886..f953d5cd5 100644
--- a/manual/docs/Configuration - List of attributes.php
+++ b/manual/docs/Configuration - List of attributes.php
@@ -1,44 +1,44 @@
-
-// setting default batch size for batch collections
-
-$manager->setAttribute(Doctrine::ATTR_BATCH_SIZE, 7);
-
+
+// setting default batch size for batch collections
+
+$manager->setAttribute(Doctrine::ATTR_BATCH_SIZE, 7);
+
diff --git a/manual/docs/Configuration - Setting attributes - Event listener.php b/manual/docs/Configuration - Setting attributes - Event listener.php
index d1652dd56..61cf10e8d 100644
--- a/manual/docs/Configuration - Setting attributes - Event listener.php
+++ b/manual/docs/Configuration - Setting attributes - Event listener.php
@@ -1,6 +1,6 @@
-
-// setting default event listener
-
-$manager->setAttribute(Doctrine::ATTR_LISTENER, new MyListener());
-
+
+// setting default event listener
+
+$manager->setAttribute(Doctrine::ATTR_LISTENER, new MyListener());
+
diff --git a/manual/docs/Configuration - Setting attributes - Fetching strategy.php b/manual/docs/Configuration - Setting attributes - Fetching strategy.php
index 70dc56c8b..518fbae0b 100644
--- a/manual/docs/Configuration - Setting attributes - Fetching strategy.php
+++ b/manual/docs/Configuration - Setting attributes - Fetching strategy.php
@@ -1,6 +1,6 @@
-
-// sets the default collection type (fetching strategy)
-
-$manager->setAttribute(Doctrine::ATTR_FETCHMODE, Doctrine::FETCH_LAZY);
-
+
+// sets the default collection type (fetching strategy)
+
+$manager->setAttribute(Doctrine::ATTR_FETCHMODE, Doctrine::FETCH_LAZY);
+
diff --git a/manual/docs/Configuration - Setting attributes - Identifier quoting.php b/manual/docs/Configuration - Setting attributes - Identifier quoting.php
index 9422007c1..fbe9a77d0 100644
--- a/manual/docs/Configuration - Setting attributes - Identifier quoting.php
+++ b/manual/docs/Configuration - Setting attributes - Identifier quoting.php
@@ -1,51 +1,59 @@
-
-You can quote the db identifiers (table and field names) with quoteIdentifier(). The delimiting style depends on which database driver is being used. NOTE: just because you CAN use delimited identifiers, it doesn't mean you SHOULD use them. In general, they end up causing way more problems than they solve. Anyway, it may be necessary when you have a reserved word as a field name (in this case, we suggest you to change it, if you can).
-
-Some of the internal Doctrine methods generate queries. Enabling the "quote_identifier" attribute of Doctrine you can tell Doctrine to quote the identifiers in these generated queries. For all user supplied queries this option is irrelevant.
-
-Portability is broken by using the following characters inside delimited identifiers:
-
-
-
-
-
-Delimited identifiers are known to generally work correctly under the following drivers:
-
-
-
-
-
-When using the quoteIdentifiers option, all of the field identifiers will be automatically quoted in the resulting SQL statements:
-
-setAttribute('quote_identifiers', true);
-?>");
-?>
-
-
-
-will result in a SQL statement that all the field names are quoted with the backtick '`' operator (in MySQL).
-
-
-as opposed to:
-
-
+\$conn->setAttribute('quote_identifiers', true);
+?>
+
+
+
+
+
+will result in a SQL statement that all the field names are quoted with the backtick '`' operator (in MySQL).
+
+
+
-// sets the default offset collection limit
-
-$manager->setAttribute(Doctrine::ATTR_COLL_LIMIT, 10);
-
+
+// sets the default offset collection limit
+
+$manager->setAttribute(Doctrine::ATTR_COLL_LIMIT, 10);
+
diff --git a/manual/docs/Configuration - Setting attributes - Portability.php b/manual/docs/Configuration - Setting attributes - Portability.php
index d1591e677..1771b1820 100644
--- a/manual/docs/Configuration - Setting attributes - Portability.php
+++ b/manual/docs/Configuration - Setting attributes - Portability.php
@@ -1,79 +1,123 @@
-
-Each database management system (DBMS) has it's own behaviors. For example, some databases capitalize field names in their output, some lowercase them, while others leave them alone. These quirks make it difficult to port your scripts over to another server type. PEAR Doctrine:: strives to overcome these differences so your program can switch between DBMS's without any changes.
-
-You control which portability modes are enabled by using the portability configuration option. Configuration options are set via factory() and setOption().
-
-The portability modes are bitwised, so they can be combined using | and removed using ^. See the examples section below on how to do this.
-
-Portability Mode Constants
-
-
-Doctrine::PORTABILITY_ALL (default)
-
-turn on all portability features. this is the default setting.
-
-Doctrine::PORTABILITY_DELETE_COUNT
-
-Force reporting the number of rows deleted. Some DBMS's don't count the number of rows deleted when performing simple DELETE FROM tablename queries. This mode tricks such DBMS's into telling the count by adding WHERE 1=1 to the end of DELETE queries.
-
-Doctrine::PORTABILITY_EMPTY_TO_NULL
-
-Convert empty strings values to null in data in and output. Needed because Oracle considers empty strings to be null, while most other DBMS's know the difference between empty and null.
-
-Doctrine::PORTABILITY_ERRORS
-
-Makes certain error messages in certain drivers compatible with those from other DBMS's
-
-
-Table 33-1. Error Code Re-mappings
-
-Driver Description Old Constant New Constant
-mysql, mysqli unique and primary key constraints Doctrine::ERROR_ALREADY_EXISTS Doctrine::ERROR_CONSTRAINT
-mysql, mysqli not-null constraints Doctrine::ERROR_CONSTRAINT Doctrine::ERROR_CONSTRAINT_NOT_NULL
-
-
-Doctrine::PORTABILITY_FIX_ASSOC_FIELD_NAMES
-
-This removes any qualifiers from keys in associative fetches. some RDBMS , like for example SQLite, will be default use the fully qualified name for a column in assoc fetches if it is qualified in a query.
-
-Doctrine::PORTABILITY_FIX_CASE
-
-Convert names of tables and fields to lower or upper case in all methods. The case depends on the 'field_case' option that may be set to either CASE_LOWER (default) or CASE_UPPER
-
-Doctrine::PORTABILITY_NONE
-
-Turn off all portability features
-
-Doctrine::PORTABILITY_NUMROWS
-
-Enable hack that makes numRows() work in Oracle
-
-Doctrine::PORTABILITY_RTRIM
-
-Right trim the data output for all data fetches. This does not applied in drivers for RDBMS that automatically right trim values of fixed length character values, even if they do not right trim value of variable length character values.
-
-
-
-Using setAttribute() to enable portability for lowercasing and trimming
-
-setAttribute('portability',
- Doctrine::PORTABILITY_FIX_CASE | Doctrine::PORTABILITY_RTRIM);
-
-?>");
-?>
-
-
-
-
-Using setAttribute() to enable all portability options except trimming
-
-
-setAttribute('portability',
- Doctrine::PORTABILITY_ALL ^ Doctrine::PORTABILITY_RTRIM);
-?>");
-?>
+
+Each database management system (DBMS) has it's own behaviors. For example, some databases capitalize field names in their output, some lowercase them, while others leave them alone. These quirks make it difficult to port your scripts over to another server type. PEAR Doctrine:: strives to overcome these differences so your program can switch between DBMS's without any changes.
+
+You control which portability modes are enabled by using the portability configuration option. Configuration options are set via factory() and setOption().
+
+The portability modes are bitwised, so they can be combined using | and removed using ^. See the examples section below on how to do this.
+
+
+
+Portability Mode Constants
+
+
+
+
+//Doctrine::PORTABILITY_ALL (default)//
+
+
+
+turn on all portability features. this is the default setting.
+
+
+
+//Doctrine::PORTABILITY_DELETE_COUNT//
+
+
+
+Force reporting the number of rows deleted. Some DBMS's don't count the number of rows deleted when performing simple DELETE FROM tablename queries. This mode tricks such DBMS's into telling the count by adding WHERE 1=1 to the end of DELETE queries.
+
+
+
+//Doctrine::PORTABILITY_EMPTY_TO_NULL//
+
+
+
+Convert empty strings values to null in data in and output. Needed because Oracle considers empty strings to be null, while most other DBMS's know the difference between empty and null.
+
+
+
+//Doctrine::PORTABILITY_ERRORS//
+
+
+
+Makes certain error messages in certain drivers compatible with those from other DBMS's
+
+
+
+
+Table 33-1. Error Code Re-mappings
+
+Driver Description Old Constant New Constant
+mysql, mysqli unique and primary key constraints Doctrine::ERROR_ALREADY_EXISTS Doctrine::ERROR_CONSTRAINT
+mysql, mysqli not-null constraints Doctrine::ERROR_CONSTRAINT Doctrine::ERROR_CONSTRAINT_NOT_NULL
+
+
+
+
+//Doctrine::PORTABILITY_FIX_ASSOC_FIELD_NAMES//
+
+
+
+This removes any qualifiers from keys in associative fetches. some RDBMS , like for example SQLite, will be default use the fully qualified name for a column in assoc fetches if it is qualified in a query.
+
+
+
+//Doctrine::PORTABILITY_FIX_CASE//
+
+
+
+Convert names of tables and fields to lower or upper case in all methods. The case depends on the 'field_case' option that may be set to either CASE_LOWER (default) or CASE_UPPER
+
+
+
+//Doctrine::PORTABILITY_NONE//
+
+
+
+Turn off all portability features
+
+
+
+//Doctrine::PORTABILITY_NUMROWS//
+
+
+
+Enable hack that makes numRows() work in Oracle
+
+
+
+//Doctrine::PORTABILITY_RTRIM//
+
+
+
+Right trim the data output for all data fetches. This does not applied in drivers for RDBMS that automatically right trim values of fixed length character values, even if they do not right trim value of variable length character values.
+
+
+
+
+
+Using setAttribute() to enable portability for lowercasing and trimming
+
+
+
+
+\$conn->setAttribute('portability',
+ Doctrine::PORTABILITY_FIX_CASE | Doctrine::PORTABILITY_RTRIM);
+
+?>
+
+
+
+
+
+
+Using setAttribute() to enable all portability options except trimming
+
+
+
+
+
+\$conn->setAttribute('portability',
+ Doctrine::PORTABILITY_ALL ^ Doctrine::PORTABILITY_RTRIM);
+?>
diff --git a/manual/docs/Configuration - Setting attributes - Session lockmode.php b/manual/docs/Configuration - Setting attributes - Session lockmode.php
index 302a8d758..82fb24a7e 100644
--- a/manual/docs/Configuration - Setting attributes - Session lockmode.php
+++ b/manual/docs/Configuration - Setting attributes - Session lockmode.php
@@ -1,6 +1,6 @@
-
-// setting default lockmode
-
-$manager->setAttribute(Doctrine::ATTR_LOCKMODE, Doctrine::LOCK_PESSIMISTIC);
-
+
+// setting default lockmode
+
+$manager->setAttribute(Doctrine::ATTR_LOCKMODE, Doctrine::LOCK_PESSIMISTIC);
+
diff --git a/manual/docs/Configuration - Setting attributes - Table creation.php b/manual/docs/Configuration - Setting attributes - Table creation.php
index 82eca78a7..dd3e2c114 100644
--- a/manual/docs/Configuration - Setting attributes - Table creation.php
+++ b/manual/docs/Configuration - Setting attributes - Table creation.php
@@ -1,6 +1,6 @@
-
-// turns automatic table creation off
-
-$manager->setAttribute(Doctrine::ATTR_CREATE_TABLES, false);
-
+
+// turns automatic table creation off
+
+$manager->setAttribute(Doctrine::ATTR_CREATE_TABLES, false);
+
diff --git a/manual/docs/Configuration - Setting attributes - Validation.php b/manual/docs/Configuration - Setting attributes - Validation.php
index 3c770280d..91302dbf8 100644
--- a/manual/docs/Configuration - Setting attributes - Validation.php
+++ b/manual/docs/Configuration - Setting attributes - Validation.php
@@ -1,6 +1,6 @@
-
-// turns transactional validation on
-
-$manager->setAttribute(Doctrine::ATTR_VLD, true);
-
+
+// turns transactional validation on
+
+$manager->setAttribute(Doctrine::ATTR_VLD, true);
+
diff --git a/manual/docs/Configuration - Setting default eventlistener.php b/manual/docs/Configuration - Setting default eventlistener.php
index 1dc8551db..8bf431544 100644
--- a/manual/docs/Configuration - Setting default eventlistener.php
+++ b/manual/docs/Configuration - Setting default eventlistener.php
@@ -1,11 +1,11 @@
-
-class Email extends Doctrine_Record {
- public function setUp() {
- $this->setAttribute(Doctrine::ATTR_LISTENER,new MyListener());
- }
- public function setTableDefinition() {
- $this->hasColumn("address","string",150,"email|unique");
- }
-}
-
+
+class Email extends Doctrine_Record {
+ public function setUp() {
+ $this->setAttribute(Doctrine::ATTR_LISTENER,new MyListener());
+ }
+ public function setTableDefinition() {
+ $this->hasColumn("address","string",150,"email|unique");
+ }
+}
+
diff --git a/manual/docs/Configuration - Setting default fetchmode.php b/manual/docs/Configuration - Setting default fetchmode.php
index dbb0d02a4..09e50959e 100644
--- a/manual/docs/Configuration - Setting default fetchmode.php
+++ b/manual/docs/Configuration - Setting default fetchmode.php
@@ -1,12 +1,12 @@
-
-// setting default fetchmode
-// availible fetchmodes are Doctrine::FETCH_LAZY, Doctrine::FETCH_IMMEDIATE and Doctrine::FETCH_BATCH
-// the default fetchmode is Doctrine::FETCH_LAZY
-
-class Address extends Doctrine_Record {
- public function setUp() {
- $this->setAttribute(Doctrine::ATTR_FETCHMODE,Doctrine::FETCH_IMMEDIATE);
- }
-}
-
+
+// setting default fetchmode
+// availible fetchmodes are Doctrine::FETCH_LAZY, Doctrine::FETCH_IMMEDIATE and Doctrine::FETCH_BATCH
+// the default fetchmode is Doctrine::FETCH_LAZY
+
+class Address extends Doctrine_Record {
+ public function setUp() {
+ $this->setAttribute(Doctrine::ATTR_FETCHMODE,Doctrine::FETCH_IMMEDIATE);
+ }
+}
+
diff --git a/manual/docs/Configuration - Using sequences.php b/manual/docs/Configuration - Using sequences.php
index 87efa219c..af5767efa 100644
--- a/manual/docs/Configuration - Using sequences.php
+++ b/manual/docs/Configuration - Using sequences.php
@@ -1,10 +1,10 @@
-
-// using sequences
-
-class User extends Doctrine_Record {
- public function setUp() {
- $this->setSequenceName("user_seq");
- }
-}
-
+
+// using sequences
+
+class User extends Doctrine_Record {
+ public function setUp() {
+ $this->setSequenceName("user_seq");
+ }
+}
+
diff --git a/manual/docs/Connection management - Connection-component binding.php b/manual/docs/Connection management - Connection-component binding.php
index 5ac935b34..2c1745656 100644
--- a/manual/docs/Connection management - Connection-component binding.php
+++ b/manual/docs/Connection management - Connection-component binding.php
@@ -1,24 +1,24 @@
-
-Doctrine allows you to bind connections to components (= your ActiveRecord classes). This means everytime a component issues a query
-or data is being fetched from the table the component is pointing at Doctrine will use the bound connection.
-
-openConnection(new PDO('dsn','username','password'), 'connection 1');
-
-\$conn2 = \$manager->openConnection(new PDO('dsn2','username2','password2'), 'connection 2');
-
-\$manager->bindComponent('User', 'connection 1');
-
-\$manager->bindComponent('Group', 'connection 2');
-
-\$q = new Doctrine_Query();
-
-// Doctrine uses 'connection 1' for fetching here
-\$users = \$q->from('User u')->where('u.id IN (1,2,3)')->execute();
-
-// Doctrine uses 'connection 2' for fetching here
-\$groups = \$q->from('Group g')->where('g.id IN (1,2,3)')->execute();
-?>");
-?>
+
+Doctrine allows you to bind connections to components (= your ActiveRecord classes). This means everytime a component issues a query
+or data is being fetched from the table the component is pointing at Doctrine will use the bound connection.
+
+
+
+
+\$conn = \$manager->openConnection(new PDO('dsn','username','password'), 'connection 1');
+
+\$conn2 = \$manager->openConnection(new PDO('dsn2','username2','password2'), 'connection 2');
+
+\$manager->bindComponent('User', 'connection 1');
+
+\$manager->bindComponent('Group', 'connection 2');
+
+\$q = new Doctrine_Query();
+
+// Doctrine uses 'connection 1' for fetching here
+\$users = \$q->from('User u')->where('u.id IN (1,2,3)')->execute();
+
+// Doctrine uses 'connection 2' for fetching here
+\$groups = \$q->from('Group g')->where('g.id IN (1,2,3)')->execute();
+?>
diff --git a/manual/docs/Connection management - DSN, the Data Source Name.php b/manual/docs/Connection management - DSN, the Data Source Name.php
index b6b05bf8e..906a7f3db 100644
--- a/manual/docs/Connection management - DSN, the Data Source Name.php
+++ b/manual/docs/Connection management - DSN, the Data Source Name.php
@@ -1,106 +1,106 @@
-In order to connect to a database through Doctrine, you have to create a valid DSN - data source name.
-
-Doctrine supports both PEAR DB/MDB2 like data source names as well as PDO style data source names. The following section deals with PEAR like data source names. If you need more info about the PDO-style data source names see http://www.php.net/manual/en/function.PDO-construct.php.
-
-The DSN consists in the following parts:
-
-**phptype**: Database backend used in PHP (i.e. mysql , pgsql etc.)
-**dbsyntax**: Database used with regards to SQL syntax etc.
-**protocol**: Communication protocol to use ( i.e. tcp, unix etc.)
-**hostspec**: Host specification (hostname[:port])
-**database**: Database to use on the DBMS server
-**username**: User name for login
-**password**: Password for login
-**proto_opts**: Maybe used with protocol
-**option**: Additional connection options in URI query string format. options get separated by &. The Following table shows a non complete list of options:
-
-
-**List of options**
-
-|| //Name// || //Description// ||
-|| charset || Some backends support setting the client charset.||
-|| new_link || Some RDBMS do not create new connections when connecting to the same host multiple times. This option will attempt to force a new connection. ||
-
-The DSN can either be provided as an associative array or as a string. The string format of the supplied DSN is in its fullest form:
-`` phptype(dbsyntax)://username:password@protocol+hostspec/database?option=value ``
-
-
-
-Most variations are allowed:
-
-
-phptype://username:password@protocol+hostspec:110//usr/db_file.db
-phptype://username:password@hostspec/database
-phptype://username:password@hostspec
-phptype://username@hostspec
-phptype://hostspec/database
-phptype://hostspec
-phptype:///database
-phptype:///database?option=value&anotheroption=anothervalue
-phptype(dbsyntax)
-phptype
-
-
-
-The currently supported database backends are:
-||//fbsql//|| -> FrontBase ||
-||//ibase//|| -> InterBase / Firebird (requires PHP 5) ||
-||//mssql//|| -> Microsoft SQL Server (NOT for Sybase. Compile PHP --with-mssql) ||
-||//mysql//|| -> MySQL ||
-||//mysqli//|| -> MySQL (supports new authentication protocol) (requires PHP 5) ||
-||//oci8 //|| -> Oracle 7/8/9/10 ||
-||//pgsql//|| -> PostgreSQL ||
-||//querysim//|| -> QuerySim ||
-||//sqlite//|| -> SQLite 2 ||
-
-
-
-A second DSN format is supported phptype(syntax)://user:pass@protocol(proto_opts)/database
-
-
-
-If your database, option values, username or password contain characters used to delineate DSN parts, you can escape them via URI hex encodings:
-``: = %3a``
-``/ = %2f``
-``@ = %40``
-``+ = %2b``
-``( = %28``
-``) = %29``
-``? = %3f``
-``= = %3d``
-``& = %26``
-
-
-
-
-Warning
-Please note, that some features may be not supported by all database backends.
-
-
-Example
-**Example 1.** Connect to database through a socket
-
-mysql://user@unix(/path/to/socket)/pear
-
-
-**Example 2.** Connect to database on a non standard port
-
-pgsql://user:pass@tcp(localhost:5555)/pear
-
-
-**Example 3.** Connect to SQLite on a Unix machine using options
-
-sqlite:////full/unix/path/to/file.db?mode=0666
-
-
-**Example 4.** Connect to SQLite on a Windows machine using options
-
-sqlite:///c:/full/windows/path/to/file.db?mode=0666
-
-
-**Example 5.** Connect to MySQLi using SSL
-
-mysqli://user:pass@localhost/pear?key=client-key.pem&cert=client-cert.pem
-
-
-
+In order to connect to a database through Doctrine, you have to create a valid DSN - data source name.
+
+Doctrine supports both PEAR DB/MDB2 like data source names as well as PDO style data source names. The following section deals with PEAR like data source names. If you need more info about the PDO-style data source names see http://www.php.net/manual/en/function.PDO-construct.php.
+
+The DSN consists in the following parts:
+
+**phptype**: Database backend used in PHP (i.e. mysql , pgsql etc.)
+**dbsyntax**: Database used with regards to SQL syntax etc.
+**protocol**: Communication protocol to use ( i.e. tcp, unix etc.)
+**hostspec**: Host specification (hostname[:port])
+**database**: Database to use on the DBMS server
+**username**: User name for login
+**password**: Password for login
+**proto_opts**: Maybe used with protocol
+**option**: Additional connection options in URI query string format. options get separated by &. The Following table shows a non complete list of options:
+
+
+**List of options**
+
+|| //Name// || //Description// ||
+|| charset || Some backends support setting the client charset.||
+|| new_link || Some RDBMS do not create new connections when connecting to the same host multiple times. This option will attempt to force a new connection. ||
+
+The DSN can either be provided as an associative array or as a string. The string format of the supplied DSN is in its fullest form:
+`` phptype(dbsyntax)://username:password@protocol+hostspec/database?option=value ``
+
+
+
+Most variations are allowed:
+
+
+phptype://username:password@protocol+hostspec:110//usr/db_file.db
+phptype://username:password@hostspec/database
+phptype://username:password@hostspec
+phptype://username@hostspec
+phptype://hostspec/database
+phptype://hostspec
+phptype:///database
+phptype:///database?option=value&anotheroption=anothervalue
+phptype(dbsyntax)
+phptype
+
+
+
+The currently supported database backends are:
+||//fbsql//|| -> FrontBase ||
+||//ibase//|| -> InterBase / Firebird (requires PHP 5) ||
+||//mssql//|| -> Microsoft SQL Server (NOT for Sybase. Compile PHP --with-mssql) ||
+||//mysql//|| -> MySQL ||
+||//mysqli//|| -> MySQL (supports new authentication protocol) (requires PHP 5) ||
+||//oci8 //|| -> Oracle 7/8/9/10 ||
+||//pgsql//|| -> PostgreSQL ||
+||//querysim//|| -> QuerySim ||
+||//sqlite//|| -> SQLite 2 ||
+
+
+
+A second DSN format is supported phptype(syntax)://user:pass@protocol(proto_opts)/database
+
+
+
+If your database, option values, username or password contain characters used to delineate DSN parts, you can escape them via URI hex encodings:
+``: = %3a``
+``/ = %2f``
+``@ = %40``
+``+ = %2b``
+``( = %28``
+``) = %29``
+``? = %3f``
+``= = %3d``
+``& = %26``
+
+
+
+
+Warning
+Please note, that some features may be not supported by all database backends.
+
+
+Example
+**Example 1.** Connect to database through a socket
+
+mysql://user@unix(/path/to/socket)/pear
+
+
+**Example 2.** Connect to database on a non standard port
+
+pgsql://user:pass@tcp(localhost:5555)/pear
+
+
+**Example 3.** Connect to SQLite on a Unix machine using options
+
+sqlite:////full/unix/path/to/file.db?mode=0666
+
+
+**Example 4.** Connect to SQLite on a Windows machine using options
+
+sqlite:///c:/full/windows/path/to/file.db?mode=0666
+
+
+**Example 5.** Connect to MySQLi using SSL
+
+mysqli://user:pass@localhost/pear?key=client-key.pem&cert=client-cert.pem
+
+
+
diff --git a/manual/docs/Connection management - Lazy-connecting to database.php b/manual/docs/Connection management - Lazy-connecting to database.php
index 83e291aae..02f5011c4 100644
--- a/manual/docs/Connection management - Lazy-connecting to database.php
+++ b/manual/docs/Connection management - Lazy-connecting to database.php
@@ -1,22 +1,24 @@
-
-Lazy-connecting to database is handled via Doctrine_Db wrapper. When using Doctrine_Db instead of PDO / Doctrine_Adapter, lazy-connecting
-to database is being performed (that means Doctrine will only connect to database when needed).
This feature can be very useful
-when using for example page caching, hence not actually needing a database connection on every request. Remember connecting to database is an expensive operation.
-
-query('FROM User u');
-
-?>");
-?>
+
+Lazy-connecting to database is handled via Doctrine_Db wrapper. When using Doctrine_Db instead of PDO / Doctrine_Adapter, lazy-connecting
+to database is being performed (that means Doctrine will only connect to database when needed).
+
+This feature can be very useful
+when using for example page caching, hence not actually needing a database connection on every request. Remember connecting to database is an expensive operation.
+
+
+
+
+// we may use PDO / PEAR like DSN
+// here we use PEAR like DSN
+\$dbh = new Doctrine_Db('mysql://username:password@localhost/test');
+// !! no actual database connection yet !!
+
+// initalize a new Doctrine_Connection
+\$conn = Doctrine_Manager::connection(\$dbh);
+// !! no actual database connection yet !!
+
+// connects database and performs a query
+\$conn->query('FROM User u');
+
+?>
diff --git a/manual/docs/Connection management - Managing connections.php b/manual/docs/Connection management - Managing connections.php
index d33f95112..4b20ccff2 100644
--- a/manual/docs/Connection management - Managing connections.php
+++ b/manual/docs/Connection management - Managing connections.php
@@ -1,72 +1,80 @@
-
-From the start Doctrine has been designed to work with multiple connections. Unless separately specified Doctrine always uses the current connection
-for executing the queries. The following example uses openConnection() second argument as an optional
-connection alias.
-
-openConnection(new PDO('dsn','username','password'), 'connection 1');
-?>
-");
-?>
-
-For convenience Doctrine_Manager provides static method connection() which opens new connection when arguments are given to it and returns the current
-connection when no arguments have been speficied.
-
-
-");
-?>
-
-
-
-The current connection is the lastly opened connection.
-
-openConnection(new PDO('dsn2','username2','password2'), 'connection 2');
-
-\$manager->getCurrentConnection(); // \$conn2
-?>");
-?>
-
-You can change the current connection by calling setCurrentConnection().
-
-setCurrentConnection('connection 1');
-
-\$manager->getCurrentConnection(); // \$conn
-?>
-");
-?>
-
-You can iterate over the opened connection by simple passing the manager object to foreach clause. This is possible since Doctrine_Manager implements
-special IteratorAggregate interface.
-
-");
-?>
+
+From the start Doctrine has been designed to work with multiple connections. Unless separately specified Doctrine always uses the current connection
+for executing the queries. The following example uses openConnection() second argument as an optional
+connection alias.
+
+
+
+
+// Doctrine_Manager controls all the connections
+
+\$manager = Doctrine_Manager::getInstance();
+
+// open first connection
+
+\$conn = \$manager->openConnection(new PDO('dsn','username','password'), 'connection 1');
+?>
+
+
+
+
+For convenience Doctrine_Manager provides static method connection() which opens new connection when arguments are given to it and returns the current
+connection when no arguments have been speficied.
+
+
+
+
+// open first connection
+
+\$conn = Doctrine_Manager::connection(new PDO('dsn','username','password'), 'connection 1');
+
+\$conn2 = Doctrine_Manager::connection();
+
+// \$conn2 == \$conn
+?>
+
+
+
+
+
+
+The current connection is the lastly opened connection.
+
+
+
+
+// open second connection
+
+\$conn2 = \$manager->openConnection(new PDO('dsn2','username2','password2'), 'connection 2');
+
+\$manager->getCurrentConnection(); // \$conn2
+?>
+
+
+
+You can change the current connection by calling setCurrentConnection().
+
+
+
+
+\$manager->setCurrentConnection('connection 1');
+
+\$manager->getCurrentConnection(); // \$conn
+?>
+
+
+
+
+You can iterate over the opened connection by simple passing the manager object to foreach clause. This is possible since Doctrine_Manager implements
+special IteratorAggregate interface.
+
+
+
+
+// iterating through connections
+
+foreach(\$manager as \$conn) {
+
+}
+?>
diff --git a/manual/docs/Connection management - Opening a new connection.php b/manual/docs/Connection management - Opening a new connection.php
index cec6c99d2..a5c784ed5 100644
--- a/manual/docs/Connection management - Opening a new connection.php
+++ b/manual/docs/Connection management - Opening a new connection.php
@@ -1,41 +1,45 @@
-
-Opening a new database connection in Doctrine is very easy. If you wish to use PDO (www.php.net/PDO) you can just initalize a new PDO object:
-
-getMessage();
-}
-?>");
-?>
-
-If your database extension isn't supported by PDO you can use special Doctrine_Adapter class (if availible). The following example uses db2 adapter:
-
-getMessage();
-}
-?>");
-?>
-
-The next step is opening a new Doctrine_Connection.
-
-");
-?>
+
+Opening a new database connection in Doctrine is very easy. If you wish to use PDO (www.php.net/PDO) you can just initalize a new PDO object:
+
+
+
+
+\$dsn = 'mysql:dbname=testdb;host=127.0.0.1';
+\$user = 'dbuser';
+\$password = 'dbpass';
+
+try {
+ \$dbh = new PDO(\$dsn, \$user, \$password);
+} catch (PDOException \$e) {
+ echo 'Connection failed: ' . \$e->getMessage();
+}
+?>
+
+
+
+If your database extension isn't supported by PDO you can use special Doctrine_Adapter class (if availible). The following example uses db2 adapter:
+
+
+
+
+\$dsn = 'db2:dbname=testdb;host=127.0.0.1';
+\$user = 'dbuser';
+\$password = 'dbpass';
+
+try {
+ \$dbh = Doctrine_Adapter::connect(\$dsn, \$user, \$password);
+} catch (PDOException \$e) {
+ echo 'Connection failed: ' . \$e->getMessage();
+}
+?>
+
+
+
+The next step is opening a new Doctrine_Connection.
+
+
+
+
+\$conn = Doctrine_Manager::connection(\$dbh);
+?>
diff --git a/manual/docs/Connection modules - Export - Altering table.php b/manual/docs/Connection modules - Export - Altering table.php
index 814b3e683..c67fdfa02 100644
--- a/manual/docs/Connection modules - Export - Altering table.php
+++ b/manual/docs/Connection modules - Export - Altering table.php
@@ -1,95 +1,96 @@
-
-Doctrine_Export drivers provide an easy database portable way of altering existing database tables.
-
-NOTE: if you only want to get the generated sql (and not execute it) use Doctrine_Export::alterTableSql()
-
-openConnection(\$dbh);
-
-\$a = array('add' => array('name' => array('type' => 'string', 'length' => 255)));
-
-
-\$conn->export->alterTableSql('mytable', \$a);
-
-// On mysql this method returns:
-// ALTER TABLE mytable ADD COLUMN name VARCHAR(255)
-?>");
-?>
-
-Doctrine_Export::alterTable() takes two parameters:
-
-string $name
-
-array $changes
-
-
-
-
-
-
-The value of each entry of the array should be set to another associative array with the properties of the fields to that are meant to be changed as array entries. These entries should be assigned to the new values of the respective properties. The properties of the fields should be the same as defined by the Doctrine parser.
-
+
+Doctrine_Export drivers provide an easy database portable way of altering existing database tables.
-
-$a = array('name' => 'userlist',
- 'add' => array(
- 'quota' => array(
- 'type' => 'integer',
- 'unsigned' => 1
- )
- ),
- 'remove' => array(
- 'file_limit' => array(),
- 'time_limit' => array()
- ),
- 'change' => array(
- 'name' => array(
- 'length' => '20',
- 'definition' => array(
- 'type' => 'text',
- 'length' => 20
- )
- )
- ),
- 'rename' => array(
- 'sex' => array(
- 'name' => 'gender',
- 'definition' => array(
- 'type' => 'text',
- 'length' => 1,
- 'default' => 'M'
- )
- )
- )
-
- );
-
-$dbh = new PDO('dsn','username','pw');
-$conn = Doctrine_Manager::getInstance()->openConnection($dbh);
-
-$conn->export->alterTable('mytable', $a);
-
+
+
+NOTE: if you only want to get the generated sql (and not execute it) use Doctrine_Export::alterTableSql()
+
+
+
+
+\$dbh = new PDO('dsn','username','pw');
+\$conn = Doctrine_Manager::getInstance()
+ ->openConnection(\$dbh);
+
+\$a = array('add' => array('name' => array('type' => 'string', 'length' => 255)));
+
+
+\$conn->export->alterTableSql('mytable', \$a);
+
+// On mysql this method returns:
+// ALTER TABLE mytable ADD COLUMN name VARCHAR(255)
+?>
+
+
+
+Doctrine_Export::alterTable() takes two parameters:
+
+
+
+: string //$name// : name of the table that is intended to be changed.
+
+: array //$changes// : associative array that contains the details of each type of change that is intended to be performed.
+The types of changes that are currently supported are defined as follows:
+
+* //name//
+New name for the table.
+
+* //add//
+
+Associative array with the names of fields to be added as indexes of the array. The value of each entry of the array should be set to another associative array with the properties of the fields to be added. The properties of the fields should be the same as defined by the Doctrine parser.
+
+* //remove//
+
+Associative array with the names of fields to be removed as indexes of the array. Currently the values assigned to each entry are ignored. An empty array should be used for future compatibility.
+
+* //rename//
+
+Associative array with the names of fields to be renamed as indexes of the array. The value of each entry of the array should be set to another associative array with the entry named name with the new field name and the entry named Declaration that is expected to contain the portion of the field declaration already in DBMS specific SQL code as it is used in the CREATE TABLE statement.
+
+* //change//
+
+Associative array with the names of the fields to be changed as indexes of the array. Keep in mind that if it is intended to change either the name of a field and any other properties, the change array entries should have the new names of the fields as array indexes.
+
+
+The value of each entry of the array should be set to another associative array with the properties of the fields to that are meant to be changed as array entries. These entries should be assigned to the new values of the respective properties. The properties of the fields should be the same as defined by the Doctrine parser.
+
+
+
+$a = array('name' => 'userlist',
+ 'add' => array(
+ 'quota' => array(
+ 'type' => 'integer',
+ 'unsigned' => 1
+ )
+ ),
+ 'remove' => array(
+ 'file_limit' => array(),
+ 'time_limit' => array()
+ ),
+ 'change' => array(
+ 'name' => array(
+ 'length' => '20',
+ 'definition' => array(
+ 'type' => 'text',
+ 'length' => 20
+ )
+ )
+ ),
+ 'rename' => array(
+ 'sex' => array(
+ 'name' => 'gender',
+ 'definition' => array(
+ 'type' => 'text',
+ 'length' => 1,
+ 'default' => 'M'
+ )
+ )
+ )
+
+ );
+
+$dbh = new PDO('dsn','username','pw');
+$conn = Doctrine_Manager::getInstance()->openConnection($dbh);
+
+$conn->export->alterTable('mytable', $a);
+
diff --git a/manual/docs/Connection modules - Export - Creating new table.php b/manual/docs/Connection modules - Export - Creating new table.php
index 84ce54319..a8cff18e1 100644
--- a/manual/docs/Connection modules - Export - Creating new table.php
+++ b/manual/docs/Connection modules - Export - Creating new table.php
@@ -1,23 +1,23 @@
-
-$dbh = new PDO('dsn','username','pw');
-$conn = Doctrine_Manager::getInstance()->openConnection($dbh);
-
-$fields = array('id' => array(
- 'type' => 'integer',
- 'autoincrement' => true),
- 'name' => array(
- 'type' => 'string',
- 'fixed' => true,
- 'length' => 8)
- );
-// the following option is mysql specific and
-// skipped by other drivers
-$options = array('type' => 'MYISAM');
-
-$conn->export->createTable('mytable', $fields);
-
-// on mysql this executes query:
-// CREATE TABLE mytable (id INT AUTO_INCREMENT PRIMARY KEY,
-// name CHAR(8));
-
+
+$dbh = new PDO('dsn','username','pw');
+$conn = Doctrine_Manager::getInstance()->openConnection($dbh);
+
+$fields = array('id' => array(
+ 'type' => 'integer',
+ 'autoincrement' => true),
+ 'name' => array(
+ 'type' => 'string',
+ 'fixed' => true,
+ 'length' => 8)
+ );
+// the following option is mysql specific and
+// skipped by other drivers
+$options = array('type' => 'MYISAM');
+
+$conn->export->createTable('mytable', $fields);
+
+// on mysql this executes query:
+// CREATE TABLE mytable (id INT AUTO_INCREMENT PRIMARY KEY,
+// name CHAR(8));
+
diff --git a/manual/docs/DQL (Doctrine Query Language) - Conditional expressions - All and Any Expressions.php b/manual/docs/DQL (Doctrine Query Language) - Conditional expressions - All and Any Expressions.php
index 85f7a6d84..df6881476 100644
--- a/manual/docs/DQL (Doctrine Query Language) - Conditional expressions - All and Any Expressions.php
+++ b/manual/docs/DQL (Doctrine Query Language) - Conditional expressions - All and Any Expressions.php
@@ -1,51 +1,48 @@
-Syntax:
-
-operand comparison_operator ANY (subquery)
-operand comparison_operator SOME (subquery)
-operand comparison_operator ALL (subquery)
-
-
-
-
-FROM C WHERE C.col1 < ALL (FROM C2(col1))
-
-
-FROM C WHERE C.col1 > ANY (FROM C2(col1))
-
-
-FROM C WHERE C.col1 > SOME (FROM C2(col1))
-
-
-The comparison operators that can be used with ALL or ANY conditional expressions are =, <, <=, >, >=, <>. The
-result of the subquery must be same type with the conditional expression.
-
-NOT IN is an alias for <> ALL. Thus, these two statements are equal:
-
-
-FROM C WHERE C.col1 <> ALL (FROM C2(col1));
-FROM C WHERE C.col1 NOT IN (FROM C2(col1));
-
-
+operand comparison_operator ANY (subquery)
+operand comparison_operator SOME (subquery)
+operand comparison_operator ALL (subquery)
+
+
+An ALL conditional expression returns true if the comparison operation is true for all values
+in the result of the subquery or the result of the subquery is empty. An ALL conditional expression
+is false if the result of the comparison is false for at least one row, and is unknown if neither true nor
+false.
+
+
+
+
+
+FROM C WHERE C.col1 < ALL (FROM C2(col1))
+
+
+An ANY conditional expression returns true if the comparison operation is true for some
+value in the result of the subquery. An ANY conditional expression is false if the result of the subquery
+is empty or if the comparison operation is false for every value in the result of the subquery, and is
+unknown if neither true nor false.
+
+
+FROM C WHERE C.col1 > ANY (FROM C2(col1))
+
+
+The keyword SOME is an alias for ANY.
+
+FROM C WHERE C.col1 > SOME (FROM C2(col1))
+
+
+
+The comparison operators that can be used with ALL or ANY conditional expressions are =, <, <=, >, >=, <>. The
+result of the subquery must be same type with the conditional expression.
+
+
+
+NOT IN is an alias for <> ALL. Thus, these two statements are equal:
+
+
+
+
+FROM C WHERE C.col1 <> ALL (FROM C2(col1));
+FROM C WHERE C.col1 NOT IN (FROM C2(col1));
+
diff --git a/manual/docs/DQL (Doctrine Query Language) - Conditional expressions - Between expressions.php b/manual/docs/DQL (Doctrine Query Language) - Conditional expressions - Between expressions.php
index 4e3ae44db..b28b04f64 100644
--- a/manual/docs/DQL (Doctrine Query Language) - Conditional expressions - Between expressions.php
+++ b/manual/docs/DQL (Doctrine Query Language) - Conditional expressions - Between expressions.php
@@ -1,3 +1,3 @@
-
-
+
+
diff --git a/manual/docs/DQL (Doctrine Query Language) - Conditional expressions - Exists Expressions.php b/manual/docs/DQL (Doctrine Query Language) - Conditional expressions - Exists Expressions.php
index fa97cea36..8caaab41d 100644
--- a/manual/docs/DQL (Doctrine Query Language) - Conditional expressions - Exists Expressions.php
+++ b/manual/docs/DQL (Doctrine Query Language) - Conditional expressions - Exists Expressions.php
@@ -1,27 +1,25 @@
-Syntax:
-
-operand [NOT ]EXISTS (subquery)
-
-
-
-The NOT EXISTS operator returns TRUE if the subquery returns 0 rows and FALSE otherwise.
-
-Finding all articles which have readers:
-
-FROM Article
- WHERE EXISTS (FROM ReaderLog(id)
- WHERE ReaderLog.article_id = Article.id)
-
-
-FROM Article
- WHERE NOT EXISTS (FROM ReaderLog(id)
- WHERE ReaderLog.article_id = Article.id)
-
-
+//operand// [NOT ]EXISTS (//subquery//)
+
+The EXISTS operator returns TRUE if the subquery returns one or more rows and FALSE otherwise.
+
+
+
+The NOT EXISTS operator returns TRUE if the subquery returns 0 rows and FALSE otherwise.
+
+
+
+Finding all articles which have readers:
+
+FROM Article
+ WHERE EXISTS (FROM ReaderLog(id)
+ WHERE ReaderLog.article_id = Article.id)
+
+Finding all articles which don't have readers:
+
+FROM Article
+ WHERE NOT EXISTS (FROM ReaderLog(id)
+ WHERE ReaderLog.article_id = Article.id)
+
diff --git a/manual/docs/DQL (Doctrine Query Language) - Conditional expressions - In expressions.php b/manual/docs/DQL (Doctrine Query Language) - Conditional expressions - In expressions.php
index aae88e927..fcd10c60e 100644
--- a/manual/docs/DQL (Doctrine Query Language) - Conditional expressions - In expressions.php
+++ b/manual/docs/DQL (Doctrine Query Language) - Conditional expressions - In expressions.php
@@ -1,29 +1,23 @@
-Syntax:
-
-operand IN (subquery|value list)
-
-
-FROM C1 WHERE C1.col1 IN (FROM C2(col1));
-
-FROM User WHERE User.id IN (1,3,4,5)
-
-
-FROM C1 WHERE C1.col1 = ANY (FROM C2(col1));
-FROM C1 WHERE C1.col1 IN (FROM C2(col1));
-
-
+//operand// IN (//subquery//|//value list//)
+
+An IN conditional expression returns true if the //operand// is found from result of the //subquery//
+or if its in the specificied comma separated //value list//, hence the IN expression is always false if the result of the subquery
+is empty.
+
+When //value list// is being used there must be at least one element in that list.
+
+
+FROM C1 WHERE C1.col1 IN (FROM C2(col1));
+
+FROM User WHERE User.id IN (1,3,4,5)
+
+
+The keyword IN is an alias for = ANY. Thus, these two statements are equal:
+
+FROM C1 WHERE C1.col1 = ANY (FROM C2(col1));
+FROM C1 WHERE C1.col1 IN (FROM C2(col1));
+
+
diff --git a/manual/docs/DQL (Doctrine Query Language) - Conditional expressions - Input parameters.php b/manual/docs/DQL (Doctrine Query Language) - Conditional expressions - Input parameters.php
index 8e4a0c527..86ce0f904 100644
--- a/manual/docs/DQL (Doctrine Query Language) - Conditional expressions - Input parameters.php
+++ b/manual/docs/DQL (Doctrine Query Language) - Conditional expressions - Input parameters.php
@@ -1,15 +1,15 @@
-
-
-// POSITIONAL PARAMETERS:
-$users = $conn->query("FROM User WHERE User.name = ?", array('Arnold'));
-
-$users = $conn->query("FROM User WHERE User.id > ? AND User.name LIKE ?", array(50, 'A%'));
-
-
-// NAMED PARAMETERS:
-
-$users = $conn->query("FROM User WHERE User.name = :name", array(':name' => 'Arnold'));
-
-$users = $conn->query("FROM User WHERE User.id > :id AND User.name LIKE :name", array(':id' => 50, ':name' => 'A%'));
-
+
+
+// POSITIONAL PARAMETERS:
+$users = $conn->query("FROM User WHERE User.name = ?", array('Arnold'));
+
+$users = $conn->query("FROM User WHERE User.id > ? AND User.name LIKE ?", array(50, 'A%'));
+
+
+// NAMED PARAMETERS:
+
+$users = $conn->query("FROM User WHERE User.name = :name", array(':name' => 'Arnold'));
+
+$users = $conn->query("FROM User WHERE User.id > :id AND User.name LIKE :name", array(':id' => 50, ':name' => 'A%'));
+
diff --git a/manual/docs/DQL (Doctrine Query Language) - Conditional expressions - Like Expressions.php b/manual/docs/DQL (Doctrine Query Language) - Conditional expressions - Like Expressions.php
index 192eb47b7..38b939126 100644
--- a/manual/docs/DQL (Doctrine Query Language) - Conditional expressions - Like Expressions.php
+++ b/manual/docs/DQL (Doctrine Query Language) - Conditional expressions - Like Expressions.php
@@ -1,33 +1,40 @@
-Syntax:
-string_expression [NOT] LIKE pattern_value [ESCAPE escape_character]
-
-
-
-The string_expression must have a string value. The pattern_value is a string literal or a string-valued
-input parameter in which an underscore (_) stands for any single character, a percent (%) character
-stands for any sequence of characters (including the empty sequence), and all other characters stand for
-themselves. The optional escape_character is a single-character string literal or a character-valued
-input parameter (i.e., char or Character) and is used to escape the special meaning of the underscore
-and percent characters in pattern_value.
-
-Examples:
-
-
-
-
-If the value of the string_expression or pattern_value is NULL or unknown, the value of the LIKE
-expression is unknown. If the escape_characteris specified and is NULL, the value of the LIKE expression
-is unknown.
+Syntax:
-
-
-// finding all users whose email ends with '@gmail.com'
-$users = $conn->query("FROM User u, u.Email e WHERE e.address LIKE '%@gmail.com'");
-
-// finding all users whose name starts with letter 'A'
-$users = $conn->query("FROM User u WHERE u.name LIKE 'A%'");
-
+string_expression [NOT] LIKE pattern_value [ESCAPE escape_character]
+
+
+
+
+
+The string_expression must have a string value. The pattern_value is a string literal or a string-valued
+input parameter in which an underscore (_) stands for any single character, a percent (%) character
+stands for any sequence of characters (including the empty sequence), and all other characters stand for
+themselves. The optional escape_character is a single-character string literal or a character-valued
+input parameter (i.e., char or Character) and is used to escape the special meaning of the underscore
+and percent characters in pattern_value.
+
+
+
+Examples:
+
+
+
+* address.phone LIKE ‘12%3’ is true for '123' '12993' and false for '1234'
+* asentence.word LIKE ‘l_se’ is true for ‘lose’ and false for 'loose'
+* aword.underscored LIKE ‘\_%’ ESCAPE '\' is true for '_foo' and false for 'bar'
+* address.phone NOT LIKE ‘12%3’ is false for '123' and '12993' and true for '1234'
+
+
+
+If the value of the string_expression or pattern_value is NULL or unknown, the value of the LIKE
+expression is unknown. If the escape_characteris specified and is NULL, the value of the LIKE expression
+is unknown.
+
+
+
+// finding all users whose email ends with '@gmail.com'
+$users = $conn->query("FROM User u, u.Email e WHERE e.address LIKE '%@gmail.com'");
+
+// finding all users whose name starts with letter 'A'
+$users = $conn->query("FROM User u WHERE u.name LIKE 'A%'");
+
diff --git a/manual/docs/DQL (Doctrine Query Language) - Conditional expressions - Literals.php b/manual/docs/DQL (Doctrine Query Language) - Conditional expressions - Literals.php
index 3c4299cc3..baef581c2 100644
--- a/manual/docs/DQL (Doctrine Query Language) - Conditional expressions - Literals.php
+++ b/manual/docs/DQL (Doctrine Query Language) - Conditional expressions - Literals.php
@@ -1,51 +1,49 @@
-Strings
-
-A string literal is enclosed in single quotes—for example: 'literal'. A string literal that includes a single
-quote is represented by two single quotes—for example: 'literal''s'.
-
-FROM User WHERE User.name = 'Vincent'
-
-
-Integer literals support the use of PHP integer literal syntax.
-
-FROM User WHERE User.id = 4
-
-
-Float literals support the use of PHP float literal syntax.
-
-FROM Account WHERE Account.amount = 432.123
-
-
-Booleans
-The boolean literals are true and false.
-
-
-FROM User WHERE User.admin = true
-
-FROM Session WHERE Session.is_authed = false
-
-
-Enums
-The enumerated values work in the same way as string literals.
-
-
-FROM User WHERE User.type = 'admin'
-
-
-Predefined reserved literals are case insensitive, although its a good standard to write them in uppercase.
+**Strings**
+
+
+A string literal is enclosed in single quotes—for example: 'literal'. A string literal that includes a single
+quote is represented by two single quotes—for example: 'literal''s'.
+
+FROM User WHERE User.name = 'Vincent'
+
+
+**Integers**
+
+Integer literals support the use of PHP integer literal syntax.
+
+FROM User WHERE User.id = 4
+
+
+**Floats**
+
+Float literals support the use of PHP float literal syntax.
+
+FROM Account WHERE Account.amount = 432.123
+
+
+
+
+**Booleans**
+
+The boolean literals are true and false.
+
+
+FROM User WHERE User.admin = true
+
+FROM Session WHERE Session.is_authed = false
+
+
+
+
+**Enums**
+
+The enumerated values work in the same way as string literals.
+
+
+FROM User WHERE User.type = 'admin'
+
+
+
+
+Predefined reserved literals are case insensitive, although its a good standard to write them in uppercase.
diff --git a/manual/docs/DQL (Doctrine Query Language) - Conditional expressions - Operators and operator precedence.php b/manual/docs/DQL (Doctrine Query Language) - Conditional expressions - Operators and operator precedence.php
index 9e2a75aa6..4fdb7caed 100644
--- a/manual/docs/DQL (Doctrine Query Language) - Conditional expressions - Operators and operator precedence.php
+++ b/manual/docs/DQL (Doctrine Query Language) - Conditional expressions - Operators and operator precedence.php
@@ -1,15 +1,25 @@
-The operators are listed below in order of decreasing precedence.
-
-
+The operators are listed below in order of decreasing precedence.
+
+* Navigation operator (.)
+* Arithmetic operators:
+
++, - unary
+
+*, / multiplication and division
+
++, - addition and subtraction
+
+* Comparison operators : =, >, >=, <, <=, <> (not equal), [NOT] LIKE,
+
+[NOT] IN, IS [NOT] NULL, IS [NOT] EMPTY
+
+* Logical operators:
+
+NOT
+
+AND
+
+OR
+
+
diff --git a/manual/docs/DQL (Doctrine Query Language) - Conditional expressions - Subqueries.php b/manual/docs/DQL (Doctrine Query Language) - Conditional expressions - Subqueries.php
index bc62779c7..b576d31bc 100644
--- a/manual/docs/DQL (Doctrine Query Language) - Conditional expressions - Subqueries.php
+++ b/manual/docs/DQL (Doctrine Query Language) - Conditional expressions - Subqueries.php
@@ -1,31 +1,33 @@
-A subquery can contain any of the keywords or clauses that an ordinary SELECT query can contain.
-
-+, - unary
-*, / multiplication and division
-+, - addition and subtraction
-
-[NOT] IN, IS [NOT] NULL, IS [NOT] EMPTY
-
-NOT
-AND
-OR
-
-Some advantages of the subqueries:
-
-
+A subquery can contain any of the keywords or clauses that an ordinary SELECT query can contain.
-
-// finding all users which don't belong to any group 1
-$query = "FROM User WHERE User.id NOT IN
- (SELECT u.id FROM User u
- INNER JOIN u.Group g WHERE g.id = ?";
-
-$users = $conn->query($query, array(1));
-
-// finding all users which don't belong to any groups
-// Notice:
-// the usage of INNER JOIN
-// the usage of empty brackets preceding the Group component
-
-$query = "FROM User WHERE User.id NOT IN
- (SELECT u.id FROM User u
- INNER JOIN u.Group g)";
-
-$users = $conn->query($query);
-
+
+
+Some advantages of the subqueries:
+
+* They allow queries that are structured so that it is possible to isolate each part of a statement.
+
+* They provide alternative ways to perform operations that would otherwise require complex joins and unions.
+
+* They are, in many people's opinion, readable. Indeed, it was the innovation of subqueries that gave people the original idea of calling the early SQL “Structured Query Language.”
+
+
+
+
+// finding all users which don't belong to any group 1
+$query = "FROM User WHERE User.id NOT IN
+ (SELECT u.id FROM User u
+ INNER JOIN u.Group g WHERE g.id = ?";
+
+$users = $conn->query($query, array(1));
+
+// finding all users which don't belong to any groups
+// Notice:
+// the usage of INNER JOIN
+// the usage of empty brackets preceding the Group component
+
+$query = "FROM User WHERE User.id NOT IN
+ (SELECT u.id FROM User u
+ INNER JOIN u.Group g)";
+
+$users = $conn->query($query);
+
diff --git a/manual/docs/DQL (Doctrine Query Language) - DELETE queries.php b/manual/docs/DQL (Doctrine Query Language) - DELETE queries.php
index 76b235f7d..399a8a0fc 100644
--- a/manual/docs/DQL (Doctrine Query Language) - DELETE queries.php
+++ b/manual/docs/DQL (Doctrine Query Language) - DELETE queries.php
@@ -1,37 +1,35 @@
-
-DELETE FROM component_name
- [WHERE where_condition]
- [ORDER BY ...]
- [LIMIT record_count]
-
-
-
+
+DELETE FROM //component_name//
+ [WHERE //where_condition//]
+ [ORDER BY ...]
+ [LIMIT //record_count//]
+
-
-$q = 'DELETE FROM Account WHERE id > ?';
-
-$rows = $this->conn->query($q, array(3));
-
-// the same query using the query interface
-
-$q = new Doctrine_Query();
-
-$rows = $q->delete('Account')
- ->from('Account a')
- ->where('a.id > ?', 3)
- ->execute();
-
-print $rows; // the number of affected rows
-
+* The DELETE statement deletes records from //component_name// and returns the number of records deleted.
+
+* The optional WHERE clause specifies the conditions that identify which records to delete.
+Without WHERE clause, all records are deleted.
+
+* If the ORDER BY clause is specified, the records are deleted in the order that is specified.
+
+* The LIMIT clause places a limit on the number of rows that can be deleted.
+The statement will stop as soon as it has deleted //record_count// records.
+
+
+
+
+$q = 'DELETE FROM Account WHERE id > ?';
+
+$rows = $this->conn->query($q, array(3));
+
+// the same query using the query interface
+
+$q = new Doctrine_Query();
+
+$rows = $q->delete('Account')
+ ->from('Account a')
+ ->where('a.id > ?', 3)
+ ->execute();
+
+print $rows; // the number of affected rows
+
diff --git a/manual/docs/DQL (Doctrine Query Language) - FROM clause.php b/manual/docs/DQL (Doctrine Query Language) - FROM clause.php
index 72aec367c..b68a9adf5 100644
--- a/manual/docs/DQL (Doctrine Query Language) - FROM clause.php
+++ b/manual/docs/DQL (Doctrine Query Language) - FROM clause.php
@@ -1,32 +1,29 @@
-Syntax:
-
-
-FROM component_reference [[LEFT | INNER] JOIN component_reference] ...
-
-
-
-
-
-SELECT u.*, p.* FROM User u LEFT JOIN u.Phonenumber
-
-SELECT u.*, p.* FROM User u, u.Phonenumber p
-
-
-SELECT u.*, p.* FROM User u INNER JOIN u.Phonenumber p
-
-
+FROM //component_reference// [[LEFT | INNER] JOIN //component_reference//] ...
+
+
+The FROM clause indicates the component or components from which to retrieve records.
+If you name more than one component, you are performing a join.
+For each table specified, you can optionally specify an alias.
+
+
+
+
+
+* The default join type is //LEFT JOIN//. This join can be indicated by the use of either 'LEFT JOIN' clause or simply ',', hence the following queries are equal:
+
+SELECT u.*, p.* FROM User u LEFT JOIN u.Phonenumber
+
+SELECT u.*, p.* FROM User u, u.Phonenumber p
+
+
+* //INNER JOIN// produces an intersection between two specified components (that is, each and every record in the first component is joined to each and every record in the second component).
+So basically //INNER JOIN// can be used when you want to efficiently fetch for example all users which have one or more phonenumbers.
+
+SELECT u.*, p.* FROM User u INNER JOIN u.Phonenumber p
+
+
diff --git a/manual/docs/DQL (Doctrine Query Language) - Functional Expressions - String functions.php b/manual/docs/DQL (Doctrine Query Language) - Functional Expressions - String functions.php
index 54e7c9709..ca89cec22 100644
--- a/manual/docs/DQL (Doctrine Query Language) - Functional Expressions - String functions.php
+++ b/manual/docs/DQL (Doctrine Query Language) - Functional Expressions - String functions.php
@@ -1,77 +1,87 @@
-
-
-
+
+
+* The //CONCAT// function returns a string that is a concatenation of its arguments. In the example above we
+map the concatenation of users firstname and lastname to a value called name
+
+
+
select('CONCAT(u.firstname, u.lastname) name')->from('User u')->execute();
-
-foreach(\$users as \$user) {
- // here 'name' is not a property of \$user,
- // its a mapped function value
- print \$user->name;
-}
-?>");
-?>
-
-
-
select('u.name')->from('User u')->where(\"SUBSTRING(u.name, 0, 1) = 'z'\")->execute();
-
-foreach(\$users as \$user) {
- print \$user->name;
-}
-?>");
-?>
-
-
-
select('u.name')->from('User u')->where(\"TRIM(u.name) = 'Someone'\")->execute();
-
-foreach(\$users as \$user) {
- print \$user->name;
-}
-?>");
-?>
-
-
-select('u.name')->from('User u')->where(\"LOWER(u.name) = 'someone'\")->execute();
-
-foreach(\$users as \$user) {
- print \$user->name;
-}
-?>");
-?>
-
-
+\$q = new Doctrine_Query();
+
+\$users = \$q->select('CONCAT(u.firstname, u.lastname) name')->from('User u')->execute();
+
+foreach(\$users as \$user) {
+ // here 'name' is not a property of \$user,
+ // its a mapped function value
+ print \$user->name;
+}
+?>
+
+
+
+
+* The second and third arguments of the //SUBSTRING// function denote the starting position and length of
+the substring to be returned. These arguments are integers. The first position of a string is denoted by 1.
+The //SUBSTRING// function returns a string.
+
+
+
+\$q = new Doctrine_Query();
+
+\$users = \$q->select('u.name')->from('User u')->where(\"SUBSTRING(u.name, 0, 1) = 'z'\")->execute();
+
+foreach(\$users as \$user) {
+ print \$user->name;
+}
+?>
+
+
+
+
+* The //TRIM// function trims the specified character from a string. If the character to be trimmed is not
+specified, it is assumed to be space (or blank). The optional trim_character is a single-character string
+literal or a character-valued input parameter (i.e., char or Character)[30]. If a trim specification is
+not provided, BOTH is assumed. The //TRIM// function returns the trimmed string.
+
+
+
+\$q = new Doctrine_Query();
+
+\$users = \$q->select('u.name')->from('User u')->where(\"TRIM(u.name) = 'Someone'\")->execute();
+
+foreach(\$users as \$user) {
+ print \$user->name;
+}
+?>
+
+
+* The //LOWER// and //UPPER// functions convert a string to lower and upper case, respectively. They return a
+string.
+
+
+
+
+\$q = new Doctrine_Query();
+
+\$users = \$q->select('u.name')->from('User u')->where(\"LOWER(u.name) = 'someone'\")->execute();
+
+foreach(\$users as \$user) {
+ print \$user->name;
+}
+?>
+
+
+*
+The //LOCATE// function returns the position of a given string within a string, starting the search at a specified
+position. It returns the first position at which the string was found as an integer. The first argument
+is the string to be located; the second argument is the string to be searched; the optional third argument
+is an integer that represents the string position at which the search is started (by default, the beginning of
+the string to be searched). The first position in a string is denoted by 1. If the string is not found, 0 is
+returned.
+
+
+
+
+* The //LENGTH// function returns the length of the string in characters as an integer.
+
+
diff --git a/manual/docs/DQL (Doctrine Query Language) - Functions - Contains.php b/manual/docs/DQL (Doctrine Query Language) - Functions - Contains.php
index 86497ee87..67b931d12 100644
--- a/manual/docs/DQL (Doctrine Query Language) - Functions - Contains.php
+++ b/manual/docs/DQL (Doctrine Query Language) - Functions - Contains.php
@@ -1,8 +1,8 @@
-
-$q = new Doctrine_Query();
-
-$q->from('User')->where('User.Phonenumber.phonenumber.contains(?,?,?)');
-
-$users = $q->execute(array('123 123 123', '0400 999 999', '+358 100 100'));
-
+
+$q = new Doctrine_Query();
+
+$q->from('User')->where('User.Phonenumber.phonenumber.contains(?,?,?)');
+
+$users = $q->execute(array('123 123 123', '0400 999 999', '+358 100 100'));
+
diff --git a/manual/docs/DQL (Doctrine Query Language) - Functions - Like.php b/manual/docs/DQL (Doctrine Query Language) - Functions - Like.php
index 32bf2999e..1c3aa1ceb 100644
--- a/manual/docs/DQL (Doctrine Query Language) - Functions - Like.php
+++ b/manual/docs/DQL (Doctrine Query Language) - Functions - Like.php
@@ -1,8 +1,8 @@
-
-$q = new Doctrine_Query();
-
-$q->from('User')->where('User.Phonenumber.phonenumber.like(?,?)');
-
-$users = $q->execute(array('%123%', '456%'));
-
+
+$q = new Doctrine_Query();
+
+$q->from('User')->where('User.Phonenumber.phonenumber.like(?,?)');
+
+$users = $q->execute(array('%123%', '456%'));
+
diff --git a/manual/docs/DQL (Doctrine Query Language) - Functions - Regexp.php b/manual/docs/DQL (Doctrine Query Language) - Functions - Regexp.php
index 6e1fb4736..7ff724015 100644
--- a/manual/docs/DQL (Doctrine Query Language) - Functions - Regexp.php
+++ b/manual/docs/DQL (Doctrine Query Language) - Functions - Regexp.php
@@ -1,8 +1,8 @@
-
-$q = new Doctrine_Query();
-
-$q->from('User')->where('User.Phonenumber.phonenumber.regexp(?,?)');
-
-$users = $q->execute(array('[123]', '^[3-5]'));
-
+
+$q = new Doctrine_Query();
+
+$q->from('User')->where('User.Phonenumber.phonenumber.regexp(?,?)');
+
+$users = $q->execute(array('[123]', '^[3-5]'));
+
diff --git a/manual/docs/DQL (Doctrine Query Language) - GROUP BY, HAVING clauses.php b/manual/docs/DQL (Doctrine Query Language) - GROUP BY, HAVING clauses.php
index 8d61ce2f7..32521a292 100644
--- a/manual/docs/DQL (Doctrine Query Language) - GROUP BY, HAVING clauses.php
+++ b/manual/docs/DQL (Doctrine Query Language) - GROUP BY, HAVING clauses.php
@@ -1,51 +1,47 @@
-
-
-
-
-
-Selecting alphabetically first user by name.
-
-SELECT MIN(u.name) FROM User u
-
-
-SELECT SUM(a.amount) FROM Account a
-
-
-
-SELECT u.*, COUNT(p.id) FROM User u, u.Phonenumber p GROUP BY u.id
-
-
-
-SELECT u.* FROM User u, u.Phonenumber p HAVING COUNT(p.id) >= 2
-
-
-
-// retrieve all users and the phonenumber count for each user
-
-$users = $conn->query("SELECT u.*, COUNT(p.id) count FROM User u, u.Phonenumber p GROUP BY u.id");
-
-foreach($users as $user) {
- print $user->name . ' has ' . $user->Phonenumber[0]->count . ' phonenumbers';
-}
-
+
+SELECT MIN(u.name) FROM User u
+
+
+Selecting the sum of all Account amounts.
+
+SELECT SUM(a.amount) FROM Account a
+
+
+
+
+
+SELECT u.*, COUNT(p.id) FROM User u, u.Phonenumber p GROUP BY u.id
+
+
+
+
+
+SELECT u.* FROM User u, u.Phonenumber p HAVING COUNT(p.id) >= 2
+
+
+
+
+
+
+
+// retrieve all users and the phonenumber count for each user
+
+$users = $conn->query("SELECT u.*, COUNT(p.id) count FROM User u, u.Phonenumber p GROUP BY u.id");
+
+foreach($users as $user) {
+ print $user->name . ' has ' . $user->Phonenumber[0]->count . ' phonenumbers';
+}
+
diff --git a/manual/docs/DQL (Doctrine Query Language) - Introduction.php b/manual/docs/DQL (Doctrine Query Language) - Introduction.php
index a432af305..f3cddb132 100644
--- a/manual/docs/DQL (Doctrine Query Language) - Introduction.php
+++ b/manual/docs/DQL (Doctrine Query Language) - Introduction.php
@@ -1,50 +1,57 @@
-Doctrine Query Language(DQL) is an Object Query Language created for helping users in complex object retrieval.
-You should always consider using DQL(or raw SQL) when retrieving relational data efficiently (eg. when fetching users and their phonenumbers).
-
-When compared to using raw SQL, DQL has several benefits:
-
-
-
-
-
-
-
-
-
-
-
-If the power of DQL isn't enough, you should consider using the rawSql API for object population.
-
+Doctrine Query Language(DQL) is an Object Query Language created for helping users in complex object retrieval.
+You should always consider using DQL(or raw SQL) when retrieving relational data efficiently (eg. when fetching users and their phonenumbers).
-
-// DO NOT USE THE FOLLOWING CODE
-// (using many sql queries for object population):
-
-$users = $conn->getTable('User')->findAll();
-
-foreach($users as $user) {
- print $user->name."
+
+
+When compared to using raw SQL, DQL has several benefits:
+
+
+ * From the start it has been designed to retrieve records(objects) not result set rows
+
+
+ * DQL understands relations so you don't have to type manually sql joins and join conditions
+
+
+ * DQL is portable on different databases
+
+
+ * DQL has some very complex built-in algorithms like (the record limit algorithm) which can help
+ developer to efficiently retrieve objects
+
+
+ * It supports some functions that can save time when dealing with one-to-many, many-to-many relational data with conditional fetching.
+
+
+If the power of DQL isn't enough, you should consider using the rawSql API for object population.
+
+
+
";
- foreach($user->Phonenumber as $phonenumber) {
- print $phonenumber."
";
- }
-}
-
-// same thing implemented much more efficiently:
-// (using only one sql query for object population)
-
-$users = $conn->query("FROM User.Phonenumber");
-
-foreach($users as $user) {
- print $user->name."
";
- foreach($user->Phonenumber as $phonenumber) {
- print $phonenumber."
";
- }
-}
-
-
+// DO NOT USE THE FOLLOWING CODE
+// (using many sql queries for object population):
+
+$users = $conn->getTable('User')->findAll();
+
+foreach($users as $user) {
+ print $user->name."
+";
+ foreach($user->Phonenumber as $phonenumber) {
+ print $phonenumber."
+";
+ }
+}
+
+// same thing implemented much more efficiently:
+// (using only one sql query for object population)
+
+$users = $conn->query("FROM User.Phonenumber");
+
+foreach($users as $user) {
+ print $user->name."
+";
+ foreach($user->Phonenumber as $phonenumber) {
+ print $phonenumber."
+";
+ }
+}
+
+
diff --git a/manual/docs/DQL (Doctrine Query Language) - LIMIT and OFFSET clauses - Driver portability.php b/manual/docs/DQL (Doctrine Query Language) - LIMIT and OFFSET clauses - Driver portability.php
index 6720d7a82..00b692c75 100644
--- a/manual/docs/DQL (Doctrine Query Language) - LIMIT and OFFSET clauses - Driver portability.php
+++ b/manual/docs/DQL (Doctrine Query Language) - LIMIT and OFFSET clauses - Driver portability.php
@@ -1,13 +1,23 @@
-DQL LIMIT clause is portable on all supported databases. Special attention have been paid to following facts:
-
-
-
-
-
-
-In the following example we have users and phonenumbers with their relation being one-to-many. Now lets say we want fetch the first 20 users
-and all their related phonenumbers.
-
-Now one might consider that adding a simple driver specific LIMIT 20 at the end of query would return the correct results.
-Thats wrong, since we you might get anything between 1-20 users as the first user might have 20 phonenumbers and then record set would consist of 20 rows.
-
-DQL overcomes this problem with subqueries and with complex but efficient subquery analysis. In the next example we are going to fetch first 20 users and all their phonenumbers with single efficient query.
-Notice how the DQL parser is smart enough to use column aggregation inheritance even in the subquery and how its smart enough to use different aliases
-for the tables in the subquery to avoid alias collisions.
-
-
-DQL QUERY:
-
-SELECT u.id, u.name, p.* FROM User u LEFT JOIN u.Phonenumber p LIMIT 20
-
-SELECT
- e.id AS e__id,
- e.name AS e__name,
- p.id AS p__id,
- p.phonenumber AS p__phonenumber,
- p.entity_id AS p__entity_id
-FROM entity e
-LEFT JOIN phonenumber p ON e.id = p.entity_id
-WHERE e.id IN (
-SELECT DISTINCT e2.id
-FROM entity e2
-WHERE (e2.type = 0) LIMIT 20) AND (e.type = 0)
-
-
-In the next example we are going to fetch first 20 users and all their phonenumbers and only
-those users that actually have phonenumbers with single efficient query, hence we use an INNER JOIN.
-Notice how the DQL parser is smart enough to use the INNER JOIN in the subquery.
-
-
-DQL QUERY:
-
-SELECT u.id, u.name, p.* FROM User u LEFT JOIN u.Phonenumber p LIMIT 20
-
-SELECT
- e.id AS e__id,
- e.name AS e__name,
- p.id AS p__id,
- p.phonenumber AS p__phonenumber,
- p.entity_id AS p__entity_id
-FROM entity e
-LEFT JOIN phonenumber p ON e.id = p.entity_id
-WHERE e.id IN (
-SELECT DISTINCT e2.id
-FROM entity e2
-INNER JOIN phonenumber p2 ON e2.id = p2.entity_id
-WHERE (e2.type = 0) LIMIT 20) AND (e.type = 0)
-
-
+SELECT u.id, u.name, p.* FROM User u LEFT JOIN u.Phonenumber p LIMIT 20
+
+SELECT
+ e.id AS e__id,
+ e.name AS e__name,
+ p.id AS p__id,
+ p.phonenumber AS p__phonenumber,
+ p.entity_id AS p__entity_id
+FROM entity e
+LEFT JOIN phonenumber p ON e.id = p.entity_id
+WHERE e.id IN (
+SELECT DISTINCT e2.id
+FROM entity e2
+WHERE (e2.type = 0) LIMIT 20) AND (e.type = 0)
+
+
+
+
+
+In the next example we are going to fetch first 20 users and all their phonenumbers and only
+those users that actually have phonenumbers with single efficient query, hence we use an INNER JOIN.
+Notice how the DQL parser is smart enough to use the INNER JOIN in the subquery.
+
+
+
+
+DQL QUERY:
+
+SELECT u.id, u.name, p.* FROM User u LEFT JOIN u.Phonenumber p LIMIT 20
+
+SELECT
+ e.id AS e__id,
+ e.name AS e__name,
+ p.id AS p__id,
+ p.phonenumber AS p__phonenumber,
+ p.entity_id AS p__entity_id
+FROM entity e
+LEFT JOIN phonenumber p ON e.id = p.entity_id
+WHERE e.id IN (
+SELECT DISTINCT e2.id
+FROM entity e2
+INNER JOIN phonenumber p2 ON e2.id = p2.entity_id
+WHERE (e2.type = 0) LIMIT 20) AND (e.type = 0)
+
+
diff --git a/manual/docs/DQL (Doctrine Query Language) - LIMIT and OFFSET clauses.php b/manual/docs/DQL (Doctrine Query Language) - LIMIT and OFFSET clauses.php
index 06228c5ca..810e4ef2e 100644
--- a/manual/docs/DQL (Doctrine Query Language) - LIMIT and OFFSET clauses.php
+++ b/manual/docs/DQL (Doctrine Query Language) - LIMIT and OFFSET clauses.php
@@ -1,16 +1,16 @@
-
-
-
-// retrieve the first 20 users and all their associated phonenumbers
-
-$users = $conn->query("SELECT u.*, p.* FROM User u, u.Phonenumber p LIMIT 20");
-
-foreach($users as $user) {
- print ' --- '.$user->name.' --- \n';
-
- foreach($user->Phonenumber as $p) {
- print $p->phonenumber.'\n';
- }
-}
-
+
+
+
+// retrieve the first 20 users and all their associated phonenumbers
+
+$users = $conn->query("SELECT u.*, p.* FROM User u, u.Phonenumber p LIMIT 20");
+
+foreach($users as $user) {
+ print ' --- '.$user->name.' --- \n';
+
+ foreach($user->Phonenumber as $p) {
+ print $p->phonenumber.'\n';
+ }
+}
+
diff --git a/manual/docs/DQL (Doctrine Query Language) - ORDER BY clause - Introduction.php b/manual/docs/DQL (Doctrine Query Language) - ORDER BY clause - Introduction.php
index cd02f6d6a..012901401 100644
--- a/manual/docs/DQL (Doctrine Query Language) - ORDER BY clause - Introduction.php
+++ b/manual/docs/DQL (Doctrine Query Language) - ORDER BY clause - Introduction.php
@@ -1,29 +1,25 @@
-Record collections can be sorted efficiently at the database level using the ORDER BY clause.
-
-Syntax:
-
- [ORDER BY {ComponentAlias.columnName}
- [ASC | DESC], ...]
-
-
-
-FROM User.Phonenumber
- ORDER BY User.name, Phonenumber.phonenumber
-
-FROM User u, u.Email e
- ORDER BY e.address, u.id
-
-
-
-FROM User u, u.Email e
- ORDER BY e.address DESC, u.id ASC;
-
-
+ [ORDER BY {ComponentAlias.columnName}
+ [ASC | DESC], ...]
+
+
+Examples:
+
+
+
+FROM User.Phonenumber
+ ORDER BY User.name, Phonenumber.phonenumber
+
+FROM User u, u.Email e
+ ORDER BY e.address, u.id
+
+In order to sort in reverse order you can add the DESC (descending) keyword to the name of the column in the ORDER BY clause that you are sorting by. The default is ascending order; this can be specified explicitly using the ASC keyword.
+
+
+
+FROM User u, u.Email e
+ ORDER BY e.address DESC, u.id ASC;
+
diff --git a/manual/docs/DQL (Doctrine Query Language) - Operators - Logical operators.php b/manual/docs/DQL (Doctrine Query Language) - Operators - Logical operators.php
index 37e479bc8..faf5081cd 100644
--- a/manual/docs/DQL (Doctrine Query Language) - Operators - Logical operators.php
+++ b/manual/docs/DQL (Doctrine Query Language) - Operators - Logical operators.php
@@ -1,111 +1,167 @@
-
-
- -> 0
-DQL condition : NOT 0
- -> 1
-DQL condition : NOT NULL
- -> NULL
-DQL condition : ! (1+1)
- -> 0
-DQL condition : ! 1+1
- -> 1
-
-
- -> 1
-DQL condition : 1 AND 0
- -> 0
-DQL condition : 1 AND NULL
- -> NULL
-DQL condition : 0 AND NULL
- -> 0
-DQL condition : NULL AND 0
- -> 0
-
-
- Logical OR. When both operands are - non-NULL, the result is - 1 if any operand is non-zero, and - 0 otherwise. With a - NULL operand, the result is - 1 if the other operand is non-zero, and - NULL otherwise. If both operands are - NULL, the result is - NULL. -
-DQL condition : 1 OR 1- Logical XOR. Returns NULL if either - operand is NULL. For - non-NULL operands, evaluates to - 1 if an odd number of operands is - non-zero, otherwise 0 is returned. -
-DQL condition : 1 XOR 1- a XOR b is mathematically equal to - (a AND (NOT b)) OR ((NOT a) and b). -
-
-// SELECT u.*, COUNT(p.id) num_posts FROM User u, u.Posts p WHERE u.id = 1 GROUP BY u.id
-
-$query = new Doctrine_Query();
-
-$query->select('u.*, COUNT(p.id) num_posts')
- ->from('User u, u.Posts p')
- ->where('u.id = ?', 1)
- ->groupby('u.id');
-
-$users = $query->execute();
-
-echo $users->Posts[0]->num_posts . ' posts found';
-
+
+// SELECT u.*, COUNT(p.id) num_posts FROM User u, u.Posts p WHERE u.id = 1 GROUP BY u.id
+
+$query = new Doctrine_Query();
+
+$query->select('u.*, COUNT(p.id) num_posts')
+ ->from('User u, u.Posts p')
+ ->where('u.id = ?', 1)
+ ->groupby('u.id');
+
+$users = $query->execute();
+
+echo $users->Posts[0]->num_posts . ' posts found';
+
diff --git a/manual/docs/DQL (Doctrine Query Language) - SELECT queries.php b/manual/docs/DQL (Doctrine Query Language) - SELECT queries.php
index 3c4c2a070..150c57fed 100644
--- a/manual/docs/DQL (Doctrine Query Language) - SELECT queries.php
+++ b/manual/docs/DQL (Doctrine Query Language) - SELECT queries.php
@@ -1,70 +1,55 @@
-SELECT statement syntax:
--SELECT - [ALL | DISTINCT] - select_expr, ... - [FROM components - [WHERE where_condition] - [GROUP BY groupby_expr - [ASC | DESC], ... ] - [HAVING where_condition] - [ORDER BY orderby_expr - [ASC | DESC], ...] - [LIMIT row_count OFFSET offset}] --
-SELECT a.name, a.amount FROM Account a --
-SELECT a.* FROM Account a --
-SELECT a.* FROM Account a - -SELECT u.*, p.*, g.* FROM User u LEFT JOIN u.Phonenumber p LEFT JOIN u.Group g --
-SELECT a.* FROM Account a WHERE a.amount > 2000 --
-SELECT u.* FROM User u LEFT JOIN u.Phonenumber p HAVING COUNT(p.id) > 3 --
-SELECT u.* FROM User u ORDER BY u.name --
-SELECT u.* FROM User u LIMIT 20 --
+SELECT
+ [ALL | DISTINCT]
+ //select_expr//, ...
+ [FROM //components//
+ [WHERE //where_condition//]
+ [GROUP BY //groupby_expr//
+ [ASC | DESC], ... ]
+ [HAVING //where_condition//]
+ [ORDER BY //orderby_expr//
+ [ASC | DESC], ...]
+ [LIMIT //row_count// OFFSET //offset//}]
+
+
+
+The SELECT statement is used for the retrieval of data from one or more components.
+
+* Each //select_expr// indicates a column or an aggregate function value that you want to retrieve. There must be at least one //select_expr// in every SELECT statement.
+
+SELECT a.name, a.amount FROM Account a
+
+
+* An asterisk can be used for selecting all columns from given component. Even when using an asterisk the executed sql queries never actually use it
+(Doctrine converts asterisk to appropriate column names, hence leading to better performance on some databases).
+
+SELECT a.* FROM Account a
+
+* FROM clause //components// indicates the component or components from which to retrieve records.
+
+SELECT a.* FROM Account a
+
+SELECT u.*, p.*, g.* FROM User u LEFT JOIN u.Phonenumber p LEFT JOIN u.Group g
+
+* The WHERE clause, if given, indicates the condition or conditions that the records must satisfy to be selected. //where_condition// is an expression that evaluates to true for each row to be selected. The statement selects all rows if there is no WHERE clause.
+
+SELECT a.* FROM Account a WHERE a.amount > 2000
+
+* In the WHERE clause, you can use any of the functions and operators that DQL supports, except for aggregate (summary) functions
+
+* The HAVING clause can be used for narrowing the results with aggregate functions
+
+SELECT u.* FROM User u LEFT JOIN u.Phonenumber p HAVING COUNT(p.id) > 3
+
+* The ORDER BY clause can be used for sorting the results
+
+SELECT u.* FROM User u ORDER BY u.name
+
+* The LIMIT and OFFSET clauses can be used for efficiently limiting the number of records to a given //row_count//
+
+SELECT u.* FROM User u LIMIT 20
+
+
+
diff --git a/manual/docs/DQL (Doctrine Query Language) - UPDATE queries.php b/manual/docs/DQL (Doctrine Query Language) - UPDATE queries.php
index 8d34a2a8d..21f1a8c74 100644
--- a/manual/docs/DQL (Doctrine Query Language) - UPDATE queries.php
+++ b/manual/docs/DQL (Doctrine Query Language) - UPDATE queries.php
@@ -1,41 +1,39 @@
-UPDATE statement syntax:
--UPDATE component_name - SET col_name1=expr1 [, col_name2=expr2 ...] - [WHERE where_condition] - [ORDER BY ...] - [LIMIT record_count] --
+UPDATE //component_name//
+ SET //col_name1//=//expr1// [, //col_name2//=//expr2// ...]
+ [WHERE //where_condition//]
+ [ORDER BY ...]
+ [LIMIT //record_count//]
+
-
-$q = 'UPDATE Account SET amount = amount + 200 WHERE id > 200';
-
-$rows = $this->conn->query($q);
-
-// the same query using the query interface
-
-$q = new Doctrine_Query();
-
-$rows = $q->update('Account')
- ->set('amount', 'amount + 200')
- ->where('id > 200')
- ->execute();
-
-print $rows; // the number of affected rows
-
+* The UPDATE statement updates columns of existing records in //component_name// with new values and returns the number of affected records.
+
+* The SET clause indicates which columns to modify and the values they should be given.
+
+* The optional WHERE clause specifies the conditions that identify which records to update.
+Without WHERE clause, all records are updated.
+
+* The optional ORDER BY clause specifies the order in which the records are being updated.
+
+* The LIMIT clause places a limit on the number of records that can be updated. You can use LIMIT row_count to restrict the scope of the UPDATE.
+A LIMIT clause is a **rows-matched restriction** not a rows-changed restriction.
+The statement stops as soon as it has found //record_count// rows that satisfy the WHERE clause, whether or not they actually were changed.
+
+
+
+$q = 'UPDATE Account SET amount = amount + 200 WHERE id > 200';
+
+$rows = $this->conn->query($q);
+
+// the same query using the query interface
+
+$q = new Doctrine_Query();
+
+$rows = $q->update('Account')
+ ->set('amount', 'amount + 200')
+ ->where('id > 200')
+ ->execute();
+
+print $rows; // the number of affected rows
+
diff --git a/manual/docs/DQL (Doctrine Query Language) - WHERE clause.php b/manual/docs/DQL (Doctrine Query Language) - WHERE clause.php
index f115102a8..ebc930b15 100644
--- a/manual/docs/DQL (Doctrine Query Language) - WHERE clause.php
+++ b/manual/docs/DQL (Doctrine Query Language) - WHERE clause.php
@@ -1,17 +1,23 @@
-Syntax:
--WHERE where_condition --
+WHERE //where_condition//
+
+
+* The WHERE clause, if given, indicates the condition or conditions that the records must satisfy to be selected.
+
+
+
+* //where_condition// is an expression that evaluates to true for each row to be selected.
+
+
+
+* The statement selects all rows if there is no WHERE clause.
+
+
+
+* When narrowing results with aggregate function values HAVING clause should be used instead of WHERE clause
+
+
+
+
diff --git a/manual/docs/Database operations - Limit and offset.php b/manual/docs/Database operations - Limit and offset.php
index 99889887d..9dc98d60d 100644
--- a/manual/docs/Database operations - Limit and offset.php
+++ b/manual/docs/Database operations - Limit and offset.php
@@ -1,8 +1,8 @@
-
-$sess = Doctrine_Manager::getInstance()->openConnection(new PDO("dsn","username","password"));
-
-// select first ten rows starting from the row 20
-
-$sess->select("select * from user",10,20);
-
+
+$sess = Doctrine_Manager::getInstance()->openConnection(new PDO("dsn","username","password"));
+
+// select first ten rows starting from the row 20
+
+$sess->select("select * from user",10,20);
+
diff --git a/manual/docs/Database operations - Nested transactions.php b/manual/docs/Database operations - Nested transactions.php
index 18efcfbeb..ecdb3d370 100644
--- a/manual/docs/Database operations - Nested transactions.php
+++ b/manual/docs/Database operations - Nested transactions.php
@@ -1,18 +1,18 @@
-
-try {
- $conn->beginTransaction();
-
- $user->save();
-
- $conn->beginTransaction();
- $group->save();
- $email->save();
-
- $conn->commit();
-
- $conn->commit();
-} catch(Exception $e) {
- $conn->rollback();
-}
-
+
+try {
+ $conn->beginTransaction();
+
+ $user->save();
+
+ $conn->beginTransaction();
+ $group->save();
+ $email->save();
+
+ $conn->commit();
+
+ $conn->commit();
+} catch(Exception $e) {
+ $conn->rollback();
+}
+
diff --git a/manual/docs/Database operations - Query logging.php b/manual/docs/Database operations - Query logging.php
index e63dcfb2b..f3714c558 100644
--- a/manual/docs/Database operations - Query logging.php
+++ b/manual/docs/Database operations - Query logging.php
@@ -1,16 +1,16 @@
-
-
-// works only if you use doctrine database handler
-
-$dbh = $conn->getDBH();
-
-$times = $dbh->getExecTimes();
-
-// print all executed queries and their execution times
-
-foreach($dbh->getQueries() as $index => $query) {
- print $query." ".$times[$index];
-}
-
-
+
+
+// works only if you use doctrine database handler
+
+$dbh = $conn->getDBH();
+
+$times = $dbh->getExecTimes();
+
+// print all executed queries and their execution times
+
+foreach($dbh->getQueries() as $index => $query) {
+ print $query." ".$times[$index];
+}
+
+
diff --git a/manual/docs/Database operations - Sequences.php b/manual/docs/Database operations - Sequences.php
index 233b3e378..a9f2e9e02 100644
--- a/manual/docs/Database operations - Sequences.php
+++ b/manual/docs/Database operations - Sequences.php
@@ -1,8 +1,8 @@
-
-$sess = Doctrine_Manager::getInstance()->openConnection(new PDO("dsn","username","password"));
-
-// gets the next ID from a sequence
-
-$sess->getNextID($sequence);
-
+
+$sess = Doctrine_Manager::getInstance()->openConnection(new PDO("dsn","username","password"));
+
+// gets the next ID from a sequence
+
+$sess->getNextID($sequence);
+
diff --git a/manual/docs/Database operations - Transactions.php b/manual/docs/Database operations - Transactions.php
index 5a5ce8f49..04f5f624d 100644
--- a/manual/docs/Database operations - Transactions.php
+++ b/manual/docs/Database operations - Transactions.php
@@ -1,15 +1,15 @@
-
-$sess = Doctrine_Manager::getInstance()->openConnection(new PDO("dsn","username","password"));
-try {
-$sess->beginTransaction();
-
- // some database operations
-
-$sess->commit();
-
-} catch(Exception $e) {
- $sess->rollback();
-}
-
-
+
+$sess = Doctrine_Manager::getInstance()->openConnection(new PDO("dsn","username","password"));
+try {
+$sess->beginTransaction();
+
+ // some database operations
+
+$sess->commit();
+
+} catch(Exception $e) {
+ $sess->rollback();
+}
+
+
diff --git a/manual/docs/Getting started - Compile.php b/manual/docs/Getting started - Compile.php
index 7ade52f99..fc8e9146d 100644
--- a/manual/docs/Getting started - Compile.php
+++ b/manual/docs/Getting started - Compile.php
@@ -1,10 +1,10 @@
-Doctrine is quite big framework and usually dozens of files are being included on each request.
-This brings a lot of overhead. In fact these file operations are as time consuming as sending multiple queries to database server.
-The clean separation of class per file works well in developing environment, however when project
-goes commercial distribution the speed overcomes the clean separation of class per file -convention.
-
-Doctrine offers method called compile() to solve this issue. The compile method makes a single file of most used
-Doctrine components which can then be included on top of your script. By default the file is created into Doctrine root by the name
-Doctrine.compiled.php.
-
+Doctrine is quite big framework and usually dozens of files are being included on each request.
+This brings a lot of overhead. In fact these file operations are as time consuming as sending multiple queries to database server.
+The clean separation of class per file works well in developing environment, however when project
+goes commercial distribution the speed overcomes the clean separation of class per file -convention.
+
+Doctrine offers method called compile() to solve this issue. The compile method makes a single file of most used
+Doctrine components which can then be included on top of your script. By default the file is created into Doctrine root by the name
+Doctrine.compiled.php.
+
diff --git a/manual/docs/Getting started - Exporting classes - Export options.php b/manual/docs/Getting started - Exporting classes - Export options.php
index 3a0c824a7..36ee78f09 100644
--- a/manual/docs/Getting started - Exporting classes - Export options.php
+++ b/manual/docs/Getting started - Exporting classes - Export options.php
@@ -1,14 +1,14 @@
-
-// export everything, table definitions and constraints
-
-$manager->setAttribute(Doctrine::ATTR_EXPORT, Doctrine::EXPORT_ALL);
-
-// export classes without constraints
-
-$manager->setAttribute(Doctrine::ATTR_EXPORT, Doctrine::EXPORT_TABLES ^
- Doctrine::EXPORT_CONSTRAINTS);
-
-// turn off exporting
-
-$manager->setAttribute(Doctrine::ATTR_EXPORT, Doctrine::EXPORT_NONE);
-
+
+// export everything, table definitions and constraints
+
+$manager->setAttribute(Doctrine::ATTR_EXPORT, Doctrine::EXPORT_ALL);
+
+// export classes without constraints
+
+$manager->setAttribute(Doctrine::ATTR_EXPORT, Doctrine::EXPORT_TABLES ^
+ Doctrine::EXPORT_CONSTRAINTS);
+
+// turn off exporting
+
+$manager->setAttribute(Doctrine::ATTR_EXPORT, Doctrine::EXPORT_NONE);
+
diff --git a/manual/docs/Getting started - Installation.php b/manual/docs/Getting started - Installation.php
index 03f477082..39004bceb 100644
--- a/manual/docs/Getting started - Installation.php
+++ b/manual/docs/Getting started - Installation.php
@@ -1,15 +1,15 @@
-The installation of doctrine is very easy. Just get the latest revision of Doctrine from http://doctrine.pengus.net/svn/trunk.
-
-You need a SVN(Subversion) client for downloading Doctrine.
-
-In order to check out Doctrine in the current directory using the **svn** command line tool use the following code:
-
-svn co http://doctrine.pengus.net/svn/trunk .
-
-
-If you do not have a SVN client, chose one from the list below. Find the **Checkout** option and enter http://doctrine.pengus.net/svn/trunk in the **path** or **repository url** parameter. There is no need for a username or password to check out Doctrine.
-
-* [http://tortoisesvn.tigris.org/ TortoiseSVN] a Windows application that integrates into Windows Explorer
-* [http://www.apple.com/downloads/macosx/development_tools/svnx.html svnx] a Mac OS X GUI svn application
-* Eclipse has SVN integration through the [http://subclipse.tigris.org/ subeclipse] plugin
-
+The installation of doctrine is very easy. Just get the latest revision of Doctrine from http://doctrine.pengus.net/svn/trunk.
+
+You need a SVN(Subversion) client for downloading Doctrine.
+
+In order to check out Doctrine in the current directory using the **svn** command line tool use the following code:
+
+svn co http://doctrine.pengus.net/svn/trunk .
+
+
+If you do not have a SVN client, chose one from the list below. Find the **Checkout** option and enter http://doctrine.pengus.net/svn/trunk in the **path** or **repository url** parameter. There is no need for a username or password to check out Doctrine.
+
+* [http://tortoisesvn.tigris.org/ TortoiseSVN] a Windows application that integrates into Windows Explorer
+* [http://www.apple.com/downloads/macosx/development_tools/svnx.html svnx] a Mac OS X GUI svn application
+* Eclipse has SVN integration through the [http://subclipse.tigris.org/ subeclipse] plugin
+
diff --git a/manual/docs/Getting started - Requirements.php b/manual/docs/Getting started - Requirements.php
index 0c9b7213c..6627dac6e 100644
--- a/manual/docs/Getting started - Requirements.php
+++ b/manual/docs/Getting started - Requirements.php
@@ -1,3 +1,3 @@
-Doctrine requires PHP >= 5.1. it doesn't require any external libraries.
-For database abstraction Doctrine uses PDO which is bundled with php by default. Doctrine also requires a little adodb-hack for table creation, which comes with doctrine.
+Doctrine requires PHP >= 5.1. it doesn't require any external libraries.
+For database abstraction Doctrine uses PDO which is bundled with php by default. Doctrine also requires a little adodb-hack for table creation, which comes with doctrine.
diff --git a/manual/docs/Getting started - Setting table definition - Constraints and validators.php b/manual/docs/Getting started - Setting table definition - Constraints and validators.php
index 8b9ef5b89..86038c5ef 100644
--- a/manual/docs/Getting started - Setting table definition - Constraints and validators.php
+++ b/manual/docs/Getting started - Setting table definition - Constraints and validators.php
@@ -1,258 +1,44 @@
-Following attributes are availible for columns
-- name - | -- args - | -- description - | -
- - |
-
- ||
- »» Basic attributes
- - |
- ||
- primary - | -- bool true - | -- Defines column as a primary key column. - | -
- autoincrement - | -- bool true - | -- Defines column as autoincremented column. If the underlying database doesn't support autoincrementation natively its emulated with triggers and sequence tables. - | -
- default - | -- mixed default - | -- Sets default as an application level default value for a column. When default value has been set for a column every time a record is created the specified column has the default as its value. - | -
- zerofill - | -- boolean zerofill - | -- Defines column as zerofilled column. Only supported by some drivers. - | -
- unsigned - | -- boolean true - | -- Defines column with integer type as unsigned. Only supported by some drivers. - | -
- fixed - | -- boolean true - | -- Defines string typed column as fixed length. - | -
- enum - | -- array enum - | -- Sets enum as an application level enum value list for a column. - | -
- »» Basic validators
- - |
-
- ||
- unique - | -- bool true - | -- Acts as database level unique constraint. Also validates that the specified column is unique. - | -
- nospace - | -- bool true - | -
- Nospace validator. This validator validates that specified column doesn't contain any space/newline characters. - - |
-
- notblank - | -- bool true - | -- Notblank validator. This validator validates that specified column doesn't contain only space/newline characters. Useful in for example comment posting applications - where users are not allowed to post empty comments. - | -
- notnull - | -- bool true - | -- Acts as database level notnull constraint as well as notnull validator for the specified column. - | -
- »» Advanced validators
- - |
-
- ||
- email - | -- bool true - | -- Email validator. Validates that specified column is a valid email address. - | -
- date - | -- bool true - | -- Date validator. - | -
- range - | -- array(min, max) - | -- Range validator. Validates that the column is between min and max. - | -
- country - | -- bool true - | -- Country code validator validates that specified column has a valid country code. - | -
- regexp - | -- string regexp - | -- Regular expression validator validates that specified column matches regexp. - | -
- ip - | -- bool true - | -- Ip validator validates that specified column is a valid internet protocol address. - | -
- usstate - | -- bool true - | -- Usstate validator validates that specified column is a valid usstate. - | -
-class User extends Doctrine_Record {
- public function setTableDefinition() {
- // the name cannot contain whitespace
- $this->hasColumn("name", "string", 50, array("nospace" => true));
-
- // the email should be a valid email
- $this->hasColumn("email", "string", 200, array("email" => true));
-
- // home_country should be a valid country code and not null
- $this->hasColumn("home_country", "string", 2, array("country" => true, "notnull" => true));
-
- }
-}
-
+
+|| name** || args** || description** ||
+|||||| »» Basic attributes ||
+|| **primary** || bool true || Defines column as a primary key column. ||
+|| **autoincrement** || bool true || Defines column as autoincremented column. If the underlying database doesn't support autoincrementation natively its emulated with triggers and sequence tables.
+|| **default** || mixed default || Sets //default// as an application level default value for a column. When default value has been set for a column every time a record is created the specified column has the //default// as its value.
+|| **zerofill** || boolean zerofill || Defines column as zerofilled column. Only supported by some drivers.
+|| **unsigned** || boolean true || Defines column with integer type as unsigned. Only supported by some drivers.
+|| **fixed** || boolean true || Defines string typed column as fixed length.
+|| **enum** || array enum || Sets //enum// as an application level enum value list for a column.
+|||||| »» Basic validators ||
+|| **unique** || bool true || Acts as database level unique constraint. Also validates that the specified column is unique.
+|| **nospace** || bool true || Nospace validator. This validator validates that specified column doesn't contain any space/newline characters.
+
+|| **notblank** || bool true || Notblank validator. This validator validates that specified column doesn't contain only space/newline characters. Useful in for example comment posting applications where users are not allowed to post empty comments.
+|| **notnull** || bool true || Acts as database level notnull constraint as well as notnull validator for the specified column.
+|||||| »» Advanced validators ||
+|| **email** || bool true || Email validator. Validates that specified column is a valid email address.
+|| **date** || bool true || Date validator.
+|| **range** || array(min, max) || Range validator. Validates that the column is between //min// and //max//.
+|| **country** || bool true || Country code validator validates that specified column has a valid country code.
+|| **regexp ** || string regexp || Regular expression validator validates that specified column matches //regexp//.
+|| **ip** || bool true || Ip validator validates that specified column is a valid internet protocol address.
+|| **usstate** || bool true || Usstate validator validates that specified column is a valid usstate.
+
+
+
+
+class User extends Doctrine_Record {
+ public function setTableDefinition() {
+ // the name cannot contain whitespace
+ $this->hasColumn("name", "string", 50, array("nospace" => true));
+
+ // the email should be a valid email
+ $this->hasColumn("email", "string", 200, array("email" => true));
+
+ // home_country should be a valid country code and not null
+ $this->hasColumn("home_country", "string", 2, array("country" => true, "notnull" => true));
+
+ }
+}
+
diff --git a/manual/docs/Getting started - Setting table definition - Data types and lengths.php b/manual/docs/Getting started - Setting table definition - Data types and lengths.php
index 4dca2aaa0..1fbd2553c 100644
--- a/manual/docs/Getting started - Setting table definition - Data types and lengths.php
+++ b/manual/docs/Getting started - Setting table definition - Data types and lengths.php
@@ -1,66 +1,76 @@
-Following data types are availible in doctrine:
-
-class Article extends Doctrine_Record {
- public function setTableDefinition() {
- // few mapping examples:
-
- // maps into VARCHAR(100) on mysql
- $this->hasColumn("title","string",100);
-
- // maps into TEXT on mysql
- $this->hasColumn("content","string",4000);
-
- // maps into TINYINT on mysql
- $this->hasColumn("type","integer",1);
-
- // maps into INT on mysql
- $this->hasColumn("type2","integer",11);
-
- // maps into BIGINT on mysql
- $this->hasColumn("type3","integer",20);
-
- // maps into TEXT on mysql
- // (serialized and unserialized automatically by doctrine)
- $this->hasColumn("types","array",4000);
-
- }
-}
-
+ ** integer**
+ The same as type 'integer' in php
+
+ ** boolean **
+ The same as type 'boolean' in php
+
+ ** array **
+ The same as type 'array' in php. Automatically serialized when saved into database and unserialized when retrieved from database.
+ ** object **
+ The same as type 'object' in php. Automatically serialized when saved into database and unserialized when retrieved from database.
+ ** enum **
+
+ ** timestamp **
+ Database 'timestamp' type
+ ** clob**
+ Database 'clob' type
+ ** blob**
+ Database 'blob' type
+ ** date **
+ Database 'date' type
+
+
+It should be noted that the length of the column affects in database level type
+as well as application level validated length (the length that is validated with Doctrine validators).
+
+
+
+Example 1. Column named 'content' with type 'string' and length 3000 results in database type 'TEXT' of which has database level length of 4000.
+However when the record is validated it is only allowed to have 'content' -column with maximum length of 3000.
+
+
+
+Example 2. Column with type 'integer' and length 1 results in 'TINYINT' on many databases.
+
+
+
+
+In general Doctrine is smart enough to know which integer/string type to use depending on the specified length.
+
+
+
+
+
+class Article extends Doctrine_Record {
+ public function setTableDefinition() {
+ // few mapping examples:
+
+ // maps into VARCHAR(100) on mysql
+ $this->hasColumn("title","string",100);
+
+ // maps into TEXT on mysql
+ $this->hasColumn("content","string",4000);
+
+ // maps into TINYINT on mysql
+ $this->hasColumn("type","integer",1);
+
+ // maps into INT on mysql
+ $this->hasColumn("type2","integer",11);
+
+ // maps into BIGINT on mysql
+ $this->hasColumn("type3","integer",20);
+
+ // maps into TEXT on mysql
+ // (serialized and unserialized automatically by doctrine)
+ $this->hasColumn("types","array",4000);
+
+ }
+}
+
diff --git a/manual/docs/Getting started - Setting table definition - Default values.php b/manual/docs/Getting started - Setting table definition - Default values.php
index ea1648215..14a1102ff 100644
--- a/manual/docs/Getting started - Setting table definition - Default values.php
+++ b/manual/docs/Getting started - Setting table definition - Default values.php
@@ -1,20 +1,22 @@
-
-Doctrine supports default values for all data types. When default value is attached to a record column this means two of things.
-First this value is attached to every newly created Record.
-
+hasColumn('name', 'string', 50, array('default' => 'default name'));
+ }
+}
+
+\$user = new User();
+print \$user->name; // default name
+?>
+
+
+Also when exporting record class to database DEFAULT //value// is attached to column definition statement.
+
diff --git a/manual/docs/Getting started - Setting table definition - Enum emulation.php b/manual/docs/Getting started - Setting table definition - Enum emulation.php
index ab05ad413..dde1a901f 100644
--- a/manual/docs/Getting started - Setting table definition - Enum emulation.php
+++ b/manual/docs/Getting started - Setting table definition - Enum emulation.php
@@ -1,23 +1,23 @@
-Doctrine offers enum data type emulation for all databases. The enum data type of Doctrine maps to
-integer on database. Doctrine takes care of converting the enumerated value automatically to its valuelist equivalent when a record is being fetched
-and the valuelist value back to its enumerated equivalent when record is being saved.
+Doctrine offers enum data type emulation for all databases. The enum data type of Doctrine maps to
+integer on database. Doctrine takes care of converting the enumerated value automatically to its valuelist equivalent when a record is being fetched
+and the valuelist value back to its enumerated equivalent when record is being saved.
-
-class Article extends Doctrine_Record {
- public function setTableDefinition() {
- $this->hasColumn("title","string", 200);
-
- // maps to TINYINT on mysql
- $this->hasColumn("section", "enum", 2, array('values' => array("PHP","Python","Java","Ruby")));
- }
-}
-$article = new Article;
-$article->title = 'My first php article';
-// doctrine auto-converts the section to integer when the
-// record is being saved
-$article->section = 'PHP';
-$article->save();
-
-// on insert query with values 'My first php article' and 0
-// would be issued
-
+
+class Article extends Doctrine_Record {
+ public function setTableDefinition() {
+ $this->hasColumn("title","string", 200);
+
+ // maps to TINYINT on mysql
+ $this->hasColumn("section", "enum", 2, array('values' => array("PHP","Python","Java","Ruby")));
+ }
+}
+$article = new Article;
+$article->title = 'My first php article';
+// doctrine auto-converts the section to integer when the
+// record is being saved
+$article->section = 'PHP';
+$article->save();
+
+// on insert query with values 'My first php article' and 0
+// would be issued
+
diff --git a/manual/docs/Getting started - Setting table definition.php b/manual/docs/Getting started - Setting table definition.php
index 2007b4dbb..0d8d5fedc 100644
--- a/manual/docs/Getting started - Setting table definition.php
+++ b/manual/docs/Getting started - Setting table definition.php
@@ -1,16 +1,16 @@
-
-class Email extends Doctrine_Record {
- public function setTableDefinition() {
- /**
- * email table has one column named 'address' which is
- * php type 'string'
- * maximum length 200
- * database constraints: UNIQUE
- * validators: email, unique
- *
- */
- $this->hasColumn("address","string",200,"email|unique");
- }
-}
-
+
+class Email extends Doctrine_Record {
+ public function setTableDefinition() {
+ /**
+ * email table has one column named 'address' which is
+ * php type 'string'
+ * maximum length 200
+ * database constraints: UNIQUE
+ * validators: email, unique
+ *
+ */
+ $this->hasColumn("address","string",200,"email|unique");
+ }
+}
+
diff --git a/manual/docs/Getting started - Starting new project.php b/manual/docs/Getting started - Starting new project.php
index 3a40b264c..cef7e7f3a 100644
--- a/manual/docs/Getting started - Starting new project.php
+++ b/manual/docs/Getting started - Starting new project.php
@@ -1,29 +1,29 @@
-Doctrine_Record is the basic component of every doctrine-based project.
-There should be atleast one Doctrine_Record for each of your database tables.
-Doctrine_Record follows the [http://www.martinfowler.com/eaaCatalog/activeRecord.html Active Record pattern]
-
-Doctrine auto-creates database tables and always adds a primary key column named 'id' to tables that doesn't have any primary keys specified. Only thing you need to for creating database tables is defining a class which extends Doctrine_Record and setting a setTableDefinition method with hasColumn() method calls.
-
-An short example:
-
-We want to create a database table called 'user' with columns id(primary key), name, username, password and created. Provided that you have already installed Doctrine these few lines of code are all you need:
-
-
-require_once('lib/Doctrine.php');
-
-spl_autoload_register(array('Doctrine', 'autoload'));
-
-class User extends Doctrine_Record {
- public function setTableDefinition() {
- // set 'user' table columns, note that
- // id column is always auto-created
-
- $this->hasColumn('name','string',30);
- $this->hasColumn('username','string',20);
- $this->hasColumn('password','string',16);
- $this->hasColumn('created','integer',11);
- }
-}
-
-
-We now have a user model that supports basic CRUD opperations!
+Doctrine_Record is the basic component of every doctrine-based project.
+There should be atleast one Doctrine_Record for each of your database tables.
+Doctrine_Record follows the [http://www.martinfowler.com/eaaCatalog/activeRecord.html Active Record pattern]
+
+Doctrine auto-creates database tables and always adds a primary key column named 'id' to tables that doesn't have any primary keys specified. Only thing you need to for creating database tables is defining a class which extends Doctrine_Record and setting a setTableDefinition method with hasColumn() method calls.
+
+An short example:
+
+We want to create a database table called 'user' with columns id(primary key), name, username, password and created. Provided that you have already installed Doctrine these few lines of code are all you need:
+
+
+require_once('lib/Doctrine.php');
+
+spl_autoload_register(array('Doctrine', 'autoload'));
+
+class User extends Doctrine_Record {
+ public function setTableDefinition() {
+ // set 'user' table columns, note that
+ // id column is always auto-created
+
+ $this->hasColumn('name','string',30);
+ $this->hasColumn('username','string',20);
+ $this->hasColumn('password','string',16);
+ $this->hasColumn('created','integer',11);
+ }
+}
+
+
+We now have a user model that supports basic CRUD opperations!
diff --git a/manual/docs/Getting started - Working with existing databases - Making the first import.php b/manual/docs/Getting started - Working with existing databases - Making the first import.php
index 60e41226a..b4a530b09 100644
--- a/manual/docs/Getting started - Working with existing databases - Making the first import.php
+++ b/manual/docs/Getting started - Working with existing databases - Making the first import.php
@@ -1,56 +1,56 @@
-Let's consider we have a mysql database called test with a single table called 'file'.
-
-The file table has been created with the following sql statement:
-
-{{CREATE TABLE file (
- id INT UNSIGNED AUTO_INCREMENT NOT NULL,
- name VARCHAR(150),
- size BIGINT,
- modified BIGINT,
- type VARCHAR(10),
- content TEXT,
- path TEXT,
- PRIMARY KEY(id))}}
-
-Now we would like to convert it into Doctrine record class. It can be achieved easily with the following code snippet:
-
-
-require_once('lib/Doctrine.php');
-
-spl_autoload_register(array('Doctrine', 'autoload'));
-
-$conn = Doctrine_Manager::connection(new Doctrine_Db('mysql://root:dc34@localhost/test'));
-
-// import method takes one parameter: the import directory (the directory where
-// the generated record files will be put in
-$conn->import->import('myrecords');
-
-
-That's it! Now there should be a file called File.php in your myrecords directory. The file should look like:
-
-
-/**
- * This class has been auto-generated by the Doctrine ORM Framework
- * Created: Saturday 10th of February 2007 01:03:15 PM
- */
-class File extends Doctrine_Record
-{
- public function setTableDefinition()
- {
- $this->hasColumn('id', 'integer', 4, array('notnull' => true,
- 'primary' => true,
- 'unsigned' > true,
- 'autoincrement' => true));
- $this->hasColumn('name', 'string', 150);
- $this->hasColumn('size', 'integer', 8);
- $this->hasColumn('modified', 'integer', 8);
- $this->hasColumn('type', 'string', 10);
- $this->hasColumn('content', 'string', null);
- $this->hasColumn('path', 'string', null);
- }
- public function setUp()
- {
-
- }
-}
-
+Let's consider we have a mysql database called test with a single table called 'file'.
+
+The file table has been created with the following sql statement:
+
+{{CREATE TABLE file (
+ id INT UNSIGNED AUTO_INCREMENT NOT NULL,
+ name VARCHAR(150),
+ size BIGINT,
+ modified BIGINT,
+ type VARCHAR(10),
+ content TEXT,
+ path TEXT,
+ PRIMARY KEY(id))}}
+
+Now we would like to convert it into Doctrine record class. It can be achieved easily with the following code snippet:
+
+
+require_once('lib/Doctrine.php');
+
+spl_autoload_register(array('Doctrine', 'autoload'));
+
+$conn = Doctrine_Manager::connection(new Doctrine_Db('mysql://root:dc34@localhost/test'));
+
+// import method takes one parameter: the import directory (the directory where
+// the generated record files will be put in
+$conn->import->import('myrecords');
+
+
+That's it! Now there should be a file called File.php in your myrecords directory. The file should look like:
+
+
+/**
+ * This class has been auto-generated by the Doctrine ORM Framework
+ * Created: Saturday 10th of February 2007 01:03:15 PM
+ */
+class File extends Doctrine_Record
+{
+ public function setTableDefinition()
+ {
+ $this->hasColumn('id', 'integer', 4, array('notnull' => true,
+ 'primary' => true,
+ 'unsigned' > true,
+ 'autoincrement' => true));
+ $this->hasColumn('name', 'string', 150);
+ $this->hasColumn('size', 'integer', 8);
+ $this->hasColumn('modified', 'integer', 8);
+ $this->hasColumn('type', 'string', 10);
+ $this->hasColumn('content', 'string', null);
+ $this->hasColumn('path', 'string', null);
+ }
+ public function setUp()
+ {
+
+ }
+}
+
diff --git a/manual/docs/Hierarchical data - Examples.php b/manual/docs/Hierarchical data - Examples.php
index db1c059ea..56198ad04 100644
--- a/manual/docs/Hierarchical data - Examples.php
+++ b/manual/docs/Hierarchical data - Examples.php
@@ -204,11 +204,13 @@ echo $two->getNode()->getNumberChildren() .'';
output_message('path to 1');
$path = $one->getNode()->getPath(' > ');
-echo $path .'
-class Book extends Doctrine_Record
-{
- public function setTableDefinition()
- {
- $this->hasColumn('bookName as name', 'string');
- }
-}
-$book = new Book();
-$book->name = 'Some book';
-$book->save();
-
+
+class Book extends Doctrine_Record
+{
+ public function setTableDefinition()
+ {
+ $this->hasColumn('bookName as name', 'string');
+ }
+}
+$book = new Book();
+$book->name = 'Some book';
+$book->save();
+
diff --git a/manual/docs/Object relational mapping - Columns - Column naming.php b/manual/docs/Object relational mapping - Columns - Column naming.php
index 1bf034c49..fba098210 100644
--- a/manual/docs/Object relational mapping - Columns - Column naming.php
+++ b/manual/docs/Object relational mapping - Columns - Column naming.php
@@ -1,15 +1,21 @@
-One problem with database compatibility is that many databases differ in their behaviour of how the result set of a
-query is returned. MySql leaves the field names unchanged, which means if you issue a query of the form
-"SELECT myField FROM ..." then the result set will contain the field 'myField'.
-
-class Test extends Doctrine_Record {
- public function setTableDefinition() {
- $this->hasColumn('arraytest', 'array', 10000);
- }
-}
-
+
+class Test extends Doctrine_Record {
+ public function setTableDefinition() {
+ $this->hasColumn('arraytest', 'array', 10000);
+ }
+}
+
diff --git a/manual/docs/Object relational mapping - Columns - Data types - Boolean.php b/manual/docs/Object relational mapping - Columns - Data types - Boolean.php
index 39caa37e8..81e676b10 100644
--- a/manual/docs/Object relational mapping - Columns - Data types - Boolean.php
+++ b/manual/docs/Object relational mapping - Columns - Data types - Boolean.php
@@ -1,13 +1,13 @@
-The boolean data type represents only two values that can be either 1 or 0.
-Do not assume that these data types are stored as integers because some DBMS drivers may implement this
-type with single character text fields for a matter of efficiency.
-Ternary logic is possible by using null as the third possible value that may be assigned to fields of this type.
-
+The boolean data type represents only two values that can be either 1 or 0.
+Do not assume that these data types are stored as integers because some DBMS drivers may implement this
+type with single character text fields for a matter of efficiency.
+Ternary logic is possible by using null as the third possible value that may be assigned to fields of this type.
-
-class Test extends Doctrine_Record {
- public function setTableDefinition() {
- $this->hasColumn('booltest', 'boolean');
- }
-}
-
+
+
+class Test extends Doctrine_Record {
+ public function setTableDefinition() {
+ $this->hasColumn('booltest', 'boolean');
+ }
+}
+
diff --git a/manual/docs/Object relational mapping - Columns - Data types - Date.php b/manual/docs/Object relational mapping - Columns - Data types - Date.php
index 937dd2312..9e33d2e4c 100644
--- a/manual/docs/Object relational mapping - Columns - Data types - Date.php
+++ b/manual/docs/Object relational mapping - Columns - Data types - Date.php
@@ -1,14 +1,20 @@
-The date data type may represent dates with year, month and day. DBMS independent representation of dates is accomplished by using text strings formatted according to the IS0-8601 standard.
-
-class Test extends Doctrine_Record {
- public function setTableDefinition() {
- $this->hasColumn('datetest', 'date');
- }
-}
-
+
+
+The format defined by the ISO-8601 standard for dates is YYYY-MM-DD where YYYY is the number of the year (Gregorian calendar), MM is the number of the month from 01 to 12 and DD is the number of the day from 01 to 31. Months or days numbered below 10 should be padded on the left with 0.
+
+
+
+Some DBMS have native support for date formats, but for others the DBMS driver may have to represent them as integers or text values. In any case, it is always possible to make comparisons between date values as well sort query results by fields of this type.
+
+
+
+
+
+class Test extends Doctrine_Record {
+ public function setTableDefinition() {
+ $this->hasColumn('datetest', 'date');
+ }
+}
+
diff --git a/manual/docs/Object relational mapping - Columns - Data types - Enum.php b/manual/docs/Object relational mapping - Columns - Data types - Enum.php
index ded9d05a9..10fd48b51 100644
--- a/manual/docs/Object relational mapping - Columns - Data types - Enum.php
+++ b/manual/docs/Object relational mapping - Columns - Data types - Enum.php
@@ -1,18 +1,18 @@
-Doctrine has a unified enum type. Enum typed columns automatically convert the string values into index numbers and vice versa. The possible values for the column
-can be specified with Doctrine_Record::setEnumValues(columnName, array values).
+Doctrine has a unified enum type. Enum typed columns automatically convert the string values into index numbers and vice versa. The possible values for the column
+can be specified with Doctrine_Record::setEnumValues(columnName, array values).
-
-class Test extends Doctrine_Record {
- public function setTableDefinition() {
- $this->hasColumn('enumtest', 'enum', 4,
- array(
- 'values' => array(
- 'php',
- 'java',
- 'python'
- )
- )
- );
- }
-}
-
+
+class Test extends Doctrine_Record {
+ public function setTableDefinition() {
+ $this->hasColumn('enumtest', 'enum', 4,
+ array(
+ 'values' => array(
+ 'php',
+ 'java',
+ 'python'
+ )
+ )
+ );
+ }
+}
+
diff --git a/manual/docs/Object relational mapping - Columns - Data types - Float.php b/manual/docs/Object relational mapping - Columns - Data types - Float.php
index e32f9c484..2cbcb1eff 100644
--- a/manual/docs/Object relational mapping - Columns - Data types - Float.php
+++ b/manual/docs/Object relational mapping - Columns - Data types - Float.php
@@ -1,9 +1,9 @@
-The float data type may store floating point decimal numbers. This data type is suitable for representing numbers within a large scale range that do not require high accuracy. The scale and the precision limits of the values that may be stored in a database depends on the DBMS that it is used.
+The float data type may store floating point decimal numbers. This data type is suitable for representing numbers within a large scale range that do not require high accuracy. The scale and the precision limits of the values that may be stored in a database depends on the DBMS that it is used.
-
-class Test extends Doctrine_Record {
- public function setTableDefinition() {
- $this->hasColumn('floattest', 'float');
- }
-}
-
+
+class Test extends Doctrine_Record {
+ public function setTableDefinition() {
+ $this->hasColumn('floattest', 'float');
+ }
+}
+
diff --git a/manual/docs/Object relational mapping - Columns - Data types - Gzip.php b/manual/docs/Object relational mapping - Columns - Data types - Gzip.php
index 58d270876..a6e46748d 100644
--- a/manual/docs/Object relational mapping - Columns - Data types - Gzip.php
+++ b/manual/docs/Object relational mapping - Columns - Data types - Gzip.php
@@ -1,9 +1,9 @@
-Gzip datatype is the same as string except that its automatically compressed when persisted and uncompressed when fetched. This datatype can be useful when storing data with a large compressibility ratio, such as bitmap images.
+Gzip datatype is the same as string except that its automatically compressed when persisted and uncompressed when fetched. This datatype can be useful when storing data with a large compressibility ratio, such as bitmap images.
-
-class Test extends Doctrine_Record {
- public function setTableDefinition() {
- $this->hasColumn('gziptest', 'gzip');
- }
-}
-
+
+class Test extends Doctrine_Record {
+ public function setTableDefinition() {
+ $this->hasColumn('gziptest', 'gzip');
+ }
+}
+
diff --git a/manual/docs/Object relational mapping - Columns - Data types - Introduction.php b/manual/docs/Object relational mapping - Columns - Data types - Introduction.php
index a7fb8bd4a..807d31707 100644
--- a/manual/docs/Object relational mapping - Columns - Data types - Introduction.php
+++ b/manual/docs/Object relational mapping - Columns - Data types - Introduction.php
@@ -1,25 +1,39 @@
-All DBMS provide multiple choice of data types for the information that can be stored in their database table fields.
-However, the set of data types made available varies from DBMS to DBMS.
-
-class Test extends Doctrine_Record {
- public function setTableDefinition() {
- $this->hasColumn('objecttest', 'object');
- }
-}
-
+
+class Test extends Doctrine_Record {
+ public function setTableDefinition() {
+ $this->hasColumn('objecttest', 'object');
+ }
+}
+
diff --git a/manual/docs/Object relational mapping - Columns - Data types - Timestamp.php b/manual/docs/Object relational mapping - Columns - Data types - Timestamp.php
index 783093395..9aeb7a9cb 100644
--- a/manual/docs/Object relational mapping - Columns - Data types - Timestamp.php
+++ b/manual/docs/Object relational mapping - Columns - Data types - Timestamp.php
@@ -1,12 +1,12 @@
-The timestamp data type is a mere combination of the date and the time of the day data types.
-The representation of values of the time stamp type is accomplished by joining the date and time
-string values in a single string joined by a space. Therefore, the format template is YYYY-MM-DD HH:MI:SS.
-The represented values obey the same rules and ranges described for the date and time data types
+The timestamp data type is a mere combination of the date and the time of the day data types.
+The representation of values of the time stamp type is accomplished by joining the date and time
+string values in a single string joined by a space. Therefore, the format template is YYYY-MM-DD HH:MI:SS.
+The represented values obey the same rules and ranges described for the date and time data types
-
-class Test extends Doctrine_Record {
- public function setTableDefinition() {
- $this->hasColumn('timestamptest', 'timestamp');
- }
-}
-
+
+class Test extends Doctrine_Record {
+ public function setTableDefinition() {
+ $this->hasColumn('timestamptest', 'timestamp');
+ }
+}
+
diff --git a/manual/docs/Object relational mapping - Columns - Data types - Type modifiers.php b/manual/docs/Object relational mapping - Columns - Data types - Type modifiers.php
index 44f1284f3..1c05837cb 100644
--- a/manual/docs/Object relational mapping - Columns - Data types - Type modifiers.php
+++ b/manual/docs/Object relational mapping - Columns - Data types - Type modifiers.php
@@ -1,48 +1,57 @@
-Within the Doctrine API there are a few modifiers that have been designed to aid in optimal table design. These are:
-
-class User extends Doctrine_record {
- public function setTableDefinition() {
- $this->hasColumn('name', 'string', 50, array('default' => 'default name'));
- }
-}
-$user = new User();
-print $user->name; // default name
-
-
-Also when exporting record class to database DEFAULT //value// is attached to column definition statement.
+Doctrine supports default values for all data types. When default value is attached to a record column this means two of things.
+First this value is attached to every newly created Record.
+
+
+class User extends Doctrine_record {
+ public function setTableDefinition() {
+ $this->hasColumn('name', 'string', 50, array('default' => 'default name'));
+ }
+}
+$user = new User();
+print $user->name; // default name
+
+
+Also when exporting record class to database DEFAULT //value// is attached to column definition statement.
diff --git a/manual/docs/Object relational mapping - Constraints and validators - Check.php b/manual/docs/Object relational mapping - Constraints and validators - Check.php
index 24505080e..7e800fc4e 100644
--- a/manual/docs/Object relational mapping - Constraints and validators - Check.php
+++ b/manual/docs/Object relational mapping - Constraints and validators - Check.php
@@ -1,41 +1,41 @@
-Doctrine check constraints act as database level constraints as well as application level validators. When a record with check validators is exported additional CHECK constraints are being added to CREATE TABLE statement.
-
-Doctrine provides the following simple check operators:
-
-* '''gt'''
-> greater than constraint ( > )
-* '''lt'''
-> less than constraint ( < )
-* '''gte'''
-> greater than or equal to constraint ( >= )
-* '''lte'''
-> less than or equal to constraint ( <= )
-
-
-Consider the following example:
-
-
-class Product extends Doctrine_Record
-{
- public function setTableDefinition()
- {
- $this->hasColumn('id', 'integer', 4, 'primary');
- $this->hasColumn('price', 'numeric', 200, array('gt' => 0);
- }
-}
-
-
-When exported the given class definition would execute the following statement (in pgsql):
-
-CREATE TABLE product (
- id INTEGER,
- price NUMERIC CHECK (price > 0)
- PRIMARY KEY(id))
-
-So Doctrine optionally ensures even at the database level that the price of any product cannot be below zero.
-
-> NOTE: some databases don't support CHECK constraints. When this is the case Doctrine simple skips the creation of check constraints.
-
-If the Doctrine validators are turned on the given definition would also ensure that when a record is being saved its price is always greater than zero.
-
-If some of the prices of the saved products within a transaction is below zero, Doctrine throws Doctrine_Validator_Exception and automatically rolls back the transaction.
+Doctrine check constraints act as database level constraints as well as application level validators. When a record with check validators is exported additional CHECK constraints are being added to CREATE TABLE statement.
+
+Doctrine provides the following simple check operators:
+
+* '''gt'''
+> greater than constraint ( > )
+* '''lt'''
+> less than constraint ( < )
+* '''gte'''
+> greater than or equal to constraint ( >= )
+* '''lte'''
+> less than or equal to constraint ( <= )
+
+
+Consider the following example:
+
+
+class Product extends Doctrine_Record
+{
+ public function setTableDefinition()
+ {
+ $this->hasColumn('id', 'integer', 4, 'primary');
+ $this->hasColumn('price', 'numeric', 200, array('gt' => 0);
+ }
+}
+
+
+When exported the given class definition would execute the following statement (in pgsql):
+
+CREATE TABLE product (
+ id INTEGER,
+ price NUMERIC CHECK (price > 0)
+ PRIMARY KEY(id))
+
+So Doctrine optionally ensures even at the database level that the price of any product cannot be below zero.
+
+> NOTE: some databases don't support CHECK constraints. When this is the case Doctrine simple skips the creation of check constraints.
+
+If the Doctrine validators are turned on the given definition would also ensure that when a record is being saved its price is always greater than zero.
+
+If some of the prices of the saved products within a transaction is below zero, Doctrine throws Doctrine_Validator_Exception and automatically rolls back the transaction.
diff --git a/manual/docs/Object relational mapping - Constraints and validators - Introduction.php b/manual/docs/Object relational mapping - Constraints and validators - Introduction.php
index 850283c26..34631e4a5 100644
--- a/manual/docs/Object relational mapping - Constraints and validators - Introduction.php
+++ b/manual/docs/Object relational mapping - Constraints and validators - Introduction.php
@@ -1,7 +1,7 @@
-Data types are a way to limit the kind of data that can be stored in a table. For many applications, however, the constraint they provide is too coarse. For example, a column containing a product price should probably only accept positive values. But there is no standard data type that accepts only positive numbers. Another issue is that you might want to constrain column data with respect to other columns or rows. For example, in a table containing product information, there should be only one row for each product number.
-[source: http://www.postgresql.org/docs/8.2/static/ddl-constraints.html#AEN2032]
-
-Doctrine allows you to define *portable* constraints on columns and tables. Constraints give you as much control over the data in your tables as you wish. If a user attempts to store data in a column that would violate a constraint, an error is raised. This applies even if the value came from the default value definition.
-
-Doctrine constraints act as database level constraints as well as application level validators. This means double security: the database doesn't allow wrong kind of values and neither does the application.
-
+Data types are a way to limit the kind of data that can be stored in a table. For many applications, however, the constraint they provide is too coarse. For example, a column containing a product price should probably only accept positive values. But there is no standard data type that accepts only positive numbers. Another issue is that you might want to constrain column data with respect to other columns or rows. For example, in a table containing product information, there should be only one row for each product number.
+[source: http://www.postgresql.org/docs/8.2/static/ddl-constraints.html#AEN2032]
+
+Doctrine allows you to define *portable* constraints on columns and tables. Constraints give you as much control over the data in your tables as you wish. If a user attempts to store data in a column that would violate a constraint, an error is raised. This applies even if the value came from the default value definition.
+
+Doctrine constraints act as database level constraints as well as application level validators. This means double security: the database doesn't allow wrong kind of values and neither does the application.
+
diff --git a/manual/docs/Object relational mapping - Constraints and validators - Notnull.php b/manual/docs/Object relational mapping - Constraints and validators - Notnull.php
index ca1a38a06..1207cf9b6 100644
--- a/manual/docs/Object relational mapping - Constraints and validators - Notnull.php
+++ b/manual/docs/Object relational mapping - Constraints and validators - Notnull.php
@@ -1,23 +1,23 @@
-A not-null constraint simply specifies that a column must not assume the null value. A not-null constraint is always written as a column constraint.
-
-The following definition uses a notnull constraint for column 'name'. This means that the specified column doesn't accept
-null values.
-
-
-class User extends Doctrine_Record
-{
- public function setTableDefinition()
- {
- $this->hasColumn('name', 'string', 200, array('notnull' => true,
- 'primary' => true));
- }
-}
-
-
-When this class gets exported to database the following Sql statement would get executed (in Mysql):
-
-CREATE TABLE user (name VARCHAR(200) NOT NULL, PRIMARY KEY(name))
-
-The notnull constraint also acts as an application level validator. This means that if Doctrine validators are turned on, Doctrine will automatically check that specified columns do not contain null values when saved.
-
-If those columns happen to contain null values Doctrine_Validator_Exception is raised.
+A not-null constraint simply specifies that a column must not assume the null value. A not-null constraint is always written as a column constraint.
+
+The following definition uses a notnull constraint for column 'name'. This means that the specified column doesn't accept
+null values.
+
+
+class User extends Doctrine_Record
+{
+ public function setTableDefinition()
+ {
+ $this->hasColumn('name', 'string', 200, array('notnull' => true,
+ 'primary' => true));
+ }
+}
+
+
+When this class gets exported to database the following Sql statement would get executed (in Mysql):
+
+CREATE TABLE user (name VARCHAR(200) NOT NULL, PRIMARY KEY(name))
+
+The notnull constraint also acts as an application level validator. This means that if Doctrine validators are turned on, Doctrine will automatically check that specified columns do not contain null values when saved.
+
+If those columns happen to contain null values Doctrine_Validator_Exception is raised.
diff --git a/manual/docs/Object relational mapping - Constraints and validators - Unique.php b/manual/docs/Object relational mapping - Constraints and validators - Unique.php
index 2eb1d2ce7..7c2dad0b3 100644
--- a/manual/docs/Object relational mapping - Constraints and validators - Unique.php
+++ b/manual/docs/Object relational mapping - Constraints and validators - Unique.php
@@ -1,32 +1,32 @@
-Unique constraints ensure that the data contained in a column or a group of columns is unique with respect to all the rows in the table.
-
-In general, a unique constraint is violated when there are two or more rows in the table where the values of all of the columns included in the constraint are equal. However, two null values are not considered equal in this comparison. That means even in the presence of a unique constraint it is possible to store duplicate rows that contain a null value in at least one of the constrained columns. This behavior conforms to the SQL standard, but some databases do not follow this rule. So be careful when developing applications that are intended to be portable.
-
-The following definition uses a unique constraint for column 'name'.
-
-
-class User extends Doctrine_Record
-{
- public function setTableDefinition()
- {
- $this->hasColumn('name', 'string', 200, array('unique' => true));
- }
-}
-
-
->> Note: You should only use unique constraints for other than primary key columns. Primary key columns are always unique.
-
-The following definition adds a unique constraint for columns 'name' and 'age'.
-
-
-class User extends Doctrine_Record
-{
- public function setTableDefinition()
- {
- $this->hasColumn('name', 'string', 200);
- $this->hasColumn('age', 'integer', 2);
-
- $this->unique(array('name', 'age'));
- }
-}
-
+Unique constraints ensure that the data contained in a column or a group of columns is unique with respect to all the rows in the table.
+
+In general, a unique constraint is violated when there are two or more rows in the table where the values of all of the columns included in the constraint are equal. However, two null values are not considered equal in this comparison. That means even in the presence of a unique constraint it is possible to store duplicate rows that contain a null value in at least one of the constrained columns. This behavior conforms to the SQL standard, but some databases do not follow this rule. So be careful when developing applications that are intended to be portable.
+
+The following definition uses a unique constraint for column 'name'.
+
+
+class User extends Doctrine_Record
+{
+ public function setTableDefinition()
+ {
+ $this->hasColumn('name', 'string', 200, array('unique' => true));
+ }
+}
+
+
+>> Note: You should only use unique constraints for other than primary key columns. Primary key columns are always unique.
+
+The following definition adds a unique constraint for columns 'name' and 'age'.
+
+
+class User extends Doctrine_Record
+{
+ public function setTableDefinition()
+ {
+ $this->hasColumn('name', 'string', 200);
+ $this->hasColumn('age', 'integer', 2);
+
+ $this->unique(array('name', 'age'));
+ }
+}
+
diff --git a/manual/docs/Object relational mapping - Hierarchical data - Introduction - About.php b/manual/docs/Object relational mapping - Hierarchical data - Introduction - About.php
index 4d6862245..8da77bfb7 100644
--- a/manual/docs/Object relational mapping - Hierarchical data - Introduction - About.php
+++ b/manual/docs/Object relational mapping - Hierarchical data - Introduction - About.php
@@ -1,16 +1,27 @@
-Most users at one time or another have dealt with hierarchical data in a SQL database and no doubt learned that the management of hierarchical data is not what a relational database is intended for. The tables of a relational database are not hierarchical (like XML), but are simply a flat list. Hierarchical data has a parent-child relationship that is not naturally represented in a relational database table.
-For our purposes, hierarchical data is a collection of data where each item has a single parent and zero or more children (with the exception of the root item, which has no parent). Hierarchical data can be found in a variety of database applications, including forum and mailing list threads, business organization charts, content management categories, and product categories.
-In a hierarchical data model, data is organized into a tree-like structure. The tree structure allows repeating information using parent/child relationships. For an explanation of the tree data structure, see here http://en.wikipedia.org/wiki/Tree_data_structure
+Most users at one time or another have dealt with hierarchical data in a SQL database and no doubt learned that the management of hierarchical data is not what a relational database is intended for. The tables of a relational database are not hierarchical (like XML), but are simply a flat list. Hierarchical data has a parent-child relationship that is not naturally represented in a relational database table. + + + +For our purposes, hierarchical data is a collection of data where each item has a single parent and zero or more children (with the exception of the root item, which has no parent). Hierarchical data can be found in a variety of database applications, including forum and mailing list threads, business organization charts, content management categories, and product categories. + + + +In a hierarchical data model, data is organized into a tree-like structure. The tree structure allows repeating information using parent/child relationships. For an explanation of the tree data structure, see here [http://en.wikipedia.org/wiki/Tree_data_structure" >http://en.wikipedia.org/wiki/Tree_data_structure] + + + +There are three major approaches to managing tree structures in relational databases, these are: -There are three major approaches to managing tree structures in relational databases, these are:
-These are explained in more detail in the following chapters, or see
-http://www.dbazine.com/oracle/or-articles/tropashko4, http://dev.mysql.com/tech-resources/articles/hierarchical-data.html
The node interface, for inserting and manipulating nodes within the tree, is accessed on a record level. A full implementation of this interface will be as follows:
\ No newline at end of file + + +The node interface, for inserting and manipulating nodes within the tree, is accessed on a record level. A full implementation of this interface will be as follows: \ No newline at end of file diff --git a/manual/docs/Object relational mapping - Hierarchical data - Introduction - Read me.php b/manual/docs/Object relational mapping - Hierarchical data - Introduction - Read me.php index 2be9cb626..363f56157 100644 --- a/manual/docs/Object relational mapping - Hierarchical data - Introduction - Read me.php +++ b/manual/docs/Object relational mapping - Hierarchical data - Introduction - Read me.php @@ -1,9 +1,19 @@ -If performing batch tree manipulation tasks, then remember to refresh your records (see record::refresh()), as any transformations of the tree are likely to affect all instances of records that you have in your scope.
-You can save an already existing node using record::save() without affecting it's position within the tree. Remember to never set the tree specific record attributes manually.
-If you are inserting or moving a node within the tree, you must use the appropriate node method. Note: you do not need to save a record once you have inserted it or moved it within the tree, any other changes to your record will also be saved within these operations. You cannot save a new record without inserting it into the tree.
+If performing batch tree manipulation tasks, then remember to refresh your records (see record::refresh()), as any transformations of the tree are likely to affect all instances of records that you have in your scope. -If you wish to delete a record, you MUST delete the node and not the record, using $record->deleteNode() or $record->getNode()->delete(). Deleting a node, will by default delete all its descendants. if you delete a record without using the node::delete() method you tree is likely to become corrupt (and fall down)!
-The difference between descendants and children is that descendants include children of children whereas children are direct descendants of their parent (real children not gran children and great gran children etc etc).
\ No newline at end of file + +You can save an already existing node using record::save() without affecting it's position within the tree. Remember to never set the tree specific record attributes manually. + + + +If you are inserting or moving a node within the tree, you must use the appropriate node method. Note: you do not need to save a record once you have inserted it or moved it within the tree, any other changes to your record will also be saved within these operations. You cannot save a new record without inserting it into the tree. + + + +If you wish to delete a record, you MUST delete the node and not the record, using $record->deleteNode() or $record->getNode()->delete(). Deleting a node, will by default delete all its descendants. if you delete a record without using the node::delete() method you tree is likely to become corrupt (and fall down)! + + + +The difference between descendants and children is that descendants include children of children whereas children are direct descendants of their parent (real children not gran children and great gran children etc etc). \ No newline at end of file diff --git a/manual/docs/Object relational mapping - Hierarchical data - Introduction - Setting up.php b/manual/docs/Object relational mapping - Hierarchical data - Introduction - Setting up.php index 3df395fd0..43780ac34 100644 --- a/manual/docs/Object relational mapping - Hierarchical data - Introduction - Setting up.php +++ b/manual/docs/Object relational mapping - Hierarchical data - Introduction - Setting up.php @@ -1,5 +1,11 @@ -Managing tree structures in doctrine is easy. Doctrine currently fully supports Nested Set, and plans to support the other implementations soon. To set your model to act as a tree, simply add the code below to your models table definition.
-Now that Doctrine knows that this model acts as a tree, it will automatically add any required columns for your chosen implementation, so you do not need to set any tree specific columns within your table definition.
-Doctrine has standard interface's for managing tree's, that are used by all the implementations. Every record in the table represents a node within the tree (the table), so doctrine provides two interfaces, Tree and Node.
\ No newline at end of file +Managing tree structures in doctrine is easy. Doctrine currently fully supports Nested Set, and plans to support the other implementations soon. To set your model to act as a tree, simply add the code below to your models table definition. + + + +Now that Doctrine knows that this model acts as a tree, it will automatically add any required columns for your chosen implementation, so you do not need to set any tree specific columns within your table definition. + + + +Doctrine has standard interface's for managing tree's, that are used by all the implementations. Every record in the table represents a node within the tree (the table), so doctrine provides two interfaces, Tree and Node. \ No newline at end of file diff --git a/manual/docs/Object relational mapping - Hierarchical data - Introduction - Traversing or Walking Trees.php b/manual/docs/Object relational mapping - Hierarchical data - Introduction - Traversing or Walking Trees.php index 046a3c6f6..6aa3f35a0 100644 --- a/manual/docs/Object relational mapping - Hierarchical data - Introduction - Traversing or Walking Trees.php +++ b/manual/docs/Object relational mapping - Hierarchical data - Introduction - Traversing or Walking Trees.php @@ -1,3 +1,7 @@ -You can traverse a Tree in different ways, please see here for more information http://en.wikipedia.org/wiki/Tree_traversal.
-The most common way of traversing a tree is Pre Order Traversal as explained in the link above, this is also what is known as walking the tree, this is the default approach when traversing a tree in Doctrine, however Doctrine does plan to provide support for Post and Level Order Traversal (not currently implemented)
\ No newline at end of file + +You can traverse a Tree in different ways, please see here for more information [http://en.wikipedia.org/wiki/Tree_traversal http://en.wikipedia.org/wiki/Tree_traversal]. + + + +The most common way of traversing a tree is Pre Order Traversal as explained in the link above, this is also what is known as walking the tree, this is the default approach when traversing a tree in Doctrine, however Doctrine does plan to provide support for Post and Level Order Traversal (not currently implemented) \ No newline at end of file diff --git a/manual/docs/Object relational mapping - Hierarchical data - Introduction - Tree interface.php b/manual/docs/Object relational mapping - Hierarchical data - Introduction - Tree interface.php index 49e27c648..bd817a0a5 100644 --- a/manual/docs/Object relational mapping - Hierarchical data - Introduction - Tree interface.php +++ b/manual/docs/Object relational mapping - Hierarchical data - Introduction - Tree interface.php @@ -1 +1,3 @@ -The tree interface, for creating and accessing the tree, is accessed on a table level. A full implementation of this interface would be as follows:
\ No newline at end of file + + +The tree interface, for creating and accessing the tree, is accessed on a table level. A full implementation of this interface would be as follows: \ No newline at end of file diff --git a/manual/docs/Object relational mapping - Hierarchical data - Nested set - Introduction.php b/manual/docs/Object relational mapping - Hierarchical data - Nested set - Introduction.php index d6353f581..031e0c5b1 100644 --- a/manual/docs/Object relational mapping - Hierarchical data - Nested set - Introduction.php +++ b/manual/docs/Object relational mapping - Hierarchical data - Nested set - Introduction.php @@ -1,6 +1,10 @@ -Basically Nested Set is optimized for traversing trees, as this can be done with minimal queries, however updating the tree can be costly as it will affect all rows within the table.
-For more information, read here:
-http://www.sitepoint.com/article/hierarchical-data-database/2,
-http://dev.mysql.com/tech-resources/articles/hierarchical-data.html
-
The most effective way to traverse a tree from the root node, is to use the tree::fetchTree() method. -It will by default include the root node in the tree and will return an iterator to traverse the tree.
-To traverse a tree from a given node, it will normally cost 3 queries, one to fetch the starting node, one to fetch the branch from this node, and one to determine the level of the start node, the traversal algorithm with then determine the level of each subsequent node for you.
\ No newline at end of file + +The most effective way to traverse a tree from the root node, is to use the tree::fetchTree() method. +It will by default include the root node in the tree and will return an iterator to traverse the tree. + + + +To traverse a tree from a given node, it will normally cost 3 queries, one to fetch the starting node, one to fetch the branch from this node, and one to determine the level of the start node, the traversal algorithm with then determine the level of each subsequent node for you. \ No newline at end of file diff --git a/manual/docs/Object relational mapping - Hierarchical data - Nested set - Setting up.php b/manual/docs/Object relational mapping - Hierarchical data - Nested set - Setting up.php index 6407181f2..05acc4ec9 100644 --- a/manual/docs/Object relational mapping - Hierarchical data - Nested set - Setting up.php +++ b/manual/docs/Object relational mapping - Hierarchical data - Nested set - Setting up.php @@ -1 +1,3 @@ -To set up your model as Nested Set, you must add the following code to your model's table definition.
\ No newline at end of file + + +To set up your model as Nested Set, you must add the following code to your model's table definition. \ No newline at end of file diff --git a/manual/docs/Object relational mapping - Hierarchical data - Nested set - Tree options.php b/manual/docs/Object relational mapping - Hierarchical data - Nested set - Tree options.php index 6ef340e4e..b344d7d11 100644 --- a/manual/docs/Object relational mapping - Hierarchical data - Nested set - Tree options.php +++ b/manual/docs/Object relational mapping - Hierarchical data - Nested set - Tree options.php @@ -1,3 +1,7 @@ -The nested implementation can be configured to allow your table to have multiple root nodes, and therefore multiple trees within the same table.
-The example below shows how to setup and use multiple roots based upon the set up above:
\ No newline at end of file + +The nested implementation can be configured to allow your table to have multiple root nodes, and therefore multiple trees within the same table. + + + +The example below shows how to setup and use multiple roots based upon the set up above: \ No newline at end of file diff --git a/manual/docs/Object relational mapping - Indexes - Adding indexes.php b/manual/docs/Object relational mapping - Indexes - Adding indexes.php index 073777a31..6d0f3792c 100644 --- a/manual/docs/Object relational mapping - Indexes - Adding indexes.php +++ b/manual/docs/Object relational mapping - Indexes - Adding indexes.php @@ -1,55 +1,61 @@ - -You can add indexes by simple calling Doctrine_Record::index('indexName', $definition) where $definition is the -definition array. -
+class IndexTest extends Doctrine_Record
+{
+ public function setTableDefinition()
+ {
+ \$this->hasColumn('name', 'string');
+
+ \$this->index('myindex', array('fields' => 'name');
+ }
+}
+?>
+
+
+
+An example of adding a multi-column index to field called 'name':
+
+
+
+
+class MultiColumnIndexTest extends Doctrine_Record
+{
+ public function setTableDefinition()
+ {
+ \$this->hasColumn('name', 'string');
+ \$this->hasColumn('code', 'string');
+
+ \$this->index('myindex', array('fields' => array('name', 'code')));
+ }
+}
+?>
+
+
+
+An example of adding a multiple indexes on same table:
+
+
+
+
+class MultipleIndexTest extends Doctrine_Record
+{
+ public function setTableDefinition()
+ {
+ \$this->hasColumn('name', 'string');
+ \$this->hasColumn('code', 'string');
+ \$this->hasColumn('age', 'integer');
+
+ \$this->index('myindex', array('fields' => array('name', 'code')));
+ \$this->index('ageindex', array('fields' => array('age'));
+ }
+}
+?>
diff --git a/manual/docs/Object relational mapping - Indexes - Index options.php b/manual/docs/Object relational mapping - Indexes - Index options.php
index 7e4f14b10..d53aafdfd 100644
--- a/manual/docs/Object relational mapping - Indexes - Index options.php
+++ b/manual/docs/Object relational mapping - Indexes - Index options.php
@@ -1,42 +1,38 @@
-
-Doctrine offers many index options, some of them being db-specific. Here is a full list of availible options:
-- -sorting => string('ASC' / 'DESC') - what kind of sorting does the index use (ascending / descending) - -length => integer - index length (only some drivers support this) - -primary => boolean(true / false) - whether or not the index is primary index - -type => string('unique', -- supported by most drivers - 'fulltext', -- only availible on Mysql driver - 'gist', -- only availible on Pgsql driver - 'gin') -- only availible on Pgsql driver --
+
+sorting => string('ASC' / 'DESC')
+ what kind of sorting does the index use (ascending / descending)
+
+length => integer
+ index length (only some drivers support this)
+
+primary => boolean(true / false)
+ whether or not the index is primary index
+
+type => string('unique', -- supported by most drivers
+ 'fulltext', -- only availible on Mysql driver
+ 'gist', -- only availible on Pgsql driver
+ 'gin') -- only availible on Pgsql driver
+
+
+class MultipleIndexTest extends Doctrine_Record
+{
+ public function setTableDefinition()
+ {
+ \$this->hasColumn('name', 'string');
+ \$this->hasColumn('code', 'string');
+ \$this->hasColumn('age', 'integer');
+
+ \$this->index('myindex', array(
+ 'fields' => array(
+ 'name' =>
+ array('sorting' => 'ASC',
+ 'length' => 10),
+ 'code'),
+ 'type' => 'unique',
+ ));
+ }
+}
+?>
diff --git a/manual/docs/Object relational mapping - Indexes - Introduction.php b/manual/docs/Object relational mapping - Indexes - Introduction.php
index d2f6535c2..b2fca0275 100644
--- a/manual/docs/Object relational mapping - Indexes - Introduction.php
+++ b/manual/docs/Object relational mapping - Indexes - Introduction.php
@@ -1,9 +1,13 @@
-Indexes are used to find rows with specific column values quickly.
-Without an index, the database must begin with the first row and then read through the entire table to find the relevant rows.
-
-class Email extends Doctrine_Record {
- public function setTableDefinition() {
- // setting custom table name:
- $this->setTableName('emails');
-
- $this->hasColumn('address', // name of the column
- 'string', // column type
- '200', // column length
- array('notblank' => true,
- 'email' => true // validators / constraints
- )
- );
-
-
- $this->hasColumn('address2', // name of the column
- 'string', // column type
- '200', // column length
- // validators / constraints without arguments can be
- // specified also as as string with | separator
- 'notblank|email'
- );
-
- // Doctrine even supports the following format for
- // validators / constraints which have no arguments:
-
- $this->hasColumn('address3', // name of the column
- 'string', // column type
- '200', // column length
- array('notblank', 'email')
- );
- }
-}
-
+Doctrine_Record::hasColumn() takes 4 arguments:
+
+# **column name**
+# **column type**
+# **column length**
+# **column constraints and validators**
+
+
+class Email extends Doctrine_Record {
+ public function setTableDefinition() {
+ // setting custom table name:
+ $this->setTableName('emails');
+
+ $this->hasColumn('address', // name of the column
+ 'string', // column type
+ '200', // column length
+ array('notblank' => true,
+ 'email' => true // validators / constraints
+ )
+ );
+
+
+ $this->hasColumn('address2', // name of the column
+ 'string', // column type
+ '200', // column length
+ // validators / constraints without arguments can be
+ // specified also as as string with | separator
+ 'notblank|email'
+ );
+
+ // Doctrine even supports the following format for
+ // validators / constraints which have no arguments:
+
+ $this->hasColumn('address3', // name of the column
+ 'string', // column type
+ '200', // column length
+ array('notblank', 'email')
+ );
+ }
+}
+
diff --git a/manual/docs/Object relational mapping - Record identifiers - Autoincremented.php b/manual/docs/Object relational mapping - Record identifiers - Autoincremented.php
index 2472be09f..e2eba833b 100644
--- a/manual/docs/Object relational mapping - Record identifiers - Autoincremented.php
+++ b/manual/docs/Object relational mapping - Record identifiers - Autoincremented.php
@@ -1,11 +1,11 @@
-Autoincrement primary key is the most basic identifier and its usage is strongly encouraged. Sometimes you may want to use some other name than 'id'
-for your autoinc primary key. It can be specified as follows:
+Autoincrement primary key is the most basic identifier and its usage is strongly encouraged. Sometimes you may want to use some other name than 'id'
+for your autoinc primary key. It can be specified as follows:
-
-class User extends Doctrine_Record {
- public function setTableDefinition() {
- $this->hasColumn('uid','integer',20,'primary|autoincrement');
-
- }
-}
-
+
+class User extends Doctrine_Record {
+ public function setTableDefinition() {
+ $this->hasColumn('uid','integer',20,'primary|autoincrement');
+
+ }
+}
+
diff --git a/manual/docs/Object relational mapping - Record identifiers - Composite.php b/manual/docs/Object relational mapping - Record identifiers - Composite.php
index ec30807ab..f401944f3 100644
--- a/manual/docs/Object relational mapping - Record identifiers - Composite.php
+++ b/manual/docs/Object relational mapping - Record identifiers - Composite.php
@@ -1,13 +1,15 @@
-Composite primary key can be used efficiently in association tables (tables that connect two components together). It is not recommended
-to use composite primary keys in anywhere else as Doctrine does not support mapping relations on multiple columns.
-
-class Groupuser extends Doctrine_Record {
- public function setTableDefinition() {
- $this->hasColumn('user_id', 'integer', 20, 'primary');
- $this->hasColumn('group_id', 'integer', 20, 'primary');
- }
-}
-
+
+
+Due to this fact your doctrine-based system will scale better if it has autoincremented primary key even for association tables.
+
+
+class Groupuser extends Doctrine_Record {
+ public function setTableDefinition() {
+ $this->hasColumn('user_id', 'integer', 20, 'primary');
+ $this->hasColumn('group_id', 'integer', 20, 'primary');
+ }
+}
+
diff --git a/manual/docs/Object relational mapping - Record identifiers - Introduction.php b/manual/docs/Object relational mapping - Record identifiers - Introduction.php
index b111e4ab7..7446de7ee 100644
--- a/manual/docs/Object relational mapping - Record identifiers - Introduction.php
+++ b/manual/docs/Object relational mapping - Record identifiers - Introduction.php
@@ -1,5 +1,5 @@
-Doctrine supports many kind of identifiers. For most cases it is recommended not to
-specify any primary keys (Doctrine will then use field name 'id' as an autoincremented
-primary key). When using table creation Doctrine is smart enough to emulate the
-autoincrementation with sequences and triggers on databases that doesn't support it natively.
+Doctrine supports many kind of identifiers. For most cases it is recommended not to
+specify any primary keys (Doctrine will then use field name 'id' as an autoincremented
+primary key). When using table creation Doctrine is smart enough to emulate the
+autoincrementation with sequences and triggers on databases that doesn't support it natively.
diff --git a/manual/docs/Object relational mapping - Record identifiers - Natural.php b/manual/docs/Object relational mapping - Record identifiers - Natural.php
index cfb204e61..661cd4783 100644
--- a/manual/docs/Object relational mapping - Record identifiers - Natural.php
+++ b/manual/docs/Object relational mapping - Record identifiers - Natural.php
@@ -1,10 +1,10 @@
-Natural identifier is a property or combination of properties that is unique and non-null. The use of natural identifiers
-is discouraged. You should consider using autoincremented or sequential primary keys as they make your system more scalable.
+Natural identifier is a property or combination of properties that is unique and non-null. The use of natural identifiers
+is discouraged. You should consider using autoincremented or sequential primary keys as they make your system more scalable.
-
-class User extends Doctrine_Record {
- public function setTableDefinition() {
- $this->hasColumn('name','string',200,'primary');
- }
-}
-
+
+class User extends Doctrine_Record {
+ public function setTableDefinition() {
+ $this->hasColumn('name','string',200,'primary');
+ }
+}
+
diff --git a/manual/docs/Object relational mapping - Record identifiers - Sequence.php b/manual/docs/Object relational mapping - Record identifiers - Sequence.php
index c42f08731..b94e0f749 100644
--- a/manual/docs/Object relational mapping - Record identifiers - Sequence.php
+++ b/manual/docs/Object relational mapping - Record identifiers - Sequence.php
@@ -1,69 +1,81 @@
-
-Doctrine supports sequences for generating record identifiers. Sequences are a way of offering unique IDs for data rows. If you do most of your work with e.g. MySQL, think of sequences as another way of doing AUTO_INCREMENT.
-
+class Book extends Doctrine_Record {
+ public function setTableDefinition()
+ {
+ \$this->hasColumn('id', 'integer', null, array('primary', 'sequence'));
+ \$this->hasColumn('name', 'string');
+ }
+}
+?>
+
+
+
+By default Doctrine uses the following format for sequence tables [tablename]_seq. If you wish to change this you can use the following
+piece of code to change the formatting:
+
+
+
+
+\$manager = Doctrine_Manager::getInstance();
+\$manager->setAttribute(Doctrine::ATTR_SEQNAME_FORMAT,
+'%s_my_seq');
+?>
+
+
+
+Doctrine uses column named id as the sequence generator column of the sequence table. If you wish to change this globally (for all connections and all tables)
+you can use the following code:
+
+
+
+
+\$manager = Doctrine_Manager::getInstance();
+\$manager->setAttribute(Doctrine::ATTR_SEQCOL_NAME,
+'my_seq_column');
+?>
+
+
+
+In the following example we do not wish to change global configuration we just want to make the id column to use sequence table called
+book_sequence. It can be done as follows:
+
+
+
+class Book extends Doctrine_Record {
+ public function setTableDefinition()
+ {
+ \$this->hasColumn('id', 'integer', null, array('primary', 'sequence' => 'book_sequence'));
+ \$this->hasColumn('name', 'string');
+ }
+}
+?>
+
+
+
+Here we take the preceding example a little further: we want to have a custom sequence column. Here it goes:
+
+
+
+class Book extends Doctrine_Record {
+ public function setTableDefinition()
+ {
+ \$this->hasColumn('id', 'integer', null, array('primary', 'sequence' => array('book_sequence', 'sequence')));
+ \$this->hasColumn('name', 'string');
+ }
+}
+?>
diff --git a/manual/docs/Object relational mapping - Relations - Composites and aggregates.php b/manual/docs/Object relational mapping - Relations - Composites and aggregates.php
index ff03450b4..bdf774f06 100644
--- a/manual/docs/Object relational mapping - Relations - Composites and aggregates.php
+++ b/manual/docs/Object relational mapping - Relations - Composites and aggregates.php
@@ -1,10 +1,14 @@
-Doctrine supports aggregates and composites. When binding composites you can use methods Doctrine_Record::ownsOne() and Doctrine_Record::ownsMany(). When binding
-aggregates you can use methods Doctrine_Record::hasOne() and Doctrine_Record::hasMany(). Basically using the owns* methods is like adding a database level ON CASCADE DELETE
-constraint on related component with an exception that doctrine handles the deletion in application level.
-
-class User extends Doctrine_Record {
- public function setUp() {
- $this->ownsMany('Phonenumber','Phonenumber.user_id');
- }
- public function setTableDefition() {
- $this->hasColumn('name','string',50);
- $this->hasColumn('loginname','string',20);
- $this->hasColumn('password','string',16);
- }
-}
-class Phonenumber extends Doctrine_Record {
- public function setTableDefinition() {
- $this->hasColumn('phonenumber','string',50);
- $this->hasColumn('user_id','integer');
- }
-}
-
+
+class User extends Doctrine_Record {
+ public function setUp() {
+ $this->ownsMany('Phonenumber','Phonenumber.user_id');
+ }
+ public function setTableDefition() {
+ $this->hasColumn('name','string',50);
+ $this->hasColumn('loginname','string',20);
+ $this->hasColumn('password','string',16);
+ }
+}
+class Phonenumber extends Doctrine_Record {
+ public function setTableDefinition() {
+ $this->hasColumn('phonenumber','string',50);
+ $this->hasColumn('user_id','integer');
+ }
+}
+
diff --git a/manual/docs/Object relational mapping - Relations - Foreign key associations - One-to-One.php b/manual/docs/Object relational mapping - Relations - Foreign key associations - One-to-One.php
index f7dfc414a..c919e275a 100644
--- a/manual/docs/Object relational mapping - Relations - Foreign key associations - One-to-One.php
+++ b/manual/docs/Object relational mapping - Relations - Foreign key associations - One-to-One.php
@@ -1,36 +1,38 @@
-Binding One-To-One foreign key associations is done with Doctrine_Record::ownsOne() and Doctrine_Record::hasOne() methods.
-In the following example user owns one email and has one address. So the relationship between user and email is one-to-one composite.
-The relationship between user and address is one-to-one aggregate.
-
-class User extends Doctrine_Record {
- public function setUp() {
- $this->hasOne('Address','Address.user_id');
- $this->ownsOne('Email','User.email_id');
- $this->ownsMany('Phonenumber','Phonenumber.user_id');
- }
- public function setTableDefition() {
- $this->hasColumn('name','string',50);
- $this->hasColumn('loginname','string',20);
- $this->hasColumn('password','string',16);
-
- // foreign key column for email ID
- $this->hasColumn('email_id','integer');
- }
-}
-class Email extends Doctrine_Record {
- public function setTableDefinition() {
- $this->hasColumn('address','string',150);
- }
-}
-class Address extends Doctrine_Record {
- public function setTableDefinition() {
- $this->hasColumn('street','string',50);
- $this->hasColumn('user_id','integer');
- }
-}
-
+
+
+The Email component here is mapped to User component's column email_id hence their relation is called LOCALKEY relation.
+On the other hand the Address component is mapped to User by it's user_id column hence the relation between User and Address is called
+FOREIGNKEY relation.
+
+
+class User extends Doctrine_Record {
+ public function setUp() {
+ $this->hasOne('Address','Address.user_id');
+ $this->ownsOne('Email','User.email_id');
+ $this->ownsMany('Phonenumber','Phonenumber.user_id');
+ }
+ public function setTableDefition() {
+ $this->hasColumn('name','string',50);
+ $this->hasColumn('loginname','string',20);
+ $this->hasColumn('password','string',16);
+
+ // foreign key column for email ID
+ $this->hasColumn('email_id','integer');
+ }
+}
+class Email extends Doctrine_Record {
+ public function setTableDefinition() {
+ $this->hasColumn('address','string',150);
+ }
+}
+class Address extends Doctrine_Record {
+ public function setTableDefinition() {
+ $this->hasColumn('street','string',50);
+ $this->hasColumn('user_id','integer');
+ }
+}
+
diff --git a/manual/docs/Object relational mapping - Relations - Foreign key associations - Tree structure.php b/manual/docs/Object relational mapping - Relations - Foreign key associations - Tree structure.php
index ecb9e7c12..eafa8ee36 100644
--- a/manual/docs/Object relational mapping - Relations - Foreign key associations - Tree structure.php
+++ b/manual/docs/Object relational mapping - Relations - Foreign key associations - Tree structure.php
@@ -1,13 +1,13 @@
-
-class Task extends Doctrine_Record {
- public function setUp() {
- $this->hasOne('Task as Parent','Task.parent_id');
- $this->hasMany('Task as Subtask','Subtask.parent_id');
- }
- public function setTableDefinition() {
- $this->hasColumn('name','string',100);
- $this->hasColumn('parent_id','integer');
- }
-}
-
+
+class Task extends Doctrine_Record {
+ public function setUp() {
+ $this->hasOne('Task as Parent','Task.parent_id');
+ $this->hasMany('Task as Subtask','Subtask.parent_id');
+ }
+ public function setTableDefinition() {
+ $this->hasColumn('name','string',100);
+ $this->hasColumn('parent_id','integer');
+ }
+}
+
diff --git a/manual/docs/Object relational mapping - Relations - Foreign key constraints - Constraint actions.php b/manual/docs/Object relational mapping - Relations - Foreign key constraints - Constraint actions.php
index 155021776..1992b19f7 100644
--- a/manual/docs/Object relational mapping - Relations - Foreign key constraints - Constraint actions.php
+++ b/manual/docs/Object relational mapping - Relations - Foreign key constraints - Constraint actions.php
@@ -1,39 +1,39 @@
-//CASCADE//:
-Delete or update the row from the parent table and automatically delete or update the matching rows in the child table. Both ON DELETE CASCADE and ON UPDATE CASCADE are supported. Between two tables, you should not define several ON UPDATE CASCADE clauses that act on the same column in the parent table or in the child table.
-
-//SET NULL// :
-Delete or update the row from the parent table and set the foreign key column or columns in the child table to NULL. This is valid only if the foreign key columns do not have the NOT NULL qualifier specified. Both ON DELETE SET NULL and ON UPDATE SET NULL clauses are supported.
-
-//NO ACTION// :
-In standard SQL, NO ACTION means no action in the sense that an attempt to delete or update a primary key value is not allowed to proceed if there is a related foreign key value in the referenced table.
-
-//RESTRICT// :
-Rejects the delete or update operation for the parent table. NO ACTION and RESTRICT are the same as omitting the ON DELETE or ON UPDATE clause.
-
-//SET DEFAULT// :
-
-In the following example we define two classes, User and Phonenumber with their relation being one-to-many. We also add a foreign key constraint with onDelete cascade action.
-
-
-class User extends Doctrine_Record
-{
- public function setUp()
- {
- $this->hasMany('Phonenumber', 'Phonenumber.user_id', array('onDelete' => 'cascade'));
- }
- public function setTableDefition()
- {
- $this->hasColumn('name', 'string', 50);
- $this->hasColumn('loginname', 'string', 20);
- $this->hasColumn('password', 'string', 16);
- }
-}
-class Phonenumber extends Doctrine_Record
-{
- public function setTableDefinition()
- {
- $this->hasColumn('phonenumber', 'string', 50);
- $this->hasColumn('user_id', 'integer');
- }
-}
-
+//CASCADE//:
+Delete or update the row from the parent table and automatically delete or update the matching rows in the child table. Both ON DELETE CASCADE and ON UPDATE CASCADE are supported. Between two tables, you should not define several ON UPDATE CASCADE clauses that act on the same column in the parent table or in the child table.
+
+//SET NULL// :
+Delete or update the row from the parent table and set the foreign key column or columns in the child table to NULL. This is valid only if the foreign key columns do not have the NOT NULL qualifier specified. Both ON DELETE SET NULL and ON UPDATE SET NULL clauses are supported.
+
+//NO ACTION// :
+In standard SQL, NO ACTION means no action in the sense that an attempt to delete or update a primary key value is not allowed to proceed if there is a related foreign key value in the referenced table.
+
+//RESTRICT// :
+Rejects the delete or update operation for the parent table. NO ACTION and RESTRICT are the same as omitting the ON DELETE or ON UPDATE clause.
+
+//SET DEFAULT// :
+
+In the following example we define two classes, User and Phonenumber with their relation being one-to-many. We also add a foreign key constraint with onDelete cascade action.
+
+
+class User extends Doctrine_Record
+{
+ public function setUp()
+ {
+ $this->hasMany('Phonenumber', 'Phonenumber.user_id', array('onDelete' => 'cascade'));
+ }
+ public function setTableDefition()
+ {
+ $this->hasColumn('name', 'string', 50);
+ $this->hasColumn('loginname', 'string', 20);
+ $this->hasColumn('password', 'string', 16);
+ }
+}
+class Phonenumber extends Doctrine_Record
+{
+ public function setTableDefinition()
+ {
+ $this->hasColumn('phonenumber', 'string', 50);
+ $this->hasColumn('user_id', 'integer');
+ }
+}
+
diff --git a/manual/docs/Object relational mapping - Relations - Foreign key constraints - Introduction.php b/manual/docs/Object relational mapping - Relations - Foreign key constraints - Introduction.php
index 32c52413b..23d532511 100644
--- a/manual/docs/Object relational mapping - Relations - Foreign key constraints - Introduction.php
+++ b/manual/docs/Object relational mapping - Relations - Foreign key constraints - Introduction.php
@@ -1,51 +1,51 @@
-A foreign key constraint specifies that the values in a column (or a group of columns) must match the values appearing in some row of another table. In other words foreign key constraints maintain the referential integrity between two related tables.
-
-Say you have the product table with the following definition:
-
-
-class Product extends Doctrine_Record
-{
- public function setTableDefinition()
- {
- $this->hasColumn('id', 'integer', null, 'primary');
- $this->hasColumn('name', 'string');
- $this->hasColumn('price', 'numeric');
- }
-}
-
-
-Let's also assume you have a table storing orders of those products. We want to ensure that the order table only contains orders of products that actually exist. So we define a foreign key constraint in the orders table that references the products table:
-
-
-class Order extends Doctrine_Record
-{
- public function setTableDefinition()
- {
- $this->hasColumn('order_id', 'integer', null, 'primary');
- $this->hasColumn('product_id', 'integer');
- $this->hasColumn('quantity', 'integer');
- }
- public function setUp()
- {
- $this->hasOne('Product', 'Order.product_id');
-
- // foreign key columns should *always* have indexes
-
- $this->index('product_id', array('fields' => 'product_id'));
- }
-}
-
-
-When exported the class 'Order' would execute the following sql:
-
-CREATE TABLE orders (
- order_id integer PRIMARY KEY,
- product_id integer REFERENCES products (id),
- quantity integer,
- INDEX product_id_idx (product_id)
-)
-
-Now it is impossible to create orders with product_no entries that do not appear in the products table.
-
-We say that in this situation the orders table is the referencing table and the products table is the referenced table. Similarly, there are referencing and referenced columns.
-
+A foreign key constraint specifies that the values in a column (or a group of columns) must match the values appearing in some row of another table. In other words foreign key constraints maintain the referential integrity between two related tables.
+
+Say you have the product table with the following definition:
+
+
+class Product extends Doctrine_Record
+{
+ public function setTableDefinition()
+ {
+ $this->hasColumn('id', 'integer', null, 'primary');
+ $this->hasColumn('name', 'string');
+ $this->hasColumn('price', 'numeric');
+ }
+}
+
+
+Let's also assume you have a table storing orders of those products. We want to ensure that the order table only contains orders of products that actually exist. So we define a foreign key constraint in the orders table that references the products table:
+
+
+class Order extends Doctrine_Record
+{
+ public function setTableDefinition()
+ {
+ $this->hasColumn('order_id', 'integer', null, 'primary');
+ $this->hasColumn('product_id', 'integer');
+ $this->hasColumn('quantity', 'integer');
+ }
+ public function setUp()
+ {
+ $this->hasOne('Product', 'Order.product_id');
+
+ // foreign key columns should *always* have indexes
+
+ $this->index('product_id', array('fields' => 'product_id'));
+ }
+}
+
+
+When exported the class 'Order' would execute the following sql:
+
+CREATE TABLE orders (
+ order_id integer PRIMARY KEY,
+ product_id integer REFERENCES products (id),
+ quantity integer,
+ INDEX product_id_idx (product_id)
+)
+
+Now it is impossible to create orders with product_no entries that do not appear in the products table.
+
+We say that in this situation the orders table is the referencing table and the products table is the referenced table. Similarly, there are referencing and referenced columns.
+
diff --git a/manual/docs/Object relational mapping - Relations - Inheritance - Column aggregation.php b/manual/docs/Object relational mapping - Relations - Inheritance - Column aggregation.php
index 9a5a43152..3eee55337 100644
--- a/manual/docs/Object relational mapping - Relations - Inheritance - Column aggregation.php
+++ b/manual/docs/Object relational mapping - Relations - Inheritance - Column aggregation.php
@@ -1,87 +1,87 @@
-In the following example we have one database table called 'entity'. Users and groups are both entities and they share the same database table.
-
-The entity table has a column called 'type' which tells whether an entity is a group or a user. Then we decide that users are type 1 and groups type 2.
-
-The only thing we have to do is to create 3 records (the same as before) and add call the Doctrine_Table::setInheritanceMap() method inside the setUp() method.
-
-
-class Entity extends Doctrine_Record {
- public function setTableDefinition() {
- $this->hasColumn('name','string',30);
- $this->hasColumn('username','string',20);
- $this->hasColumn('password','string',16);
- $this->hasColumn('created','integer',11);
-
- // this column is used for column
- // aggregation inheritance
- $this->hasColumn('type', 'integer', 11);
- }
-}
-
-class User extends Entity {
- public function setUp() {
- $this->setInheritanceMap(array('type'=>1));
- }
-}
-
-class Group extends Entity {
- public function setUp() {
- $this->setInheritanceMap(array('type'=>2));
- }
-}
-
-
-If we want to be able to fetch a record from the Entity table and automatically get a User record if the Entity we fetched is a user we have to do set the subclasses option in the parent class. The adjusted example:
-
-
-class Entity extends Doctrine_Record {
- public function setTableDefinition() {
- $this->hasColumn('name','string',30);
- $this->hasColumn('username','string',20);
- $this->hasColumn('password','string',16);
- $this->hasColumn('created','integer',11);
-
- // this column is used for column
- // aggregation inheritance
- $this->hasColumn('type', 'integer', 11);
- $this->option('subclasses', array('User', 'Group');
- }
-}
-
-class User extends Entity {
- public function setUp() {
- $this->setInheritanceMap(array('type'=>1));
- }
-}
-
-class Group extends Entity {
- public function setUp() {
- $this->setInheritanceMap(array('type'=>2));
- }
-}
-
-
-We can then do the following given the previous table mapping.
-
-
-$user = new User();
-$user->name='Bjarte S. Karlsen';
-$user->username='meus';
-$user->password='rat';
-$user->save();
-
-$group = new Group();
-$group->name='Users';
-$group->username='users';
-$group->password='password';
-$group->save();
-
-$q = Doctrine_Query();
-$user = $q->from('Entity')->where('id=?')->execute(array($user->id))->getFirst();
-
-$q = Doctrine_Query();
-$group = $q->from('Entity')->where('id=?')->execute(array($group->id))->getFirst();
-
-
-The user object is here an instance of User while the group object is an instance of Group.
-
+In the following example we have one database table called 'entity'. Users and groups are both entities and they share the same database table.
+
+The entity table has a column called 'type' which tells whether an entity is a group or a user. Then we decide that users are type 1 and groups type 2.
+
+The only thing we have to do is to create 3 records (the same as before) and add call the Doctrine_Table::setInheritanceMap() method inside the setUp() method.
+
+
+class Entity extends Doctrine_Record {
+ public function setTableDefinition() {
+ $this->hasColumn('name','string',30);
+ $this->hasColumn('username','string',20);
+ $this->hasColumn('password','string',16);
+ $this->hasColumn('created','integer',11);
+
+ // this column is used for column
+ // aggregation inheritance
+ $this->hasColumn('type', 'integer', 11);
+ }
+}
+
+class User extends Entity {
+ public function setUp() {
+ $this->setInheritanceMap(array('type'=>1));
+ }
+}
+
+class Group extends Entity {
+ public function setUp() {
+ $this->setInheritanceMap(array('type'=>2));
+ }
+}
+
+
+If we want to be able to fetch a record from the Entity table and automatically get a User record if the Entity we fetched is a user we have to do set the subclasses option in the parent class. The adjusted example:
+
+
+class Entity extends Doctrine_Record {
+ public function setTableDefinition() {
+ $this->hasColumn('name','string',30);
+ $this->hasColumn('username','string',20);
+ $this->hasColumn('password','string',16);
+ $this->hasColumn('created','integer',11);
+
+ // this column is used for column
+ // aggregation inheritance
+ $this->hasColumn('type', 'integer', 11);
+ $this->option('subclasses', array('User', 'Group');
+ }
+}
+
+class User extends Entity {
+ public function setUp() {
+ $this->setInheritanceMap(array('type'=>1));
+ }
+}
+
+class Group extends Entity {
+ public function setUp() {
+ $this->setInheritanceMap(array('type'=>2));
+ }
+}
+
+
+We can then do the following given the previous table mapping.
+
+
+$user = new User();
+$user->name='Bjarte S. Karlsen';
+$user->username='meus';
+$user->password='rat';
+$user->save();
+
+$group = new Group();
+$group->name='Users';
+$group->username='users';
+$group->password='password';
+$group->save();
+
+$q = Doctrine_Query();
+$user = $q->from('Entity')->where('id=?')->execute(array($user->id))->getFirst();
+
+$q = Doctrine_Query();
+$group = $q->from('Entity')->where('id=?')->execute(array($group->id))->getFirst();
+
+
+The user object is here an instance of User while the group object is an instance of Group.
+
diff --git a/manual/docs/Object relational mapping - Relations - Inheritance - One table many classes.php b/manual/docs/Object relational mapping - Relations - Inheritance - One table many classes.php
index ffe77627a..f4aa1be95 100644
--- a/manual/docs/Object relational mapping - Relations - Inheritance - One table many classes.php
+++ b/manual/docs/Object relational mapping - Relations - Inheritance - One table many classes.php
@@ -1,22 +1,24 @@
-When it comes to handling inheritance Doctrine is very smart.
-In the following example we have one database table called 'entity'.
-Users and groups are both entities and they share the same database table.
-The only thing we have to make is 3 records (Entity, Group and User).
-
-class Entity extends Doctrine_Record {
- public function setTableDefinition() {
- $this->hasColumn('name','string',30);
- $this->hasColumn('username','string',20);
- $this->hasColumn('password','string',16);
- $this->hasColumn('created','integer',11);
- }
-}
-
-class User extends Entity { }
-
-class Group extends Entity { }
-
+
+
+Doctrine is smart enough to know that the inheritance type here is one-table-many-classes.
+
+
+
+class Entity extends Doctrine_Record {
+ public function setTableDefinition() {
+ $this->hasColumn('name','string',30);
+ $this->hasColumn('username','string',20);
+ $this->hasColumn('password','string',16);
+ $this->hasColumn('created','integer',11);
+ }
+}
+
+class User extends Entity { }
+
+class Group extends Entity { }
+
diff --git a/manual/docs/Object relational mapping - Relations - Inheritance - One table one class.php b/manual/docs/Object relational mapping - Relations - Inheritance - One table one class.php
index 4d27c8423..c24a1eabc 100644
--- a/manual/docs/Object relational mapping - Relations - Inheritance - One table one class.php
+++ b/manual/docs/Object relational mapping - Relations - Inheritance - One table one class.php
@@ -1,32 +1,34 @@
-In the following example we have three database tables called 'entity', 'user' and 'group'.
-Users and groups are both entities.
-The only thing we have to do is write 3 classes (Entity, Group and User) and make iterative
-setTableDefinition method calls.
-
-class Entity extends Doctrine_Record {
- public function setTableDefinition() {
- $this->hasColumn('name','string',30);
- $this->hasColumn('username','string',20);
- $this->hasColumn('password','string',16);
- $this->hasColumn('created','integer',11);
- }
-}
-
-class User extends Entity {
- public function setTableDefinition() {
- // the following method call is needed in
- // one-table-one-class inheritance
- parent::setTableDefinition();
- }
-}
-
-class Group extends Entity {
- public function setTableDefinition() {
- // the following method call is needed in
- // one-table-one-class inheritance
- parent::setTableDefinition();
- }
-}
-
+
+
+
+
+class Entity extends Doctrine_Record {
+ public function setTableDefinition() {
+ $this->hasColumn('name','string',30);
+ $this->hasColumn('username','string',20);
+ $this->hasColumn('password','string',16);
+ $this->hasColumn('created','integer',11);
+ }
+}
+
+class User extends Entity {
+ public function setTableDefinition() {
+ // the following method call is needed in
+ // one-table-one-class inheritance
+ parent::setTableDefinition();
+ }
+}
+
+class Group extends Entity {
+ public function setTableDefinition() {
+ // the following method call is needed in
+ // one-table-one-class inheritance
+ parent::setTableDefinition();
+ }
+}
+
diff --git a/manual/docs/Object relational mapping - Relations - Introduction.php b/manual/docs/Object relational mapping - Relations - Introduction.php
index 37508325b..c904cd9e1 100644
--- a/manual/docs/Object relational mapping - Relations - Introduction.php
+++ b/manual/docs/Object relational mapping - Relations - Introduction.php
@@ -1,3 +1,3 @@
-In Doctrine all record relations are being set with hasMany, hasOne, ownsMany and ownsOne methods. Doctrine supports almost any kind of database relation
-from simple one-to-one foreign key relations to join table self-referencing relations.
+In Doctrine all record relations are being set with hasMany, hasOne, ownsMany and ownsOne methods. Doctrine supports almost any kind of database relation
+from simple one-to-one foreign key relations to join table self-referencing relations.
diff --git a/manual/docs/Object relational mapping - Relations - Join table associations - Many-to-Many.php b/manual/docs/Object relational mapping - Relations - Join table associations - Many-to-Many.php
index c651dd67f..1e9b35ecd 100644
--- a/manual/docs/Object relational mapping - Relations - Join table associations - Many-to-Many.php
+++ b/manual/docs/Object relational mapping - Relations - Join table associations - Many-to-Many.php
@@ -1,69 +1,75 @@
-If you are coming from relational database background it may be familiar to you
-how many-to-many associations are handled: an additional association table is needed.
-
-class User extends Doctrine_Record {
- public function setUp() {
- $this->hasMany('Group','Groupuser.group_id');
- }
- public function setTableDefinition() {
- $this->hasColumn('name','string',30);
- }
-}
-
-class Group extends Doctrine_Record {
- public function setUp() {
- $this->hasMany('User','Groupuser.user_id');
- }
- public function setTableDefinition() {
- $this->hasColumn('name','string',30);
- }
-}
-
-class Groupuser extends Doctrine_Record {
- public function setTableDefinition() {
- $this->hasColumn('user_id','integer');
- $this->hasColumn('group_id','integer');
- }
-}
-
-
-$user = new User();
-
-// add two groups
-$user->Group[0]->name = 'First Group';
-
-$user->Group[1]->name = 'Second Group';
-
-// save changes into database
-$user->save();
-
-// deleting the associations between user and groups it belongs to
-
-$user->Groupuser->delete();
-
-$groups = new Doctrine_Collection($conn->getTable('Group'));
-
-$groups[0]->name = 'Third Group';
-
-$groups[1]->name = 'Fourth Group';
-
-$user->Group[2] = $groups[0];
-// $user will now have 3 groups
-
-$user->Group = $groups;
-// $user will now have two groups 'Third Group' and 'Fourth Group'
-
-
+
+
+In many-to-many relations the relation between the two components is always an aggregate
+relation and the association table is owned by both ends. For example in the case of users and groups
+when user is being deleted the groups it belongs to are not being deleted and the associations between this user
+and the groups it belongs to are being deleted.
+
+
+
+Sometimes you may not want that association table rows are being deleted when user / group is being deleted. You can override
+this behoviour by setting the relations to association component (in this case Groupuser) explicitly.
+
+
+
+In the following example we have Groups and Users of which relation is defined as
+many-to-many. In this case we also need to define an additional class called Groupuser.
+
+
+
+class User extends Doctrine_Record {
+ public function setUp() {
+ $this->hasMany('Group','Groupuser.group_id');
+ }
+ public function setTableDefinition() {
+ $this->hasColumn('name','string',30);
+ }
+}
+
+class Group extends Doctrine_Record {
+ public function setUp() {
+ $this->hasMany('User','Groupuser.user_id');
+ }
+ public function setTableDefinition() {
+ $this->hasColumn('name','string',30);
+ }
+}
+
+class Groupuser extends Doctrine_Record {
+ public function setTableDefinition() {
+ $this->hasColumn('user_id','integer');
+ $this->hasColumn('group_id','integer');
+ }
+}
+
+
+$user = new User();
+
+// add two groups
+$user->Group[0]->name = 'First Group';
+
+$user->Group[1]->name = 'Second Group';
+
+// save changes into database
+$user->save();
+
+// deleting the associations between user and groups it belongs to
+
+$user->Groupuser->delete();
+
+$groups = new Doctrine_Collection($conn->getTable('Group'));
+
+$groups[0]->name = 'Third Group';
+
+$groups[1]->name = 'Fourth Group';
+
+$user->Group[2] = $groups[0];
+// $user will now have 3 groups
+
+$user->Group = $groups;
+// $user will now have two groups 'Third Group' and 'Fourth Group'
+
+
diff --git a/manual/docs/Object relational mapping - Relations - Join table associations - Self-referencing.php b/manual/docs/Object relational mapping - Relations - Join table associations - Self-referencing.php
index 1ac461341..b20062149 100644
--- a/manual/docs/Object relational mapping - Relations - Join table associations - Self-referencing.php
+++ b/manual/docs/Object relational mapping - Relations - Join table associations - Self-referencing.php
@@ -1,18 +1,18 @@
-Self-referencing with join tables is done as follows:
+Self-referencing with join tables is done as follows:
-
-class User extends Doctrine_Record {
- public function setUp() {
- $this->hasMany('User as Friend','UserReference.user_id-user_id2');
- }
- public function setTableDefinition() {
- $this->hasColumn('name','string',30);
- }
-}
-class UserReference extends Doctrine_Record {
- public function setTableDefinition() {
- $this->hasColumn('user_id','integer');
- $this->hasColumn('user_id2','integer');
- }
-}
-
+
+class User extends Doctrine_Record {
+ public function setUp() {
+ $this->hasMany('User as Friend','UserReference.user_id-user_id2');
+ }
+ public function setTableDefinition() {
+ $this->hasColumn('name','string',30);
+ }
+}
+class UserReference extends Doctrine_Record {
+ public function setTableDefinition() {
+ $this->hasColumn('user_id','integer');
+ $this->hasColumn('user_id2','integer');
+ }
+}
+
diff --git a/manual/docs/Object relational mapping - Relations - One-to-Many and One-to-One relationships.php b/manual/docs/Object relational mapping - Relations - One-to-Many and One-to-One relationships.php
index d3f5a12fa..8b1378917 100644
--- a/manual/docs/Object relational mapping - Relations - One-to-Many and One-to-One relationships.php
+++ b/manual/docs/Object relational mapping - Relations - One-to-Many and One-to-One relationships.php
@@ -1 +1 @@
-
+
diff --git a/manual/docs/Object relational mapping - Relations - Relation aliases.php b/manual/docs/Object relational mapping - Relations - Relation aliases.php
index b1acca309..7562b3d0d 100644
--- a/manual/docs/Object relational mapping - Relations - Relation aliases.php
+++ b/manual/docs/Object relational mapping - Relations - Relation aliases.php
@@ -1,28 +1,28 @@
-Doctrine supports relation aliases through 'as' keyword.
+Doctrine supports relation aliases through 'as' keyword.
-
-class Forum_Board extends Doctrine_Record {
- public function setTableDefinition() {
- $this->hasColumn('name', 'string', 100);
- $this->hasColumn('description', 'string', 5000);
- }
- public function setUp() {
- // notice the 'as' keyword here
- $this->ownsMany('Forum_Thread as Threads', 'Forum_Thread.board_id');
- }
-}
-
-class Forum_Thread extends Doctrine_Record {
- public function setTableDefinition() {
- $this->hasColumn('board_id', 'integer', 10);
- $this->hasColumn('updated', 'integer', 10);
- $this->hasColumn('closed', 'integer', 1);
- }
- public function setUp() {
- // notice the 'as' keyword here
- $this->hasOne('Forum_Board as Board', 'Forum_Thread.board_id');
- }
-}
-$board = new Board();
-$board->Threads[0]->updated = time();
-
+
+class Forum_Board extends Doctrine_Record {
+ public function setTableDefinition() {
+ $this->hasColumn('name', 'string', 100);
+ $this->hasColumn('description', 'string', 5000);
+ }
+ public function setUp() {
+ // notice the 'as' keyword here
+ $this->ownsMany('Forum_Thread as Threads', 'Forum_Thread.board_id');
+ }
+}
+
+class Forum_Thread extends Doctrine_Record {
+ public function setTableDefinition() {
+ $this->hasColumn('board_id', 'integer', 10);
+ $this->hasColumn('updated', 'integer', 10);
+ $this->hasColumn('closed', 'integer', 1);
+ }
+ public function setUp() {
+ // notice the 'as' keyword here
+ $this->hasOne('Forum_Board as Board', 'Forum_Thread.board_id');
+ }
+}
+$board = new Board();
+$board->Threads[0]->updated = time();
+
diff --git a/manual/docs/Object relational mapping - Table and class naming.php b/manual/docs/Object relational mapping - Table and class naming.php
index 3cb96d21d..c96c14a6b 100644
--- a/manual/docs/Object relational mapping - Table and class naming.php
+++ b/manual/docs/Object relational mapping - Table and class naming.php
@@ -1,19 +1,29 @@
-Doctrine automatically creates table names from the record class names. For this reason, it is recommended to name your record classes using the following rules:
-
+class MyInnoDbRecord extends Doctrine_Record
+{
+ public function setTableDefinition()
+ {
+ \$this->hasColumn('name', 'string');
+
+ \$this->option('type', 'INNODB');
+ }
+}
+?>
+
+
+In the following example we set the collate and character set options:
+
+
+
+
+class MyCustomOptionRecord extends Doctrine_Record
+{
+ public function setTableDefinition()
+ {
+ \$this->hasColumn('name', 'string');
+
+ \$this->option('collate', 'utf8_unicode_ci');
+ \$this->option('charset', 'utf8');
+ }
+}
+?>
+
diff --git a/manual/docs/Performance - Internal optimizations - DELETE.php b/manual/docs/Performance - Internal optimizations - DELETE.php
index 9842097df..43353b8a2 100644
--- a/manual/docs/Performance - Internal optimizations - DELETE.php
+++ b/manual/docs/Performance - Internal optimizations - DELETE.php
@@ -1,25 +1,25 @@
-
-/**
- * lets presume $users contains a collection of users
- * each having 0-1 email and 0-* phonenumbers
- */
-$users->delete();
-/**
- * On connection drivers other than mysql doctrine would now perform three queries
- * regardless of how many users, emails and phonenumbers there are
- *
- * the queries would look something like:
- * DELETE FROM entity WHERE entity.id IN (1,2,3, ... ,15)
- * DELETE FROM phonenumber WHERE phonenumber.id IN (4,6,7,8)
- * DELETE FROM email WHERE email.id IN (1,2, ... ,10)
- *
- * On mysql doctrine is EVEN SMARTER! Now it would perform only one query!
- * the query would look like:
- * DELETE entity, email, phonenumber FROM entity
- * LEFT JOIN phonenumber ON entity.id = phonenumber.entity_id, email
- * WHERE (entity.email_id = email.id) && (entity.id IN(4, 5, 6, 7, 8, 9, 10, 11)) && (entity.type = 0)
- */
-
-
-
+
+/**
+ * lets presume $users contains a collection of users
+ * each having 0-1 email and 0-* phonenumbers
+ */
+$users->delete();
+/**
+ * On connection drivers other than mysql doctrine would now perform three queries
+ * regardless of how many users, emails and phonenumbers there are
+ *
+ * the queries would look something like:
+ * DELETE FROM entity WHERE entity.id IN (1,2,3, ... ,15)
+ * DELETE FROM phonenumber WHERE phonenumber.id IN (4,6,7,8)
+ * DELETE FROM email WHERE email.id IN (1,2, ... ,10)
+ *
+ * On mysql doctrine is EVEN SMARTER! Now it would perform only one query!
+ * the query would look like:
+ * DELETE entity, email, phonenumber FROM entity
+ * LEFT JOIN phonenumber ON entity.id = phonenumber.entity_id, email
+ * WHERE (entity.email_id = email.id) && (entity.id IN(4, 5, 6, 7, 8, 9, 10, 11)) && (entity.type = 0)
+ */
+
+
+
diff --git a/manual/docs/Performance - Internal optimizations - INSERT.php b/manual/docs/Performance - Internal optimizations - INSERT.php
index 29c51746d..0202c5ce3 100644
--- a/manual/docs/Performance - Internal optimizations - INSERT.php
+++ b/manual/docs/Performance - Internal optimizations - INSERT.php
@@ -1,29 +1,29 @@
-
-// lets presume $users contains a collection of new users
-// each having 0-1 email and 0-* phonenumbers
-$users->save();
-/**
- * now doctrine would perform prepared queries in the following order:
- *
- * first the emails since every user needs to get the primary key of their newly created email
- * INSERT INTO email (address) VALUES (:address)
- * INSERT INTO email (address) VALUES (:address)
- * INSERT INTO email (address) VALUES (:address)
- *
- * then the users
- * INSERT INTO entity (name,email_id) VALUES (:name,:email_id)
- * INSERT INTO entity (name,email_id) VALUES (:name,:email_id)
- * INSERT INTO entity (name,email_id) VALUES (:name,:email_id)
- *
- * and at last the phonenumbers since they need the primary keys of the newly created users
- * INSERT INTO phonenumber (phonenumber,entity_id) VALUES (:phonenumber,:entity_id)
- * INSERT INTO phonenumber (phonenumber,entity_id) VALUES (:phonenumber,:entity_id)
- * INSERT INTO phonenumber (phonenumber,entity_id) VALUES (:phonenumber,:entity_id)
- * INSERT INTO phonenumber (phonenumber,entity_id) VALUES (:phonenumber,:entity_id)
- * INSERT INTO phonenumber (phonenumber,entity_id) VALUES (:phonenumber,:entity_id)
- *
- * These operations are considerably fast, since many databases perform multiple
- * prepared queries very rapidly
- */
-
+
+// lets presume $users contains a collection of new users
+// each having 0-1 email and 0-* phonenumbers
+$users->save();
+/**
+ * now doctrine would perform prepared queries in the following order:
+ *
+ * first the emails since every user needs to get the primary key of their newly created email
+ * INSERT INTO email (address) VALUES (:address)
+ * INSERT INTO email (address) VALUES (:address)
+ * INSERT INTO email (address) VALUES (:address)
+ *
+ * then the users
+ * INSERT INTO entity (name,email_id) VALUES (:name,:email_id)
+ * INSERT INTO entity (name,email_id) VALUES (:name,:email_id)
+ * INSERT INTO entity (name,email_id) VALUES (:name,:email_id)
+ *
+ * and at last the phonenumbers since they need the primary keys of the newly created users
+ * INSERT INTO phonenumber (phonenumber,entity_id) VALUES (:phonenumber,:entity_id)
+ * INSERT INTO phonenumber (phonenumber,entity_id) VALUES (:phonenumber,:entity_id)
+ * INSERT INTO phonenumber (phonenumber,entity_id) VALUES (:phonenumber,:entity_id)
+ * INSERT INTO phonenumber (phonenumber,entity_id) VALUES (:phonenumber,:entity_id)
+ * INSERT INTO phonenumber (phonenumber,entity_id) VALUES (:phonenumber,:entity_id)
+ *
+ * These operations are considerably fast, since many databases perform multiple
+ * prepared queries very rapidly
+ */
+
diff --git a/manual/docs/Real world examples - Forum application.php b/manual/docs/Real world examples - Forum application.php
index ab9a2514e..b81dfaf1f 100644
--- a/manual/docs/Real world examples - Forum application.php
+++ b/manual/docs/Real world examples - Forum application.php
@@ -1,53 +1,53 @@
-
-class Forum_Category extends Doctrine_Record {
- public function setTableDefinition() {
- $this->hasColumn("root_category_id", "integer", 10);
- $this->hasColumn("parent_category_id", "integer", 10);
- $this->hasColumn("name", "string", 50);
- $this->hasColumn("description", "string", 99999);
- }
- public function setUp() {
- $this->hasMany("Forum_Category as Subcategory", "Subcategory.parent_category_id");
- $this->hasOne("Forum_Category as Rootcategory", "Forum_Category.root_category_id");
- }
-}
-class Forum_Board extends Doctrine_Record {
- public function setTableDefinition() {
- $this->hasColumn("category_id", "integer", 10);
- $this->hasColumn("name", "string", 100);
- $this->hasColumn("description", "string", 5000);
- }
- public function setUp() {
- $this->hasOne("Forum_Category as Category", "Forum_Board.category_id");
- $this->ownsMany("Forum_Thread as Threads", "Forum_Thread.board_id");
- }
-}
-
-class Forum_Entry extends Doctrine_Record {
- public function setTableDefinition() {
- $this->hasColumn("author", "string", 50);
- $this->hasColumn("topic", "string", 100);
- $this->hasColumn("message", "string", 99999);
- $this->hasColumn("parent_entry_id", "integer", 10);
- $this->hasColumn("thread_id", "integer", 10);
- $this->hasColumn("date", "integer", 10);
- }
- public function setUp() {
- $this->hasOne("Forum_Entry as Parent", "Forum_Entry.parent_entry_id");
- $this->hasOne("Forum_Thread as Thread", "Forum_Entry.thread_id");
- }
-}
-
-class Forum_Thread extends Doctrine_Record {
- public function setTableDefinition() {
- $this->hasColumn("board_id", "integer", 10);
- $this->hasColumn("updated", "integer", 10);
- $this->hasColumn("closed", "integer", 1);
- }
- public function setUp() {
- $this->hasOne("Forum_Board as Board", "Forum_Thread.board_id");
- $this->ownsMany("Forum_Entry as Entries", "Forum_Entry.thread_id");
- }
-}
-
+
+class Forum_Category extends Doctrine_Record {
+ public function setTableDefinition() {
+ $this->hasColumn("root_category_id", "integer", 10);
+ $this->hasColumn("parent_category_id", "integer", 10);
+ $this->hasColumn("name", "string", 50);
+ $this->hasColumn("description", "string", 99999);
+ }
+ public function setUp() {
+ $this->hasMany("Forum_Category as Subcategory", "Subcategory.parent_category_id");
+ $this->hasOne("Forum_Category as Rootcategory", "Forum_Category.root_category_id");
+ }
+}
+class Forum_Board extends Doctrine_Record {
+ public function setTableDefinition() {
+ $this->hasColumn("category_id", "integer", 10);
+ $this->hasColumn("name", "string", 100);
+ $this->hasColumn("description", "string", 5000);
+ }
+ public function setUp() {
+ $this->hasOne("Forum_Category as Category", "Forum_Board.category_id");
+ $this->ownsMany("Forum_Thread as Threads", "Forum_Thread.board_id");
+ }
+}
+
+class Forum_Entry extends Doctrine_Record {
+ public function setTableDefinition() {
+ $this->hasColumn("author", "string", 50);
+ $this->hasColumn("topic", "string", 100);
+ $this->hasColumn("message", "string", 99999);
+ $this->hasColumn("parent_entry_id", "integer", 10);
+ $this->hasColumn("thread_id", "integer", 10);
+ $this->hasColumn("date", "integer", 10);
+ }
+ public function setUp() {
+ $this->hasOne("Forum_Entry as Parent", "Forum_Entry.parent_entry_id");
+ $this->hasOne("Forum_Thread as Thread", "Forum_Entry.thread_id");
+ }
+}
+
+class Forum_Thread extends Doctrine_Record {
+ public function setTableDefinition() {
+ $this->hasColumn("board_id", "integer", 10);
+ $this->hasColumn("updated", "integer", 10);
+ $this->hasColumn("closed", "integer", 1);
+ }
+ public function setUp() {
+ $this->hasOne("Forum_Board as Board", "Forum_Thread.board_id");
+ $this->ownsMany("Forum_Entry as Entries", "Forum_Entry.thread_id");
+ }
+}
+
diff --git a/manual/docs/Real world examples - User management system.php b/manual/docs/Real world examples - User management system.php
index 87e6f8c5a..41c154fad 100644
--- a/manual/docs/Real world examples - User management system.php
+++ b/manual/docs/Real world examples - User management system.php
@@ -1,100 +1,120 @@
-In the following example we make a user management system where
-
-class Entity extends Doctrine_Record {
- public function setUp() {
- $this->ownsOne("Email","Entity.email_id");
- $this->ownsMany("Phonenumber","Phonenumber.entity_id");
- $this->setAttribute(Doctrine::ATTR_FETCHMODE,Doctrine::FETCH_BATCH);
- $this->setAttribute(Doctrine::ATTR_LISTENER,new EntityListener());
- }
- public function setTableDefinition() {
- $this->hasColumn("name","string",50);
- $this->hasColumn("loginname","string",20);
- $this->hasColumn("password","string",16);
- $this->hasColumn("type","integer",1);
- $this->hasColumn("created","integer",11);
- $this->hasColumn("updated","integer",11);
- $this->hasColumn("email_id","integer");
- }
-}
-class Group extends Entity {
- public function setUp() {
- parent::setUp();
- $this->hasMany("User","Groupuser.user_id");
- $this->setInheritanceMap(array("type"=>1));
- }
-}
-class User extends Entity {
- public function setUp() {
- parent::setUp();
- $this->hasMany("Group","Groupuser.group_id");
- $this->setInheritanceMap(array("type"=>0));
- }
-}
-class Groupuser extends Doctrine_Record {
- public function setTableDefinition() {
- $this->hasColumn("group_id","integer");
- $this->hasColumn("user_id","integer");
- }
-}
-
-class Phonenumber extends Doctrine_Record {
- public function setTableDefinition() {
- $this->hasColumn("phonenumber","string",20);
- $this->hasColumn("entity_id","integer");
- }
-}
-class Email extends Doctrine_Record {
- public function setTableDefinition() {
- $this->hasColumn("address","string",150,"email|unique");
- }
-}
-class EntityListener extends Doctrine_EventListener {
- public function onPreUpdate(Doctrine_Record $record) {
- $record->updated = time();
- }
- public function onPreInsert(Doctrine_Record $record) {
- $record->created = time();
- }
-}
-
-// USER MANAGEMENT SYSTEM IN ACTION:
-
-$manager = Doctrine_Manager::getInstance();
-
-$conn = $manager->openConnection(new PDO("DSN","username","password"));
-
-$user = new User();
-
-$user->name = "Jack Daniels";
-$user->Email->address = "jackdaniels@drinkmore.info";
-$user->Phonenumber[0]->phonenumber = "123 123";
-$user->Phonenumber[1]->phonenumber = "133 133";
-$user->save();
-
-$user->Group[0]->name = "beer lovers";
-$user->Group[0]->Email->address = "beerlovers@drinkmore.info";
-$user->Group[0]->save();
-
-
+
+
+1. Each user and group are entities
+
+
+
+2. User is an entity of type 0
+
+
+
+3. Group is an entity of type 1
+
+
+
+4. Each entity (user/group) has 0-1 email
+
+
+
+5. Each entity has 0-* phonenumbers
+
+
+
+6. If an entity is saved all its emails and phonenumbers are also saved
+
+
+
+7. If an entity is deleted all its emails and phonenumbers are also deleted
+
+
+
+8. When an entity is created and saved a current timestamp will be assigned to 'created' field
+
+
+
+9. When an entity is updated a current timestamp will be assigned to 'updated' field
+
+
+
+10. Entities will always be fetched in batches
+
+
+class Entity extends Doctrine_Record {
+ public function setUp() {
+ $this->ownsOne("Email","Entity.email_id");
+ $this->ownsMany("Phonenumber","Phonenumber.entity_id");
+ $this->setAttribute(Doctrine::ATTR_FETCHMODE,Doctrine::FETCH_BATCH);
+ $this->setAttribute(Doctrine::ATTR_LISTENER,new EntityListener());
+ }
+ public function setTableDefinition() {
+ $this->hasColumn("name","string",50);
+ $this->hasColumn("loginname","string",20);
+ $this->hasColumn("password","string",16);
+ $this->hasColumn("type","integer",1);
+ $this->hasColumn("created","integer",11);
+ $this->hasColumn("updated","integer",11);
+ $this->hasColumn("email_id","integer");
+ }
+}
+class Group extends Entity {
+ public function setUp() {
+ parent::setUp();
+ $this->hasMany("User","Groupuser.user_id");
+ $this->setInheritanceMap(array("type"=>1));
+ }
+}
+class User extends Entity {
+ public function setUp() {
+ parent::setUp();
+ $this->hasMany("Group","Groupuser.group_id");
+ $this->setInheritanceMap(array("type"=>0));
+ }
+}
+class Groupuser extends Doctrine_Record {
+ public function setTableDefinition() {
+ $this->hasColumn("group_id","integer");
+ $this->hasColumn("user_id","integer");
+ }
+}
+
+class Phonenumber extends Doctrine_Record {
+ public function setTableDefinition() {
+ $this->hasColumn("phonenumber","string",20);
+ $this->hasColumn("entity_id","integer");
+ }
+}
+class Email extends Doctrine_Record {
+ public function setTableDefinition() {
+ $this->hasColumn("address","string",150,"email|unique");
+ }
+}
+class EntityListener extends Doctrine_EventListener {
+ public function onPreUpdate(Doctrine_Record $record) {
+ $record->updated = time();
+ }
+ public function onPreInsert(Doctrine_Record $record) {
+ $record->created = time();
+ }
+}
+
+// USER MANAGEMENT SYSTEM IN ACTION:
+
+$manager = Doctrine_Manager::getInstance();
+
+$conn = $manager->openConnection(new PDO("DSN","username","password"));
+
+$user = new User();
+
+$user->name = "Jack Daniels";
+$user->Email->address = "jackdaniels@drinkmore.info";
+$user->Phonenumber[0]->phonenumber = "123 123";
+$user->Phonenumber[1]->phonenumber = "133 133";
+$user->save();
+
+$user->Group[0]->name = "beer lovers";
+$user->Group[0]->Email->address = "beerlovers@drinkmore.info";
+$user->Group[0]->save();
+
+
diff --git a/manual/docs/Runtime classes - Doctrine_Association.php b/manual/docs/Runtime classes - Doctrine_Association.php
index d29d1e7ff..17a2a8859 100644
--- a/manual/docs/Runtime classes - Doctrine_Association.php
+++ b/manual/docs/Runtime classes - Doctrine_Association.php
@@ -1 +1 @@
-Doctrine_Association represents a many-to-many association between database tables.
+Doctrine_Association represents a many-to-many association between database tables.
diff --git a/manual/docs/Runtime classes - Doctrine_Collection.php b/manual/docs/Runtime classes - Doctrine_Collection.php
index 775cb0c86..3eee67814 100644
--- a/manual/docs/Runtime classes - Doctrine_Collection.php
+++ b/manual/docs/Runtime classes - Doctrine_Collection.php
@@ -1 +1 @@
-Doctrine_Collection is a collection of Data Access Objects. Doctrine_Collection represents a record set.
+Doctrine_Collection is a collection of Data Access Objects. Doctrine_Collection represents a record set.
diff --git a/manual/docs/Runtime classes - Doctrine_Collection_Batch.php b/manual/docs/Runtime classes - Doctrine_Collection_Batch.php
index 77b2e4f41..d894cbb1b 100644
--- a/manual/docs/Runtime classes - Doctrine_Collection_Batch.php
+++ b/manual/docs/Runtime classes - Doctrine_Collection_Batch.php
@@ -1 +1 @@
-Doctrine_Collection_Batch is a Doctrine_Collection with batch fetching strategy.
+Doctrine_Collection_Batch is a Doctrine_Collection with batch fetching strategy.
diff --git a/manual/docs/Runtime classes - Doctrine_Collection_Immediate.php b/manual/docs/Runtime classes - Doctrine_Collection_Immediate.php
index dde19e48b..88a47e37d 100644
--- a/manual/docs/Runtime classes - Doctrine_Collection_Immediate.php
+++ b/manual/docs/Runtime classes - Doctrine_Collection_Immediate.php
@@ -1 +1 @@
-Doctrine_Collection_Immediate is a Doctrine_Collection with immediate fetching strategy.
+Doctrine_Collection_Immediate is a Doctrine_Collection with immediate fetching strategy.
diff --git a/manual/docs/Runtime classes - Doctrine_Collection_Lazy.php b/manual/docs/Runtime classes - Doctrine_Collection_Lazy.php
index d36ad04dc..9e0fbcc21 100644
--- a/manual/docs/Runtime classes - Doctrine_Collection_Lazy.php
+++ b/manual/docs/Runtime classes - Doctrine_Collection_Lazy.php
@@ -1 +1 @@
-Doctrine_Collection_Lazy is a Doctrine_Collection with lazy fetching strategy.
+Doctrine_Collection_Lazy is a Doctrine_Collection with lazy fetching strategy.
diff --git a/manual/docs/Runtime classes - Doctrine_ForeignKey.php b/manual/docs/Runtime classes - Doctrine_ForeignKey.php
index a039df04d..db22a18d6 100644
--- a/manual/docs/Runtime classes - Doctrine_ForeignKey.php
+++ b/manual/docs/Runtime classes - Doctrine_ForeignKey.php
@@ -1 +1 @@
-Doctrine_ForeignKey represents a one-to-many association or one-to-one association between two database tables.
+Doctrine_ForeignKey represents a one-to-many association or one-to-one association between two database tables.
diff --git a/manual/docs/Runtime classes - Doctrine_Manager.php b/manual/docs/Runtime classes - Doctrine_Manager.php
index 665f22726..3e40e60a8 100644
--- a/manual/docs/Runtime classes - Doctrine_Manager.php
+++ b/manual/docs/Runtime classes - Doctrine_Manager.php
@@ -1,2 +1,2 @@
-Doctrine_Manager is the base component of Doctrine ORM framework. Doctrine_Manager is a colletion of Doctrine_Connections. All the new connections are being
-opened by Doctrine_Manager::openConnection().
+Doctrine_Manager is the base component of Doctrine ORM framework. Doctrine_Manager is a colletion of Doctrine_Connections. All the new connections are being
+opened by Doctrine_Manager::openConnection().
diff --git a/manual/docs/Runtime classes - Doctrine_Record.php b/manual/docs/Runtime classes - Doctrine_Record.php
index c05645e6c..0d522f176 100644
--- a/manual/docs/Runtime classes - Doctrine_Record.php
+++ b/manual/docs/Runtime classes - Doctrine_Record.php
@@ -1,43 +1,43 @@
-Doctrine_Record is a wrapper for database row.
-
+Doctrine_Record is a wrapper for database row.
-
-$user = $table->find(2);
-
-// get state
-$state = $user->getState();
-
-print $user->name;
-
-print $user["name"];
-
-print $user->get("name");
-
-$user->name = "Jack Daniels";
-
-$user->set("name","Jack Daniels");
-
-// serialize record
-
-$serialized = serialize($user);
-
-$user = unserialize($serialized);
-
-// create a copy
-
-$copy = $user->copy();
-
-// get primary key
-
-$id = $user->getID();
-
-// print lots of useful info
-
-print $user;
-
-// save all the properties and composites
-$user->save();
-
-// delete this data access object and related objects
-$user->delete();
-
+
+
+$user = $table->find(2);
+
+// get state
+$state = $user->getState();
+
+print $user->name;
+
+print $user["name"];
+
+print $user->get("name");
+
+$user->name = "Jack Daniels";
+
+$user->set("name","Jack Daniels");
+
+// serialize record
+
+$serialized = serialize($user);
+
+$user = unserialize($serialized);
+
+// create a copy
+
+$copy = $user->copy();
+
+// get primary key
+
+$id = $user->getID();
+
+// print lots of useful info
+
+print $user;
+
+// save all the properties and composites
+$user->save();
+
+// delete this data access object and related objects
+$user->delete();
+
diff --git a/manual/docs/Runtime classes - Doctrine_Session.php b/manual/docs/Runtime classes - Doctrine_Session.php
index 9bb515b4d..13549761f 100644
--- a/manual/docs/Runtime classes - Doctrine_Session.php
+++ b/manual/docs/Runtime classes - Doctrine_Session.php
@@ -1,34 +1,34 @@
-Doctrine_Connection is a wrapper for database connection. It creates Doctrine_Tables and keeps track of all the created tables.
-Doctrine_Connection provides things that are missing from PDO like sequence support and limit/offset emulation.
-
+Doctrine_Connection is a wrapper for database connection. It creates Doctrine_Tables and keeps track of all the created tables.
+Doctrine_Connection provides things that are missing from PDO like sequence support and limit/offset emulation.
-
-$sess = $manager->openConnection(Doctrine_Db::getConnection("schema://username:password@hostname/database"));
-
-// get connection state:
-switch($sess):
- case Doctrine_Connection::STATE_BUSY:
- // multiple open transactions
- break;
- case Doctrine_Connection::STATE_ACTIVE:
- // one open transaction
- break;
- case Doctrine_Connection::STATE_CLOSED:
- // closed state
- break;
- case Doctrine_Connection::STATE_OPEN:
- // open state and zero open transactions
- break;
-endswitch;
-
-// getting database handler
-
-$dbh = $sess->getDBH();
-
-// flushing the connection
-$sess->flush();
-
-
-// print lots of useful info about connection:
-print $sess;
-
+
+
+$sess = $manager->openConnection(Doctrine_Db::getConnection("schema://username:password@hostname/database"));
+
+// get connection state:
+switch($sess):
+ case Doctrine_Connection::STATE_BUSY:
+ // multiple open transactions
+ break;
+ case Doctrine_Connection::STATE_ACTIVE:
+ // one open transaction
+ break;
+ case Doctrine_Connection::STATE_CLOSED:
+ // closed state
+ break;
+ case Doctrine_Connection::STATE_OPEN:
+ // open state and zero open transactions
+ break;
+endswitch;
+
+// getting database handler
+
+$dbh = $sess->getDBH();
+
+// flushing the connection
+$sess->flush();
+
+
+// print lots of useful info about connection:
+print $sess;
+
diff --git a/manual/docs/Runtime classes - Doctrine_Table.php b/manual/docs/Runtime classes - Doctrine_Table.php
index 748406d97..90fbb5320 100644
--- a/manual/docs/Runtime classes - Doctrine_Table.php
+++ b/manual/docs/Runtime classes - Doctrine_Table.php
@@ -1,2 +1,2 @@
-Doctrine_Table creates records and holds info of all foreign keys and associations. Doctrine_Table
-represents a database table.
+Doctrine_Table creates records and holds info of all foreign keys and associations. Doctrine_Table
+represents a database table.
diff --git a/manual/docs/Schema reference - Data types - Array.php b/manual/docs/Schema reference - Data types - Array.php
index 449cbabd1..7666e9bc7 100644
--- a/manual/docs/Schema reference - Data types - Array.php
+++ b/manual/docs/Schema reference - Data types - Array.php
@@ -1 +1 @@
-This is the same as 'array' type in PHP.
+This is the same as 'array' type in PHP.
diff --git a/manual/docs/Schema reference - Foreign keys - Introduction.php b/manual/docs/Schema reference - Foreign keys - Introduction.php
index 2c391bde9..24be45d15 100644
--- a/manual/docs/Schema reference - Foreign keys - Introduction.php
+++ b/manual/docs/Schema reference - Foreign keys - Introduction.php
@@ -1,2 +1,2 @@
-A foreign key constraint specifies that the values in a column (or a group of columns) must match the values appearing in some row of another table.
-In other words foreign key constraints maintain the referential integrity between two related tables.
+A foreign key constraint specifies that the values in a column (or a group of columns) must match the values appearing in some row of another table.
+In other words foreign key constraints maintain the referential integrity between two related tables.
diff --git a/manual/docs/Technology - Architecture.php b/manual/docs/Technology - Architecture.php
index d798b4c1c..341c6bfa9 100644
--- a/manual/docs/Technology - Architecture.php
+++ b/manual/docs/Technology - Architecture.php
@@ -1,16 +1,16 @@
-Doctrine is divided into 3 main packages:
-
->> Doctrine CORE
- Doctrine
- Doctrine_Manager
- Doctrine_Connection
-
->> Doctrine DBAL
- Doctrine_Expression
- Doctrine_Export
- Doctrine_Import
- Doctrine_Sequence
-
->> Doctrine ORM
-
+Doctrine is divided into 3 main packages:
+
+>> Doctrine CORE
+ Doctrine
+ Doctrine_Manager
+ Doctrine_Connection
+
+>> Doctrine DBAL
+ Doctrine_Expression
+ Doctrine_Export
+ Doctrine_Import
+ Doctrine_Sequence
+
+>> Doctrine ORM
+
diff --git a/manual/docs/Technology - Design patterns used.php b/manual/docs/Technology - Design patterns used.php
index 10c805c97..b0e37f586 100644
--- a/manual/docs/Technology - Design patterns used.php
+++ b/manual/docs/Technology - Design patterns used.php
@@ -1,47 +1,34 @@
-GoF [Gang Of Four] design patterns used:
-
-$conn->beginTransaction();
-
-$user = new User();
-$user->name = 'New user';
-$user->save();
-
-$user = $conn->getTable('User')->find(5);
-$user->name = 'Modified user';
-$user->save();
-
-$conn->commit(); // all the queries are executed here
-
+
+$conn->beginTransaction();
+
+$user = new User();
+$user->name = 'New user';
+$user->save();
+
+$user = $conn->getTable('User')->find(5);
+$user->name = 'Modified user';
+$user->save();
+
+$conn->commit(); // all the queries are executed here
+
diff --git a/manual/docs/Transactions - Isolation levels.php b/manual/docs/Transactions - Isolation levels.php
index c939144a3..438fc9551 100644
--- a/manual/docs/Transactions - Isolation levels.php
+++ b/manual/docs/Transactions - Isolation levels.php
@@ -1,32 +1,40 @@
-
-A transaction isolation level sets the default transactional behaviour.
-As the name 'isolation level' suggests, the setting determines how isolated each transation is,
-or what kind of locks are associated with queries inside a transaction.
-The four availible levels are (in ascending order of strictness):
-
+\$tx = \$conn->transaction; // get the transaction module
+
+// sets the isolation level to READ COMMITTED
+\$tx->setIsolation('READ COMMITTED');
+
+// sets the isolation level to SERIALIZABLE
+\$tx->setIsolation('SERIALIZABLE');
+
+// Some drivers (like Mysql) support the fetching of current transaction
+// isolation level. It can be done as follows:
+\$level = \$tx->getIsolation();
+?>
diff --git a/manual/docs/Transactions - Nesting.php b/manual/docs/Transactions - Nesting.php
index 8fa868563..4c6b8793c 100644
--- a/manual/docs/Transactions - Nesting.php
+++ b/manual/docs/Transactions - Nesting.php
@@ -1,24 +1,24 @@
-
-function saveUserAndGroup(Doctrine_Connection $conn, User $user, Group $group) {
- $conn->beginTransaction();
-
- $user->save();
-
- $group->save();
-
- $conn->commit();
-}
-
-try {
- $conn->beginTransaction();
-
- saveUserAndGroup($conn,$user,$group);
- saveUserAndGroup($conn,$user2,$group2);
- saveUserAndGroup($conn,$user3,$group3);
-
- $conn->commit();
-} catch(Doctrine_Exception $e) {
- $conn->rollback();
-}
-
+
+function saveUserAndGroup(Doctrine_Connection $conn, User $user, Group $group) {
+ $conn->beginTransaction();
+
+ $user->save();
+
+ $group->save();
+
+ $conn->commit();
+}
+
+try {
+ $conn->beginTransaction();
+
+ saveUserAndGroup($conn,$user,$group);
+ saveUserAndGroup($conn,$user2,$group2);
+ saveUserAndGroup($conn,$user3,$group3);
+
+ $conn->commit();
+} catch(Doctrine_Exception $e) {
+ $conn->rollback();
+}
+
diff --git a/manual/docs/Transactions - Savepoints.php b/manual/docs/Transactions - Savepoints.php
index f1016ac6b..bad2fe484 100644
--- a/manual/docs/Transactions - Savepoints.php
+++ b/manual/docs/Transactions - Savepoints.php
@@ -1,57 +1,65 @@
-
-Doctrine supports transaction savepoints. This means you can set named transactions and have them nested.
-
+try {
+ \$conn->beginTransaction();
+ // do some operations here
+
+ // creates a new savepoint called mysavepoint
+ \$conn->beginTransaction('mysavepoint');
+ try {
+ // do some operations here
+
+ \$conn->commit('mysavepoint');
+ } catch(Exception \$e) {
+ \$conn->rollback('mysavepoint');
+ }
+ \$conn->commit();
+} catch(Exception \$e) {
+ \$conn->rollback();
+}
+?>
+
+
+
+
+The Doctrine_Transaction::rollback(//$savepoint//) rolls back a transaction to the named savepoint.
+Modifications that the current transaction made to rows after the savepoint was set are undone in the rollback.
+
+NOTE: Mysql, for example, does not release the row locks that were stored in memory after the savepoint.
+
+
+
+Savepoints that were set at a later time than the named savepoint are deleted.
+
+
+
+The Doctrine_Transaction::commit(//$savepoint//) removes the named savepoint from the set of savepoints of the current transaction.
+
+
+
+All savepoints of the current transaction are deleted if you execute a commit or rollback is being called without savepoint name parameter.
+
+try {
+ \$conn->beginTransaction();
+ // do some operations here
+
+ // creates a new savepoint called mysavepoint
+ \$conn->beginTransaction('mysavepoint');
+
+ // do some operations here
+
+ \$conn->commit(); // deletes all savepoints
+} catch(Exception \$e) {
+ \$conn->rollback(); // deletes all savepoints
+}
+?>
diff --git a/manual/docs/Transactions - Unit of work.php b/manual/docs/Transactions - Unit of work.php
index dc1336c43..50e52d07d 100644
--- a/manual/docs/Transactions - Unit of work.php
+++ b/manual/docs/Transactions - Unit of work.php
@@ -1,19 +1,19 @@
-
-$conn->beginTransaction();
-
-$user = new User();
-$user->name = 'New user';
-$user->save();
-
-$user = $conn->getTable('User')->find(5);
-$user->name = 'Modified user';
-$user->save();
-
-
-$pending = $conn->getInserts(); // an array containing one element
-
-$pending = $conn->getUpdates(); // an array containing one element
-
-$conn->commit(); // all the queries are executed here
-
+
+$conn->beginTransaction();
+
+$user = new User();
+$user->name = 'New user';
+$user->save();
+
+$user = $conn->getTable('User')->find(5);
+$user->name = 'Modified user';
+$user->save();
+
+
+$pending = $conn->getInserts(); // an array containing one element
+
+$pending = $conn->getUpdates(); // an array containing one element
+
+$conn->commit(); // all the queries are executed here
+
diff --git a/manual/docs/Working with objects - Component overview - Collection - Accessing elements.php b/manual/docs/Working with objects - Component overview - Collection - Accessing elements.php
index 4df4467d4..861ff42ab 100644
--- a/manual/docs/Working with objects - Component overview - Collection - Accessing elements.php
+++ b/manual/docs/Working with objects - Component overview - Collection - Accessing elements.php
@@ -1,17 +1,17 @@
-You can access the elements of Doctrine_Collection with set() and get() methods or with ArrayAccess interface.
+You can access the elements of Doctrine_Collection with set() and get() methods or with ArrayAccess interface.
-
-$table = $conn->getTable("User");
-
-$users = $table->findAll();
-
-// accessing elements with ArrayAccess interface
-
-$users[0]->name = "Jack Daniels";
-
-$users[1]->name = "John Locke";
-
-// accessing elements with get()
-
-print $users->get(1)->name;
-
+
+$table = $conn->getTable("User");
+
+$users = $table->findAll();
+
+// accessing elements with ArrayAccess interface
+
+$users[0]->name = "Jack Daniels";
+
+$users[1]->name = "John Locke";
+
+// accessing elements with get()
+
+print $users->get(1)->name;
+
diff --git a/manual/docs/Working with objects - Component overview - Collection - Adding new elements.php b/manual/docs/Working with objects - Component overview - Collection - Adding new elements.php
index b6b9eb11d..eae643b72 100644
--- a/manual/docs/Working with objects - Component overview - Collection - Adding new elements.php
+++ b/manual/docs/Working with objects - Component overview - Collection - Adding new elements.php
@@ -1,15 +1,19 @@
-When accessing single elements of the collection and those elements (records) don't exist Doctrine auto-adds them.
-
-$users = $table->findAll();
-
-print count($users); // 5
-
-$users[5]->name = "new user 1";
-$users[6]->name = "new user 2";
-
+
+
+In the following example
+we fetch all users from database (there are 5) and then add couple of users in the collection.
+
+
+
+As with PHP arrays the indexes start from zero.
+
+
+$users = $table->findAll();
+
+print count($users); // 5
+
+$users[5]->name = "new user 1";
+$users[6]->name = "new user 2";
+
diff --git a/manual/docs/Working with objects - Component overview - Collection - Deleting collection.php b/manual/docs/Working with objects - Component overview - Collection - Deleting collection.php
index 997b332e1..b5aa78ae3 100644
--- a/manual/docs/Working with objects - Component overview - Collection - Deleting collection.php
+++ b/manual/docs/Working with objects - Component overview - Collection - Deleting collection.php
@@ -1,21 +1,29 @@
-Doctrine Collections can be deleted in very same way is Doctrine Records you just call delete() method.
-As for all collections Doctrine knows how to perform single-shot-delete meaning it only performs one
-database query for the each collection.
-
-// delete all users with name 'John'
-
-$users = $table->findByDql("name LIKE '%John%'");
-
-$users->delete();
-
+
+
+For example if we have collection of users which own [0-*] phonenumbers. When deleting the collection
+of users doctrine only performs two queries for this whole transaction. The queries would look something like:
+
+
+
+DELETE FROM user WHERE id IN (1,2,3, ... ,N)
+
+DELETE FROM phonenumber WHERE id IN (1,2,3, ... ,M)
+
+
+
+
+It should also be noted that Doctrine is smart enough to perform single-shot-delete per table when transactions are used.
+So if you are deleting a lot of records and want to optimize the operation just wrap the delete calls in Doctrine_Connection transaction.
+
+
+
+// delete all users with name 'John'
+
+$users = $table->findByDql("name LIKE '%John%'");
+
+$users->delete();
+
diff --git a/manual/docs/Working with objects - Component overview - Collection - Fetching strategies.php b/manual/docs/Working with objects - Component overview - Collection - Fetching strategies.php
index dc71711eb..b848a1474 100644
--- a/manual/docs/Working with objects - Component overview - Collection - Fetching strategies.php
+++ b/manual/docs/Working with objects - Component overview - Collection - Fetching strategies.php
@@ -1,95 +1,124 @@
-Whenever you fetch records with eg. Doctrine_Table::findAll or Doctrine_Connection::query methods an instance of
-Doctrine_Collection is returned. There are many types of collections in Doctrine and it is crucial to understand
-the differences of these collections. Remember choosing the right fetching strategy (collection type) is one of the most
-influental things when it comes to boosting application performance.
-
-$table = $conn->getTable("User");
-
-$table->setAttribute(Doctrine::ATTR_FETCHMODE, Doctrine::FETCH_IMMEDIATE);
-
-$users = $table->findAll();
-
-// or
-
-$users = $conn->query("FROM User-I"); // immediate collection
-
-foreach($users as $user) {
- print $user->name;
-}
-
-
-$table->setAttribute(Doctrine::ATTR_FETCHMODE, Doctrine::FETCH_LAZY);
-
-$users = $table->findAll();
-
-// or
-
-$users = $conn->query("FROM User-L"); // lazy collection
-
-foreach($users as $user) {
- print $user->name;
-}
-
-$table->setAttribute(Doctrine::ATTR_FETCHMODE, Doctrine::FETCH_BATCH);
-
-$users = $table->findAll();
-
-// or
-
-$users = $conn->query("FROM User-B"); // batch collection
-
-foreach($users as $user) {
- print $user->name;
-}
-
-$table->setAttribute(Doctrine::ATTR_FETCHMODE, Doctrine::FETCH_OFFSET);
-
-$users = $table->findAll();
-
-// or
-
-$users = $conn->query("FROM User-O"); // offset collection
-
-foreach($users as $user) {
- print $user->name;
-}
-
+
+
+
+$table = $conn->getTable("User");
+
+$table->setAttribute(Doctrine::ATTR_FETCHMODE, Doctrine::FETCH_IMMEDIATE);
+
+$users = $table->findAll();
+
+// or
+
+$users = $conn->query("FROM User-I"); // immediate collection
+
+foreach($users as $user) {
+ print $user->name;
+}
+
+
+$table->setAttribute(Doctrine::ATTR_FETCHMODE, Doctrine::FETCH_LAZY);
+
+$users = $table->findAll();
+
+// or
+
+$users = $conn->query("FROM User-L"); // lazy collection
+
+foreach($users as $user) {
+ print $user->name;
+}
+
+$table->setAttribute(Doctrine::ATTR_FETCHMODE, Doctrine::FETCH_BATCH);
+
+$users = $table->findAll();
+
+// or
+
+$users = $conn->query("FROM User-B"); // batch collection
+
+foreach($users as $user) {
+ print $user->name;
+}
+
+$table->setAttribute(Doctrine::ATTR_FETCHMODE, Doctrine::FETCH_OFFSET);
+
+$users = $table->findAll();
+
+// or
+
+$users = $conn->query("FROM User-O"); // offset collection
+
+foreach($users as $user) {
+ print $user->name;
+}
+
diff --git a/manual/docs/Working with objects - Component overview - Collection - Getting collection count.php b/manual/docs/Working with objects - Component overview - Collection - Getting collection count.php
index 4485a1228..7e494d8a8 100644
--- a/manual/docs/Working with objects - Component overview - Collection - Getting collection count.php
+++ b/manual/docs/Working with objects - Component overview - Collection - Getting collection count.php
@@ -1,11 +1,11 @@
-The Doctrine_Collection method count returns the number of elements currently in the collection.
+The Doctrine_Collection method count returns the number of elements currently in the collection.
-
-$users = $table->findAll();
-
-$users->count();
-
-// or
-
-count($users); // Doctrine_Collection implements Countable interface
-
+
+$users = $table->findAll();
+
+$users->count();
+
+// or
+
+count($users); // Doctrine_Collection implements Countable interface
+
diff --git a/manual/docs/Working with objects - Component overview - Collection - Introduction.php b/manual/docs/Working with objects - Component overview - Collection - Introduction.php
index 2a3cb2703..7b93bb3a0 100644
--- a/manual/docs/Working with objects - Component overview - Collection - Introduction.php
+++ b/manual/docs/Working with objects - Component overview - Collection - Introduction.php
@@ -1,26 +1,30 @@
-Doctrine_Collection is a collection of records (see Doctrine_Record). As with records the collections can be deleted and saved using
-Doctrine_Collection::delete() and Doctrine_Collection::save() accordingly.
-
-$conn = Doctrine_Manager::getInstance()
- ->openConnection(new PDO("dsn", "username", "pw"));
-
-// initalizing a new collection
-$users = new Doctrine_Collection($conn->getTable('User'));
-
-// alternative (propably easier)
-$users = new Doctrine_Collection('User');
-
-// adding some data
-$coll[0]->name = 'Arnold';
-
-$coll[1]->name = 'Somebody';
-
-// finally save it!
-$coll->save();
-
+
+
+When fetching data from database with either DQL API (see Doctrine_Query) or rawSql API (see Doctrine_RawSql) the methods return an instance of
+Doctrine_Collection by default.
+
+
+
+The following example shows how to initialize a new collection:
+
+
+$conn = Doctrine_Manager::getInstance()
+ ->openConnection(new PDO("dsn", "username", "pw"));
+
+// initalizing a new collection
+$users = new Doctrine_Collection($conn->getTable('User'));
+
+// alternative (propably easier)
+$users = new Doctrine_Collection('User');
+
+// adding some data
+$coll[0]->name = 'Arnold';
+
+$coll[1]->name = 'Somebody';
+
+// finally save it!
+$coll->save();
+
diff --git a/manual/docs/Working with objects - Component overview - Collection - Key mapping.php b/manual/docs/Working with objects - Component overview - Collection - Key mapping.php
index 6a3c5ecb2..eb7f0cdcf 100644
--- a/manual/docs/Working with objects - Component overview - Collection - Key mapping.php
+++ b/manual/docs/Working with objects - Component overview - Collection - Key mapping.php
@@ -1,35 +1,35 @@
-Sometimes you may not want to use normal indexing for collection elements. For example in
-some cases mapping primary keys as collection keys might be useful. The following example
-demonstrates how this can be achieved.
+Sometimes you may not want to use normal indexing for collection elements. For example in
+some cases mapping primary keys as collection keys might be useful. The following example
+demonstrates how this can be achieved.
-
-// mapping id column
-
-$user = new User();
-
-$user->setAttribute(Doctrine::ATTR_COLL_KEY, 'id');
-
-// now user collections will use the values of
-// id column as element indexes
-
-$users = $user->getTable()->findAll();
-
-foreach($users as $id => $user) {
- print $id . $user->name;
-}
-
-// mapping name column
-
-$user = new User();
-
-$user->setAttribute(Doctrine::ATTR_COLL_KEY, 'name');
-
-// now user collections will use the values of
-// name column as element indexes
-
-$users = $user->getTable()->findAll();
-
-foreach($users as $name => $user) {
- print $name . $user->type;
-}
-
+
+// mapping id column
+
+$user = new User();
+
+$user->setAttribute(Doctrine::ATTR_COLL_KEY, 'id');
+
+// now user collections will use the values of
+// id column as element indexes
+
+$users = $user->getTable()->findAll();
+
+foreach($users as $id => $user) {
+ print $id . $user->name;
+}
+
+// mapping name column
+
+$user = new User();
+
+$user->setAttribute(Doctrine::ATTR_COLL_KEY, 'name');
+
+// now user collections will use the values of
+// name column as element indexes
+
+$users = $user->getTable()->findAll();
+
+foreach($users as $name => $user) {
+ print $name . $user->type;
+}
+
diff --git a/manual/docs/Working with objects - Component overview - Collection - Loading related records.php b/manual/docs/Working with objects - Component overview - Collection - Loading related records.php
index 1dfed0b19..63053a5e2 100644
--- a/manual/docs/Working with objects - Component overview - Collection - Loading related records.php
+++ b/manual/docs/Working with objects - Component overview - Collection - Loading related records.php
@@ -1,24 +1,24 @@
-Doctrine provides means for effiently retrieving all related records for all record elements. That means
-when you have for example a collection of users you can load all phonenumbers for all users by simple calling
-the loadRelated() method.
+Doctrine provides means for effiently retrieving all related records for all record elements. That means
+when you have for example a collection of users you can load all phonenumbers for all users by simple calling
+the loadRelated() method.
-
-$users = $conn->query("FROM User");
-
-// now lets load phonenumbers for all users
-
-$users->loadRelated("Phonenumber");
-
-foreach($users as $user) {
- print $user->Phonenumber->phonenumber;
- // no additional db queries needed here
-}
-
-// the loadRelated works an any relation, even associations:
-
-$users->loadRelated("Group");
-
-foreach($users as $user) {
- print $user->Group->name;
-}
-
+
+$users = $conn->query("FROM User");
+
+// now lets load phonenumbers for all users
+
+$users->loadRelated("Phonenumber");
+
+foreach($users as $user) {
+ print $user->Phonenumber->phonenumber;
+ // no additional db queries needed here
+}
+
+// the loadRelated works an any relation, even associations:
+
+$users->loadRelated("Group");
+
+foreach($users as $user) {
+ print $user->Group->name;
+}
+
diff --git a/manual/docs/Working with objects - Component overview - Collection - Saving the collection.php b/manual/docs/Working with objects - Component overview - Collection - Saving the collection.php
index cd4e65abb..5ae46c44d 100644
--- a/manual/docs/Working with objects - Component overview - Collection - Saving the collection.php
+++ b/manual/docs/Working with objects - Component overview - Collection - Saving the collection.php
@@ -1,11 +1,11 @@
-As with records the collection can be saved by calling the save method.
+As with records the collection can be saved by calling the save method.
-
-$users = $table->findAll();
-
-$users[0]->name = "Jack Daniels";
-
-$users[1]->name = "John Locke";
-
-$users->save();
-
+
+$users = $table->findAll();
+
+$users[0]->name = "Jack Daniels";
+
+$users[1]->name = "John Locke";
+
+$users->save();
+
diff --git a/manual/docs/Working with objects - Component overview - Connection - Available drivers.php b/manual/docs/Working with objects - Component overview - Connection - Available drivers.php
index 779829fdd..418a5e7f2 100644
--- a/manual/docs/Working with objects - Component overview - Connection - Available drivers.php
+++ b/manual/docs/Working with objects - Component overview - Connection - Available drivers.php
@@ -1,12 +1,12 @@
-Doctrine has drivers for every PDO-supported database. The supported databases are:
-
-$user = new User();
-$user->name = 'Jack';
-
-$group = $conn->create('Group');
-$group->name = 'Drinking Club';
-
-// saves all the changed objects into database
-
-$conn->flush();
-
+
+$user = new User();
+$user->name = 'Jack';
+
+$group = $conn->create('Group');
+$group->name = 'Drinking Club';
+
+// saves all the changed objects into database
+
+$conn->flush();
+
diff --git a/manual/docs/Working with objects - Component overview - Connection - Getting a table object.php b/manual/docs/Working with objects - Component overview - Connection - Getting a table object.php
index bddde1ff0..36fbf92b7 100644
--- a/manual/docs/Working with objects - Component overview - Connection - Getting a table object.php
+++ b/manual/docs/Working with objects - Component overview - Connection - Getting a table object.php
@@ -1,13 +1,13 @@
-In order to get table object for specified record just call Doctrine_Record::getTable() or Doctrine_Connection::getTable().
+In order to get table object for specified record just call Doctrine_Record::getTable() or Doctrine_Connection::getTable().
-
-$manager = Doctrine_Manager::getInstance();
-
-// open new connection
-
-$conn = $manager->openConnection(new PDO('dsn','username','password'));
-
-// getting a table object
-
-$table = $conn->getTable('User');
-
+
+$manager = Doctrine_Manager::getInstance();
+
+// open new connection
+
+$conn = $manager->openConnection(new PDO('dsn','username','password'));
+
+// getting a table object
+
+$table = $conn->getTable('User');
+
diff --git a/manual/docs/Working with objects - Component overview - Connection - Getting connection state.php b/manual/docs/Working with objects - Component overview - Connection - Getting connection state.php
index 671a04b6d..11d41ad4b 100644
--- a/manual/docs/Working with objects - Component overview - Connection - Getting connection state.php
+++ b/manual/docs/Working with objects - Component overview - Connection - Getting connection state.php
@@ -1,19 +1,19 @@
-Connection state gives you information about how active connection currently is. You can get the current state
-by calling Doctrine_Connection::getState().
+Connection state gives you information about how active connection currently is. You can get the current state
+by calling Doctrine_Connection::getState().
-
-switch($conn->getState()):
- case Doctrine_Connection::STATE_ACTIVE:
- // connection open and zero open transactions
- break;
- case Doctrine_Connection::STATE_ACTIVE:
- // one open transaction
- break;
- case Doctrine_Connection::STATE_BUSY:
- // multiple open transactions
- break;
- case Doctrine_Connection::STATE_CLOSED:
- // connection closed
- break;
-endswitch;
-
+
+switch($conn->getState()):
+ case Doctrine_Connection::STATE_ACTIVE:
+ // connection open and zero open transactions
+ break;
+ case Doctrine_Connection::STATE_ACTIVE:
+ // one open transaction
+ break;
+ case Doctrine_Connection::STATE_BUSY:
+ // multiple open transactions
+ break;
+ case Doctrine_Connection::STATE_CLOSED:
+ // connection closed
+ break;
+endswitch;
+
diff --git a/manual/docs/Working with objects - Component overview - Connection - Introduction.php b/manual/docs/Working with objects - Component overview - Connection - Introduction.php
index 6e6dd9235..2fcdce335 100644
--- a/manual/docs/Working with objects - Component overview - Connection - Introduction.php
+++ b/manual/docs/Working with objects - Component overview - Connection - Introduction.php
@@ -1,22 +1,22 @@
-Doctrine_Connection is a wrapper for database connection. It handles several things:
-
-
-// select all users
-
-$users = $conn->query('FROM User');
-
-// select all users where user email is jackdaniels@drinkmore.info
-
-$users = $conn->query("FROM User WHERE User.Email.address = 'jackdaniels@drinkmore.info'");
-
-// using prepared statements
-
-$users = $conn->query('FROM User WHERE User.name = ?', array('Jack'));
-
+
+
+// select all users
+
+$users = $conn->query('FROM User');
+
+// select all users where user email is jackdaniels@drinkmore.info
+
+$users = $conn->query("FROM User WHERE User.Email.address = 'jackdaniels@drinkmore.info'");
+
+// using prepared statements
+
+$users = $conn->query('FROM User WHERE User.name = ?', array('Jack'));
+
diff --git a/manual/docs/Working with objects - Component overview - Db - Chaining listeners.php b/manual/docs/Working with objects - Component overview - Db - Chaining listeners.php
index 85fe6f671..26c0f08b6 100644
--- a/manual/docs/Working with objects - Component overview - Db - Chaining listeners.php
+++ b/manual/docs/Working with objects - Component overview - Db - Chaining listeners.php
@@ -1,42 +1,46 @@
-Doctrine_Db supports event listener chaining. It means multiple listeners can be attached for
-listening the events of a single instance of Doctrine_Db.
-
-
-// using PDO dsn for connecting sqlite memory table
-
-$dbh = Doctrine_Db::getConnection('sqlite::memory:');
-
-class Counter extends Doctrine_Db_EventListener {
- private $queries = 0;
-
- public function onQuery(Doctrine_Db_Event $event) {
- $this->queries++;
- }
- public function count() {
- return count($this->queries);
- }
-}
-class OutputLogger extends Doctrine_Overloadable {
- public function __call($m, $a) {
- print $m." called!";
- }
-}
-$counter = new Counter();
-
-$dbh->addListener($counter);
-$dbh->addListener(new OutputLogger());
-
-$dbh->query("SELECT * FROM foo");
-// prints:
-// onPreQuery called!
-// onQuery called!
-
-print $counter->count(); // 1
-
-
+
+
+For example you might want to add different aspects to your Doctrine_Db instance on-demand. These aspects may include
+caching, query profiling etc.
+
+
+
+
+
+
+
+// using PDO dsn for connecting sqlite memory table
+
+$dbh = Doctrine_Db::getConnection('sqlite::memory:');
+
+class Counter extends Doctrine_Db_EventListener {
+ private $queries = 0;
+
+ public function onQuery(Doctrine_Db_Event $event) {
+ $this->queries++;
+ }
+ public function count() {
+ return count($this->queries);
+ }
+}
+class OutputLogger extends Doctrine_Overloadable {
+ public function __call($m, $a) {
+ print $m." called!";
+ }
+}
+$counter = new Counter();
+
+$dbh->addListener($counter);
+$dbh->addListener(new OutputLogger());
+
+$dbh->query("SELECT * FROM foo");
+// prints:
+// onPreQuery called!
+// onQuery called!
+
+print $counter->count(); // 1
+
+
diff --git a/manual/docs/Working with objects - Component overview - Db - Connecting to a database.php b/manual/docs/Working with objects - Component overview - Db - Connecting to a database.php
index 670d2a3c0..63c6dcc9e 100644
--- a/manual/docs/Working with objects - Component overview - Db - Connecting to a database.php
+++ b/manual/docs/Working with objects - Component overview - Db - Connecting to a database.php
@@ -1,58 +1,73 @@
-
-Doctrine_Db allows both PEAR-like DSN (data source name) as well as PDO like DSN as constructor parameters.
-
-
-// using PDO dsn for connecting sqlite memory table
-
-$dbh = Doctrine_Db::getConnection('sqlite::memory:');
-
-class MyLogger extends Doctrine_Db_EventListener {
- public function onPreQuery(Doctrine_Db_Event $event) {
- print "database is going to be queried!";
- }
- public function onQuery(Doctrine_Db_Event $event) {
- print "executed: " . $event->getQuery();
- }
-}
-
-$dbh->setListener(new MyLogger());
-
-$dbh->query("SELECT * FROM foo");
-// prints:
-// database is going to be queried
-// executed: SELECT * FROM foo
-
-
-class MyLogger2 extends Doctrine_Overloadable {
- public function __call($m, $a) {
- print $m." called!";
- }
-}
-
-$dbh->setListener(new MyLogger2());
-
-$dbh->exec("DELETE FROM foo");
-// prints:
-// onPreExec called!
-// onExec called!
-
+
+
+Every listener object must either implement the Doctrine_Db_EventListener_Interface or Doctrine_Overloadable interface.
+Using Doctrine_Overloadable interface
+only requires you to implement __call() which is then used for listening all the events.
+
+
+";
+renderCode($str);
+?>
+
+
+
+For convience
+you may want to make your listener class extend Doctrine_Db_EventListener which has empty listener methods, hence allowing you not to define
+all the listener methods by hand. The following listener, 'MyLogger', is used for listening only onPreQuery and onQuery methods.
+
+
+getQuery();
+ }
+}
+?>";
+renderCode($str);
+?>
+
+
+
+Now the next thing we need to do is bind the eventlistener objects to our database handler.
+
+
+
+
+
+
+// using PDO dsn for connecting sqlite memory table
+
+$dbh = Doctrine_Db::getConnection('sqlite::memory:');
+
+class MyLogger extends Doctrine_Db_EventListener {
+ public function onPreQuery(Doctrine_Db_Event $event) {
+ print "database is going to be queried!";
+ }
+ public function onQuery(Doctrine_Db_Event $event) {
+ print "executed: " . $event->getQuery();
+ }
+}
+
+$dbh->setListener(new MyLogger());
+
+$dbh->query("SELECT * FROM foo");
+// prints:
+// database is going to be queried
+// executed: SELECT * FROM foo
+
+
+class MyLogger2 extends Doctrine_Overloadable {
+ public function __call($m, $a) {
+ print $m." called!";
+ }
+}
+
+$dbh->setListener(new MyLogger2());
+
+$dbh->exec("DELETE FROM foo");
+// prints:
+// onPreExec called!
+// onExec called!
+
diff --git a/manual/docs/Working with objects - Component overview - Exceptions - List of exceptions.php b/manual/docs/Working with objects - Component overview - Exceptions - List of exceptions.php
index 453f5fd76..cefd6b053 100644
--- a/manual/docs/Working with objects - Component overview - Exceptions - List of exceptions.php
+++ b/manual/docs/Working with objects - Component overview - Exceptions - List of exceptions.php
@@ -1,25 +1,25 @@
--InvalidKeyException - -Doctrine_Exception - -DQLException - -Doctrine_PrimaryKey_Exception thrown when Doctrine_Record is loaded and there is no primary key field - -Doctrine_Refresh_Exception thrown when Doctrine_Record is refreshed and the refreshed primary key doens't match the old one - -Doctrine_Find_Exception thrown when user tries to find a Doctrine_Record for given primary key and that object is not found - -Doctrine_Naming_Exception thrown when user defined Doctrine_Table is badly named - - -Doctrine_Connection_Exception thrown when user tries to get the current - connection and there are no open connections - -Doctrine_Table_Exception thrown when user tries to initialize a new instance of Doctrine_Table, - while there already exists an instance of that factory - -Doctrine_Mapping_Exception thrown when user tries to get a foreign key object but the mapping is not done right -+
+InvalidKeyException + +Doctrine_Exception + +DQLException + +Doctrine_PrimaryKey_Exception thrown when Doctrine_Record is loaded and there is no primary key field + +Doctrine_Refresh_Exception thrown when Doctrine_Record is refreshed and the refreshed primary key doens't match the old one + +Doctrine_Find_Exception thrown when user tries to find a Doctrine_Record for given primary key and that object is not found + +Doctrine_Naming_Exception thrown when user defined Doctrine_Table is badly named + + +Doctrine_Connection_Exception thrown when user tries to get the current + connection and there are no open connections + +Doctrine_Table_Exception thrown when user tries to initialize a new instance of Doctrine_Table, + while there already exists an instance of that factory + +Doctrine_Mapping_Exception thrown when user tries to get a foreign key object but the mapping is not done right +diff --git a/manual/docs/Working with objects - Component overview - Manager - Introduction.php b/manual/docs/Working with objects - Component overview - Manager - Introduction.php index e6c4f534b..d89222fc1 100644 --- a/manual/docs/Working with objects - Component overview - Manager - Introduction.php +++ b/manual/docs/Working with objects - Component overview - Manager - Introduction.php @@ -1,2 +1,2 @@ -Doctrine_Manager is the heart of every Doctrine based application. Doctrine_Manager handles all connections (database connections). +Doctrine_Manager is the heart of every Doctrine based application. Doctrine_Manager handles all connections (database connections). diff --git a/manual/docs/Working with objects - Component overview - Manager - Managing connections.php b/manual/docs/Working with objects - Component overview - Manager - Managing connections.php index b97a00edb..89c0dcfde 100644 --- a/manual/docs/Working with objects - Component overview - Manager - Managing connections.php +++ b/manual/docs/Working with objects - Component overview - Manager - Managing connections.php @@ -1,29 +1,29 @@ -Switching between connections in Doctrine is very easy, you just call Doctrine_Manager::setCurrentConnection() method. -You can access the connection by calling Doctrine_Manager::getConnection() or Doctrine_Manager::getCurrentConnection() if you only -want to get the current connection. +Switching between connections in Doctrine is very easy, you just call Doctrine_Manager::setCurrentConnection() method. +You can access the connection by calling Doctrine_Manager::getConnection() or Doctrine_Manager::getCurrentConnection() if you only +want to get the current connection. -
-// Doctrine_Manager controls all the connections
-
-$manager = Doctrine_Manager::getInstance();
-
-// open first connection
-
-$conn = $manager->openConnection(new PDO('dsn','username','password'), 'connection 1');
-
-// open second connection
-
-$conn2 = $manager->openConnection(new PDO('dsn2','username2','password2'), 'connection 2');
-
-$manager->getCurrentConnection(); // $conn2
-
-$manager->setCurrentConnection('connection 1');
-
-$manager->getCurrentConnection(); // $conn
-
-// iterating through connections
-
-foreach($manager as $conn) {
-
-}
-
+
+// Doctrine_Manager controls all the connections
+
+$manager = Doctrine_Manager::getInstance();
+
+// open first connection
+
+$conn = $manager->openConnection(new PDO('dsn','username','password'), 'connection 1');
+
+// open second connection
+
+$conn2 = $manager->openConnection(new PDO('dsn2','username2','password2'), 'connection 2');
+
+$manager->getCurrentConnection(); // $conn2
+
+$manager->setCurrentConnection('connection 1');
+
+$manager->getCurrentConnection(); // $conn
+
+// iterating through connections
+
+foreach($manager as $conn) {
+
+}
+
diff --git a/manual/docs/Working with objects - Component overview - Manager - Opening a new connection.php b/manual/docs/Working with objects - Component overview - Manager - Opening a new connection.php
index 4b3759813..22a1a7e41 100644
--- a/manual/docs/Working with objects - Component overview - Manager - Opening a new connection.php
+++ b/manual/docs/Working with objects - Component overview - Manager - Opening a new connection.php
@@ -1,22 +1,22 @@
-In order to get your first application started you first
-need to get an instance of Doctrine_Manager which handles all the connections (database connections).
-The second thing to do is to open a new connection.
+In order to get your first application started you first
+need to get an instance of Doctrine_Manager which handles all the connections (database connections).
+The second thing to do is to open a new connection.
-
-// Doctrine_Manager controls all the connections
-
-$manager = Doctrine_Manager::getInstance();
-
-// Doctrine_Connection
-// a script may have multiple open connections
-// (= multiple database connections)
-$dbh = new PDO('dsn','username','password');
-$conn = $manager->openConnection();
-
-// or if you want to use Doctrine Doctrine_Db and its
-// performance monitoring capabilities
-
-$dsn = 'schema://username:password@dsn/dbname';
-$dbh = Doctrine_Db::getConnection($dsn);
-$conn = $manager->openConnection();
-
+
+// Doctrine_Manager controls all the connections
+
+$manager = Doctrine_Manager::getInstance();
+
+// Doctrine_Connection
+// a script may have multiple open connections
+// (= multiple database connections)
+$dbh = new PDO('dsn','username','password');
+$conn = $manager->openConnection();
+
+// or if you want to use Doctrine Doctrine_Db and its
+// performance monitoring capabilities
+
+$dsn = 'schema://username:password@dsn/dbname';
+$dbh = Doctrine_Db::getConnection($dsn);
+$conn = $manager->openConnection();
+
diff --git a/manual/docs/Working with objects - Component overview - Query - Aggregate functions.php b/manual/docs/Working with objects - Component overview - Query - Aggregate functions.php
index f8ffe17ff..b5db6f348 100644
--- a/manual/docs/Working with objects - Component overview - Query - Aggregate functions.php
+++ b/manual/docs/Working with objects - Component overview - Query - Aggregate functions.php
@@ -1,16 +1,16 @@
-
-$q = new Doctrine_Query();
-
-$q->from('User(COUNT(id))');
-
-// returns an array
-$a = $q->execute();
-
-// selecting multiple aggregate values:
-$q = new Doctrine_Query();
-
-$q->from('User(COUNT(id)).Phonenumber(MAX(phonenumber))');
-
-$a = $q->execute();
-
+
+$q = new Doctrine_Query();
+
+$q->from('User(COUNT(id))');
+
+// returns an array
+$a = $q->execute();
+
+// selecting multiple aggregate values:
+$q = new Doctrine_Query();
+
+$q->from('User(COUNT(id)).Phonenumber(MAX(phonenumber))');
+
+$a = $q->execute();
+
diff --git a/manual/docs/Working with objects - Component overview - Query - Bound parameters.php b/manual/docs/Working with objects - Component overview - Query - Bound parameters.php
index 9c47359e6..1985b8f04 100644
--- a/manual/docs/Working with objects - Component overview - Query - Bound parameters.php
+++ b/manual/docs/Working with objects - Component overview - Query - Bound parameters.php
@@ -1,7 +1,7 @@
-
-$query->from("User")
- ->where("User.name = ?");
-
-$query->execute(array('Jack Daniels'));
-
+
+$query->from("User")
+ ->where("User.name = ?");
+
+$query->execute(array('Jack Daniels'));
+
diff --git a/manual/docs/Working with objects - Component overview - Query - DQL - SQL conversion.php b/manual/docs/Working with objects - Component overview - Query - DQL - SQL conversion.php
index 8c597c207..e68c79aed 100644
--- a/manual/docs/Working with objects - Component overview - Query - DQL - SQL conversion.php
+++ b/manual/docs/Working with objects - Component overview - Query - DQL - SQL conversion.php
@@ -1,58 +1,63 @@
-SELECT",$line);
- $l = str_replace("FROM","
-// find all groups
-
-$coll = $q->from("FROM Group");
-
-// find all users and user emails
-
-$coll = $q->from("FROM User u LEFT JOIN u.Email e");
-
-// find all users and user emails with only user name and
-// age + email address loaded
-
-$coll = $q->select('u.name, u.age, e.address')
- ->from('FROM User u')
- ->leftJoin('u.Email e')
- ->execute();
-
-// find all users, user email and user phonenumbers
-
-$coll = $q->from('FROM User u')
- ->innerJoin('u.Email e')
- ->innerJoin('u.Phonenumber p')
- ->execute();
-
+
+
+
+// find all users
+\$q = new Doctrine_Query();
+
+\$coll = \$q->from('User')->execute();
+
+// find all users with only their names (and primary keys) fetched
+
+\$coll = \$q->select('u.name')->('User u');
+?>
+
+
+The following example shows how to use leftJoin and innerJoin methods:
+
+
+
+
+// find all groups
+
+$coll = $q->from("FROM Group");
+
+// find all users and user emails
+
+$coll = $q->from("FROM User u LEFT JOIN u.Email e");
+
+// find all users and user emails with only user name and
+// age + email address loaded
+
+$coll = $q->select('u.name, u.age, e.address')
+ ->from('FROM User u')
+ ->leftJoin('u.Email e')
+ ->execute();
+
+// find all users, user email and user phonenumbers
+
+$coll = $q->from('FROM User u')
+ ->innerJoin('u.Email e')
+ ->innerJoin('u.Phonenumber p')
+ ->execute();
+
diff --git a/manual/docs/Working with objects - Component overview - Query - Fetching strategies.php b/manual/docs/Working with objects - Component overview - Query - Fetching strategies.php
index beb54fe92..5c73a8e9c 100644
--- a/manual/docs/Working with objects - Component overview - Query - Fetching strategies.php
+++ b/manual/docs/Working with objects - Component overview - Query - Fetching strategies.php
@@ -1,26 +1,26 @@
-
-// select all users and load the data directly (Immediate fetching strategy)
-
-$coll = $conn->query("FROM User-I");
-
-// or
-
-$coll = $conn->query("FROM User-IMMEDIATE");
-
-// select all users and load the data in batches
-
-$coll = $conn->query("FROM User-B");
-
-// or
-
-$coll = $conn->query("FROM User-BATCH");
-
-// select all user and use lazy fetching
-
-$coll = $conn->query("FROM User-L");
-
-// or
-
-$coll = $conn->query("FROM User-LAZY");
-
+
+// select all users and load the data directly (Immediate fetching strategy)
+
+$coll = $conn->query("FROM User-I");
+
+// or
+
+$coll = $conn->query("FROM User-IMMEDIATE");
+
+// select all users and load the data in batches
+
+$coll = $conn->query("FROM User-B");
+
+// or
+
+$coll = $conn->query("FROM User-BATCH");
+
+// select all user and use lazy fetching
+
+$coll = $conn->query("FROM User-L");
+
+// or
+
+$coll = $conn->query("FROM User-LAZY");
+
diff --git a/manual/docs/Working with objects - Component overview - Query - HAVING conditions.php b/manual/docs/Working with objects - Component overview - Query - HAVING conditions.php
index 413e320ec..b7510f011 100644
--- a/manual/docs/Working with objects - Component overview - Query - HAVING conditions.php
+++ b/manual/docs/Working with objects - Component overview - Query - HAVING conditions.php
@@ -1,15 +1,17 @@
-
-Doctrine_Query provides having() method for adding HAVING conditions to the DQL query. This method is identical in function to the Doctrine_Query::where() method.
-
+\$q = new Doctrine_Query();
+
+\$users = \$q->select('u.name')
+ ->from('User u')
+ ->leftJoin('u.Phonenumber p');
+ ->having('COUNT(p.id) > 3');
+?>
diff --git a/manual/docs/Working with objects - Component overview - Query - Introduction.php b/manual/docs/Working with objects - Component overview - Query - Introduction.php
index 9294fd6bd..71146fc3e 100644
--- a/manual/docs/Working with objects - Component overview - Query - Introduction.php
+++ b/manual/docs/Working with objects - Component overview - Query - Introduction.php
@@ -1,22 +1,24 @@
-
-DQL (Doctrine Query Language) is a object query language which allows
-you to find objects. DQL understands things like object relationships, polymorphism and
-inheritance (including column aggregation inheritance).
-For more info about DQL see the actual DQL chapter.
-
-// initalizing a new Doctrine_Query (using the current connection)
-$q = new Doctrine_Query();
-
-// initalizing a new Doctrine_Query (using custom connection parameter)
-// here $conn is an instance of Doctrine_Connection
-$q = new Doctrine_Query($conn);
-
-// an example using the create method
-// here we simple fetch all users
-$users = Doctrine_Query::create()->from('User')->execute();
-
+
+
+Doctrine_Query along with Doctrine_Expression provide an easy-to-use wrapper for writing DQL queries. Creating a new
+query object can be done by either using the new operator or by calling create method. The create method exists for allowing easy
+method call chaining.
+
+
+// initalizing a new Doctrine_Query (using the current connection)
+$q = new Doctrine_Query();
+
+// initalizing a new Doctrine_Query (using custom connection parameter)
+// here $conn is an instance of Doctrine_Connection
+$q = new Doctrine_Query($conn);
+
+// an example using the create method
+// here we simple fetch all users
+$users = Doctrine_Query::create()->from('User')->execute();
+
diff --git a/manual/docs/Working with objects - Component overview - Query - LIMIT and OFFSET - limiting the query results.php b/manual/docs/Working with objects - Component overview - Query - LIMIT and OFFSET - limiting the query results.php
index ffd0993fc..34e42ab3e 100644
--- a/manual/docs/Working with objects - Component overview - Query - LIMIT and OFFSET - limiting the query results.php
+++ b/manual/docs/Working with objects - Component overview - Query - LIMIT and OFFSET - limiting the query results.php
@@ -1,14 +1,14 @@
-
-
-// find the first ten users and associated emails
-
-$q = new Doctrine_Query();
-
-$coll = $q->from('User u LEFT JOIN u.Email e')->limit(10);
-
-// find the first ten users starting from the user number 5
-
-$coll = $q->from('User u')->limit(10)->offset(5);
-
-
+
+
+// find the first ten users and associated emails
+
+$q = new Doctrine_Query();
+
+$coll = $q->from('User u LEFT JOIN u.Email e')->limit(10);
+
+// find the first ten users starting from the user number 5
+
+$coll = $q->from('User u')->limit(10)->offset(5);
+
+
diff --git a/manual/docs/Working with objects - Component overview - Query - Lazy property fetching.php b/manual/docs/Working with objects - Component overview - Query - Lazy property fetching.php
index 2608e2c30..777285716 100644
--- a/manual/docs/Working with objects - Component overview - Query - Lazy property fetching.php
+++ b/manual/docs/Working with objects - Component overview - Query - Lazy property fetching.php
@@ -1,7 +1,7 @@
-
-
-// retrieve all users with only their properties id and name loaded
-
-$users = $conn->query("FROM User(id, name)");
-
+
+
+// retrieve all users with only their properties id and name loaded
+
+$users = $conn->query("FROM User(id, name)");
+
diff --git a/manual/docs/Working with objects - Component overview - Query - Method overloading.php b/manual/docs/Working with objects - Component overview - Query - Method overloading.php
index 7118ce5e1..ac9a8f05f 100644
--- a/manual/docs/Working with objects - Component overview - Query - Method overloading.php
+++ b/manual/docs/Working with objects - Component overview - Query - Method overloading.php
@@ -1,22 +1,22 @@
-You can overload the query object by calling the dql query parts as methods.
+You can overload the query object by calling the dql query parts as methods.
-
-$conn = Doctrine_Manager::getInstance()->openConnection(new PDO("dsn","username","password"));
-
-$query = new Doctrine_Query($conn);
-
-$query->from("User-b")
- ->where("User.name LIKE 'Jack%'")
- ->orderby("User.created")
- ->limit(5);
-
-$users = $query->execute();
-
-$query->from("User.Group.Phonenumber")
- ->where("User.Group.name LIKE 'Actors%'")
- ->orderby("User.name")
- ->limit(10)
- ->offset(5);
-
-$users = $query->execute();
-
+
+$conn = Doctrine_Manager::getInstance()->openConnection(new PDO("dsn","username","password"));
+
+$query = new Doctrine_Query($conn);
+
+$query->from("User-b")
+ ->where("User.name LIKE 'Jack%'")
+ ->orderby("User.created")
+ ->limit(5);
+
+$users = $query->execute();
+
+$query->from("User.Group.Phonenumber")
+ ->where("User.Group.name LIKE 'Actors%'")
+ ->orderby("User.name")
+ ->limit(10)
+ ->offset(5);
+
+$users = $query->execute();
+
diff --git a/manual/docs/Working with objects - Component overview - Query - ORDER BY - sorting query results.php b/manual/docs/Working with objects - Component overview - Query - ORDER BY - sorting query results.php
index f772c4b76..8cd3016d4 100644
--- a/manual/docs/Working with objects - Component overview - Query - ORDER BY - sorting query results.php
+++ b/manual/docs/Working with objects - Component overview - Query - ORDER BY - sorting query results.php
@@ -1,25 +1,25 @@
-ORDER BY - part works in much same way as SQL ORDER BY.
+ORDER BY - part works in much same way as SQL ORDER BY.
-
-$q = new Doctrine_Query();
-
-// find all users, sort by name descending
-
-$users = $q->from('User u')->orderby('u.name DESC');
-
-// find all users sort by name ascending
-
-$users = $q->from('User u')->orderby('u.name ASC');
-
-// find all users and their emails, sort by email address in ascending order
-
-$users = $q->from('User u')->leftJoin('u.Email e')->orderby('e.address');
-
-// find all users and their emails, sort by user name and email address
-
-$users = $q->from('User u')->leftJoin('u.Email e')
- ->addOrderby('u.name')->addOrderby('e.address');
+
+$q = new Doctrine_Query();
+
+// find all users, sort by name descending
+
+$users = $q->from('User u')->orderby('u.name DESC');
+
+// find all users sort by name ascending
+
+$users = $q->from('User u')->orderby('u.name ASC');
+
+// find all users and their emails, sort by email address in ascending order
+
+$users = $q->from('User u')->leftJoin('u.Email e')->orderby('e.address');
+
+// find all users and their emails, sort by user name and email address
+
+$users = $q->from('User u')->leftJoin('u.Email e')
+ ->addOrderby('u.name')->addOrderby('e.address');
// grab randomly 10 users
$users = $q->select('u.*, RAND() rand')->from('User u')->limit(10)->orderby('rand DESC');
-
+
diff --git a/manual/docs/Working with objects - Component overview - Query - Relation operators.php b/manual/docs/Working with objects - Component overview - Query - Relation operators.php
index a9aabdde7..6886e3ad0 100644
--- a/manual/docs/Working with objects - Component overview - Query - Relation operators.php
+++ b/manual/docs/Working with objects - Component overview - Query - Relation operators.php
@@ -1,23 +1,27 @@
-Doctrine provides two relation operators: '.' aka dot and ':' aka colon.
-
-$query->from('User u')->innerJoin('u.Email e');
-
-$query->execute();
-
-// executed SQL query:
-// SELECT ... FROM user INNER JOIN email ON ...
-
-$query->from('User u')->leftJoin('u.Email e');
-
-$query->execute();
-
-// executed SQL query:
-// SELECT ... FROM user LEFT JOIN email ON ...
-
+
+
+The dot-operator is used for SQL LEFT JOINs and the colon-operator is used
+for SQL INNER JOINs. Basically you should use dot operator if you want for example
+to select all users and their phonenumbers AND it doesn't matter if the users actually have any phonenumbers.
+
+
+
+On the other hand if you want to select only the users which actually have phonenumbers you should use the colon-operator.
+
+
+$query->from('User u')->innerJoin('u.Email e');
+
+$query->execute();
+
+// executed SQL query:
+// SELECT ... FROM user INNER JOIN email ON ...
+
+$query->from('User u')->leftJoin('u.Email e');
+
+$query->execute();
+
+// executed SQL query:
+// SELECT ... FROM user LEFT JOIN email ON ...
+
diff --git a/manual/docs/Working with objects - Component overview - Query - WHERE - setting query conditions.php b/manual/docs/Working with objects - Component overview - Query - WHERE - setting query conditions.php
index b92f2f9f3..931b3405d 100644
--- a/manual/docs/Working with objects - Component overview - Query - WHERE - setting query conditions.php
+++ b/manual/docs/Working with objects - Component overview - Query - WHERE - setting query conditions.php
@@ -1,61 +1,63 @@
-
-The WHERE clause, if given, indicates the condition or conditions that the records must satisfy to be selected.
-
-Doctrine_Query provides easy to use WHERE -part management methods where and addWhere. The where methods always overrides
-the query WHERE -part whereas addWhere adds new condition to the WHERE -part stack.
-
+// find all groups where the group primary key is bigger than 10
+
+\$coll = \$q->from('Group')->where('Group.id > 10');
+
+// the same query using Doctrine_Expression component
+\$e = \$q->expr;
+\$coll = \$q->from('Group')->where(\$e->gt('Group.id', 10));
+?>
+
+
+
+Using regular expression operator:
+
+
+
+// find all users where users where user name matches
+// a regular expression, regular expressions must be
+// supported by the underlying database
+
+\$coll = \$conn->query(\"FROM User WHERE User.name REGEXP '[ad]'\
+
+
+
+DQL has support for portable LIKE operator:
+
+
+
+// find all users and their associated emails
+// where SOME of the users phonenumbers
+// (the association between user and phonenumber
+// tables is One-To-Many) starts with 123
+
+\$coll = \$q->select('u.*, e.*')
+ ->from('User u LEFT JOIN u.Email e LEFT JOIN u.Phonenumber p')
+ ->where(\"p.phonenumber LIKE '123%'\
+
+
+
+Using multiple conditions and condition nesting are also possible:
+
+
+
+// multiple conditions
+
+\$coll = \$q->select('u.*')
+ ->from('User u LEFT JOIN u.Email e')
+ ->where(\"u.name LIKE '%Jack%' AND e.address LIKE '%@drinkmore.info'\");
+
+// nesting conditions
+
+\$coll = \$q->select('u.*')
+ ->from('User u LEFT JOIN u.Email e')
+ ->where(\"u.name LIKE '%Jack%' OR u.name LIKE '%John%') AND e.address LIKE '%@drinkmore.info'\
+
-
diff --git a/manual/docs/Working with objects - Component overview - RawSql - Adding components.php b/manual/docs/Working with objects - Component overview - RawSql - Adding components.php
index 8f30e9f5f..cfd8abbd5 100644
--- a/manual/docs/Working with objects - Component overview - RawSql - Adding components.php
+++ b/manual/docs/Working with objects - Component overview - RawSql - Adding components.php
@@ -1,20 +1,24 @@
-The following example represents a bit harder case where we select all entities and their associated phonenumbers using a left join. Again we
-wrap all the columns in curly brackets but we also specify what tables associate to which components.
-
-$query = new Doctrine_RawSql($conn);
-
-$query->parseQuery("SELECT {entity.*}, {phonenumber.*}
- FROM entity
- LEFT JOIN phonenumber
- ON phonenumber.entity_id = entity.id");
-
-$query->addComponent("entity", "Entity");
-$query->addComponent("phonenumber", "Entity.Phonenumber");
-
-$entities = $query->execute();
-
+
+
+First we specify that table entity maps to record class 'Entity'
+
+
+
+Then we specify that table phonenumber maps to Entity.Phonenumber (meaning phonenumber associated with an entity)
+
+
+$query = new Doctrine_RawSql($conn);
+
+$query->parseQuery("SELECT {entity.*}, {phonenumber.*}
+ FROM entity
+ LEFT JOIN phonenumber
+ ON phonenumber.entity_id = entity.id");
+
+$query->addComponent("entity", "Entity");
+$query->addComponent("phonenumber", "Entity.Phonenumber");
+
+$entities = $query->execute();
+
diff --git a/manual/docs/Working with objects - Component overview - RawSql - Introduction.php b/manual/docs/Working with objects - Component overview - RawSql - Introduction.php
index b342e3b41..119940f3a 100644
--- a/manual/docs/Working with objects - Component overview - RawSql - Introduction.php
+++ b/manual/docs/Working with objects - Component overview - RawSql - Introduction.php
@@ -1,5 +1,7 @@
-In Doctrine you may express your queries in the native SQL dialect of your database.
-This is useful if you want to use the full power of your database vendor's features (like query hints or the CONNECT keyword in Oracle).
-
-$query = new Doctrine_RawSql($conn);
-
-$query->select('{entity.name}')
- ->from('entity');
-
-$query->addComponent("entity", "User");
-
-$coll = $query->execute();
-
+
+$query = new Doctrine_RawSql($conn);
+
+$query->select('{entity.name}')
+ ->from('entity');
+
+$query->addComponent("entity", "User");
+
+$coll = $query->execute();
+
diff --git a/manual/docs/Working with objects - Component overview - RawSql - Using SQL.php b/manual/docs/Working with objects - Component overview - RawSql - Using SQL.php
index a22567f39..350dfcf36 100644
--- a/manual/docs/Working with objects - Component overview - RawSql - Using SQL.php
+++ b/manual/docs/Working with objects - Component overview - RawSql - Using SQL.php
@@ -1,18 +1,24 @@
-The rawSql component works in much same way as Zend_Db_Select. You may use method overloading like $q->from()->where() or just use
-$q->parseQuery(). There are some differences though:
-
-$query = new Doctrine_RawSql($conn);
-
-$query->parseQuery("SELECT {entity.name} FROM entity");
-
-$entities = $query->execute();
-
+
+
+1. In Doctrine_RawSql component you need to specify all the mapped table columns in curly brackets {} this is used for smart column aliasing.
+
+
+
+2. When joining multiple tables you need to specify the component paths with addComponent() method
+
+
+
+The following example represents a very simple case where no addComponent() calls are needed.
+Here we select all entities from table entity with all the columns loaded in the records.
+
+
+
+$query = new Doctrine_RawSql($conn);
+
+$query->parseQuery("SELECT {entity.name} FROM entity");
+
+$entities = $query->execute();
+
diff --git a/manual/docs/Working with objects - Component overview - Record - Accessing properties.php b/manual/docs/Working with objects - Component overview - Record - Accessing properties.php
index 54c744d9c..0e9f4f2cb 100644
--- a/manual/docs/Working with objects - Component overview - Record - Accessing properties.php
+++ b/manual/docs/Working with objects - Component overview - Record - Accessing properties.php
@@ -1,25 +1,25 @@
-You can retrieve existing objects (database rows) with Doctrine_Table or Doctrine_Connection.
-Doctrine_Table provides simple methods like findBySql, findAll and find for finding objects whereas
-Doctrine_Connection provides complete OQL API for retrieving objects (see chapter 9).
+You can retrieve existing objects (database rows) with Doctrine_Table or Doctrine_Connection.
+Doctrine_Table provides simple methods like findBySql, findAll and find for finding objects whereas
+Doctrine_Connection provides complete OQL API for retrieving objects (see chapter 9).
-
-$user = $table->find(3);
-
-// access property through overloading
-
-$name = $user->name;
-
-// access property with get()
-
-$name = $user->get("name");
-
-// access property with ArrayAccess interface
-
-$name = $user['name'];
-
-// iterating through properties
-
-foreach($user as $key => $value) {
-
-}
-
+
+$user = $table->find(3);
+
+// access property through overloading
+
+$name = $user->name;
+
+// access property with get()
+
+$name = $user->get("name");
+
+// access property with ArrayAccess interface
+
+$name = $user['name'];
+
+// iterating through properties
+
+foreach($user as $key => $value) {
+
+}
+
diff --git a/manual/docs/Working with objects - Component overview - Record - Adding records.php b/manual/docs/Working with objects - Component overview - Record - Adding records.php
index b766d4b09..074911bcc 100644
--- a/manual/docs/Working with objects - Component overview - Record - Adding records.php
+++ b/manual/docs/Working with objects - Component overview - Record - Adding records.php
@@ -1,3 +1,3 @@
-There are three possible ways to access the properties of a record (fields of database row).
-You can use overloading, ArrayAccess interface or simply Doctrine_Record::get() method.
-Doctrine_Record objects have always all properties in lowercase.
+There are three possible ways to access the properties of a record (fields of database row).
+You can use overloading, ArrayAccess interface or simply Doctrine_Record::get() method.
+**Doctrine_Record objects have always all properties in lowercase**.
diff --git a/manual/docs/Working with objects - Component overview - Record - Checking Existence.php b/manual/docs/Working with objects - Component overview - Record - Checking Existence.php
index a3cb7fab4..3048d6392 100644
--- a/manual/docs/Working with objects - Component overview - Record - Checking Existence.php
+++ b/manual/docs/Working with objects - Component overview - Record - Checking Existence.php
@@ -1,11 +1,11 @@
-
-$record = new User();
-
-$record->exists(); // false
-
-$record->name = 'someone';
-$record->save();
-
-$record->exists(); // true
-
+
+$record = new User();
+
+$record->exists(); // false
+
+$record->name = 'someone';
+$record->save();
+
+$record->exists(); // true
+
diff --git a/manual/docs/Working with objects - Component overview - Record - Creating new records.php b/manual/docs/Working with objects - Component overview - Record - Creating new records.php
index 28816254e..493eff574 100644
--- a/manual/docs/Working with objects - Component overview - Record - Creating new records.php
+++ b/manual/docs/Working with objects - Component overview - Record - Creating new records.php
@@ -1,24 +1,24 @@
-There are couple of ways for creating new records. Propably the easiest is using
-native php new -operator. The other ways are calling Doctrine_Table::create() or Doctrine_Connection::create().
-The last two exists only for backward compatibility. The recommended way of creating new objects is the new operator.
+There are couple of ways for creating new records. Propably the easiest is using
+native php new -operator. The other ways are calling Doctrine_Table::create() or Doctrine_Connection::create().
+The last two exists only for backward compatibility. The recommended way of creating new objects is the new operator.
-
-$user = $conn->create("User");
-
-// alternative way:
-
-$table = $conn->getTable("User");
-
-$user = $table->create();
-
-// the simpliest way:
-
-$user = new User();
-
-
-// records support array access
-$user["name"] = "John Locke";
-
-// save user into database
-$user->save();
-
+
+$user = $conn->create("User");
+
+// alternative way:
+
+$table = $conn->getTable("User");
+
+$user = $table->create();
+
+// the simpliest way:
+
+$user = new User();
+
+
+// records support array access
+$user["name"] = "John Locke";
+
+// save user into database
+$user->save();
+
diff --git a/manual/docs/Working with objects - Component overview - Record - Deleting records.php b/manual/docs/Working with objects - Component overview - Record - Deleting records.php
index 31d99e38f..a3aa602be 100644
--- a/manual/docs/Working with objects - Component overview - Record - Deleting records.php
+++ b/manual/docs/Working with objects - Component overview - Record - Deleting records.php
@@ -1,19 +1,19 @@
-Deleting records in Doctrine is handled by Doctrine_Record::delete(), Doctrine_Collection::delete() and
-Doctrine_Connection::delete() methods.
+Deleting records in Doctrine is handled by Doctrine_Record::delete(), Doctrine_Collection::delete() and
+Doctrine_Connection::delete() methods.
-
-$table = $conn->getTable("User");
-
-$user = $table->find(2);
-
-// deletes user and all related composite objects
-if($user !== false)
- $user->delete();
-
-
-$users = $table->findAll();
-
-
-// delete all users and their related composite objects
-$users->delete();
-
+
+$table = $conn->getTable("User");
+
+$user = $table->find(2);
+
+// deletes user and all related composite objects
+if($user !== false)
+ $user->delete();
+
+
+$users = $table->findAll();
+
+
+// delete all users and their related composite objects
+$users->delete();
+
diff --git a/manual/docs/Working with objects - Component overview - Record - Getting object copy.php b/manual/docs/Working with objects - Component overview - Record - Getting object copy.php
index ff008f2ec..a5243e670 100644
--- a/manual/docs/Working with objects - Component overview - Record - Getting object copy.php
+++ b/manual/docs/Working with objects - Component overview - Record - Getting object copy.php
@@ -1,6 +1,6 @@
-Sometimes you may want to get a copy of your object (a new object with all properties copied).
-Doctrine provides a simple method for this: Doctrine_Record::copy().
+Sometimes you may want to get a copy of your object (a new object with all properties copied).
+Doctrine provides a simple method for this: Doctrine_Record::copy().
-
-$copy = $user->copy();
-
+
+$copy = $user->copy();
+
diff --git a/manual/docs/Working with objects - Component overview - Record - Getting record state.php b/manual/docs/Working with objects - Component overview - Record - Getting record state.php
index 76d130cea..c822c2d13 100644
--- a/manual/docs/Working with objects - Component overview - Record - Getting record state.php
+++ b/manual/docs/Working with objects - Component overview - Record - Getting record state.php
@@ -1,39 +1,41 @@
-Every Doctrine_Record has a state. First of all record can be transient or persistent.
-Every record that is retrieved from database is persistent and every newly created record is transient.
-If a Doctrine_Record is retrieved from database but the only loaded property is its primary key, then this record
-has a state called proxy.
-
-$state = $record->getState();
-
-switch($state):
- case Doctrine_Record::STATE_PROXY:
- // record is in proxy state,
- // meaning its persistent but not all of its properties are
- // loaded from the database
- break;
- case Doctrine_Record::STATE_TCLEAN:
- // record is transient clean,
- // meaning its transient and
- // none of its properties are changed
- break;
- case Doctrine_Record::STATE_TDIRTY:
- // record is transient dirty,
- // meaning its transient and
- // some of its properties are changed
- break;
- case Doctrine_Record::STATE_DIRTY:
- // record is dirty,
- // meaning its persistent and
- // some of its properties are changed
- break;
- case Doctrine_Record::STATE_CLEAN:
- // record is clean,
- // meaning its persistent and
- // none of its properties are changed
- break;
-endswitch;
-
+
+
+Every transient and persistent Doctrine_Record is either clean or dirty. Doctrine_Record is clean when none of its properties are changed and
+dirty when atleast one of its properties has changed.
+
+
+$state = $record->getState();
+
+switch($state):
+ case Doctrine_Record::STATE_PROXY:
+ // record is in proxy state,
+ // meaning its persistent but not all of its properties are
+ // loaded from the database
+ break;
+ case Doctrine_Record::STATE_TCLEAN:
+ // record is transient clean,
+ // meaning its transient and
+ // none of its properties are changed
+ break;
+ case Doctrine_Record::STATE_TDIRTY:
+ // record is transient dirty,
+ // meaning its transient and
+ // some of its properties are changed
+ break;
+ case Doctrine_Record::STATE_DIRTY:
+ // record is dirty,
+ // meaning its persistent and
+ // some of its properties are changed
+ break;
+ case Doctrine_Record::STATE_CLEAN:
+ // record is clean,
+ // meaning its persistent and
+ // none of its properties are changed
+ break;
+endswitch;
+
diff --git a/manual/docs/Working with objects - Component overview - Record - Introduction.php b/manual/docs/Working with objects - Component overview - Record - Introduction.php
index 9e1fa695e..f31c7cd73 100644
--- a/manual/docs/Working with objects - Component overview - Record - Introduction.php
+++ b/manual/docs/Working with objects - Component overview - Record - Introduction.php
@@ -1,5 +1,7 @@
-Doctrine_Record is a wrapper for database row but along with that it speficies what relations it has
-on other components and what columns it has. It may access the related components, hence its refered as an ActiveRecord.
-
-$table = $conn->getTable("User");
-
-// find by primary key
-
-$user = $table->find(2);
-if($user !== false)
- print $user->name;
-
-// get all users
-foreach($table->findAll() as $user) {
- print $user->name;
-}
-
-// finding by dql
-foreach($table->findByDql("name LIKE '%John%'") as $user) {
- print $user->created;
-}
-
-// finding objects with DQL
-
-$users = $conn->query("FROM User WHERE User.name LIKE '%John%'");
-
+
+$table = $conn->getTable("User");
+
+// find by primary key
+
+$user = $table->find(2);
+if($user !== false)
+ print $user->name;
+
+// get all users
+foreach($table->findAll() as $user) {
+ print $user->name;
+}
+
+// finding by dql
+foreach($table->findByDql("name LIKE '%John%'") as $user) {
+ print $user->created;
+}
+
+// finding objects with DQL
+
+$users = $conn->query("FROM User WHERE User.name LIKE '%John%'");
+
diff --git a/manual/docs/Working with objects - Component overview - Record - Serializing.php b/manual/docs/Working with objects - Component overview - Record - Serializing.php
index ca505e906..df52c169e 100644
--- a/manual/docs/Working with objects - Component overview - Record - Serializing.php
+++ b/manual/docs/Working with objects - Component overview - Record - Serializing.php
@@ -1,8 +1,8 @@
-Sometimes you may want to serialize your record objects (possibly for caching purposes). Records can be serialized,
-but remember: Doctrine cleans all relations, before doing this. So remember to persist your objects into database before serializing them.
+Sometimes you may want to serialize your record objects (possibly for caching purposes). Records can be serialized,
+but remember: Doctrine cleans all relations, before doing this. So remember to persist your objects into database before serializing them.
-
-$string = serialize($user);
-
-$user = unserialize($string);
-
+
+$string = serialize($user);
+
+$user = unserialize($string);
+
diff --git a/manual/docs/Working with objects - Component overview - Record - Updating records.php b/manual/docs/Working with objects - Component overview - Record - Updating records.php
index c68b264ed..1b2b12def 100644
--- a/manual/docs/Working with objects - Component overview - Record - Updating records.php
+++ b/manual/docs/Working with objects - Component overview - Record - Updating records.php
@@ -1,16 +1,16 @@
-Updating objects is very easy, you just call the Doctrine_Record::save() method. The other way
-(perhaps even easier) is to call Doctrine_Connection::flush() which saves all objects. It should be noted though
-that flushing is a much heavier operation than just calling save method.
+Updating objects is very easy, you just call the Doctrine_Record::save() method. The other way
+(perhaps even easier) is to call Doctrine_Connection::flush() which saves all objects. It should be noted though
+that flushing is a much heavier operation than just calling save method.
-
-$table = $conn->getTable("User");
-
-
-$user = $table->find(2);
-
-if($user !== false) {
- $user->name = "Jack Daniels";
-
- $user->save();
-}
-
+
+$table = $conn->getTable("User");
+
+
+$user = $table->find(2);
+
+if($user !== false) {
+ $user->name = "Jack Daniels";
+
+ $user->save();
+}
+
diff --git a/manual/docs/Working with objects - Component overview - Table - Custom finders.php b/manual/docs/Working with objects - Component overview - Table - Custom finders.php
index bed97fb58..20c2f8816 100644
--- a/manual/docs/Working with objects - Component overview - Table - Custom finders.php
+++ b/manual/docs/Working with objects - Component overview - Table - Custom finders.php
@@ -1,27 +1,27 @@
-You can add custom finder methods to your custom table object. These finder methods may use fast
-Doctrine_Table finder methods or DQL API (Doctrine_Connection::query()).
+You can add custom finder methods to your custom table object. These finder methods may use fast
+Doctrine_Table finder methods or DQL API (Doctrine_Connection::query()).
-
-class UserTable extends Doctrine_Table {
- /**
- * you can add your own finder methods here
- */
- public function findByName($name) {
- return $this->getConnection()->query("FROM User WHERE name LIKE '%$name%'");
- }
-}
-class User extends Doctrine_Record { }
-
-$conn = Doctrine_Manager::getInstance()
- ->openConnection(new PDO("dsn","username","password"));
-
-// doctrine will now check if a class called UserTable exists
-// and if it inherits Doctrine_Table
-
-$table = $conn->getTable("User");
-
-print get_class($table); // UserTable
-
-$users = $table->findByName("Jack");
-
-
+
+class UserTable extends Doctrine_Table {
+ /**
+ * you can add your own finder methods here
+ */
+ public function findByName($name) {
+ return $this->getConnection()->query("FROM User WHERE name LIKE '%$name%'");
+ }
+}
+class User extends Doctrine_Record { }
+
+$conn = Doctrine_Manager::getInstance()
+ ->openConnection(new PDO("dsn","username","password"));
+
+// doctrine will now check if a class called UserTable exists
+// and if it inherits Doctrine_Table
+
+$table = $conn->getTable("User");
+
+print get_class($table); // UserTable
+
+$users = $table->findByName("Jack");
+
+
diff --git a/manual/docs/Working with objects - Component overview - Table - Custom table classes.php b/manual/docs/Working with objects - Component overview - Table - Custom table classes.php
index 836902abd..642a5d6b0 100644
--- a/manual/docs/Working with objects - Component overview - Table - Custom table classes.php
+++ b/manual/docs/Working with objects - Component overview - Table - Custom table classes.php
@@ -1,16 +1,16 @@
-Adding custom table classes is very easy. Only thing you need to do is name the classes as [componentName]Table and make them
-inherit Doctrine_Table.
+Adding custom table classes is very easy. Only thing you need to do is name the classes as [componentName]Table and make them
+inherit Doctrine_Table.
+
+
+
+// valid table object
+
+class UserTable extends Doctrine_Table {
+
+}
+
+// not valid [doesn't extend Doctrine_Table]
+class GroupTable { }
+
+
-
-
-// valid table object
-
-class UserTable extends Doctrine_Table {
-
-}
-
-// not valid [doesn't extend Doctrine_Table]
-class GroupTable { }
-
-
-
diff --git a/manual/docs/Working with objects - Component overview - Table - Finder methods.php b/manual/docs/Working with objects - Component overview - Table - Finder methods.php
index c1e041d77..2da4ab063 100644
--- a/manual/docs/Working with objects - Component overview - Table - Finder methods.php
+++ b/manual/docs/Working with objects - Component overview - Table - Finder methods.php
@@ -1,24 +1,24 @@
-Doctrine_Table provides basic finder methods. These finder methods are very fast and should be used if you only need to fetch
-data from one database table. If you need queries that use several components (database tables) use Doctrine_Connection::query().
+Doctrine_Table provides basic finder methods. These finder methods are very fast and should be used if you only need to fetch
+data from one database table. If you need queries that use several components (database tables) use Doctrine_Connection::query().
-
-$table = $conn->getTable("User");
-
-// find by primary key
-
-$user = $table->find(2);
-
-if($user !== false)
- print $user->name;
-
-
-// get all users
-foreach($table->findAll() as $user) {
- print $user->name;
-}
-
-// finding by dql
-foreach($table->findByDql("name LIKE '%John%'") as $user) {
- print $user->created;
-}
-
+
+$table = $conn->getTable("User");
+
+// find by primary key
+
+$user = $table->find(2);
+
+if($user !== false)
+ print $user->name;
+
+
+// get all users
+foreach($table->findAll() as $user) {
+ print $user->name;
+}
+
+// finding by dql
+foreach($table->findByDql("name LIKE '%John%'") as $user) {
+ print $user->created;
+}
+
diff --git a/manual/docs/Working with objects - Component overview - Table - Getting table information.php b/manual/docs/Working with objects - Component overview - Table - Getting table information.php
index 762f16b1e..3040b728b 100644
--- a/manual/docs/Working with objects - Component overview - Table - Getting table information.php
+++ b/manual/docs/Working with objects - Component overview - Table - Getting table information.php
@@ -1,12 +1,12 @@
-
-$table = $conn->getTable('User');
-
-// getting column names
-
-$names = $table->getColumnNames();
-
-// getting column information
-
-$columns = $table->getColumns();
-
+
+$table = $conn->getTable('User');
+
+// getting column names
+
+$names = $table->getColumnNames();
+
+// getting column information
+
+$columns = $table->getColumns();
+
diff --git a/manual/docs/Working with objects - Dealing with relations - Creating related records.php b/manual/docs/Working with objects - Dealing with relations - Creating related records.php
index 07bbd529b..8ba796e49 100644
--- a/manual/docs/Working with objects - Dealing with relations - Creating related records.php
+++ b/manual/docs/Working with objects - Dealing with relations - Creating related records.php
@@ -1,16 +1,16 @@
-When accessing related records and if those records do not exists Doctrine automatically creates new records.
+When accessing related records and if those records do not exists Doctrine automatically creates new records.
-
-// NOTE: related record have always the first letter in uppercase
-$email = $user->Email;
-
-$email->address = 'jackdaniels@drinkmore.info';
-
-$user->save();
-
-// alternative:
-
-$user->Email->address = 'jackdaniels@drinkmore.info';
-
-$user->save();
-
+
+// NOTE: related record have always the first letter in uppercase
+$email = $user->Email;
+
+$email->address = 'jackdaniels@drinkmore.info';
+
+$user->save();
+
+// alternative:
+
+$user->Email->address = 'jackdaniels@drinkmore.info';
+
+$user->save();
+
diff --git a/manual/docs/Working with objects - Dealing with relations - Deleting related records.php b/manual/docs/Working with objects - Dealing with relations - Deleting related records.php
index 56156563c..6db69eb99 100644
--- a/manual/docs/Working with objects - Dealing with relations - Deleting related records.php
+++ b/manual/docs/Working with objects - Dealing with relations - Deleting related records.php
@@ -1,12 +1,12 @@
-You can delete related records individually be calling delete() on each record. If you want to delete a whole record graph just call
-delete on the owner record.
+You can delete related records individually be calling delete() on each record. If you want to delete a whole record graph just call
+delete on the owner record.
-
-$user->Email->delete();
-
-$user->Phonenumber[3]->delete();
-
-// deleting user and all related objects:
-
-$user->delete();
-
+
+$user->Email->delete();
+
+$user->Phonenumber[3]->delete();
+
+// deleting user and all related objects:
+
+$user->delete();
+
diff --git a/manual/docs/Working with objects - Dealing with relations - Retrieving related records.php b/manual/docs/Working with objects - Dealing with relations - Retrieving related records.php
index 43ffb533f..b97e04be2 100644
--- a/manual/docs/Working with objects - Dealing with relations - Retrieving related records.php
+++ b/manual/docs/Working with objects - Dealing with relations - Retrieving related records.php
@@ -1,10 +1,10 @@
-You can retrieve related records by the very same Doctrine_Record methods you've already propably used for accessing record properties.
-When accessing related record you just simply use the class names.
+You can retrieve related records by the very same Doctrine_Record methods you've already propably used for accessing record properties.
+When accessing related record you just simply use the class names.
-
-print $user->Email['address'];
-
-print $user->Phonenumber[0]->phonenumber;
-
-print $user->Group[0]->name;
-
+
+print $user->Email['address'];
+
+print $user->Phonenumber[0]->phonenumber;
+
+print $user->Group[0]->name;
+
diff --git a/manual/docs/Working with objects - Dealing with relations - Updating related records.php b/manual/docs/Working with objects - Dealing with relations - Updating related records.php
index 9eab04af0..2f02323ea 100644
--- a/manual/docs/Working with objects - Dealing with relations - Updating related records.php
+++ b/manual/docs/Working with objects - Dealing with relations - Updating related records.php
@@ -1,12 +1,12 @@
-You can update the related records by calling save for each related object / collection individually or by calling
-save on the object that owns the other objects. You can also call Doctrine_Connection::flush which saves all pending objects.
+You can update the related records by calling save for each related object / collection individually or by calling
+save on the object that owns the other objects. You can also call Doctrine_Connection::flush which saves all pending objects.
-
-$user->Email['address'] = 'koskenkorva@drinkmore.info';
-
-$user->Phonenumber[0]->phonenumber = '123123';
-
-$user->save();
-
-// saves the email and phonenumber
-
+
+$user->Email['address'] = 'koskenkorva@drinkmore.info';
+
+$user->Phonenumber[0]->phonenumber = '123123';
+
+$user->save();
+
+// saves the email and phonenumber
+