cvs: peardoc /peardoc2/en/package/database/db-dataobject intro-filters.xml intro-relations.xml
/peardoc2/en/package/database/db-dataobject/db-dataobject staticget2.xml

From: Date: Tue, 14 Jan 2003 08:22:58 +0000
Subject: cvs: peardoc /peardoc2/en/package/database/db-dataobject intro-filters.xml intro-relations.xml
/peardoc2/en/package/database/db-dataobject/db-dataobject staticget2.xml
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-263@lists.php.net to get a copy of this message
alan_k Tue Jan 14 03:22:58 2003 EDT Added files: /peardoc/peardoc2/en/package/database/db-dataobject intro-filters.xml intro-relations.xml /peardoc/peardoc2/en/package/database/db-dataobject/db-dataobject staticget2.xml Log: the new files in dataobject documentation - will send email seperatly about it...

Index: peardoc/peardoc2/en/package/database/db-dataobject/intro-filters.xml +++ peardoc/peardoc2/en/package/database/db-dataobject/intro-filters.xml <refentry id="package.database.db-dataobject.intro-filters"> <refnamediv> <refname>Advanced Filters</refname> <refpurpose> Advanced Filters - ::query(), ::SelectAdd(), ::whereAdd(), ::Limit(), ::OrderBy(), ::GroupBy(), </refpurpose> </refnamediv> <refsect1> <title>More advanced Querying</title> <para> The basic features allow most simple queries to be done very quickly, however building more complex queries can be done using the methods listed below, which append or set conditions that build the query. You will find that there is a fine balance between using these builder methods and just using raw SQL. </para> <para> The DB_DataObject can now handle JOIN queries, however please read the introduction to linking and Joining before jumping in and using the Join feature, as you may be trading the use of a cool feature, against the readibility of your code. </para> </refsect1> </refentry> Index: peardoc/peardoc2/en/package/database/db-dataobject/intro-relations.xml +++ peardoc/peardoc2/en/package/database/db-dataobject/intro-relations.xml <refentry id="packages.database.db-dataobject.relations"> <refnamediv> <refname>Automatic Table Linking and Joins</refname> <refpurpose> Automatic Table Linking - ::getLink(), ::getLinks(), ::joinAdd() </refpurpose> </refnamediv> <refsect1> <title>Automating the collection of related data</title> <para> When designing a database, often some tables are related to others - a membership table would contain a reference to a person's id and the group id that they are a member of. Using the Link methods, you can automatically fetch objects into the parents variables. </para> <para> Currently automated links are supported by column naming conventions, this feature is depreciated in favour of using the links.ini files. As this offers a more flexible and clearer way of performing these operations. </para> <para> 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. </para> <para> Recent versions of DB_DataObject also included support for table joins, this uses the same links.ini configuration to build join queries. </para> </refsect1> <refsect1> <title>Using link ini files for table links</title> <para> DB_DataObject Version 0.3 introduced the ability to create link ini files so you can map rows to other database columns using an ini file this ini file should have the name databasename.links.ini, and be placed in the same folder as the databasename.ini file that is created automatically by createTables.php </para> <para> The 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. 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. <example> <title> An example databasename.links.ini file</title> <programlisting role="ini"><![CDATA[ ; for table person [person] ; link value of eycolor to table colors, match name column eyecolor = colors:name ; link value of owner to table grp, match id column owner = grp:id ; link value of picture to table attachments, match id column picture = attachments:id ; for a sales example with multiple links of a single column [sales] ; for autoloading the car object into $sales->_car_id car_id = car:id ; for autoloading the part number object into $sales->_car_id_partnum car_id.partnum = part_numbers:car_id ]]> </programlisting> </example> </para> </refsect1> </refentry> Index: peardoc/peardoc2/en/package/database/db-dataobject/db-dataobject/staticget2.xml +++ peardoc/peardoc2/en/package/database/db-dataobject/db-dataobject/staticget2.xml <!-- $Revision: 1.1 $ --> <refentry id="package.database.db-dataobject.db-dataobject.staticget2"> <refnamediv> <refname>{Child Class}::staticGet()</refname> <refpurpose>Simple Get (Select) request, abbreviated (autogenerated)</refpurpose> </refnamediv> <refsynopsisdiv> <funcsynopsis> <funcprototype> <funcdef>object <function>{Child Class}::staticGet</function></funcdef> <paramdef> mixed <parameter>$key or $value</parameter> </paramdef> <paramdef> mixed <parameter><optional>$value</optional></parameter> </paramdef> </funcprototype> </funcsynopsis> </refsynopsisdiv> <refsect1 id="package.database.db-dataobject.db-dataobject.staticget2.desc"> &title.desc; <para> The static method is similar to the get request, however it does not require the initial instantiation of the class. <function>staticGet</function> can optionally cache the results. (see the configuration section) </para> </refsect1> <refsect1 id="package.database.db-dataobject.db-dataobject.staticget2.parameter"> &title.param; <para> <itemizedlist> <listitem> <para> <parameter>string $key</parameter> - column or value if only one parameter is given </para> </listitem> <listitem> <para> <parameter>mixed $value</parameter> - value </para> </listitem> </itemizedlist> </para> </refsect1> <refsect1 id="package.database.db-dataobject.db-dataobject.staticget2.return"> &title.returns; <para> <parameter>object mixed</parameter> - false or the object </para> </refsect1> <refsect1 id="package.database.db-dataobject.db-dataobject.staticget2.throws"> &title.throws; <para> <table> <title>&title.throws.errortable;</title> <tgroup cols="4"> <thead> <row> <entry>Error code</entry> <entry>Error message</entry> <entry>Meaning</entry> <entry>Solution</entry> </row> </thead> <tbody> <row> <entry>DB_DATAOBJECT_ERROR_NOCLASS</entry> <entry><quote>could not autoload $class</quote></entry> <entry></entry> <entry></entry> </row> <row> <entry>DB_DATAOBJECT_ERROR_NOCLASS</entry> <entry><quote>Error creating $newclass</quote></entry> <entry></entry> <entry></entry> </row> <row> <entry>DB_DATAOBJECT_ERROR_NODATA</entry> <entry><quote>No Data return from get $key $value</quote></entry> <entry></entry> <entry></entry> </row> </tbody> </tgroup> </table> </para> </refsect1> <refsect1 id="package.database.db-dataobject.db-dataobject.staticget2.note"> &title.note; <simpara>This method must be called statically.</simpara> <simpara></simpara> </refsect1> <refsect1 id="package.database.db-dataobject.db-dataobject.staticget2.example"> &title.example; <example> <title>Simple fetch of data based on Primary Key</title> <programlisting role="php"> <![CDATA[ $person = DataObjects_Person::staticGet(12); print_r($person); ]]> </programlisting> </example> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->
« previous php.pear.doc (#263) next »