cvs: pear /DB_DataObject/doc packages.db.dataobject.autobuilding.html packages.db.dataobject.configuration.html packages.db.dataobject.filters.html
packages.db.dataobject.find_fetch.html packages.db.dataobject.introduction.html packages.db.dataobject.links.html packages.db.dataobject.updating.html
packages.db.dataobject.utils.html

From: Date: Thu, 11 Jul 2002 06:05:20 +0000
Subject: cvs: pear /DB_DataObject/doc packages.db.dataobject.autobuilding.html packages.db.dataobject.configuration.html packages.db.dataobject.filters.html
packages.db.dataobject.find_fetch.html packages.db.dataobject.introduction.html packages.db.dataobject.links.html packages.db.dataobject.updating.html
packages.db.dataobject.utils.html
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-5025@lists.php.net to get a copy of this message
alan_k Thu Jul 11 02:05:20 2002 EDT Modified files: /pear/DB_DataObject/doc packages.db.dataobject.autobuilding.html packages.db.dataobject.configuration.html packages.db.dataobject.filters.html packages.db.dataobject.find_fetch.html packages.db.dataobject.introduction.html packages.db.dataobject.links.html packages.db.dataobject.updating.html packages.db.dataobject.utils.html Log: updated html documentation

Index: pear/DB_DataObject/doc/packages.db.dataobject.autobuilding.html diff -u pear/DB_DataObject/doc/packages.db.dataobject.autobuilding.html:1.1 pear/DB_DataObject/doc/packages.db.dataobject.autobuilding.html:1.2 --- pear/DB_DataObject/doc/packages.db.dataobject.autobuilding.html:1.1 Fri Jun 21 05:51:49 2002 +++ pear/DB_DataObject/doc/packages.db.dataobject.autobuilding.html Thu Jul 11 02:05:20 2002 @@ -76,7 +76,7 @@ ><DIV CLASS="refnamediv" ><A -NAME="AEN3845" +NAME="AEN3851" ></A >AutoBuilding&nbsp;--&nbsp; creating the base Classes and Database schema @@ -84,29 +84,29 @@ ><DIV CLASS="refsect1" ><A -NAME="AEN3848" +NAME="AEN3854" ></A ><H2 ->What the AutoBuilder Does</H2 +>What the AutoBuilder (createTables.php) Does</H2 ><P >&#13; One of the essential features of an SQL building tool is to to have some understanding of the database structure, So that Integers can be checked, and strings can be escaped. There a few ways - this could be accomplished + that Quering the database for the table structre could be accomplished <P ></P ><UL ><LI ><P ->Request the database description from the database, on each database build</P +>on every SQL query</P ></LI ><LI ><P ->Request the database description from the database, at the initialization of every web page.</P +>At the initialization of every web page.</P ></LI ><LI ><P ->Request the database description from the database, once, and store it in a file</P +>Once, while setting up the application, and store it in a file</P ></LI ></UL > @@ -115,12 +115,12 @@ </P ><P >&#13; The other key concept of DB_DataObject is that you work with extended classes of DB_DataObject, which - do all the 'table' related work. Setting these tables up for a large database can be time consuming, so - the createTables.php file is included to assist in creating these files. + do all the 'table' related work. Setting up these classes for a large database can be time consuming, so + the createTables.php file will automatically bulid the skeletons for all these class files. </P ><P > - To start the autobulider simple go to the pear/DB/DataObject/ directory, and type + To start the autobuilder simply go to the pear/DB/DataObject/ directory, and type <B CLASS="command" >c:\php4\php.exe createTables.php myconfig.ini</B @@ -131,7 +131,7 @@ ><DIV CLASS="refsect1" ><A -NAME="AEN3861" +NAME="AEN3867" ></A ><H2 >Default Class Definition</H2 @@ -149,7 +149,7 @@ ><DIV CLASS="example" ><A -NAME="AEN3864"><P +NAME="AEN3870"><P ><B >Example 1. an generated extended class</B ></P @@ -175,16 +175,16 @@ /* the code below is auto generated do not remove the above tag */ var $__table='group'; // table name - var $id; // int(11) - var $name; // varchar(255) - var $grp_owner; // int(11) - var $official; // varchar(255) - var $street; // varchar(255) - var $postcode; // varchar(255) - var $city; // varchar(255) - var $homepage; // varchar(255) - var $email; // varchar(255) - var $extra; // longtext + var $id; // int primary_key + var $name; // string + var $grp_owner; // int + var $official; // string + var $street; // string + var $postcode; // string + var $city; // string + var $homepage; // string + var $email; // string + var $extra; // blob /* Static get */ @@ -203,6 +203,9 @@ ></TR ></TABLE > + </P +><P +>&#13; The class defines the table name, and comments some of table columns for your reference, It also adds the staticGet() method, which can be used to quickly get single rows as Objects. You should add your table related code after the ###END_AUTOCODE. @@ -211,7 +214,7 @@ ><DIV CLASS="refsect1" ><A -NAME="AEN3867" +NAME="AEN3874" ></A ><H2 >Database Definition File</H2 @@ -229,7 +232,7 @@ ><DIV CLASS="example" ><A -NAME="AEN3870"><P +NAME="AEN3877"><P ><B >Example 2. Database configuration file</B ></P @@ -265,9 +268,11 @@ ></TR ></TABLE > + </P +><P +>&#13; The blocks indicate either tables and the type of field (1=integer,2=string), - or a list of keys for each table. You should not need to edit or create this file, unless - the createTables.php does not support your database. + or a list of keys for each table. You should not need to edit file. </P ></DIV Index: pear/DB_DataObject/doc/packages.db.dataobject.configuration.html diff -u pear/DB_DataObject/doc/packages.db.dataobject.configuration.html:1.1 pear/DB_DataObject/doc/packages.db.dataobject.configuration.html:1.2 --- pear/DB_DataObject/doc/packages.db.dataobject.configuration.html:1.1 Fri Jun 21 05:51:49 2002 +++ pear/DB_DataObject/doc/packages.db.dataobject.configuration.html Thu Jul 11 02:05:20 2002 @@ -89,9 +89,9 @@ ><H2 >Configuration</H2 ><P ->&#13; DB_DataObject needs to be configured before using it and auto generating classes and definitions, - the easiest way to configure DB_DataObject is to use ini files (although you may also like to consider - the PEAR::Config class. +>&#13; DB_DataObject needs to be configured before using it and auto generating classes and definitions. + The easiest way to configure DB_DataObject is to use ini files (although you may also like to consider + the PEAR::Config class, or your own configuration system) </P ><TABLE WIDTH="100%" @@ -165,9 +165,9 @@ CLASS="php" >&#60;?php $config = parse_ini_file('example.ini',TRUE); -foreach($config as $key=&#62;$value) { - $options = &#38;PEAR::getStaticProperty($key,'options'); - $options = $value; +foreach($config as $class=&#62;$values) { + $options = &#38;PEAR::getStaticProperty($class,'options'); + $options = $values; } ?&#62;</PRE ></TD @@ -184,7 +184,7 @@ NAME="AEN3768" ></A ><H2 ->Configuration Options - Standard</H2 +>Configuration Options - Required</H2 ><P ></P ><DIV @@ -216,8 +216,8 @@ >&#13; The Directory where the DB_DataObject database schema file is store. </P ><P ->&#13; DB_DataObject Stores the Description of the database (Tables and Columns) in an .ini file, in this directory - this information is used to determine if the column is a string and needs quotes, or should be a number (and is checked) +>&#13; DB_DataObject stores the description of the database (Tables and Columns) in an .ini file, + in this directory. This information is used to determine if the column is a string and needs quotes, or should be a number (and is checked) at SQL building time. It is quite common to store the schema in the same directory as your DataObject Classes. </P @@ -232,8 +232,8 @@ directory</DT ><DD ><P ->&#13; The Path absoloute, or relative to your default include path(s), where your - extended classes can be found. +>&#13; The Path absolute, or relative to your default include path(s), where your + extended classes can be found. </P ><P >&#13; This is used by the staticGet() method and the getLinks() method to auto load classes, @@ -253,13 +253,26 @@ alter the prefixed name, this is used by the staticGet() and getLinks() methods </P ></DD +><DT +><TT +CLASS="parameter" +><I +>debug</I +></TT +> + integer</DT +><DD +><P +>&#13; The default debugging level (default 0=off), 1= basic sql logging,2=result logging, 3=everything + </P +></DD ></DL ></DIV ></DIV ><DIV CLASS="refsect1" ><A -NAME="AEN3797" +NAME="AEN3803" ></A ><H2 >Configuration Options - Mulitiple Databases (optional)</H2 @@ -293,7 +306,7 @@ ><DIV CLASS="example" ><A -NAME="AEN3807"><P +NAME="AEN3813"><P ><B >Example 3. using multiple databases - database passwords</B ></P @@ -344,7 +357,7 @@ ><DIV CLASS="example" ><A -NAME="AEN3817"><P +NAME="AEN3823"><P ><B >Example 4. using multiple databases - table settings</B ></P @@ -377,7 +390,7 @@ ><DIV CLASS="refsect1" ><A -NAME="AEN3820" +NAME="AEN3826" ></A ><H2 >Configuration Options - Builder</H2 @@ -399,7 +412,7 @@ >&#13; The Directory where your DataObject extended Classes are. </P ><P ->&#13; It is also used by the Class AutoBuilder when updating/writing to your class definitions. +>&#13; Used by the Class AutoBuilder when updating/writing to your class definitions. </P ></DD ><DT Index: pear/DB_DataObject/doc/packages.db.dataobject.filters.html diff -u pear/DB_DataObject/doc/packages.db.dataobject.filters.html:1.1 pear/DB_DataObject/doc/packages.db.dataobject.filters.html:1.2 --- pear/DB_DataObject/doc/packages.db.dataobject.filters.html:1.1 Fri Jun 21 05:51:49 2002 +++ pear/DB_DataObject/doc/packages.db.dataobject.filters.html Thu Jul 11 02:05:20 2002 @@ -76,15 +76,15 @@ ><DIV CLASS="refnamediv" ><A -NAME="AEN4013" +NAME="AEN4033" ></A >Advanced Filters&nbsp;--&nbsp; - Advanced Filters - ::query, ::SelectAdd, ::whereAdd, ::Limit, ::OrderBy, ::GroupBy, + Advanced Filters - ::query(), ::SelectAdd(), ::whereAdd(), ::Limit(), ::OrderBy(), ::GroupBy(), </DIV ><DIV CLASS="refsect1" ><A -NAME="AEN4016" +NAME="AEN4036" ></A ><H2 >More advanced Querying</H2 @@ -104,17 +104,17 @@ ><DIV CLASS="refsect1" ><A -NAME="AEN4020" +NAME="AEN4040" ></A ><H2 ->Query</H2 +>::query()</H2 ><P >&#13; Raw Database Queries </P ><DIV CLASS="funcsynopsis" ><A -NAME="AEN4023"><P +NAME="AEN4043"><P ></P ><P ><CODE @@ -142,7 +142,7 @@ ><DIV CLASS="example" ><A -NAME="AEN4030"><P +NAME="AEN4050"><P ><B >Example 1. raw Queries on the database </B ></P @@ -177,17 +177,17 @@ ><DIV CLASS="refsect1" ><A -NAME="AEN4033" +NAME="AEN4053" ></A ><H2 ->selectAdd</H2 +>::selectAdd()</H2 ><P >&#13; Adding and removing Items from select query </P ><DIV CLASS="funcsynopsis" ><A -NAME="AEN4036"><P +NAME="AEN4056"><P ></P ><P ><CODE @@ -203,8 +203,9 @@ ></P ></DIV ><P ->&#13; By default a select query will request all items '*', to change this behaviour you must first call - selectAdd() without any arguments and the add the specific items you require. +>&#13; By default a select query will request all items '*', to change this behaviour you can first call + selectAdd() without any arguments to clear the current request and then add the specific items + you require. <TABLE WIDTH="100%" BORDER="0" @@ -216,7 +217,7 @@ ><DIV CLASS="example" ><A -NAME="AEN4044"><P +NAME="AEN4064"><P ><B >Example 2. Adding select statements</B ></P @@ -255,8 +256,9 @@ ></TR ></TABLE > - - This would execute the following SQL statements, + </P +><P +>&#13; This would execute the following SQL statements, <TABLE WIDTH="100%" BORDER="0" @@ -268,7 +270,7 @@ ><DIV CLASS="example" ><A -NAME="AEN4047"><P +NAME="AEN4068"><P ><B >Example 3. Resulting SQL </B ></P @@ -292,24 +294,27 @@ ></TR ></TABLE > - + </P +><P +>&#13; You can also set up a default selection query by adding SelectAdd() method calls in the object + initialization method (the one with the same name as the class) </P ></DIV ><DIV CLASS="refsect1" ><A -NAME="AEN4050" +NAME="AEN4072" ></A ><H2 ->whereAdd</H2 +>::whereAdd()</H2 ><P >&#13; Adds conditions to the Where part of the query </P ><DIV CLASS="funcsynopsis" ><A -NAME="AEN4053"><P +NAME="AEN4075"><P ></P ><P ><CODE @@ -319,14 +324,15 @@ CLASS="function" >::whereAdd</B ></CODE -> ([string Where Items [, string Condition (eg. OR)]])</CODE +> ([string Where [, string OR]])</CODE ></P ><P ></P ></DIV ><P ->&#13; Adds items to the where part of a SQL query. - Calling this without any arguments clears the where condition. +>&#13; Adds items to the where part of a SQL query. Calling this without any arguments clears, + the where condition. The default behaviour is to add 'AND' queries, send the string 'OR' to + append OR conditions. <TABLE WIDTH="100%" BORDER="0" @@ -338,7 +344,7 @@ ><DIV CLASS="example" ><A -NAME="AEN4064"><P +NAME="AEN4086"><P ><B >Example 4. Adding Where Statements</B ></P @@ -370,8 +376,6 @@ echo "$person-&#62;id} {$person-&#62;name}&#60;BR&#62;"; } - - ?&#62;</PRE ></TD ></TR @@ -381,7 +385,9 @@ ></TR ></TABLE > - + </P +><P +>&#13; This would execute the following SQL statements, <TABLE WIDTH="100%" @@ -394,7 +400,7 @@ ><DIV CLASS="example" ><A -NAME="AEN4067"><P +NAME="AEN4090"><P ><B >Example 5. Resulting SQL </B ></P @@ -420,23 +426,22 @@ ></TABLE > - </P ></DIV ><DIV CLASS="refsect1" ><A -NAME="AEN4070" +NAME="AEN4093" ></A ><H2 ->limit</H2 +>::limit()</H2 ><P >&#13; Sets the limit of a query </P ><DIV CLASS="funcsynopsis" ><A -NAME="AEN4073"><P +NAME="AEN4096"><P ></P ><P ><CODE @@ -446,7 +451,7 @@ CLASS="function" >::limit</B ></CODE -> ([int Limit Range Start or Number [, int Limit Range Number]])</CODE +> ([int (Limit Range Start or Number) [, int (Limit Range Number)]])</CODE ></P ><P ></P @@ -465,7 +470,7 @@ ><DIV CLASS="example" ><A -NAME="AEN4084"><P +NAME="AEN4107"><P ><B >Example 6. Setting the Limit</B ></P @@ -507,7 +512,9 @@ ></TR ></TABLE > - + </P +><P +>&#13; This would execute the following SQL statements, <TABLE WIDTH="100%" @@ -520,7 +527,7 @@ ><DIV CLASS="example" ><A -NAME="AEN4087"><P +NAME="AEN4111"><P ><B >Example 7. Resulting SQL </B ></P @@ -552,17 +559,17 @@ ><DIV CLASS="refsect1" ><A -NAME="AEN4090" +NAME="AEN4114" ></A ><H2 ->orderBy</H2 +>::orderBy()</H2 ><P >&#13; Appends to the 'order by' part of the query </P ><DIV CLASS="funcsynopsis" ><A -NAME="AEN4093"><P +NAME="AEN4117"><P ></P ><P ><CODE @@ -578,7 +585,7 @@ ></P ></DIV ><P ->&#13; Appends an Order condition +>&#13; Appends an Order condition. Calling this without any arguments clears the order <TABLE WIDTH="100%" @@ -591,7 +598,7 @@ ><DIV CLASS="example" ><A -NAME="AEN4101"><P +NAME="AEN4125"><P ><B >Example 8. setting the order by</B ></P @@ -606,13 +613,12 @@ ><PRE CLASS="php" >&#60;? + $person = new DataObjects_Person; $person-&#62;orderBy('name'); $person-&#62;orderBy('age, eye'); $person-&#62;find(); - - ?&#62;</PRE ></TD ></TR @@ -622,7 +628,9 @@ ></TR ></TABLE > - + </P +><P +>&#13; This would execute the following SQL statement, <TABLE WIDTH="100%" @@ -635,7 +643,7 @@ ><DIV CLASS="example" ><A -NAME="AEN4104"><P +NAME="AEN4129"><P ><B >Example 9. Resulting SQL </B ></P @@ -665,17 +673,17 @@ ><DIV CLASS="refsect1" ><A -NAME="AEN4107" +NAME="AEN4132" ></A ><H2 ->groupBy</H2 +>::groupBy()</H2 ><P >&#13; Appends a to the 'group by' part of the query </P ><DIV CLASS="funcsynopsis" ><A -NAME="AEN4110"><P +NAME="AEN4135"><P ></P ><P ><CODE @@ -691,7 +699,7 @@ ></P ></DIV ><P ->&#13; Appends a Group condition +>&#13; Appends a Group condition. Calling this without any arguments clears the Group Condition <TABLE WIDTH="100%" @@ -704,7 +712,7 @@ ><DIV CLASS="example" ><A -NAME="AEN4118"><P +NAME="AEN4143"><P ><B >Example 10. Settin the Group by </B ></P @@ -719,13 +727,12 @@ ><PRE CLASS="php" >&#60;? + $person = new DataObjects_Person; $person-&#62;groupBy('name'); $person-&#62;groupBy('age, eye'); $person-&#62;find(); - - ?&#62;</PRE ></TD ></TR @@ -735,7 +742,9 @@ ></TR ></TABLE > - + </P +><P +>&#13; This would execute the following SQL statement, <TABLE WIDTH="100%" @@ -748,7 +757,7 @@ ><DIV CLASS="example" ><A -NAME="AEN4121"><P +NAME="AEN4147"><P ><B >Example 11. Resulting SQL </B ></P Index: pear/DB_DataObject/doc/packages.db.dataobject.find_fetch.html diff -u pear/DB_DataObject/doc/packages.db.dataobject.find_fetch.html:1.1 pear/DB_DataObject/doc/packages.db.dataobject.find_fetch.html:1.2 --- pear/DB_DataObject/doc/packages.db.dataobject.find_fetch.html:1.1 Fri Jun 21 05:51:49 2002 +++ pear/DB_DataObject/doc/packages.db.dataobject.find_fetch.html Thu Jul 11 02:05:20 2002 @@ -76,25 +76,25 @@ ><DIV CLASS="refnamediv" ><A -NAME="AEN3874" +NAME="AEN3882" ></A >Finding and fetching&nbsp;--&nbsp; - Simple Querying methods ::staticGet ::get ::find ::fetch + Simple Querying methods ::staticGet() ::get() ::find() ::fetch() </DIV ><DIV CLASS="refsect1" ><A -NAME="AEN3877" +NAME="AEN3885" ></A ><H2 ->get</H2 +>::get()</H2 ><P ->&#13; Simple Get (Select) request, are achieved using the get methods +>&#13; Simple Get (Select) request, are achieved using the get method </P ><DIV CLASS="funcsynopsis" ><A -NAME="AEN3880"><P +NAME="AEN3888"><P ></P ><P ><CODE @@ -123,7 +123,7 @@ ><DIV CLASS="example" ><A -NAME="AEN3890"><P +NAME="AEN3898"><P ><B >Example 1. Simple fetch of data based on Primary Key</B ></P @@ -150,6 +150,9 @@ ></TR ></TABLE > + </P +><P +>&#13; This would execute the following SQL statement and fetch the results into the objects variables <TABLE WIDTH="100%" @@ -162,7 +165,7 @@ ><DIV CLASS="example" ><A -NAME="AEN3893"><P +NAME="AEN3902"><P ><B >Example 2. Resulting SQL </B ></P @@ -185,7 +188,9 @@ ></TR ></TABLE > - To use another field other than the primary key, you would use it with two parameters + </P +><P +>&#13; To use another field other than the primary key, you would use it with two parameters <TABLE WIDTH="100%" BORDER="0" @@ -197,9 +202,9 @@ ><DIV CLASS="example" ><A -NAME="AEN3896"><P +NAME="AEN3906"><P ><B ->Example 3. Simple fetch of data based on Primary Key</B +>Example 3. Simple fetch of data based on Key and Value</B ></P ><TABLE WIDTH="100%" @@ -224,6 +229,9 @@ ></TR ></TABLE > + </P +><P +>&#13; This would execute the following SQL statement and fetch the results into the objects variables <TABLE WIDTH="100%" @@ -236,7 +244,7 @@ ><DIV CLASS="example" ><A -NAME="AEN3899"><P +NAME="AEN3910"><P ><B >Example 4. Resulting SQL </B ></P @@ -259,8 +267,9 @@ ></TR ></TABLE > - - The result of these two queries would be that all the objects variables would contain the matched row's + </P +><P +>&#13; The result of these two queries would be that all the objects variables would contain the matched row's data and the variable $person-&#62;N would contain the number of matches. <TABLE WIDTH="100%" @@ -273,7 +282,7 @@ ><DIV CLASS="example" ><A -NAME="AEN3902"><P +NAME="AEN3914"><P ><B >Example 5. Results of example code</B ></P @@ -308,17 +317,17 @@ ><DIV CLASS="refsect1" ><A -NAME="AEN3905" +NAME="AEN3917" ></A ><H2 ->staticGet</H2 +>::staticGet()</H2 ><P >&#13; Simple Get (Select) request, abreviated get request. </P ><DIV CLASS="funcsynopsis" ><A -NAME="AEN3908"><P +NAME="AEN3920"><P ></P ><P ><CODE @@ -335,7 +344,7 @@ ></DIV ><P >&#13; The static method is similar to the get request, however it does not require the - initial instantation of the class + initial instantation of the class. staticGet also caches the result. <TABLE WIDTH="100%" BORDER="0" @@ -347,7 +356,7 @@ ><DIV CLASS="example" ><A -NAME="AEN3918"><P +NAME="AEN3930"><P ><B >Example 6. Simple fetch of data based on Primary Key</B ></P @@ -373,9 +382,11 @@ ></TR ></TABLE > - + </P +><P +>&#13; You may also use the DB_DataObject staticGet method directly, however you need to specify which - class you wish to use. + class you wish to use. In this case, the Class file will be automatically loaded. <TABLE WIDTH="100%" BORDER="0" @@ -387,7 +398,7 @@ ><DIV CLASS="example" ><A -NAME="AEN3921"><P +NAME="AEN3934"><P ><B >Example 7. Simple fetch of data based on Primary Key</B ></P @@ -418,17 +429,17 @@ ><DIV CLASS="refsect1" ><A -NAME="AEN3924" +NAME="AEN3937" ></A ><H2 ->find</H2 +>::find()</H2 ><P >&#13; Searching for Items </P ><DIV CLASS="funcsynopsis" ><A -NAME="AEN3927"><P +NAME="AEN3940"><P ></P ><P ><CODE @@ -438,14 +449,14 @@ CLASS="function" >::find</B ></CODE -> ([boolean Auto Fetch])</CODE +> ([boolean AutoFetch])</CODE ></P ><P ></P ></DIV ><P ->&#13; The find method can be used to execute, and optionally fetch data based on the values of - the object +>&#13; The find method builds and executes the current Query, based on the object variables and any 'WhereAdd' conditions + , If the AutoFetch is TRUE, then it will also call the fetch method automatically. <TABLE WIDTH="100%" BORDER="0" @@ -457,9 +468,9 @@ ><DIV CLASS="example" ><A -NAME="AEN3935"><P +NAME="AEN3948"><P ><B ->Example 8. Simple fetch of data based on Object Vars</B +>Example 8. Simple find of data based on Object Vars</B ></P ><TABLE WIDTH="100%" @@ -485,7 +496,9 @@ ></TR ></TABLE > - + </P +><P +>&#13; This would execute the following SQL statement and fetch the results into the objects variables <TABLE WIDTH="100%" @@ -498,7 +511,7 @@ ><DIV CLASS="example" ><A -NAME="AEN3938"><P +NAME="AEN3952"><P ><B >Example 9. Resulting SQL </B ></P @@ -527,17 +540,17 @@ ><DIV CLASS="refsect1" ><A -NAME="AEN3941" +NAME="AEN3955" ></A ><H2 ->fetch</H2 +>::fetch()</H2 ><P >&#13; Getting the data. </P ><DIV CLASS="funcsynopsis" ><A -NAME="AEN3944"><P +NAME="AEN3958"><P ></P ><P ><CODE @@ -553,7 +566,8 @@ ></P ></DIV ><P ->&#13; The fetch method gets the next row and sets the objects variables to the rows data. +>&#13; The fetch method gets the next row and sets the objects variables to the rows data. It returns true if data + has been collected, and false when there is no more data. <TABLE WIDTH="100%" BORDER="0" @@ -565,9 +579,9 @@ ><DIV CLASS="example" ><A -NAME="AEN3951"><P +NAME="AEN3965"><P ><B ->Example 10. Simple fetch of data based on Object Vars</B +>Example 10. Simple find and fetch of data based on Object Vars</B ></P ><TABLE WIDTH="100%" Index: pear/DB_DataObject/doc/packages.db.dataobject.introduction.html diff -u pear/DB_DataObject/doc/packages.db.dataobject.introduction.html:1.1 pear/DB_DataObject/doc/packages.db.dataobject.introduction.html:1.2 --- pear/DB_DataObject/doc/packages.db.dataobject.introduction.html:1.1 Fri Jun 21 05:51:49 2002 +++ pear/DB_DataObject/doc/packages.db.dataobject.introduction.html Thu Jul 11 02:05:20 2002 @@ -155,11 +155,8 @@ // use one of the extended classes. require_once('DataObjects/Person.php'); - $person = new DataObjects_Person; - $person-&#62;get(12); - echo $person-&#62;name; @@ -173,13 +170,14 @@ ></TABLE ><P >&#13; The above example illustrates the two components of the DataManager, By setting the options, all - The core objects will autoload the data definitons from a generated ini file. and know how to access - the database. (multiple databases are supported - see section on configuration) + the core objects will be able to autoload the data definitons from a generated ini file, and know + how to access the database. (multiple databases are supported - see section on configuration) </P ><P ->&#13; The later half illustrates how to query and get the result for a single row. the $person-&#62;get() would connect - to the database, perform the query, fetch the result and assign the objects variables to the values from - the row returned. +>&#13; The later half illustrates how to query and get the result for a single row. The $person-&#62;get() would connect + to the database, perform the query, fetch the result and assign the objects variables to the data returned + from the query. + </P ><P >&#13; In the above example, this query would be performed. @@ -199,8 +197,8 @@ ></TR ></TABLE ><P ->&#13; to Make a change to the Object you would just change the value of the objects variables and call - the update method +>&#13; To make a change to the Database you would just change the value of the objects variables and call + the update method. </P ><TABLE WIDTH="100%" @@ -215,11 +213,8 @@ >&#60;? $person = new DataObjects_Person; - $person-&#62;get(12); - $person-&#62;name = 'Fred'; - $person-&#62;update(); ?&#62;</PRE Index: pear/DB_DataObject/doc/packages.db.dataobject.links.html diff -u pear/DB_DataObject/doc/packages.db.dataobject.links.html:1.1 pear/DB_DataObject/doc/packages.db.dataobject.links.html:1.2 --- pear/DB_DataObject/doc/packages.db.dataobject.links.html:1.1 Fri Jun 21 05:51:49 2002 +++ pear/DB_DataObject/doc/packages.db.dataobject.links.html Thu Jul 11 02:05:20 2002 @@ -76,15 +76,15 @@ ><DIV CLASS="refnamediv" ><A -NAME="AEN4125" +NAME="AEN4151" ></A >Automatic Table Linking&nbsp;--&nbsp; - Automatic Table Linking - getLink, getLinks + Automatic Table Linking - ::getLink(), ::getLinks() </DIV ><DIV CLASS="refsect1" ><A -NAME="AEN4128" +NAME="AEN4154" ></A ><H2 >Automating the colleciton of related data</H2 @@ -94,34 +94,32 @@ can automatically fetch objects into the parents variables. </P ><P ->&#13; The method of doing this is heavily dependant on naming columns relating to databases, for example in the - membership described above, you would have to have a column called person_id, group_id for the Link methods - to understand which table to fetch the data from. The principle is TABLENAME_ANYTHING, and it will always - attempt to find primary keys that match the value of field, and load the related object into $object-&#62;_tablename_anything +>&#13; The Automated method of doing this is heavily dependant on naming columns relating to databases, for example in the + membership described above, you would have to have a column called person_id, group_id for the automated Link + methods to understand which table to fetch the data from. The principle is TABLENAME_ANYTHING, and it + will always attempt to find primary keys that match the value of field, the getLinks() methods will autoload + the related object into $object-&#62;_tablename_anything </P ><P ->&#13; The linking feature is not essential to the core operation of DB_DataObject, and can be ignored if you - do not wish to set up or revise your database structure. - It just saves alot of work next time you - set up an application. - </P -><P ->&#13; +>&#13; The other way of using getLink() is to use it with the second parameter which is the table name of the related + table, it will then query the primary key on that table to see if it matches the value of the requested row. + In this method however the getLinks() method will not work, as it will not know the related table names. </P ></DIV ><DIV CLASS="refsect1" ><A -NAME="AEN4134" +NAME="AEN4159" ></A ><H2 ->getLink</H2 +>::getLink()</H2 ><P ->&#13; Loads the related object into the main object, with a variable name prefixed with _ +>&#13; Gets the Related Row Object from the Related Table </P ><DIV CLASS="funcsynopsis" ><A -NAME="AEN4137"><P +NAME="AEN4162"><P ></P ><P ><CODE @@ -131,13 +129,13 @@ CLASS="function" >::getLink</B ></CODE -> (string Row)</CODE +> (string Row [, string Table])</CODE ></P ><P ></P ></DIV ><P ->&#13; Loads the related Object +>&#13; Gets the related Object <TABLE WIDTH="100%" BORDER="0" @@ -149,9 +147,9 @@ ><DIV CLASS="example" ><A -NAME="AEN4144"><P +NAME="AEN4172"><P ><B ->Example 1. loading the related object </B +>Example 1. Getting the related object </B ></P ><TABLE WIDTH="100%" @@ -166,8 +164,10 @@ >&#60;? $person = new DataObjects_Person; $person-&#62;get(12); -$person-&#62;getLink('group_owner'); -print_r($_person_group); +$group = $person-&#62;getLink('group_owner'); +echo $group-&#62;name; +$group = $person-&#62;getLink('colourid','hair'); + ?&#62;</PRE ></TD ></TR @@ -177,8 +177,10 @@ ></TR ></TABLE > - - This would execute the following SQL statement, and fetch the data + </P +><P +>&#13; + This would execute the following SQL statements, and fetch the data <TABLE WIDTH="100%" BORDER="0" @@ -190,7 +192,7 @@ ><DIV CLASS="example" ><A -NAME="AEN4147"><P +NAME="AEN4176"><P ><B >Example 2. Resulting SQL </B ></P @@ -205,7 +207,8 @@ ><PRE CLASS="sql" >SELECT * FROM person WHERE id=12 -SELECT * FROM group WHERE id=3</PRE +SELECT * FROM group WHERE id=3 +SELECT * FROM hair WHERE id=4</PRE ></TD ></TR ></TABLE @@ -221,17 +224,18 @@ ><DIV CLASS="refsect1" ><A -NAME="AEN4150" +NAME="AEN4179" ></A ><H2 ->getLinks</H2 +>::getLinks()</H2 ><P ->&#13; Loads the all the related objects into the main object, with a variable name prefixed with _ +>&#13; Loads the all the related objects into the main object, based on the naming of columns using the tablename_xxx + naming method, and sets the main objects variables with the row name prefixed with a _ </P ><DIV CLASS="funcsynopsis" ><A -NAME="AEN4153"><P +NAME="AEN4182"><P ></P ><P ><CODE @@ -259,7 +263,7 @@ ><DIV CLASS="example" ><A -NAME="AEN4160"><P +NAME="AEN4189"><P ><B >Example 3. Loading all the related objects </B ></P @@ -277,8 +281,8 @@ $person = new DataObjects_Person; $person-&#62;get(12); $person-&#62;getLinks(); -print_r($_person_group); -print_r($_person_eyes); +print_r($person-&#62;_group); +print_r($person-&#62;_eyes); ?&#62;</PRE ></TD ></TR @@ -288,7 +292,9 @@ ></TR ></TABLE > - + </P +><P +>&#13; This would execute the following SQL statement, and fetch the data <TABLE WIDTH="100%" @@ -301,7 +307,7 @@ ><DIV CLASS="example" ><A -NAME="AEN4163"><P +NAME="AEN4193"><P ><B >Example 4. Resulting SQL </B ></P Index: pear/DB_DataObject/doc/packages.db.dataobject.updating.html diff -u pear/DB_DataObject/doc/packages.db.dataobject.updating.html:1.1 pear/DB_DataObject/doc/packages.db.dataobject.updating.html:1.2 --- pear/DB_DataObject/doc/packages.db.dataobject.updating.html:1.1 Fri Jun 21 05:51:49 2002 +++ pear/DB_DataObject/doc/packages.db.dataobject.updating.html Thu Jul 11 02:05:20 2002 @@ -76,25 +76,25 @@ ><DIV CLASS="refnamediv" ><A -NAME="AEN3955" +NAME="AEN3969" ></A >Modifying the database&nbsp;--&nbsp; - ::update, ::insert, ::delete, + ::update(), ::insert(), ::delete(), </DIV ><DIV CLASS="refsect1" ><A -NAME="AEN3958" +NAME="AEN3972" ></A ><H2 ->Update</H2 +>::update()</H2 ><P >&#13; Updating the data. </P ><DIV CLASS="funcsynopsis" ><A -NAME="AEN3961"><P +NAME="AEN3975"><P ></P ><P ><CODE @@ -110,7 +110,8 @@ ></P ></DIV ><P ->&#13; updates the database using the objects variables +>&#13; updates the database using the objects variables, returns TRUE on success + <TABLE WIDTH="100%" BORDER="0" @@ -122,9 +123,9 @@ ><DIV CLASS="example" ><A -NAME="AEN3968"><P +NAME="AEN3982"><P ><B ->Example 1. Simple fetch and updated</B +>Example 1. Simple fetch and update</B ></P ><TABLE WIDTH="100%" @@ -150,7 +151,9 @@ ></TR ></TABLE > - + </P +><P +>&#13; This would execute the following SQL statements, both fetching and updating the database. <TABLE WIDTH="100%" @@ -163,7 +166,7 @@ ><DIV CLASS="example" ><A -NAME="AEN3971"><P +NAME="AEN3986"><P ><B >Example 2. Resulting SQL </B ></P @@ -187,7 +190,9 @@ ></TR ></TABLE > - To perform a general update on a table, use the WhereAdd() method + </P +><P +>&#13; To perform a general update on a table, use the WhereAdd() method <TABLE WIDTH="100%" BORDER="0" @@ -199,7 +204,7 @@ ><DIV CLASS="example" ><A -NAME="AEN3974"><P +NAME="AEN3990"><P ><B >Example 3. Simple fetch and updated</B ></P @@ -227,7 +232,9 @@ ></TR ></TABLE > - + </P +><P +>&#13; This would execute the following SQL statements, both fetching and updating the database. <TABLE WIDTH="100%" @@ -240,7 +247,7 @@ ><DIV CLASS="example" ><A -NAME="AEN3977"><P +NAME="AEN3994"><P ><B >Example 4. Resulting SQL </B ></P @@ -270,17 +277,17 @@ ><DIV CLASS="refsect1" ><A -NAME="AEN3980" +NAME="AEN3997" ></A ><H2 ->Insert</H2 +>::insert()</H2 ><P >&#13; Inserting data. </P ><DIV CLASS="funcsynopsis" ><A -NAME="AEN3983"><P +NAME="AEN4000"><P ></P ><P ><CODE @@ -308,7 +315,7 @@ ><DIV CLASS="example" ><A -NAME="AEN3990"><P +NAME="AEN4007"><P ><B >Example 5. Simple insert </B ></P @@ -335,7 +342,9 @@ ></TR ></TABLE > - + </P +><P +>&#13; This would execute the following SQL statements, (It may also do sequences on some databases, it uses mysql_next_id on mysql) <TABLE @@ -349,7 +358,7 @@ ><DIV CLASS="example" ><A -NAME="AEN3993"><P +NAME="AEN4011"><P ><B >Example 6. Resulting SQL </B ></P @@ -377,17 +386,17 @@ ><DIV CLASS="refsect1" ><A -NAME="AEN3996" +NAME="AEN4014" ></A ><H2 ->Delete</H2 +>::delete()</H2 ><P >&#13; Deleting data. </P ><DIV CLASS="funcsynopsis" ><A -NAME="AEN3999"><P +NAME="AEN4017"><P ></P ><P ><CODE @@ -397,13 +406,15 @@ CLASS="function" >::delete</B ></CODE -> ()</CODE +> ([boolean UseWhere])</CODE ></P ><P ></P ></DIV ><P ->&#13; Deletes data from the data, either using primary key or based on a WhereAdd() method call. +>&#13; Deletes data from the database, either using primary key or based on a WhereAdd() method call. + by default the delete will base it's query on the set variables, however if you wish to use the WhereAdd + method you should set the UseWhere parameter to TRUE <TABLE WIDTH="100%" BORDER="0" @@ -415,9 +426,9 @@ ><DIV CLASS="example" ><A -NAME="AEN4006"><P +NAME="AEN4025"><P ><B ->Example 7. Simple insert </B +>Example 7. Simple Delete </B ></P ><TABLE WIDTH="100%" @@ -437,7 +448,7 @@ $person = new DataObjects_Person; $person-&#62;whereAdd('age &#60; 21'); -$person-&#62;delete(); +$person-&#62;delete(TRUE); ?&#62;</PRE @@ -449,7 +460,9 @@ ></TR ></TABLE > - + </P +><P +>&#13; This would execute the following SQL statements, <TABLE WIDTH="100%" @@ -462,7 +475,7 @@ ><DIV CLASS="example" ><A -NAME="AEN4009"><P +NAME="AEN4029"><P ><B >Example 8. Resulting SQL </B ></P Index: pear/DB_DataObject/doc/packages.db.dataobject.utils.html diff -u pear/DB_DataObject/doc/packages.db.dataobject.utils.html:1.1 pear/DB_DataObject/doc/packages.db.dataobject.utils.html:1.2 --- pear/DB_DataObject/doc/packages.db.dataobject.utils.html:1.1 Fri Jun 21 05:51:49 2002 +++ pear/DB_DataObject/doc/packages.db.dataobject.utils.html Thu Jul 11 02:05:20 2002 @@ -76,25 +76,25 @@ ><DIV CLASS="refnamediv" ><A -NAME="AEN4167" +NAME="AEN4197" ></A >AutoForm Utilities and Debugging&nbsp;--&nbsp; - setFrom(), debugLevel() + ::setFrom(), ::debugLevel() </DIV ><DIV CLASS="refsect1" ><A -NAME="AEN4170" +NAME="AEN4200" ></A ><H2 ->setFrom</H2 +>::setFrom()</H2 ><P >&#13; Copies data from an Array or object into the current object </P ><DIV CLASS="funcsynopsis" ><A -NAME="AEN4173"><P +NAME="AEN4203"><P ></P ><P ><CODE @@ -104,13 +104,13 @@ CLASS="function" >::setFrom</B ></CODE -> (Array or Object from)</CODE +> ((Array or Object) from)</CODE ></P ><P ></P ></DIV ><P ->&#13; copies all that relates to this table (Except keys) into the current object +>&#13; copies all the data that relates to this table (Except keys) into the current object <TABLE WIDTH="100%" BORDER="0" @@ -122,7 +122,7 @@ ><DIV CLASS="example" ><A -NAME="AEN4180"><P +NAME="AEN4210"><P ><B >Example 1. Copying data from post or object</B ></P @@ -163,7 +163,9 @@ ></TR ></TABLE > - + </P +><P +>&#13; Copies all the data (with names the of this objects columns) from another object or array into this one. @@ -173,17 +175,17 @@ ><DIV CLASS="refsect1" ><A -NAME="AEN4183" +NAME="AEN4214" ></A ><H2 ->DB_DataObject::debugLevel</H2 +>DB_DataObject::debugLevel()</H2 ><P ->&#13; Sets the debugging level - so you can see the Queries Being build and executed +>&#13; Sets the debugging level - so you can see the queries being built and executed </P ><DIV CLASS="funcsynopsis" ><A -NAME="AEN4186"><P +NAME="AEN4217"><P ></P ><P ><CODE @@ -200,6 +202,7 @@ ></DIV ><P >&#13; Sets the debugging level (without any parameters it will disable the debugging output) + See the configuration page for details on the various levels. <TABLE WIDTH="100%" BORDER="0" @@ -211,7 +214,7 @@ ><DIV CLASS="example" ><A -NAME="AEN4194"><P +NAME="AEN4225"><P ><B >Example 2. Setting the debugging level </B ></P
« previous php.pear.cvs (#5025) next »