Location: PHPKode > projects > PHP on Trax > johnpipi-trax-f599562/trax/doc/PHPonTrax/tutorial_ActiveRecord.cls.html
<html>
<head>
<title>ActiveRecord</title>
<link rel="stylesheet" type="text/css" href="../media/style.css">
</head>
<body>

<table border="0" cellspacing="0" cellpadding="0" height="48" width="100%">
  <tr>
    <td class="header_top">PHPonTrax</td>
  </tr>
  <tr><td class="header_line"><img src="../media/empty.png" width="1" height="1" border="0" alt=""  /></td></tr>
  <tr>
    <td class="header_menu">
  		  [ <a href="../classtrees_PHPonTrax.html" class="menu">class tree: PHPonTrax</a> ]
		  [ <a href="../elementindex_PHPonTrax.html" class="menu">index: PHPonTrax</a> ]
		  [ <a href="../elementindex.html" class="menu">all elements</a> ]
    </td>
  </tr>
  <tr><td class="header_line"><img src="../media/empty.png" width="1" height="1" border="0" alt=""  /></td></tr>
</table>

<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="200" class="menu">
	<div id="todolist">
			<p><a href="../todolist.html">Todo List</a></p>
	</div>
      <b>Packages:</b><br />
              <a href="../li_PHPonTrax.html">PHPonTrax</a><br />
              <a href="../li_PHPonTraxTest.html">PHPonTraxTest</a><br />
            <br /><br />
		<b>Tutorials/Manuals:</b><br />
					<strong>Package-level:</strong>
							<ul>
	<li type="square"><a href="../PHPonTrax/tutorial_PHPonTrax.pkg.html">PHP On Trax</a>
<ul>
	<li type="square"><a href="../PHPonTrax/tutorial_rails_examples.pkg.html">Examples From The Rails Book</a>
</ul>

<ul>
	<li type="square"><a href="../PHPonTrax/tutorial_simpleapp.pkg.html">Build A Simple Trax Application</a>
</ul>

<ul>
	<li type="square"><a href="../PHPonTrax/tutorial_database.pkg.html">Create A Database and User</a>
</ul>

<ul>
	<li type="square"><a href="../PHPonTrax/tutorial_advbuild.pkg.html">Advanced Application Build Topics</a>
</ul>

<ul>
	<li type="square"><a href="../PHPonTrax/tutorial_naming.pkg.html">The Trax Naming Convention</a>
</ul>

<ul>
	<li type="square"><a href="../PHPonTrax/tutorial_troubleshoot.pkg.html">Troubleshooting</a>
</ul>

<ul>
	<li type="square"><a href="../PHPonTrax/tutorial_reference.pkg.html">Reference</a>
</ul>

</li></ul>


										<strong>Class-level:</strong>
							<ul>
	<li type="square"><a href="../PHPonTrax/tutorial_ActiveRecordHelper.cls.html">ActiveRecordHelper</a>
</ul>


							<ul>
	<li type="square"><a href="../PHPonTrax/tutorial_FormTagHelper.cls.html">FormTagHelper</a>
</ul>


							<ul>
	<li type="square"><a href="../PHPonTrax/tutorial_Helpers.cls.html">Helpers</a>
</ul>


							<ul>
	<li type="square"><a href="../PHPonTrax/tutorial_UrlHelper.cls.html">UrlHelper</a>
</ul>


							<ul>
	<li type="square"><a href="../PHPonTrax/tutorial_FormHelper.cls.html">FormHelper</a>
</ul>


							<ul>
	<li type="square"><a href="../PHPonTrax/tutorial_InputFilter.cls.html">InputFilter</a>
</ul>


							<ul>
	<li type="square"><a href="../PHPonTrax/tutorial_ActionMailer.cls.html">ActionMailer</a>
</ul>


							<ul>
	<li type="square"><a href="../PHPonTrax/tutorial_ApplicationController.cls.html">ApplicationController</a>
</ul>


							<ul>
	<li type="square"><a href="../PHPonTrax/tutorial_ActionController.cls.html">ActionController</a>
