cvs: peardoc /en/package/database/db-dataobject intro-relations.xml
| From: | Arnaud Limbourg | Date: | Tue, 26 Aug 2003 19:27:42 +0000 |
| Subject: | cvs: peardoc /en/package/database/db-dataobject intro-relations.xml | ||
| Groups: | php.pear.doc | ||
| Request: | Send a blank email to pear-doc+get-1418@lists.php.net to get a copy of this message | ||
arnaud Tue Aug 26 15:27:42 2003 EDT
Modified files:
/peardoc/en/package/database/db-dataobject intro-relations.xml
Log:
* cvs
Index: peardoc/en/package/database/db-dataobject/intro-relations.xml
diff -u peardoc/en/package/database/db-dataobject/intro-relations.xml:1.3
peardoc/en/package/database/db-dataobject/intro-relations.xml:1.4
--- peardoc/en/package/database/db-dataobject/intro-relations.xml:1.3 Fri Aug 8 22:20:08 2003
+++ peardoc/en/package/database/db-dataobject/intro-relations.xml Tue Aug 26 15:27:42 2003
@@ -18,22 +18,22 @@
</para>
<para>
Automated links are supported by a databasename.links.ini file. which stores the relations
ship between tables, maping
- one tables column to anothers. This databasename.links.ini file is used by the getLinks()
and joinAdd() Method, to
+ one tables column to anothers. This databasename.links.ini file is used by the getLinks()
and joinAdd() Method, to
either retrieve related information of a primary object, or quickly build complex
multitable queries.
</para>
-
+
<para>
- The other way of using linking is via the getLink() method, which you can manually use
without
+ The other way of using linking is via the getLink() method, which you can manually use
without
a database.links.ini file to specify a column, and how it relates to another table and
column.
</para>
<para>
The goal of getlinks and joinAdd is to make connecting two tables as simple and fast as
possible, while
- still ensuring that the code is reasonably comprehensable. In the example below, It is
demostrated how
+ still ensuring that the code is reasonably comprehensable. In the example below, It is
demostrated how
getlinks() can be used to fetch more data about an object after the initial fetch, and it can
also be used to
test the links file prior to building a full blown join Query.
-
+
<example>
<title> A simple introduction to links and joins</title>
<programlisting role="php"><![CDATA[
@@ -47,7 +47,7 @@
// this will look up in the cars table for the id matching the person->car value.
$car = $person->getLink('car','cars','id');
-
+
echo "{$person->name} has red eyes and owns a {$car->type}\n";
}
@@ -62,11 +62,11 @@
$person->eyeColour = 'red';
$person->find();
while ($person->fetch()) {
-
+
// use the links.ini file to automatically load
// the car object into $person->_car
$person->getLinks();
-
+
echo "{$person->name} has red eyes and owns a {$person->_car->type}\n";
}
@@ -90,7 +90,7 @@
// and for fun.. lets look for red eys and red cars..
$car->colour = 'red';
-// add them together.
+// add them together.
$person->joinAdd($car);
// since both tables have the column id in them, we need to reformat the query so
@@ -103,7 +103,7 @@
$person->find();
while ($person->fetch()) {
-
+
echo "{$person->name} has red eyes and owns a {$person->car_type}\n";
}
@@ -115,9 +115,9 @@
]]>
</programlisting>
</example>
-
+
</para>
-
+
</refsect1>
@@ -130,15 +130,15 @@
same folder as the database schema ini file 'databasename.ini' file that is
created automatically by createTables.php
</para>
<para>
- The databasename.links.ini file contains a section for each table, then the row that is
linked equal to
- the table and row that it should locate the row from. It assumes the relationships are
non-primary id to primary id,
+ The databasename.links.ini file contains a section for each table, then the row that is
linked equal to
+ the table and row that it should locate the row from. It assumes the relationships are
non-primary id to primary id,
as the example below shows, the person.owner is linked to grp.id. This indicates that
running getLinks() on the
- person object, will fetch a single bit of data from 3 tables - colurs,grp,attachments.
+ person object, will fetch a single bit of data from 3 tables - colurs,grp,attachments.
</para>
- <para>
+ <para>
If you use a 'full stop' in the key (link from column), getLinks() will
look up in the table with the row name matching the string to the left of the 'full
stop', and replace the
- 'full stop' with and underscore and assign the object variable to that name. Or
you may wish to use the
+ 'full stop' with and underscore and assign the object variable to that name. Or
you may wish to use the
selectAs() method to decide how you want columns from different objects to be returned
(when using joinAdd())
<example>
<title> An example databasename.links.ini file</title>