Author: jwage
Date: 2008-08-26 23:02:50 +0100 (Tue, 26 Aug 2008)
New Revision: 4820
Modified:
branches/1.0/docs/manual/en/component-overview.txt
Log:
fixes #1270
Modified: branches/1.0/docs/manual/en/component-overview.txt
===================================================================
--- branches/1.0/docs/manual/en/component-overview.txt 2008-08-26 22:02:11 UTC
(rev 4819)
+++ branches/1.0/docs/manual/en/component-overview.txt 2008-08-26 22:02:50 UTC
(rev 4820)
@@ -193,6 +193,35 @@
->execute();
</code>
++++ Replacing records
+
+Replacing records is simple. If you instantiate a new object and save it and
then late instantiate another new object with the same primary key or unique
index value which already exists in the database, then it will replace/update
that row in the database instead of inserting a new one. Below is an example.
+
+First, imagine a User model where username is a unique index.
+
+<code type="php">
+$user = new User();
+$user->username = 'jwage';
+$user->password = 'changeme';
+$user->save();
+
+// Issues the following query
+// INSERT INTO user (username, password) VALUES (?,?) ('jwage', 'changeme')
+</code>
+
+Now lets create another new object and set the same username but a different
password.
+
+<code type="php">
+$user = new User();
+$user->username = 'jwage';
+$user->password = 'newpassword';
+$user->replace();
+
+// Issues the following query
+// REPLACE INTO user (id,username,password) VALUES (?,?,?) (null, 'jwage',
'newpassword')
+// The record is replaced/updated instead of a new one being inserted
+</code>
+
+++ Refreshing records
Sometimes you may want to refresh your record with data from the database, use
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"doctrine-svn" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.co.uk/group/doctrine-svn?hl=en-GB
-~----------~----~----~----~------~----~------~--~---