</ul>


							<ul>
	<li type="square"><a href="../PHPonTrax/tutorial_ActiveRecord.cls.html">ActiveRecord</a>
</ul>


							<ul>
	<li type="square"><a href="../PHPonTrax/tutorial_DateHelper.cls.html">DateHelper</a>
</ul>


							<ul>
	<li type="square"><a href="../PHPonTrax/tutorial_Router.cls.html">Router</a>
</ul>


							<ul>
	<li type="square"><a href="../PHPonTrax/tutorial_FormOptionsHelper.cls.html">FormOptionsHelper</a>
</ul>


							<ul>
	<li type="square"><a href="../PHPonTrax/tutorial_TraxGenerator.cls.html">TraxGenerator</a>
</ul>


							<ul>
	<li type="square"><a href="../PHPonTrax/tutorial_Session.cls.html">Session</a>
</ul>


							<ul>
	<li type="square"><a href="../PHPonTrax/tutorial_Inflector.cls.html">Inflector</a>
</ul>


							<ul>
	<li type="square"><a href="../PHPonTrax/tutorial_ActiveRecordError.cls.html">ActiveRecordError</a>
</ul>


							<ul>
	<li type="square"><a href="../PHPonTrax/tutorial_ActionControllerError.cls.html">ActionControllerError</a>
</ul>


							<ul>
	<li type="square"><a href="../PHPonTrax/tutorial_ScaffoldController.cls.html">ScaffoldController</a>
</ul>


							<ul>
	<li type="square"><a href="../PHPonTrax/tutorial_Dispatcher.cls.html">Dispatcher</a>
</ul>


							<ul>
	<li type="square"><a href="../PHPonTrax/tutorial_TraxError.cls.html">TraxError</a>
</ul>


							<ul>
	<li type="square"><a href="../PHPonTrax/tutorial_ApplicationMailer.cls.html">ApplicationMailer</a>
