Location: PHPKode > scripts > Database access class > database-access-class/databaseaccessclass.html
<html>
<head>
<title>Class: Database access</title>
</head>
<body>
<center><h1>Class: Database access</h1></center>
<hr />
<ul>
<p><b>Version control:</b> <tt>@(#) $Id: databaseaccessclass.class,v 1.17 2001/05/06 02:24:21 mlemos Exp $</tt></p>
<h2><a name="table_of_contents">Contents</a></h2>
<ul>
<li><a href="#2.1.1">Summary</a></li>
<li><a href="#4.1.1">Variables</a></li>
<ul>
<li><a href="#5.2.11">database</a></li>
<li><a href="#5.2.12">error</a></li>
<li><a href="#5.2.13">changes</a></li>
<li><a href="#5.2.14">date_year_suffix</a></li>
<li><a href="#5.2.15">date_month_suffix</a></li>
<li><a href="#5.2.16">date_day_suffix</a></li>
<li><a href="#5.2.17">date_hour_suffix</a></li>
<li><a href="#5.2.18">date_minute_suffix</a></li>
<li><a href="#5.2.19">date_second_suffix</a></li>
<li><a href="#5.2.20">verify_multiple_selected_rows</a></li>
</ul>
<li><a href="#6.1.1">Functions</a></li>
<ul>
<li><a href="#7.2.7">convertfieldvalue</a></li>
<li><a href="#9.2.8">insertformvalues</a></li>
<li><a href="#11.2.9">selectformvalues</a></li>
<li><a href="#13.2.10">deleteformvalues</a></li>
<li><a href="#15.2.11">updateformchanges</a></li>
<li><a href="#17.2.12">selectlistvalues</a></li>
</ul>
</ul>
<p><a href="#table_of_contents">Top of the table of contents</a></p>
</ul>
<hr />
<ul>
<h2><li><a name="2.1.1">Summary</a></li></h2>
<ul>
<h3>Name</h3>
<p>Database access</p>
<h3>Author</h3>
<p>Manuel Lemos (<a href="mailto:hide@address.com">hide@address.com</a>)</p>
<h3>Version</h3>
<p>@(#) $Id: databaseaccessclass.class,v 1.17 2001/05/06 02:24:21 mlemos Exp $</p>
<h3>Purpose</h3>
<p>Interchanging data between forms and databases.</p>
<h3>Usage</h3>
<p>The class has several independent functions that do different operations with data that is retrieved from a database into form fields and vice-versa.</p>
<p><a href="#table_of_contents">Table of contents</a></p>
</ul>
</ul>
<hr />
<ul>
<h2><li><a name="variables"></a><a name="4.1.1">Variables</a></li></h2>
<ul>
<li><tt><a href="#variable_database">database</a></tt></li><br />
<li><tt><a href="#variable_error">error</a></tt></li><br />
<li><tt><a href="#variable_changes">changes</a></tt></li><br />
<li><tt><a href="#variable_date_year_suffix">date_year_suffix</a></tt></li><br />
<li><tt><a href="#variable_date_month_suffix">date_month_suffix</a></tt></li><br />
<li><tt><a href="#variable_date_day_suffix">date_day_suffix</a></tt></li><br />
<li><tt><a href="#variable_date_hour_suffix">date_hour_suffix</a></tt></li><br />
<li><tt><a href="#variable_date_minute_suffix">date_minute_suffix</a></tt></li><br />
<li><tt><a href="#variable_date_second_suffix">date_second_suffix</a></tt></li><br />
<li><tt><a href="#variable_verify_multiple_selected_rows">verify_multiple_selected_rows</a></tt></li><br />
<p><a href="#table_of_contents">Table of contents</a></p>
<h3><a name="variable_database"></a><li><a name="5.2.11">database</a></li></h3>
<h3>Type</h3>
<p><tt><i>int</i></tt></p>
<h3>Default value</h3>
<p><tt>0</tt></p>
<h3>Purpose</h3>
<p>Database access handle needed to execute database queries.</p>
<h3>Usage</h3>
<p>It must be initialized by the application after creating an object of this class with a database access handle returned by the <tt>MetabaseSetupDatabase()</tt> function.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_error"></a><li><a name="5.2.12">error</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>&quot;&quot;</tt></p>
<h3>Purpose</h3>
<p>Error message text in english.</p>
<h3>Usage</h3>
<p>Retrieve this variable a call to a function of this class fails to figure the cause of failure.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_changes"></a><li><a name="5.2.13">changes</a></li></h3>
<h3>Type</h3>
<p><tt><i>int</i></tt></p>
<h3>Default value</h3>
<p><tt>0</tt></p>
<h3>Purpose</h3>
<p>Total number of changed form field values that lead to database table field updates with the function <tt><a href="#function_updateformchanges">updateformchanges</a></tt>.</p>
<h3>Usage</h3>
<p>Fetch this variable after one or more calls to the <tt><a href="#function_updateformchanges">updateformchanges</a></tt> function when you want to figure any database table changes were performed by this function.  You may want to set this variable to <tt>0</tt> when you need to start a new set of database updates from the form values.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_date_year_suffix"></a><li><a name="5.2.14">date_year_suffix</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>&quot;_year&quot;</tt></p>
<h3>Purpose</h3>
<p>Suffix of the name of the input forms that contains the year part of the a date value stored or retrieved by the functions <tt><a href="#function_insertformvalues">insertformvalues</a></tt>,  <tt><a href="#function_selectformvalues">selectformvalues</a></tt>, <tt><a href="#function_deleteformvalues">deleteformvalues</a></tt> and <tt><a href="#function_updateformchanges">updateformchanges</a></tt>.</p>
<h3>Usage</h3>
<p>Only change from the default value if the resulting names collide with another form field name.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_date_month_suffix"></a><li><a name="5.2.15">date_month_suffix</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>&quot;_month&quot;</tt></p>
<h3>Purpose</h3>
<p>Suffix of the name of the input forms that contains the month part of the a date value stored or retrieved by the functions <tt><a href="#function_insertformvalues">insertformvalues</a></tt>, <tt><a href="#function_selectformvalues">selectformvalues</a></tt>, <tt><a href="#function_deleteformvalues">deleteformvalues</a></tt> and <tt><a href="#function_updateformchanges">updateformchanges</a></tt>.</p>
<h3>Usage</h3>
<p>Only change from the default value if the resulting names collide with another form field name.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_date_day_suffix"></a><li><a name="5.2.16">date_day_suffix</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>&quot;_day&quot;</tt></p>
<h3>Purpose</h3>
<p>Suffix of the name of the input forms that contains the day part of the a date value stored or retrieved by the functions <tt><a href="#function_insertformvalues">insertformvalues</a></tt>, <tt><a href="#function_selectformvalues">selectformvalues</a></tt>, <tt><a href="#function_deleteformvalues">deleteformvalues</a></tt> and <tt><a href="#function_updateformchanges">updateformchanges</a></tt>.</p>
<h3>Usage</h3>
<p>Only change from the default value if the resulting names collide with another form field name.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_date_hour_suffix"></a><li><a name="5.2.17">date_hour_suffix</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>&quot;_hour&quot;</tt></p>
<h3>Purpose</h3>
<p>Suffix of the name of the input forms that contains the hours part of the a time value stored or retrieved by the functions <tt><a href="#function_insertformvalues">insertformvalues</a></tt>, <tt><a href="#function_selectformvalues">selectformvalues</a></tt>, <tt><a href="#function_deleteformvalues">deleteformvalues</a></tt> and <tt><a href="#function_updateformchanges">updateformchanges</a></tt>.</p>
<h3>Usage</h3>
<p>Only change from the default value if the resulting names collide with another form field name.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_date_minute_suffix"></a><li><a name="5.2.18">date_minute_suffix</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>&quot;_minute&quot;</tt></p>
<h3>Purpose</h3>
<p>Suffix of the name of the input forms that contains the minutes part of the a time value stored or retrieved by the functions <tt><a href="#function_insertformvalues">insertformvalues</a></tt>, <tt><a href="#function_selectformvalues">selectformvalues</a></tt>, <tt><a href="#function_deleteformvalues">deleteformvalues</a></tt> and <tt><a href="#function_updateformchanges">updateformchanges</a></tt>.</p>
<h3>Usage</h3>
<p>Only change from the default value if the resulting names collide with another form field name.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_date_second_suffix"></a><li><a name="5.2.19">date_second_suffix</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>&quot;_second&quot;</tt></p>
<h3>Purpose</h3>
<p>Suffix of the name of the input forms that contains the seconds part of the a time value stored or retrieved by the functions <tt><a href="#function_insertformvalues">insertformvalues</a></tt>, <tt><a href="#function_selectformvalues">selectformvalues</a></tt>, <tt><a href="#function_deleteformvalues">deleteformvalues</a></tt> and <tt><a href="#function_updateformchanges">updateformchanges</a></tt>.</p>
<h3>Usage</h3>
<p>Only change from the default value if the resulting names collide with another form field name.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_verify_multiple_selected_rows"></a><li><a name="5.2.20">verify_multiple_selected_rows</a></li></h3>
<h3>Type</h3>
<p><tt><i>bool</i></tt></p>
<h3>Default value</h3>
<p><tt>1</tt></p>
<h3>Purpose</h3>
<p>Indicate whether the function <tt><a href="#function_selectformvalues">selectformvalues</a></tt> should verify whether the <tt>SELECT</tt> database query that is executed returns more than one result row.</p>
<h3>Usage</h3>
<p>Set this variable to <tt>1</tt> if you want to verify whether there is a bug in the conditions that are used in the <tt>SELECT</tt> query executed by the <tt><a href="#function_selectformvalues">selectformvalues</a></tt> function.  In that case the function will fail with an error noticing that problem. Otherwise the situation may go unnoticed.</p>
<p><a href="#variables">Variables</a></p>
<p><a href="#table_of_contents">Table of contents</a></p>
</ul>
</ul>
<hr />
<ul>
<h2><li><a name="functions"></a><a name="6.1.1">Functions</a></li></h2>
<ul>
<li><tt><a href="#function_convertfieldvalue">convertfieldvalue</a></tt></li><br />
<li><tt><a href="#function_insertformvalues">insertformvalues</a></tt></li><br />
<li><tt><a href="#function_selectformvalues">selectformvalues</a></tt></li><br />
<li><tt><a href="#function_deleteformvalues">deleteformvalues</a></tt></li><br />
<li><tt><a href="#function_updateformchanges">updateformchanges</a></tt></li><br />
<li><tt><a href="#function_selectlistvalues">selectlistvalues</a></tt></li><br />
<p><a href="#table_of_contents">Table of contents</a></p>
<h3><a name="function_convertfieldvalue"></a><li><a name="7.2.7">convertfieldvalue</a></li></h3>
<h3>Synopsis</h3>
<p><tt><i>string</i> convertfieldvalue(</tt><ul>
<tt><i>string</i> </tt><tt><a href="#argument_convertfieldvalue_fieldvalue">fieldvalue</a></tt><tt>,<br />
</tt><tt><i>string</i> </tt><tt><a href="#argument_convertfieldvalue_type">type</a></tt><tt></tt></ul>
<tt>)</tt></p>
<h3>Purpose</h3>
<p>Convert a string value taken from a form field into a database native representation format for the specified type.</p>
<h3>Usage</h3>
<p>This function is meant only for the class internal use.</p>
<h3>Arguments</h3>
<ul>
<p><tt><b><a name="argument_convertfieldvalue_fieldvalue">fieldvalue</a></b></tt> - Value that is meant to be converted.</p>
<p><tt><b><a name="argument_convertfieldvalue_type">type</a></b></tt> - Type that should be assumed when converting the value.</p>
</ul>
<h3>Return value</h3>
<p>The string converted into the database native representation format of the specified type.</p>
<p><a href="#functions">Functions</a></p>
<h3><a name="function_insertformvalues"></a><li><a name="9.2.8">insertformvalues</a></li></h3>
<h3>Synopsis</h3>
<p><tt><i>bool</i> insertformvalues(</tt><ul>
<tt>(reference) <i>object</i> </tt><tt><a href="#argument_insertformvalues_form">form</a></tt><tt>,<br />
</tt><tt><i>string</i> </tt><tt><a href="#argument_insertformvalues_table">table</a></tt><tt>,<br />
</tt><tt><i>array</i> </tt><tt><a href="#argument_insertformvalues_fields">fields</a></tt><tt>,<br />
</tt><tt><i>array</i> </tt><tt><a href="#argument_insertformvalues_inputs">inputs</a></tt><tt>,<br />
</tt><tt><i>array</i> </tt><tt><a href="#argument_insertformvalues_nullmap">nullmap</a></tt><tt>,<br />
</tt><tt><i>array</i> </tt><tt><a href="#argument_insertformvalues_extrafields">extrafields</a></tt><tt></tt></ul>
<tt>)</tt></p>
<h3>Purpose</h3>
<p>Insert a new row into a given database table with values of specified form fields.</p>
<h3>Arguments</h3>
<ul>
<p><tt><b><a name="argument_insertformvalues_form">form</a></b></tt> - Form object from which it should be fetched the specified field values.</p>
<p><tt><b><a name="argument_insertformvalues_table">table</a></b></tt> - Name of the table into which the new row is meant to be inserted.</p>
<p><tt><b><a name="argument_insertformvalues_fields">fields</a></b></tt> - Associative array that has as entry indexes the names of the database table fields that are meant to be used expliciltly initialized when the new row is inserted.  The array values are the types of the correspondent fields.  Supported types are: <tt>&quot;TEXT&quot;</tt>, <tt>&quot;INTEGER&quot;</tt>, <tt>&quot;DECIMAL&quot;</tt>, <tt>&quot;FLOAT&quot;</tt>, <tt>&quot;DATE&quot;</tt>, <tt>&quot;TIMESTAMP&quot;</tt> and <tt>&quot;BOOLEAN&quot;</tt>.</p>
<p><tt><b><a name="argument_insertformvalues_inputs">inputs</a></b></tt> - Associative array that maps the database table column names used by this function to the correspondent form input field names. For the columns that do not have an entry in this array, the respective input field names will have the same base names of database table columns.</p>
<p><tt><b><a name="argument_insertformvalues_nullmap">nullmap</a></b></tt> - Associative array that indicates which form field values are meant to be mapped to <tt>NULL</tt> values before the new row inserted into the database table.  The array entry indexes are the names of the database fields and the entry values are strings that indicate which form values will be mapped to <tt>NULL</tt>.</p>
<p><tt><b><a name="argument_insertformvalues_extrafields">extrafields</a></b></tt> - Associative array that contains additional fields that will be inserted into the new database table row besides those specified in the <tt><a href="#argument_insertformvalues_fields">fields</a></tt> argument.  The array entry indexes are the names of the database table field columns and the entry values are the values to be assigned to those fields in the database native representation format.</p>
</ul>
<h3>Return value</h3>
<p>1 if the function succeeds or 0 otherwise.  If the function fails, the <tt><a href="#variable_error">error</a></tt> variable will contain an explaining error message.</p>
<p><a href="#functions">Functions</a></p>
<h3><a name="function_selectformvalues"></a><li><a name="11.2.9">selectformvalues</a></li></h3>
<h3>Synopsis</h3>
<p><tt><i>bool</i> selectformvalues(</tt><ul>
<tt>(reference) <i>object</i> </tt><tt><a href="#argument_selectformvalues_form">form</a></tt><tt>,<br />
</tt><tt><i>string</i> </tt><tt><a href="#argument_selectformvalues_table">table</a></tt><tt>,<br />
</tt><tt><i>array</i> </tt><tt><a href="#argument_selectformvalues_fields">fields</a></tt><tt>,<br />
</tt><tt><i>array</i> </tt><tt><a href="#argument_selectformvalues_inputs">inputs</a></tt><tt>,<br />
</tt><tt><i>array</i> </tt><tt><a href="#argument_selectformvalues_nullmap">nullmap</a></tt><tt>,<br />
</tt><tt><i>string</i> </tt><tt><a href="#argument_selectformvalues_condition">condition</a></tt><tt></tt></ul>
<tt>)</tt></p>
<h3>Purpose</h3>
<p>Fetch values from a set of columns of a given row of a database table and assign those values to a specified set of correspondent form fields.</p>
<h3>Arguments</h3>
<ul>
<p><tt><b><a name="argument_selectformvalues_form">form</a></b></tt> - Form object with the fields that should be populated from the database table values.</p>
<p><tt><b><a name="argument_selectformvalues_table">table</a></b></tt> - Name of the database table from which the from field values should be retrieved.</p>
<p><tt><b><a name="argument_selectformvalues_fields">fields</a></b></tt> - Associative array that has as entry indexes the names of the database table columns from which the field values are meant to be retrieved.  The array values are the types of the correspondent columns.  Supported types are: <tt>&quot;TEXT&quot;</tt>, <tt>&quot;INTEGER&quot;</tt>, <tt>&quot;DECIMAL&quot;</tt>, <tt>&quot;FLOAT&quot;</tt>, <tt>&quot;DATE&quot;</tt>, <tt>&quot;TIMESTAMP&quot;</tt> and <tt>&quot;BOOLEAN&quot;</tt>.</p>
<p><tt><b><a name="argument_selectformvalues_inputs">inputs</a></b></tt> - Associative array that maps the database table column names used by this function to the correspondent form input field names. For the columns that do not have an entry in this array, the respective input field names will have the same base names of database table columns.</p>
<p><tt><b><a name="argument_selectformvalues_nullmap">nullmap</a></b></tt> - Associative array that indicates the values that should be assigned to the respective form fields when the selected database table columns contain <tt>NULL</tt> values.  The array entry indexes are the names of the database fields and the entry values are strings that are mapped for <tt>NULL</tt> values.  Form fields for which the respective database table column is <tt>NULL</tt> and do not have an entry in the <tt><a href="#argument_selectformvalues_nullmap">nullmap</a></tt> argument array are not initialized.</p>
<p><tt><b><a name="argument_selectformvalues_condition">condition</a></b></tt> - <i>SQL</i> query condition to use in the <tt>SELECT</tt> statement that will retrieve form field values.  If no condition is needed, this argument should be an empty string.  Otherwise it must start by <tt>&quot; WHERE &quot;</tt>.</p>
</ul>
<h3>Return value</h3>
<p>1 if the function succeeds or 0 otherwise.  If the function fails, the <tt><a href="#variable_error">error</a></tt> variable will contain an explaining error message.</p>
<p><a href="#functions">Functions</a></p>
<h3><a name="function_deleteformvalues"></a><li><a name="13.2.10">deleteformvalues</a></li></h3>
<h3>Synopsis</h3>
<p><tt><i>bool</i> deleteformvalues(</tt><ul>
<tt>(reference) <i>object</i> </tt><tt><a href="#argument_deleteformvalues_form">form</a></tt><tt>,<br />
</tt><tt><i>string</i> </tt><tt><a href="#argument_deleteformvalues_table">table</a></tt><tt>,<br />
</tt><tt><i>array</i> </tt><tt><a href="#argument_deleteformvalues_fields">fields</a></tt><tt>,<br />
</tt><tt><i>array</i> </tt><tt><a href="#argument_deleteformvalues_inputs">inputs</a></tt><tt>,<br />
</tt><tt><i>array</i> </tt><tt><a href="#argument_deleteformvalues_nullmap">nullmap</a></tt><tt>,<br />
</tt><tt><i>string</i> </tt><tt><a href="#argument_deleteformvalues_condition">condition</a></tt><tt>,<br />
</tt><tt><i>array</i> </tt><tt><a href="#argument_deleteformvalues_extrafields">extrafields</a></tt><tt></tt></ul>
<tt>)</tt></p>
<h3>Purpose</h3>
<p>Delete database table rows whose column values match the values of a given set of form fields.</p>
<h3>Arguments</h3>
<ul>
<p><tt><b><a name="argument_deleteformvalues_form">form</a></b></tt> - Form object with the specified fields whose values should be used to determine the condition for deleting rows from specified database table.</p>
<p><tt><b><a name="argument_deleteformvalues_table">table</a></b></tt> - Name of the database table of which the rows should be deleted.</p>
<p><tt><b><a name="argument_deleteformvalues_fields">fields</a></b></tt> - Associative array that has as entry indexes the names of the database table columns that will be used to form the condition of the delete query.  The array values are the types of the correspondent columns.  Supported types are: <tt>&quot;TEXT&quot;</tt>, <tt>&quot;INTEGER&quot;</tt>, <tt>&quot;DECIMAL&quot;</tt>, <tt>&quot;FLOAT&quot;</tt>, <tt>&quot;DATE&quot;</tt>, <tt>&quot;TIMESTAMP&quot;</tt> and <tt>&quot;BOOLEAN&quot;</tt>.</p>
<p><tt><b><a name="argument_deleteformvalues_inputs">inputs</a></b></tt> - Associative array that maps the database table column names used by this function to the correspondent form input field names. For the columns that do not have an entry in this array, the respective input field names will have the same base names of database table columns.</p>
<p><tt><b><a name="argument_deleteformvalues_nullmap">nullmap</a></b></tt> - Associative array that indicates which form field values are meant to be mapped to <tt>NULL</tt> values before the database table rows are deleted.  The array entry indexes are the names of the database fields and the entry values are strings that indicate which form values will be mapped to <tt>NULL</tt>.</p>
<p><tt><b><a name="argument_deleteformvalues_condition">condition</a></b></tt> - <i>SQL</i> query condition to use in the <tt>DELETE</tt> statement that will delete the database table rows.  If no condition is needed, this argument should be an empty string. Otherwise it be the first part of the whole condition part of the query but must not start by <tt>&quot; WHERE &quot;</tt>.</p>
<p><tt><b><a name="argument_deleteformvalues_extrafields">extrafields</a></b></tt> - Associative array that contains fields that will be used to defined additional conditions to determine which rows will be deleted.  The array entry indexes are the names of the database table field columns and the entry values are the values to be assigned to those fields in the database native representation format.</p>
</ul>
<h3>Return value</h3>
<p>1 if the function succeeds or 0 otherwise.  If the function fails, the <tt><a href="#variable_error">error</a></tt> variable will contain an explaining error message.</p>
<p><a href="#functions">Functions</a></p>
<h3><a name="function_updateformchanges"></a><li><a name="15.2.11">updateformchanges</a></li></h3>
<h3>Synopsis</h3>
<p><tt><i>bool</i> updateformchanges(</tt><ul>
<tt>(reference) <i>object</i> </tt><tt><a href="#argument_updateformchanges_form">form</a></tt><tt>,<br />
</tt><tt><i>string</i> </tt><tt><a href="#argument_updateformchanges_table">table</a></tt><tt>,<br />
</tt><tt><i>array</i> </tt><tt><a href="#argument_updateformchanges_fields">fields</a></tt><tt>,<br />
</tt><tt><i>array</i> </tt><tt><a href="#argument_updateformchanges_nullmap">nullmap</a></tt><tt>,<br />
</tt><tt><i>array</i> </tt><tt><a href="#argument_updateformchanges_inputs">inputs</a></tt><tt>,<br />
</tt><tt><i>string</i> </tt><tt><a href="#argument_updateformchanges_condition">condition</a></tt><tt>,<br />
</tt><tt><i>array</i> </tt><tt><a href="#argument_updateformchanges_extrafields">extrafields</a></tt><tt></tt></ul>
<tt>)</tt></p>
<h3>Purpose</h3>
<p>Update a given set of database table rows with values of a specified set of form fields.</p>
<h3>Arguments</h3>
<ul>
<p><tt><b><a name="argument_updateformchanges_form">form</a></b></tt> - Form object from which should be retrieved the changed field values to updated the specified database table.</p>
<p><tt><b><a name="argument_updateformchanges_table">table</a></b></tt> - Name of the database table from which the rows should be updated.</p>
<p><tt><b><a name="argument_updateformchanges_fields">fields</a></b></tt> - Associative array that has as array indexes the names of the database table columns that may be updated with the form field values.  The array values are the types of the correspondent columns.  Supported types are: <tt>&quot;TEXT&quot;</tt>, <tt>&quot;INTEGER&quot;</tt>, <tt>&quot;DECIMAL&quot;</tt>, <tt>&quot;FLOAT&quot;</tt>, <tt>&quot;DATE&quot;</tt>, <tt>&quot;TIMESTAMP&quot;</tt> and <tt>&quot;BOOLEAN&quot;</tt>.</p>
<p><tt><b><a name="argument_updateformchanges_nullmap">nullmap</a></b></tt> - Associative array that indicates which form field values are meant to be mapped to <tt>NULL</tt> values before the database table rows are updated.  The array entry indexes are the names of the database fields and the entry values are strings that indicate which form values will be mapped to <tt>NULL</tt>.</p>
<p><tt><b><a name="argument_updateformchanges_inputs">inputs</a></b></tt> - Associative array that maps the database table column names used by this function to the correspondent form input field names. For the columns that do not have an entry in this array, the respective input field names will have the same base names of database table columns.</p>
<p><tt><b><a name="argument_updateformchanges_condition">condition</a></b></tt> - <i>SQL</i> query condition to use in the <tt>UPDATE</tt> statement that will updated the database table rows.  If no condition is needed, this argument should be an empty string. Otherwise it must start by <tt>&quot; WHERE &quot;</tt>.</p>
<p><tt><b><a name="argument_updateformchanges_extrafields">extrafields</a></b></tt> - Associative array that contains additional database table columns that will also be updated.  The array entry indexes are the names of the database table field columns and the entry values are the values to be assigned to those fields in the database native representation format.</p>
</ul>
<h3>Return value</h3>
<p>1 if the function succeeds or 0 otherwise.  If the function fails, the <tt><a href="#variable_error">error</a></tt> variable will contain an explaining error message.</p>
<p><a href="#functions">Functions</a></p>
<h3><a name="function_selectlistvalues"></a><li><a name="17.2.12">selectlistvalues</a></li></h3>
<h3>Synopsis</h3>
<p><tt><i>bool</i> selectlistvalues(</tt><ul>
<tt>(reference) <i>array</i> </tt><tt><a href="#argument_selectlistvalues_list">list</a></tt><tt>,<br />
</tt><tt><i>string</i> </tt><tt><a href="#argument_selectlistvalues_table">table</a></tt><tt>,<br />
</tt><tt><i>string</i> </tt><tt><a href="#argument_selectlistvalues_indexes">indexes</a></tt><tt>,<br />
</tt><tt><i>string</i> </tt><tt><a href="#argument_selectlistvalues_values">values</a></tt><tt>,<br />
</tt><tt><i>string</i> </tt><tt><a href="#argument_selectlistvalues_condition">condition</a></tt><tt>,<br />
</tt><tt><i>string</i> </tt><tt><a href="#argument_selectlistvalues_emptyerror">emptyerror</a></tt><tt></tt></ul>
<tt>)</tt></p>
<h3>Purpose</h3>
<p>Build a list of pairs of values to suitable for use with form input fields of type <tt>select</tt>.</p>
<h3>Arguments</h3>
<ul>
<p><tt><b><a name="argument_selectlistvalues_list">list</a></b></tt> - Reference to a associative array that will contain the list of selected values.  The array entry indexes are the values for the <tt>select</tt> form field and the entry values are respective entry texts.</p>
<p><tt><b><a name="argument_selectlistvalues_table">table</a></b></tt> - Name of the database table from which the selected list values should be retrieved.</p>
<p><tt><b><a name="argument_selectlistvalues_indexes">indexes</a></b></tt> - Name of the database table column that contains the values for the list of values of the <tt>select</tt> form field.</p>
<p><tt><b><a name="argument_selectlistvalues_values">values</a></b></tt> - Name of the database table column that contains the values for the list of texts correspondent to the values of the <tt>select</tt> form field.</p>
<p><tt><b><a name="argument_selectlistvalues_condition">condition</a></b></tt> - <i>SQL</i> query condition to use in the <tt>SELECT</tt> statement that will retriev the database table list of values.  If no condition is needed, this argument should be an empty string. Otherwise it must start by <tt>&quot; WHERE &quot;</tt>.</p>
<p><tt><b><a name="argument_selectlistvalues_emptyerror">emptyerror</a></b></tt> - Error message that is returned if the selected list does not contain any values.  If this argument is not an empty string, the function will fail setting the class <tt><a href="#variable_error">error</a></tt> variable to the string specified by this argument.  Otherwise, the function will not fail even the returned list is empty.</p>
</ul>
<h3>Return value</h3>
<p>1 if the function succeeds or 0 otherwise.  If the function fails, the <tt><a href="#variable_error">error</a></tt> variable will contain an explaining error message.</p>
<p><a href="#functions">Functions</a></p>
<p><a href="#table_of_contents">Table of contents</a></p>
</ul>
</ul>

<hr />
<address>Manuel Lemos (<a href="mailto:hide@address.com">hide@address.com</a>)</address>
</body>
</html>
Return current item: Database access class