</ul>


							                        <b>Files:</b><br />
      	  <div class="package">
			<a href="../PHPonTrax/_vendor_trax_action_controller_php.html">		action_controller.php
		</a><br>
			<a href="../PHPonTrax/_vendor_trax_action_mailer_php.html">		action_mailer.php
		</a><br>
			<a href="../PHPonTrax/_vendor_trax_action_view_php.html">		action_view.php
		</a><br>
			<a href="../PHPonTrax/_vendor_trax_active_record_php.html">		active_record.php
		</a><br>
			<a href="../PHPonTrax/_vendor_trax_action_view_helpers_active_record_helper_php.html">		active_record_helper.php
		</a><br>
			<a href="../PHPonTrax/_vendor_trax_templates_scaffolds_add_phtml.html">		add.phtml
		</a><br>
			<a href="../PHPonTrax/_data_app_controllers_application_php.html">		application.php
		</a><br>
			<a href="../PHPonTrax/_data_app_views_layouts_application_phtml.html">		application.phtml
		</a><br>
			<a href="../PHPonTrax/_data_app_helpers_application_helper_php.html">		application_helper.php
		</a><br>
			<a href="../PHPonTrax/_data_app_application_mailer_php.html">		application_mailer.php
		</a><br>
			<a href="../PHPonTrax/_vendor_trax_action_view_helpers_asset_tag_helper_php.html">		asset_tag_helper.php
		</a><br>
			<a href="../PHPonTrax/_test_layouts_catalog_phtml.html">		catalog.phtml
		</a><br>
			<a href="../PHPonTrax/_vendor_trax_templates_scaffolds_generator_templates_controller_php.html">		controller.php
		</a><br>
			<a href="../PHPonTrax/_vendor_trax_templates_controller_php.html">		controller.php
		</a><br>
			<a href="../PHPonTrax/_vendor_trax_action_view_helpers_date_helper_php.html">		date_helper.php
		</a><br>
			<a href="../PHPonTrax/_data_config_environments_development_php.html">		development.php
		</a><br>
			<a href="../PHPonTrax/_data_public_dispatch_php.html">		dispatch.php
		</a><br>
			<a href="../PHPonTrax/_vendor_trax_dispatcher_php.html">		dispatcher.php
		</a><br>
			<a href="../PHPonTrax/_vendor_trax_templates_scaffolds_edit_phtml.html">		edit.phtml
		</a><br>
			<a href="../PHPonTrax/_data_config_environment_php.html">		environment.php
		</a><br>
			<a href="../PHPonTrax/_vendor_trax_templates_error_phtml.html">		error.phtml
		</a><br>
			<a href="../PHPonTrax/_vendor_trax_action_view_helpers_form_helper_php.html">		form_helper.php
		</a><br>
			<a href="../PHPonTrax/_vendor_trax_action_view_helpers_form_options_helper_php.html">		form_options_helper.php
		</a><br>
			<a href="../PHPonTrax/_vendor_trax_templates_scaffolds_generator_templates_form_scaffolding_phtml.html">		form_scaffolding.phtml
		</a><br>
			<a href="../PHPonTrax/_vendor_trax_action_view_helpers_form_tag_helper_php.html">		form_tag_helper.php
		</a><br>
			<a href="../PHPonTrax/_data_script_generate_php.html">		generate.php
		</a><br>
			<a href="../PHPonTrax/_vendor_trax_templates_helper_php.html">		helper.php
		</a><br>
			<a href="../PHPonTrax/_vendor_trax_action_view_helpers_php.html">		helpers.php
		</a><br>
			<a href="../PHPonTrax/_vendor_trax_templates_scaffolds_index_phtml.html">		index.phtml
		</a><br>
			<a href="../PHPonTrax/_vendor_trax_inflector_php.html">		inflector.php
		</a><br>
			<a href="../PHPonTrax/_vendor_trax_input_filter_php.html">		input_filter.php
		</a><br>
			<a href="../PHPonTrax/_vendor_trax_action_view_helpers_javascript_helper_php.html">		javascript_helper.php
		</a><br>
			<a href="../PHPonTrax/_vendor_trax_templates_scaffolds_generator_templates_layout_phtml.html">		layout.phtml
		</a><br>
			<a href="../PHPonTrax/_vendor_trax_templates_scaffolds_layout_phtml.html">		layout.phtml
		</a><br>
			<a href="../PHPonTrax/_makepkg_php.html">		makepkg.php
		</a><br>
			<a href="../PHPonTrax/_vendor_trax_templates_model_php.html">		model.php
		</a><br>
			<a href="../PHPonTrax/_data_config_environments_production_php.html">		production.php
		</a><br>
			<a href="../PHPonTrax/_vendor_trax_router_php.html">		router.php
		</a><br>
			<a href="../PHPonTrax/_data_config_routes_php.html">		routes.php
		</a><br>
			<a href="../PHPonTrax/_vendor_trax_scaffold_controller_php.html">		scaffold_controller.php
		</a><br>
			<a href="../PHPonTrax/_vendor_trax_session_php.html">		session.php
		</a><br>
			<a href="../PHPonTrax/_vendor_trax_templates_scaffolds_show_phtml.html">		show.phtml
		</a><br>
			<a href="../PHPonTrax/_data_config_environments_test_php.html">		test.php
		</a><br>
			<a href="../PHPonTrax/_trax_php.html">		trax.php
		</a><br>
			<a href="../PHPonTrax/_vendor_trax_trax_exceptions_php.html">		trax_exceptions.php
		</a><br>
			<a href="../PHPonTrax/_vendor_trax_trax_generator_php.html">		trax_generator.php
		</a><br>
			<a href="../PHPonTrax/_vendor_trax_action_view_helpers_url_helper_php.html">		url_helper.php
		</a><br>
			<a href="../PHPonTrax/_vendor_trax_templates_view_phtml.html">		view.phtml
		</a><br>
			<a href="../PHPonTrax/_vendor_trax_templates_scaffolds_generator_templates_view_add_phtml.html">		view_add.phtml
		</a><br>
			<a href="../PHPonTrax/_vendor_trax_templates_scaffolds_generator_templates_view_edit_phtml.html">		view_edit.phtml
		</a><br>
			<a href="../PHPonTrax/_vendor_trax_templates_scaffolds_generator_templates_view_index_phtml.html">		view_index.phtml
		</a><br>
			<a href="../PHPonTrax/_vendor_trax_templates_scaffolds_generator_templates_view_show_phtml.html">		view_show.phtml
		</a><br>
	  </div><br />

      
            <b>Classes:</b><br />
        <div class="package">
		    		<a href="../PHPonTrax/.html"></a><br />
	    		<a href="../PHPonTrax/ActionController.html">ActionController</a><br />
	    		<a href="../PHPonTrax/ActionControllerError.html">ActionControllerError</a><br />
	    		<a href="../PHPonTrax/ActionMailer.html">ActionMailer</a><br />
	    		<a href="../PHPonTrax/ActiveRecord.html">ActiveRecord</a><br />
	    		<a href="../PHPonTrax/ActiveRecordError.html">ActiveRecordError</a><br />
	    		<a href="../PHPonTrax/ActiveRecordHelper.html">ActiveRecordHelper</a><br />
	    		<a href="../PHPonTrax/ApplicationController.html">ApplicationController</a><br />
	    		<a href="../PHPonTrax/ApplicationMailer.html">ApplicationMailer</a><br />
	    		<a href="../PHPonTrax/AssetTagHelper.html">AssetTagHelper</a><br />
	    		<a href="../PHPonTrax/DateHelper.html">DateHelper</a><br />
	    		<a href="../PHPonTrax/Dispatcher.html">Dispatcher</a><br />
	    		<a href="../PHPonTrax/FormHelper.html">FormHelper</a><br />
	    		<a href="../PHPonTrax/FormOptionsHelper.html">FormOptionsHelper</a><br />
	    		<a href="../PHPonTrax/FormTagHelper.html">FormTagHelper</a><br />
	    		<a href="../PHPonTrax/Helpers.html">Helpers</a><br />
	    		<a href="../PHPonTrax/Inflector.html">Inflector</a><br />
	    		<a href="../PHPonTrax/InputFilter.html">InputFilter</a><br />
	    		<a href="../PHPonTrax/JavaScriptHelper.html">JavaScriptHelper</a><br />
	    		<a href="../PHPonTrax/Router.html">Router</a><br />
	    		<a href="../PHPonTrax/ScaffoldController.html">ScaffoldController</a><br />
	    		<a href="../PHPonTrax/Session.html">Session</a><br />
	    		<a href="../PHPonTrax/TraxError.html">TraxError</a><br />
	    		<a href="../PHPonTrax/TraxGenerator.html">TraxGenerator</a><br />
	    		<a href="../PHPonTrax/UrlHelper.html">UrlHelper</a><br />
	  </div>

                </td>
    <td>
      <table cellpadding="10" cellspacing="0" width="100%" border="0"><tr><td valign="top">

<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="10%" align="left" valign="bottom"><a href=
"../PHPonTrax/tutorial_ActionController.cls.html">Prev</a></td>
<td width="80%" align="center" valign="bottom"></td>
<td width="10%" align="right" valign="bottom"><a href=
"../PHPonTrax/tutorial_DateHelper.cls.html">Next</a></td>
</tr>
</table>
<div><a name=""></a><div class="ref-title-box">ActiveRecord<h1 class="ref-title">ActiveRecord</h1>
  <h2 class="ref-purpose">Base class for the active record design pattern</h2></div>
 <div class="ref-synopsis"><span class="author">Walt Haas
   <div class="author-blurb"><a href="mailto:hide@address.com">hide@address.com</a></div></span></div>
 <h1 align="center">Table of Contents</h1>
<ul>

<a href="../PHPonTrax/tutorial_ActiveRecord.cls.html#active_record_intro">Introduction</a><br />

<a href="../PHPonTrax/tutorial_ActiveRecord.cls.html#basic_methods">Basic Methods</a><br />

&nbsp;&nbsp;&nbsp;<a href="../PHPonTrax/tutorial_ActiveRecord.cls.html#basic_methods.create_methods">Create</a><br />

&nbsp;&nbsp;&nbsp;<a href="../PHPonTrax/tutorial_ActiveRecord.cls.html#basic_methods.read_methods">Read</a><br />

&nbsp;&nbsp;&nbsp;<a href="../PHPonTrax/tutorial_ActiveRecord.cls.html#basic_methods.update_methods">Update</a><br />

&nbsp;&nbsp;&nbsp;<a href="../PHPonTrax/tutorial_ActiveRecord.cls.html#basic_methods.delete_methods">Delete</a><br />

&nbsp;&nbsp;&nbsp;<a href="../PHPonTrax/tutorial_ActiveRecord.cls.html#basic_methods.agg_methods">SQL Aggregate Functions</a><br />

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="../PHPonTrax/tutorial_ActiveRecord.cls.html#basic_methods.agg_methods.agg_method_avg">avg_all()</a><br />

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="../PHPonTrax/tutorial_ActiveRecord.cls.html#basic_methods.agg_methods.agg_method_count">count_all()</a><br />

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="../PHPonTrax/tutorial_ActiveRecord.cls.html#basic_methods.agg_methods.agg_method_max">max_all()</a><br />

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="../PHPonTrax/tutorial_ActiveRecord.cls.html#basic_methods.agg_methods.agg_method_min">min_all()</a><br />

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="../PHPonTrax/tutorial_ActiveRecord.cls.html#basic_methods.agg_methods.agg_method_sum">sum_all()</a><br />

<a href="../PHPonTrax/tutorial_ActiveRecord.cls.html#associations">Associations</a><br />
</ul>

 <span><a name="active_record_intro"></a><h2 class="title">Introduction</h2><p>Heart of Active Record design pattern.  Encapsulates all
   access to data in corresponding table.  Enforces domain rules.
   Never instantiated directly.  Subclass for each table.</p>
   <p>Each subclass of this class is associated with a database table
   in the Model section of the Model-View-Controller architecture.
   By convention, the name of each subclass is the CamelCase singular
   form of the table name, which is in the lower_case_underscore
   plural notation.  For example, 
   a table named &quot;order_details&quot; would be associated with a subclass
   of ActiveRecord named &quot;OrderDetail&quot;, and a table named &quot;people&quot;
   would be associated with subclass &quot;Person&quot;.  Naming convention
   encapsulated in <a href="../PHPonTrax/tutorial_Inflector.cls.html">Inflector</a> class.</p>
   <p>Convention: primary key of each table is column named &quot;id&quot;.</p>
   <p>For a discussion of the ActiveRecord design pattern, see
   &quot;Patterns of Enterprise 
   Application Architecture&quot; by Martin Fowler, pp. 160-164.</p>
   <p>When object constructed, the format of a row in the
   associated table is retrieved from 
   the database and stored in object variable $content_columns.
   The data values of the columns are stored as object variable with
   the same name as the column.  Therefore, it is not possible to have
   a column with the same name as an object variable</p></span>
 <span><a name="basic_methods"></a><h2 class="title">Basic Methods</h2><a name="basic_methods.create_methods"></a><h3 class="title">Create</h3><p>Before you can use the subclass of ActiveRecord associated
    with a table, you must install the table definition in the
    database.  For example:</p>
    <pre class="example">drop table if exists person_names;
create table person_names
  (id         int auto_increment primary key,
   prefix     varchar(20) null,
   first_name varchar(40) null,
   mi         char(1)     null,
   last_name  varchar(40) null,
   suffix     varchar(20) null);</pre>
    <p>With the table definition installed in the database, you can
    create an object that references that table.  The
    <a href="../PHPonTrax/ActiveRecord.html#method__construct">constructor</a> for
    PersonName connects to the database and reads the definition for
    table person_names to find the names of its columns, which then
    become the names of the related attributes of the object.</p>
    <pre class="example">class PersonName extends ActiveRecord {
};
$p = new PersonName;    
$p-&gt;first_name = &quot;Lo&quot;;
$p-&gt;last_name  = &quot;Phat&quot;;
$p-&gt;suffix     = &quot;MD&quot;;
$result = $p-&gt;save();</pre>
    <p>$result will be true if the row was saved successfully, false
    otherwise.  Slightly more compact ways to say the same thing:</p>
    <pre class="example">$p = new PersonName;    
$result = $p-&gt;save(array(&quot;first_name&quot; =&gt; &quot;Lo&quot;,&quot;last_name&quot; =&gt; &quot;Phat&quot;,
                     &quot;suffix&quot; =&gt; &quot;MD&quot;));</pre>
    <p>or assign attribute values in the constructor:</p>
    <pre class="example">$p = new PersonName(array(&quot;first_name&quot; =&gt; &quot;Lo&quot;,&quot;last_name&quot; =&gt; &quot;Phat&quot;,
                     &quot;suffix&quot; =&gt; &quot;MD&quot;));    
$result = $p-&gt;save();</pre>
    <p>You can define the class so that it requires certain
    validation tests in order
    to be saved.  Here is a definition that will generate an error on
    save() if either &quot;first_name&quot; or &quot;last_name&quot; is left blank.
    When you call save(), the object is inspected for method
    names like 'validate_*' where '*' is the name of a column.
    All such methods are executed, and the results are tested.
    The return must be an array with true or false in the first
    element, and an error message in the second if the first is
    false.  If any of the 'validate_*' methods returns false, the
    save fails:</p>
    <pre class="example">class PersonName extends ActiveRecord {
    //  Function to validate first name not blank
    function validate_first_name() {
        if ($this-&gt;first_name == '') {
            return array(false, &quot;first name is blank&quot;);
        } else {
            return array(true);
        }}
    //  Function to validate last name not blank
    function validate_last_name() {
        if ($this-&gt;last_name == '') {
            return array(false, &quot;last name is blank&quot;);
        } else {
            return array(true);
        }}
};
$result = $p-&gt;save(array(&quot;suffix&quot; =&gt; &quot;MD&quot;));
if ($result == false) {
   //  Errors are listed in array $p-&gt;errors
   echo &quot;save failed:\n&quot;;
   foreach ($p-&gt;errors as $key =&gt; $value) {
       echo &quot;  field $key: $value\n&quot;;
   }
}</pre>
    <p>This will output:</p>
    <pre class="example">save failed:
  field first_name: first name is blank
  field last_name: last name is blank</pre>
    <p>If you misspell an attribute, the misspelled name will
    become an attribute of the object, but it will not be saved
    because it is not the name of a column.  This will not result in
    an error message (unless that attribute fails validation):  For
    example:</p>
    <pre class="example">$p = new PersonName(array(&quot;first_name&quot; =&gt; &quot;Lo&quot;,&quot;last_name&quot; =&gt; &quot;Phat&quot;,
                     &quot;sufix&quot; =&gt; &quot;MD&quot;));    
$result = $p-&gt;save();</pre>
    <p>This will not fail, but the attribute $p-&gt;sufix will not be
    saved. Instead, column 'suffix' will be set to '' (empty string).</p><hr />
  <a name="basic_methods.read_methods"></a><h3 class="title">Read</h3><p>The find*() methods search the table associated with this
   class for rows that match some argument and return a new object of
   this class for each matching row.  In the simplest case, you know
   the value of the id column of the row you want:</p>
   <pre class="example">$p = new PersonName();
$rs = $p-&gt;find(&quot;42&quot;);
//  $rs is a new object representing the row with id 42,
//  or false if it wasn't found.  $p object remains empty.</pre>
   <p>You can ask for multiple id values with one find:</p>
   <pre class="example">$rs = $p-&gt;find(array(&quot;17&quot;,&quot;23&quot;,&quot;65&quot;));
//  $rs is an array containing zero or more new objects representing the
//  matching rows.  The keys of the array are the id values that matched.</pre>
   <p>You can search the table more generally with the find_all()
   method, which allows you to provide an SQL clause to describe the
   match rule.  For example:</p>
   <pre class="example">$rs = $p-&gt;find_all(&quot;last_name='Dover'&quot;);
//  $rs is an array containing zero or more new objects representing the
//  matching rows.  The keys of the array are the id values that matched.</pre>
   <p>The argument you provide must be a valid SQL WHERE clause
   and it must contain an '='.</p>
   <p>If you omit the argument or provide an argument of null, you
   get all rows in the table.</p> 
   <p>You can also use a second argument to control the order of
   the results.  This argument must be a valid SQL ORDER BY clause.
   For example:</p>
   <pre class="example">$rs = $p-&gt;find_all(&quot;last_name='Dover'&quot;,&quot;last_name,first_name&quot;);</pre>
   <p>The find_first() method returns only the first matching row.
   Is there a doctor in the house?</p>
   <pre class="example">$rs = $p-&gt;find_first(&quot;prefix='Dr.'&quot;);
//  $rs is a new object representing the first row with prefix 'Dr.',
//  or false if none was found</pre>
   <p>An error, such as incorrect SQL, causes an
   <a href="../PHPonTrax/tutorial_ActiveRecordError.cls.html">ActiveRecordError</a>
   exception to be thrown.  Note that
   it is not an error for no matching rows to be found.</p><hr />
  <a name="basic_methods.update_methods"></a><h3 class="title">Update</h3><p>@todo Update tutorial</p><hr />
  <a name="basic_methods.delete_methods"></a><h3 class="title">Delete</h3><p>@todo Delete tutorial</p><hr />
  <a name="basic_methods.agg_methods"></a><h3 class="title">SQL Aggregate Functions</h3><p>SQL defines aggregate functions AVG(), COUNT(), MAX(), MIN()
     and SUM().  Not all DBMS's implement all of them.  Implemented by
     methods avg_all(), count_all(), max_all(), min_all() and sum_all().
     Parameters: [0]: If present, expression to apply
            the aggregate function to.  Otherwise, '*' will be used.
            NOTE:SQL uses '*' only for the COUNT() function,
            where it means &quot;including rows with NULL in this column&quot;.
          [1]: argument to WHERE clause
          [2]: joins??? @todo. Joins parameter  Method call is calculated from list
          in $aggregrations</p>

   <a name="basic_methods.agg_methods.agg_method_avg"></a><h4 class="title">avg_all()</h4><p>@todo Document avg_all()</p><br />
   <a name="basic_methods.agg_methods.agg_method_count"></a><h4 class="title">count_all()</h4><p>@todo Document count_all()</p>
    <p></p><br />
   <a name="basic_methods.agg_methods.agg_method_max"></a><h4 class="title">max_all()</h4><p>@todo Document max_all()</p>
    <p></p><br />
   <a name="basic_methods.agg_methods.agg_method_min"></a><h4 class="title">min_all()</h4><p>@todo Document min_all()</p>
    <p></p><br />
   <a name="basic_methods.agg_methods.agg_method_sum"></a><h4 class="title">sum_all()</h4><p>@todo Document sum_all()</p>
    <p></p><br /><hr /></span>
 <span><a name="associations"></a><h2 class="title">Associations</h2><p>@todo Document associations</p>
    <p>belongs_to</p>
    <p>has_one</p>
    <p>has_many</p>
    <p>has_and_belongs_to_many</p></span></div>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="33%" align="left" valign="top"><a href="../PHPonTrax/tutorial_ActionController.cls.html">Prev</a></td>
<td width="34%" align="center" valign="top">&nbsp;</td>
<td width="33%" align="right" valign="top"><a href=
"../PHPonTrax/tutorial_DateHelper.cls.html">Next</a></td>
</tr>

<tr>
<td width="33%" align="left" valign="top">ActionController</td>
<td width="34%" align="center" valign="top"></td>
<td width="33%" align="right" valign="top">DateHelper</td>
</tr>
</table>
        <div class="credit">
		    <hr />
		    Documentation generated on Thu, 04 May 2006 19:46:55 -0600 by <a href="http://www.phpdoc.org">phpDocumentor 1.3.0RC4</a>
	      </div>
      </td></tr></table>
    </td>
  </tr>
</table>

</body>
</html>
Return current item: PHP on Trax