]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/WikiDB/adodb/readme.htm
First cut of ADODB backend. I've only tested this on MySql. I still have some work...
[SourceForge/phpwiki.git] / lib / WikiDB / adodb / readme.htm
1 <html>
2 <head>
3 <title>ADODB Manual</title>
4 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
5 <STYLE>
6         body,td {font-family:Arial,Helvetica,sans-serif;font-size:11pt}
7         pre {font-size:9pt}
8         .toplink {font-size:8pt}
9         </STYLE>
10 </head>
11   
12 <body bgcolor="#FFFFFF">
13
14 <h2>ADODB Library for PHP</h2>
15 <p>V1.71 18 Jan 2001 (c) 2000-2001 John Lim (jlim@natsoft.com.my)</p>
16 <p>This software is dual licensed using BSD-Style and LGPL. 
17 Where there is any discrepancy, the BSD-Style license will take precedence. 
18 This means you can use it in proprietary and commercial products.</p>
19 <p><a href="#intro"><b>Introduction</b></a><b><br>
20  <a href="#features">Unique Features</a><br>
21  <a href="#users">How People are using ADODB</a><br>
22  <a href="#bugs">Feature Requests and Bug Reports</a><br>
23  </b><b><a href="#install">Installation<br>
24  </a><a href="#coding">Initializing Code</a></b> 
25  <font size="2"><a href=#adonewconnection>ADONewConnection</a></font>
26   <font size="2"><a href=#adonewconnection>NewADOConnection</a></font><br>
27    <b> <a href="#drivers">Supported Databases</a></b><br>
28  <b> <a href="#quickstart">Tutorial</a></b><br>
29  <a href="#ex1">Example 1: Select</a><br>
30  <a href="#ex2">Example 2: Advanced Select</a><br>
31  <a href="#ex3">Example 3: Insert</a><br>
32  <a href="#ex4">Example 4: Debugging</a> &nbsp;<a href="#exrs2html">rs2html example</a><br>
33  <a href="#ex5">Example 5: MySQL and Menus</a><br>
34  <a href="#ex6">Example 6: Connecting to Multiple Databases at once</a> <br>
35  <a href="#ex7">Example 7: Generating Update and Insert SQL</a> <br>
36  <a href="#ex8">Example 8: Implementing Scrolling with Next and Previous</a> <br>
37 <b> <a href="#errorhandling">Using Custom Error Handlers and PEAR_Error</a><br>
38  <a href="#caching">Caching</a></b></p>
39 <p><a href="#ref"><b>Reference</b></a><br>
40   <a href="#ADOConnection"><b>ADOConnection</b></a>: 
41   <font size="2"><a href=#adodb_fetch_mode>$ADODB_FETCH_MODE</a></font>
42   <a href="#connect"><font size="2">Connect</font></a> 
43   <font size="2"><a href="#pconnect">PConnect</a> <a href="#execute">Execute</a> 
44   <a href="#cacheexecute">CacheExecute</a> <a href="#SelectLimit">SelectLimit</a> 
45   <a href="#cacheSelectLimit">CacheSelectLimit</a> <a href="#CacheFlush">CacheFlush</a> 
46   <a href="#Close">Close</a> <a href="#concat">Concat</a> <a href="#dbdate">DBDate</a> 
47   <a href="#dbtimestamp">DBTimeStamp</a> <a href="#qstr">qstr</a> <a href="#begintrans">BeginTrans</a> 
48   <a href="#committrans">CommitTrans</a> <a href="#rollbacktrans">RollbackTrans</a></font> 
49   <font size="2"><a href="#affected_rows">Affected_Rows</a> <a href="#inserted_id">Insert_ID</a></font> 
50   <font size="2"><a href="#errormsg">ErrorMsg</a> <a href="#errorno">ErrorNo</a> 
51   <a href="#metadatabases">MetaDatabases</a> <a href="#metatables">MetaTables 
52   </a><a href="#blankrecordset">BlankRecordSet</a> <a href="#metacolumns">MetaColumns</a> 
53   <a href="#genid">GenID</a> <a href="#getupdatesql">GetUpdateSQL</a> <a href="#getinsertsql">GetInsertSQL</a> 
54   <a href="#updateblob">UpdateBlob</a> <a href="#pageexecute">PageExecute</a> 
55   <a href="#cachepageexecute">CachePageExecute</a></font><br>
56   <a href="#ADORecordSet"><b>ADORecordSet</b></a>: <a href="#getassoc"><font size="2">GetAssoc</font></a> 
57   <font size="2"><a href="#getarray">GetArray</a> <a href="#getrows">GetRows</a> <a href="#getmenu">GetMenu</a> <a href="#getmenu2">GetMenu2</a>  
58   <a href="#userdate">UserDate</a> <a href="#usertimestamp">UserTimeStamp</a> 
59   <a href="#unixdate">UnixDate</a> <a href="#unixtimestamp">UnixTimeStamp</a> 
60   <a href="#move">Move</a> <a href="#movenext">MoveNext</a> <a href="#movefirst">MoveFirst</a> 
61   <a href="#movelast">MoveLast</a>  <a href="#getrowassoc">GetRowAssoc</a>  <a href="#fields">Fields</a> <a href="#fetchfield">FetchField</a> 
62   <a href="#currentrow">CurrentRow</a> <a href="#abspos">AbsolutePosition</a> 
63   <a href="#fieldcount">FieldCount</a> <a href="#recordcount">RecordCount</a> 
64   <a href="#fetchobject">FetchObject</a> <a href="#fetchnextobject">FetchNextObject</a> 
65   <a href="#rsclose">Close</a> <a href="#metatype">MetaType</a>
66   <a href="#atfirstpage">AtFirstPage</a>
67    <a href="#atlastpage">AtLastPage</a>
68     <a href="#absolutepage">AbsolutePage</a>
69         </font>  <br>
70   <a href="#rs2html"><b>rs2html</b></a>&nbsp; <a href="#exrs2html">example</a><br>
71   <a href="#adodiff">Differences between ADODB and ADO</a><br>
72   <a href="#driverguide"><b>Database Driver Guide<br>
73    <a href="#changes">Change Log</a></b><br>
74   </b></a> </p>
75 <h2>Introduction<a name="intro"></a></h2>
76 <p>PHP's database access functions are not standardised. This creates a need for 
77  a database class library to hide the differences between the different databases 
78  (encapsulate the differences) so we can easily switch databases.</p>
79 <p>We currently support MySQL, Interbase, Oracle, Microsoft SQL Server, Sybase, 
80   PostgreSQL, FrontBase, Foxpro, Access, ADO and ODBC. We have had successful reports of connecting
81   to Progress and DB2 via ODBC. We hope more people 
82   will contribute drivers to support other databases.</p>
83 <p>PHP4 supports session variables. You can store your session information using 
84   ADODB for true portability and scalability. See adodb-session.php for more information.</p>
85 <h2>Unique Features of ADODB<a name="features"></a></h2>
86 <ul>
87   <li><b>Easy for Windows programmers</b> to adapt to because many of the conventions 
88     are similar to Microsoft's ADO.</li>
89   <li>Unlike other PHP database classes which focus only on select statements, 
90     <b>we provide support code to handle inserts and updates which can be adapted 
91     to multiple databases quickly.</b> Methods are provided for date handling, 
92     string concatenation and string quoting characters for differing databases.</li>
93   <li>A<b> metatype system </b>is built in so that we can figure out that types 
94     such as CHAR, TEXT and STRING are equivalent in different databases.</li>
95   <li><b>Easy to port</b> because all the database dependant code are stored in 
96     stub functions. You do not need to port the core logic of the classes.</li>
97   <li><b>PHP4 session support</b>. See adodb-session.php.</li>
98 </ul>
99 <h2>How People are using ADODB<a name="users"></a></h2>
100 Here are some examples of how people are using ADODB (for a complete list, visit <a href=http://php.weblogs.com/adodb-cool-applications>http://php.weblogs.com/adodb-cool-applications</a>):
101 <ul>
102 <li><a href=http://phplens.com/>PhpLens</a> is a commercial data grid component that allows both cool Web designers and serious unshaved programmers to develop and maintain databases on the Web easily. Developed by the author of ADODB.
103
104 <li><a href=http://www.interakt.ro/phakt/>PHAkt: PHP Extension for DreamWeaver Ultradev</a> allows you to script PHP in the popular Web page editor. Database handling provided by ADODB.
105
106 <li><a href=http://www.andrew.cmu.edu/~rdanyliw/snort/snortacid.html>Analysis Console for Intrusion Databases</a> (ACID): PHP-based analysis engine to search and process a database of security incidents generated by security-related software such as IDSes and firewalls (e.g. Snort, ipchains). By Roman Danyliw.
107
108 <li><a href=http://www.postnuke.com/>PostNuke</a> is a very popular free content management
109  system and weblog system. It offers full CSS support, HTML 4.01 transitional compliance throughout, an advanced blocks system, and is fully multi-lingual enabled. 
110
111 <li><a href=http://www.auto-net.no/easypublish.php?page=index&lang_id=2>EasyPublish CMS</a>  is another free content management system for managing information and integrated modules on your internet, intranet- and extranet-sites. From Norway.
112
113 <li><a href=http://nola.noguska.com/>NOLA</a> is a full featured accounting, inventory, and job tracking application. It is licensed under the GPL, and developed by Noguska.
114 </ul>
115
116 <h2>Feature Requests and Bug Reports<a name="bugs"></a></h2>
117 <p>Feature requests and bug reports can be emailed to <a href="mailto:jlim#natsoft.com.my">jlim#natsoft.com.my</a> 
118  or posted to <a href="http://php.weblogs.com/discuss/msgReader$96">http://php.weblogs.com/discuss/msgReader$96</a>.</p>
119 <h2>Installation Guide<a name="install"></a></h2>
120 <p>Make sure you are running PHP4.01pl2 or later (it uses require_once and include_once). 
121 Unpack all the files into a directory accessible by your webserver. 
122 </p>
123 <p>To test you will need a database. Open <i>testdatabases.inc.php</i> and modify 
124  the connection parameters to suit your database. This script will create a new 
125  table in the database and perform various tests.</p>
126 <p>That's it!</p>
127 <h3>Code Initialization<a name="coding"></a></h3>
128 <p>When running ADODB, at least two files are loaded. First is adodb.inc.php, 
129  which contains all functions used by all database classes. The code specific 
130  to a particular database is in the adodb-????.inc.php file.</p>
131 <p>For example, to connect to a mysql database:</p>
132 <pre>
133 include('/path/to/set/here/adodb.inc.php');
134 $conn = &amp;ADONewConnection('mysql');
135 </pre>
136 <p>Whenever you need to connect to a database, you create a Connection object 
137  using the <b><a name=adonewconnection>ADONewConnection</a></b>( ) function. 
138   ADONewConnection accepts one optional parameter, the &lt;database-name-here&gt;. 
139   If no parameter is specified, it will create a new ADOConnection for the last 
140   database loaded by ADOLoadCode( ). <b>NewADOConnection</b>( ) 
141   is the same function.</p>
142 <p>At this point, you are not connected to the database. 
143 You will use <code>$conn-><a href=#connect>Connect()</a></code> or 
144 <code>$conn-><a href=#pconnect>PConnect()</a></code> to perform the actual connection.</p>
145 <p>See the examples below in the Tutorial.</p>
146  <h3><a name=drivers></a>Databases Supported</h3>
147 <table width="100%" border="1">
148   <tr valign="top"> 
149     <td><b>Name</b></td>
150     <td><b>Database</b></td>
151     <td><b><font size="2">RecordCount() usable</font></b></td>
152     <td><b>Prerequisites</b></td>
153     <td><b>Operating Systems</b></td>
154   </tr>
155   <tr valign="top"> 
156     <td><b>access</b></td>
157     <td>Microsoft Access. You need to create an ODBC DSN.</td>
158     <td>N</td>
159     <td>ODBC </td>
160     <td>Windows only</td>
161   </tr>
162   <tr valign="top"> 
163     <td><b>ado</b></td>
164     <td>Generic ADO, not tuned for specific databases. Slower than ODBC, but allows 
165       DSN-less connections.</td>
166     <td>? depends on database</td>
167     <td>ADO and OLEDB provider</td>
168     <td>Windows only</td>
169   </tr>
170   <tr valign="top"> 
171     <td><b>ado_access</b></td>
172     <td>Microsoft Access using ADO. Slower than ODBC, but allows DSN-less connections.</td>
173     <td>N</td>
174     <td>ADO and OLEDB provider for Access</td>
175     <td>Windows only</td>
176   </tr>
177   <tr valign="top"> 
178     <td><b>vfp</b></td>
179     <td>Microsoft Visual FoxPro. You need to create an ODBC DSN.</td>
180     <td>N</td>
181     <td>ODBC</td>
182     <td>Windows only</td>
183   </tr>
184   <tr valign="top"> 
185     <td><b>ibase</b></td>
186     <td>Interbase 6 or earlier. Some users report you might need to use this<br>
187 $db->PConnect('localhost:c:\ibase\employee.gdb', "sysdba", "masterkey") to connect.</td>
188     <td>N</td>
189     <td>Interbase client</td>
190     <td>Unix and Windows</td>
191   </tr>
192   <tr valign="top"> 
193     <td><b>firebird</b></td>
194     <td>Firebird version of interbase.</td>
195     <td>N</td>
196     <td>Interbase client</td>
197     <td>Unix and Windows</td>
198   </tr>
199   <tr valign="top"> 
200     <td><b>borland_ibase</b></td>
201     <td>Borland version of Interbase 6.5 or later. Very sad that the forks differ.</td>
202     <td>N</td>
203     <td>Interbase client</td>
204     <td>Unix and Windows</td>
205   </tr>
206   <tr valign="top"> 
207     <td><b>mssql</b></td>
208     <td> 
209       <p>Microsoft SQL Server 7. Works with Microsoft SQL Server 2000 also. Note that
210           date formating is problematic with this driver. For example, the PHP mssql extension 
211            does not return the seconds for datetime!</p>
212     </td>
213     <td>Y</td>
214     <td>Mssql client</td>
215     <td> 
216       <p>Unix and Windows. <a href="http://phpbuilder.com/columns/alberto20000919.php3"><br>
217         Unix install howto</a>.</p>
218     </td>
219   </tr>
220   <tr valign="top"> 
221     <td><b>mysql</b></td>
222     <td>MySQL without transaction support (3.22)</td>
223     <td>Y</td>
224     <td>MySQL client</td>
225     <td>Unix and Windows</td>
226   </tr>
227   <tr valign="top"> 
228     <td><b>mysqlt</b> or <b>maxsql</b></td>
229     <td>MySQL with transaction support (3.23)</td>
230     <td>Y</td>
231     <td>MySQL client</td>
232     <td>Unix and Windows</td>
233   </tr>
234   <tr valign="top"> 
235     <td><b>oci8</b></td>
236     <td>Oracle 8/9. Has more functionality than <i>oracle</i> driver (eg. Affected_Rows). 
237         You might have to putenv('ORACLE_HOME=...') before Connect/PConnect.<p>
238         There are 2 ways of connecting - 
239         with server IP and service name: <br><i>PConnect('serverip:1521','scott','tiger','service'</i>)<br> or
240         using an entry in the tnsnames.ora: <br><i>PConnect('', 'scott', 'tiger', 'tnsname')</i>.
241         </td>
242     <td>N</td>
243     <td>Oracle client</td>
244     <td>Unix and Windows</td>
245   </tr>
246    <tr valign="top"> 
247     <td><b>oci8po</b></td>
248     <td>Oracle 8/9 portable driver. This is nearly identical with the oci8 driver except 
249         (a) bind variables in Prepare() use the ? convention, instead of :bindvar, 
250         (b) field names use the more common PHP convention of lowercase names. 
251         <p>Use this driver if porting
252         from other databases is important. Otherwise the oci8 driver offers better performance.
253         </td>
254     <td>N</td>
255     <td>Oracle client</td>
256     <td>Unix and Windows</td>
257   </tr>
258   <tr valign="top"> 
259     <td><b>odbc</b></td>
260     <td>Generic ODBC, not tuned for specific databases. 
261         To connect, use <br>PConnect('DSN','user','pwd').</td>
262     <td>? depends on database</td>
263     <td>ODBC</td>
264     <td>Unix and Windows. <a href="http://phpbuilder.com/columns/alberto20000919.php3?page=4">Unix 
265       hints.</a></td>
266   </tr>
267   <tr valign="top"> 
268     <td><b>oracle</b></td>
269     <td>Oracle 7 or 8 support. Obsolete.</td>
270     <td>N</td>
271     <td>Oracle client</td>
272     <td>Unix and Windows</td>
273   </tr>
274   <tr valign="top"> 
275     <td><b>postgres</b></td>
276     <td>PostgreSQL which does not support LIMIT internally.</td>
277     <td>Y</td>
278     <td>PostgreSQL client</td>
279     <td>Unix and Windows. </td>
280   </tr>
281    <tr valign="top"> 
282     <td><b>postgres7</b></td>
283     <td>PostgreSQL which supports LIMIT and other version 7 functionality.</td>
284     <td>Y</td>
285     <td>PostgreSQL client</td>
286     <td>Unix and Windows. </td>
287   </tr>
288    <tr valign="top"> 
289     <td><b>sybase</b></td>
290     <td>Sybase. </td>
291     <td>Y</td>
292     <td>Sybase client</td>
293     <td> 
294       <p>Unix and Windows. <a href="http://www.finebyte.com/docs/sybase/ASA-PHP-Linux.html">Unix 
295         hints</a>.</p>
296     </td>
297   </tr>
298      <tr valign="top"> 
299     <td><b>db2</b></td>
300     <td>DB2. Warning: this is experimental. Please email me if there are problems.</td>
301     <td>Y</td>
302     <td>DB2 CLI/ODBC interface</td>
303     <td> 
304       <p>Unix and Windows. <a href="http://www.faqts.com/knowledge_base/view.phtml/aid/6283/fid/14">Unix 
305         install hints</a>.</p>
306     </td>
307   </tr>
308    
309      <tr valign="top"> 
310     <td><b>fbsql</b></td>
311     <td>FrontBase. Warning: this is experimental. Please email me if there are problems.</td>
312     <td>Y</td>
313     <td>?</td>
314     <td> 
315       <p>Unix and Windows</p>
316     </td>
317   </tr>
318 </table>
319 <p>RecordCount() usable indicates whether RecordCount() returns -1 instead of 
320   the number of rows when a SELECT statement is executed. For highest performance, 
321   disable RecordCount() by setting the global variable $ADODB_COUNTRECS=false. 
322   For the reason why, see the notes to <a href="http://php.net/manual/function.sybase-num-rows.php">http://php.net/manual/function.sybase-num-rows.php</a></p>
323 <p>Other database drivers used for testing ADODB.</p>
324 <table width="100%" border="0">
325  <tr valign="top"> 
326   <td width="9%"><b>ado_mssql</b></td>
327   <td width="88%">Microsoft SQL Server 7 using Microsoft ADO. This database driver 
328    is only for test purposes. Use the mssql driver instead.</td>
329  </tr>
330  <tr valign="top"> 
331   <td width="9%"><b>odbc_mssql</b></td>
332   <td width="88%">Microsoft SQL Server 7 using ODBC. This database driver is only 
333    for test purposes. Use the mssql driver instead.</td>
334  </tr>
335 </table>
336
337 <hr>
338 <h1>Tutorial<a name="quickstart"></a></h1>
339 <h3>Example 1: Select Statement<a name="ex1"></a></h3>
340 <p>Task: Connect to the Access Northwind database, display the first 2 columns 
341   of each row.</p>
342 <p>In this example, we create a ADOConnection object, which represents the connection 
343  to the database. The connection is initiated with <a href="#pconnect"><font face="Courier New, Courier, mono">PConnect</font></a>, 
344  which is a persistent connection. Whenever we want to query the database, we 
345  call the <font face="Courier New, Courier, mono">ADOConnection.<a href="#execute">Execute</a>()</font> 
346  function. This returns an ADORecordSet object which is actually a cursor that 
347  holds the current row in the array <font face="Courier New, Courier, mono">fields[]</font>. 
348  We use <font face="Courier New, Courier, mono"><a href="#movenext">MoveNext</a>()</font> 
349  to move from row to row.</p>
350 <p>NB: A useful function that is not used in this example is 
351 <font face="Courier New, Courier, mono"><a href="#selectlimit">SelectLimit</a></font>, which
352 allows us to limit the number of rows shown.
353 <pre>
354 &lt;?
355 <font face="Courier New, Courier, mono"><b>include</b>('adodb.inc.php');       # load code common to ADODB
356 $<font color="#660000">conn</font> = &amp;ADONewConnection('access');    # create a connection
357 $<font color="#660000">conn</font>->PConnect('northwind');   # connect to MS-Access, northwind db
358 $<font color="#660000">recordSet</font> = &amp;$<font color="#660000">conn</font>->Execute('select * from products');
359
360 <b>while</b> (!$<font color="#660000">recordSet</font>-&gt;EOF) &#123;
361         <b>print</b> $<font color="#660000">recordSet</font>->fields[0].' '.$<font color="#660000">recordSet</font>->fields[1].'&lt;BR&gt;';
362         $<font color="#660000">recordSet</font>-&gt;MoveNext();
363 &#125;
364
365 $<font color="#660000">recordSet</font>->Close(); # optional
366 $<font color="#660000">conn</font>->Close(); # optional
367 </font>
368 ?>
369 </pre>
370 <p>The $<font face="Courier New, Courier, mono">recordSet</font> returned stores 
371  the current row in the <font face="Courier New, Courier, mono">$recordSet-&gt;fields</font> 
372  array, indexed by column number (starting from zero). We use the <font face="Courier New, Courier, mono"><a href="#movenext">MoveNext</a>()</font> 
373  function to move to the next row. The <font face="Courier New, Courier, mono">EOF</font> 
374  property is set to true when end-of-file is reached. </p>
375 <p>The <code>$recordSet-&gt;fields[]</code> array is generated by the PHP database 
376   extension. Some database extensions only index by number and 
377   do not index the array by field name. To force indexing by name - that is associative arrays - 
378   use the $ADODB_FETCH_MODE global variable. 
379 <pre>
380         $<b>ADODB_FETCH_MODE</b> = ADODB_FETCH_NUM;
381         $rs1 = $db->Execute('select * from table');
382         $<b>ADODB_FETCH_MODE</b> = ADODB_FETCH_ASSOC;
383         $rs2 = $db->Execute('select * from table');
384         print_r($rs1->fields); // shows <i>array([0]=>'v0',[1] =>'v1')</i>
385         print_r($rs2->fields); // shows <i>array(['col1']=>'v0',['col2'] =>'v1')</i>
386 </pre>
387 <p>
388  </p>
389 <p>To get the number of rows in the select statement, you can use <font face="Courier New, Courier, mono">$recordSet-&gt;<a href="#recordcount">RecordCount</a>()</font>. 
390  Note that it can return -1 if the number of rows returned cannot be determined.</p>
391 <h3>Example 2: Advanced Select with Field Objects<a name="ex2"></a></h3>
392 <p>Select a table, display the first two columns. If the second column is a date or timestamp, reformat the date to US format.</p>
393 <pre>
394 &lt;?
395 <font face="Courier New, Courier, mono"><b>include</b>('adodb.inc.php');       # load code common to ADODB
396 $<font color="#660000">conn</font> = &amp;ADONewConnection('access');    # create a connection
397 $<font color="#660000">conn</font>->PConnect('northwind');   # connect to MS-Access, northwind db
398 $<font color="#660000">recordSet</font> = &amp;$<font color="#660000">conn</font>->Execute('select CustomerID,OrderDate from Orders');
399
400 <b>while</b> (!$<font color="#660000">recordSet</font>-&gt;EOF) &#123;
401         $<font color="#660000">fld</font> = <font color="#336600"><b>$</b><font color="#660000">recordSet</font><b>-&gt;FetchField</b></font><font color="#006600">(</font>1<font color="#006600">);</font>
402         $<font color="#660000">type</font> = <font color="#336600"><b>$</b><font color="#660000">recordSet</font><b>-&gt;MetaType</b></font>($fld-&gt;type);
403
404         <b>if</b> ( $<font color="#660000">type</font> == 'D' || $<font color="#660000">type</font> == 'T') 
405                 <b>print</b> $<font color="#660000">recordSet</font>-&gt;fields[0].' '.
406                         <b><font color="#336600">$</font></b><font color="#660000">recordSet</font><b><font color="#336600">-&gt;UserDate</font></b>($<font color="#660000">recordSet</font>-&gt;fields[1],'<b>m/d/Y</b>').'&lt;BR&gt;';
407         <b>else </b>
408                 <b>print</b> $<font color="#660000">recordSet</font>->fields[0].' '.$<font color="#660000">recordSet</font>->fields[1].'&lt;BR&gt;';
409
410         $<font color="#660000">recordSet</font>-&gt;MoveNext();
411 &#125;
412
413 $<font color="#660000">recordSet</font>->Close(); # optional
414 $<font color="#660000">conn</font>->Close(); # optional
415 </font>
416 ?>
417 </pre>
418 <p>In this example, we check the field type of the second column using <font face="Courier New, Courier, mono"><a href="#fetchfield">FetchField</a>().</font> 
419  This returns an object with at least 3 fields.</p>
420 <ul>
421  <li><b>name</b>: name of column</li>
422  <li> <b>type</b>: native field type of column</li>
423  <li> <b>max_length</b>: maximum length of field. Some databases such as MySQL 
424   do not return the maximum length of the field correctly. In these cases max_length 
425   will be set to -1.</li>
426 </ul>
427 <p>We then use <font face="Courier New, Courier, mono"><a href="#metatype">MetaType</a>()</font> 
428  to translate the native type to a <i>generic</i> type. Currently the following 
429  <i>generic</i> types are defined:</p>
430 <ul>
431  <li><b>C</b>: character fields that should be shown in a &lt;input type=&quot;text&quot;&gt; 
432   tag.</li>
433  <li><b>X</b>: TeXt, large text fields that should be shown in a &lt;textarea&gt;</li>
434  <li><b>B</b>: Blobs, or Binary Large Objects. Typically images.
435  <li><b>D</b>: Date field</li>
436  <li><b>T</b>: Timestamp field</li>
437  <li><b>L</b>: Logical field (boolean or bit-field)</li>
438  <li><b>N</b>: Numeric field. Includes autoincrement, numeric, floating point, 
439   real and integer. </li>
440  <li><b>R</b>: Serial field. Includes serial, autoincrement integers. This works for selected databases. </li>
441 </ul>
442 <p>If the metatype is of type date or timestamp, then we print it using the user 
443  defined date format with <font face="Courier New, Courier, mono"><a href="#userdate">UserDate</a>(),</font> 
444  which converts the PHP SQL date string format to a user defined one. Another 
445  use for <font face="Courier New, Courier, mono"><a href="#metatype">MetaType</a>()</font> 
446  is data validation before doing an SQL insert or update.</p>
447 <h3>Example 3: Inserting<a name="ex3"></a></h3>
448 <p>Insert a row to the Orders table containing dates and strings that need to be quoted before they can be accepted by the database, eg: the single-quote in the word <i>John's</i>.</p>
449 <pre>
450 &lt;?
451 <b>include</b>('adodb.inc.php');       # load code common to ADODB
452 $<font color="#660000">conn</font> = &amp;ADONewConnection('access');    # create a connection
453 $<font color="#660000">conn</font>->PConnect('northwind');   # connect to MS-Access, northwind db
454
455 $<font color="#660000">shipto</font> = <font color="#006600"><b>$conn-&gt;qstr</b></font>(&quot;<i>John's Old Shoppe</i>&quot;);
456
457 $<font color="#660000">sql</font> = &quot;insert into orders (customerID,EmployeeID,OrderDate,ShipName) &quot;;
458 $<font color="#660000">sql</font> .= &quot;values ('ANATR',2,&quot;.<b><font color="#006600">$conn-&gt;DBDate(</font>time()<font color="#006600">)</font></b><font color="#006600">.</font>&quot;,$<font color="#660000">shipto</font>)&quot;;
459
460 <b>if</b> ($<font color="#660000">conn</font>->Execute($<font color="#660000">sql</font>) <font color="#336600"><b>=== false</b></font>) &#123;
461         <b>print</b> 'error inserting: '.<font color="#336600"><b>$conn-&gt;ErrorMsg()</b></font>.'&lt;BR&gt;';
462 &#125;
463 ?>
464 </pre>
465 <p>In this example, we see the advanced date and quote handling facilities of 
466   ADODB. The unix timestamp (which is a long integer) is appropriately formated 
467   for Access with <font face="Courier New, Courier, mono"><a href="#dbdate">DBDate</a>()</font>, 
468   and the right escape character is used for quoting the <i>John's Old Shoppe</i>, 
469   which is<b> </b><i>John'<b>'</b>s Old Shoppe</i> and not PHP's default <i>John\<b>'</b>s 
470   Old Shoppe</i> with <font face="Courier New, Courier, mono"><a href="#qstr">qstr</a>()</font>. 
471 </p>
472 <p>Observe the error-handling of the Execute statement. False is returned by<font face="Courier New, Courier, mono"> 
473  <a href="#execute">Execute</a>() </font>if an error occured. The error message 
474  for the last error that occurred is displayed in <font face="Courier New, Courier, mono"><a href="#errormsg">ErrorMsg</a>()</font>. 
475  Note: <i>php_track_errors</i> might have to be enabled for error messages to 
476  be saved.</p>
477 <h3> Example 4: Debugging<a name="ex4"></a></h3>
478 <pre>&lt;?
479
480 <b>include</b>('adodb.inc.php');       # load code common to ADODB
481 $<font color="#663300">conn</font> = &amp;ADONewConnection('access');    # create a connection
482 $<font color="#663300">conn</font>->PConnect('northwind');   # connect to MS-Access, northwind db
483 <font color="#000000">$<font color="#663300">shipto</font> = <b>$conn-&gt;qstr</b>(&quot;John's Old Shoppe&quot;);
484 $<font color="#663300">sql</font> = &quot;insert into orders (customerID,EmployeeID,OrderDate,ShipName) &quot;;
485 $<font color="#663300">sql</font> .= &quot;values ('ANATR',2,&quot;.$<font color="#663300">conn</font>-&gt;FormatDate(time()).&quot;,$shipto)&quot;;
486 <b><font color="#336600">$<font color="#663300">conn</font>-&gt;debug = true;</font></b>
487 <b>if</b> ($<font color="#663300">conn</font>->Execute($sql) <b>=== false</b>) <b>print</b> 'error inserting';</font>
488
489 ?&gt;
490 </pre>
491 <p>In the above example, we have turned on debugging by setting <b>debug = true</b>. 
492  This will display the SQL statement before execution, and also show any error 
493  messages. There is no need to call <font face="Courier New, Courier, mono"><a href="#errormsg">ErrorMsg</a>()</font> 
494  in this case. For displaying the recordset, see the <font face="Courier New, Courier, mono"><a href="#exrs2html">rs2html</a>() 
495  </font>example.</p>
496  <p>Also see the section on <a href=#errorhandling>Custom Error Handlers</a>.</p>
497 <h3>Example 5: MySQL and Menus<a name="ex5"></a></h3>
498 <p>Connect to MySQL database <i>agora</i>, and generate a &lt;select&gt; menu 
499  from an SQL statement where the &lt;option&gt; captions are in the 1st column, 
500  and the value to send back to the server is in the 2nd column.</p>
501 <pre>&lt;?
502 <b>include</b>('adodb.inc.php'); # load code common to ADODB
503 $<font color="#663300">conn</font> = &amp;ADONewConnection('mysql');  # create a connection
504 $<font color="#663300">conn</font>->PConnect('localhost','userid','','agora');# connect to MySQL, agora db
505 <font color="#000000">$<font color="#663300">sql</font> = 'select CustomerName, CustomerID from customers';
506 $<font color="#663300">rs</font> = $<font color="#663300">conn</font>->Execute($sql);
507 <b>print</b> <b><font color="#336600">$<font color="#663300">rs</font>-&gt;GetMenu('GetCust','Mary Rosli');
508 ?&gt;</font></b></font></pre>
509 <p>Here we define a menu named GetCust, with the menu option 'Mary Rosli' selected. 
510  See <a href="#getmenu"><font face="Courier New, Courier, mono">GetMenu</font></a><font face="Courier New, Courier, mono">()</font>. 
511  We also have functions that return the recordset as an array: <font face="Courier New, Courier, mono"><a href="#getarray">GetArray</a>()</font>, 
512  and as an associative array with the key being the first column: <a href="#getassoc">GetAssoc</a>().</p>
513 <p>
514 Aslo new to ADODB 1.50 or later is the global variable $ADODB_FETCH_MODE. This allows you to define
515 whether you want associative or numeric indexing for your arrays.
516 </pre>
517 <h3>Example 6: Connecting to 2 Databases At Once<a name="ex6"></a></h3>
518 <pre>&lt;?
519 <b>include</b>('adodb.inc.php');     # load code common to ADODB
520 $<font color="#663300">conn1</font> = &amp;ADONewConnection('mysql');  # create a mysql connection
521 $<font color="#663300">conn2</font> = &amp;ADONewConnection('oracle');  # create a oracle connection
522
523 $conn1-&gt;PConnect($server, $userid, $password, $database);
524 $conn2-&gt;PConnect(false, $ora_userid, $ora_pwd, $tnsname);
525
526 $conn1-&gt;Execute('insert ...');
527 $conn2-&gt;Execute('update ...');
528 ?&gt;</pre>
529
530 <h3>Example 7: Generating Update and Insert SQL<a name="ex7"></a></h3>
531 ADODB 1.31 and later supports two new recordset functions: GetUpdateSQL( ) and 
532 GetInsertSQL( ). This allow you to perform a "SELECT * FROM table query WHERE...",
533 make a copy of the $rs->fields, modify the fields, and then generate the SQL to
534 update or insert into the table automatically.
535 <p>
536 We show how the functions can be used when
537 accessing a table with the following fields: (ID, FirstName, LastName, Created).
538 <p>
539 Before these functions can be called, you need to initialize the recordset by
540 performing a select on the table. Idea and code by Jonathan Younger jyounger#unilab.com.
541 <p>
542 <pre>&lt;?
543 #==============================================
544 # SAMPLE GetUpdateSQL() and GetInsertSQL() code
545 #==============================================
546 include('adodb.inc.php');
547 include('tohtml.inc.php');
548
549 #==========================
550 # This code tests an insert
551
552 $sql = "SELECT * FROM ADOXYZ WHERE id = -1"; 
553 # Select an empty record from the database 
554
555 $conn = &ADONewConnection("mysql");  # create a connection
556 $conn->debug=1;
557 $conn->PConnect("localhost", "admin", "", "test"); # connect to MySQL, testdb
558 $rs = $conn->Execute($sql); # Execute the query and get the empty recordset
559
560 $record = array(); # Initialize an array to hold the record data to insert
561
562 # Set the values for the fields in the record
563 $record["firstname"] = "Bob";
564 $record["lastname"] = "Smith";
565 $record["created"] = time();
566
567 # Pass the empty recordset and the array containing the data to insert
568 # into the GetInsertSQL function. The function will process the data and return
569 # a fully formatted insert sql statement.
570 $insertSQL = $conn->GetInsertSQL($rs, $record);
571
572 $conn->Execute($insertSQL); # Insert the record into the database
573
574 #==========================
575 # This code tests an update
576
577 $sql = "SELECT * FROM ADOXYZ WHERE id = 1"; 
578 # Select a record to update 
579
580 $rs = $conn->Execute($sql); # Execute the query and get the existing record to update
581
582 $record = array(); # Initialize an array to hold the record data to update
583
584 # Set the values for the fields in the record
585 $record["firstname"] = "Caroline";
586 $record["lastname"] = "Smith"; # Update Caroline's lastname from Miranda to Smith
587
588 # Pass the single record recordset and the array containing the data to update
589 # into the GetUpdateSQL function. The function will process the data and return
590 # a fully formatted update sql statement with the correct WHERE clause.
591 # If the data has not changed, no recordset is returned
592 $updateSQL = $conn->GetUpdateSQL($rs, $record);
593
594 $conn->Execute($updateSQL); # Update the record in the database
595 $conn->Close();
596 ?>
597 </pre>
598 <h3>Example 8: Implementing Scrolling with Next and Previous<a name="ex8"></a></h3>
599 <p>
600 Code and idea by Iván Oliva. <p>
601 We use the HTTP Get variable $next_page to keep track of what page to go next and
602  store the current page in the session variable $curr_page.
603 <p>
604 We call the connection object's PageExecute() function to generate the appropriate recordset, 
605 then use the recordset's AtFirstPage() and AtLastPage() functions to determine 
606 whether to display the next and previous buttons. 
607
608 <pre>
609 &lt;?php
610 include_once('adodb.inc.php');
611 include_once('tohtml.inc.php');
612 <b>session_register('curr_page');</b>
613
614 $db = NewADOConnection('mysql');
615 $db->Connect('localhost','root','','xphplens');
616 <b>$num_of_rows_per_page = 10;
617 $sql = 'select * from products';
618
619 if (isset($HTTP_GET_VARS['next_page']))
620         $curr_page = $HTTP_GET_VARS['next_page'];
621 if (empty($curr_page)) $curr_page = 1; ## at first page
622
623 $rs = $db->PageExecute($sql, $num_of_rows_per_page, $curr_page);</b>
624 if (!$rs) die('Query Failed');
625
626 if (!$rs->EOF && (!$rs-><b>AtFirstPage</b>() || !$rs-><b>AtLastPage</b>())) {
627         if (!$rs-><b>AtFirstPage</b>()) {
628 ?>
629 &lt;a href="&lt;?php echo $PHPSELF,'?next_page=',$rs-><b>AbsolutePage</b>() - 1 ?>">Previous page&lt;/a>
630 &lt;?php
631         }
632         if (!$rs-><b>AtLastPage</b>()) {
633 ?>
634 &lt;a href="&lt;?php echo $PHPSELF,'?next_page=',$rs-><b>AbsolutePage</b>() + 1 ?>">Next page&lt;/a>
635 &lt;?php
636         }
637         rs2html($rs);
638 }
639 ?>
640 </pre>
641 The above code can be found in the <i>testpaging.php</i> example included with this release.
642 <p>
643 <a name=errorhandling></a> 
644 <h2>Using Custom Error Handlers and PEAR_Error</h2>
645 Apart from the old $con->debug = true; way of debugging, ADODB 1.50 onwards provides 
646 another way of handling errors using ADODB's configurable custom handlers. <p>
647 ADODB provides two custom handlers which you can modify for your needs.
648 The first one is in the <b>adodb-errorhandler.inc.php</b> file. This makes
649 use of the standard PHP functions <a href=http://php.net/error_reporting>error_reporting</a>
650 to control what error messages types to display,
651 and <a href=http://php.net/trigger_error>trigger_error</a> which invokes the default
652 PHP error handler.
653 <p>
654 Including the above file  will cause <i>trigger_error($errorstring,E_USER_ERROR)</i>
655 to be called when Connect() or PConnect() fails, or a function that executes SQL statements such as
656  Execute() or SelectLimit() has an error. This file should be included before you create any 
657  ADOConnection objects.<p>
658  If you define error_reporting(0), no errors will be shown. 
659  If you set error_reporting(E_ALL), all errors will be displayed on the screen.
660  <pre>
661 &lt;?php
662 <b>error_reporting(E_ALL); # show any error messages triggered
663 include('adodb-errorhandler.inc.php');</b>
664 include('adodb.inc.php');
665 include('tohtml.inc.php');
666 $c = NewADOConnection('mysql');
667 $c->PConnect('localhost','root','','northwind');
668 $rs=$c->Execute('select * from productsz'); #invalid table productsz');
669 if ($rs) $rs2html($rs);
670 ?>
671 </pre>
672  <p>
673  If you want to log the error message, you can do so by defining the following optional
674   constants ADODB_ERROR_LOG_TYPE and ADODB_ERROR_LOG_DEST. ADODB_ERROR_LOG_TYPE is 
675   the error log message type (see <a href=http://php.net/error_log>error_log</a>
676   in the PHP manual). In this case we set 
677   it to 3, which means log to the file defined by the constant ADODB_ERROR_LOG_DEST.
678  <pre>
679 &lt;?php
680 <b>error_reporting(0); # do not echo any errors
681 define('ADODB_ERROR_LOG_TYPE',3);
682 define('ADODB_ERROR_LOG_DEST','C:\errors.log');
683 include('adodb-errorhandler.inc.php');</b>
684 include('adodb.inc.php');
685 include('tohtml.inc.php');
686 $c = NewADOConnection('mysql');
687 $c->PConnect('localhost','root','','northwind');
688 $rs=$c->Execute('select * from productsz'); #invalid table productsz');
689 if ($rs) $rs2html($rs);
690 ?>
691 </pre>
692 The following message will be logged in the error.log file:
693 <pre>
694 (2001-10-28 14:20:38) mysql error: [1146: Table 'northwind.productsz' doesn't exist] in
695  EXECUTE("select * from productsz")
696 </pre>
697 The second error handler is <b>adodb-errorpear.inc.php</b>. 
698 This will create a PEAR_Error derived object whenever an error occurs. 
699 The last PEAR_Error object created can be retrieved using ADODB_Pear_Error().
700 <pre>
701 &lt;?php
702 <b>include('adodb-errorpear.inc.php');</b>
703 include('adodb.inc.php');
704 include('tohtml.inc.php');
705 $c = NewADOConnection('mysql');
706 $c->PConnect('localhost','root','','northwind');
707 $rs=$c->Execute('select * from productsz'); #invalid table productsz');
708 if ($rs) $rs2html($rs);
709 else {
710         <b>$e = ADODB_Pear_Error();
711         echo '&lt;p>',$e->message(),'&lt;/p>';</b>
712 }
713 ?>
714 </pre>
715 You can use also a PEAR_Error derived class by defining the constant 
716 ADODB_PEAR_ERROR_CLASS before the adodb-errorpear.inc.php file is included. And instead
717 of retrieving the error message yourself with $e->message, you can set the default error handler
718  in the beginning of the PHP script to PEAR_ERROR_DIE, which will cause an error message to be printed, 
719  then halt script execution:
720 <pre>
721 include('PEAR.php');
722 PEAR::setErrorHandling('PEAR_ERROR_DIE');
723 </pre>
724 <p>
725 <a name=caching></a> 
726 <h2>Caching of Recordsets</h2>
727 <p>ADODB now supports caching of recordsets using the  CacheExecute( ), 
728 CachePageExecute( ) and CacheSelectLimit( ) functions. There are similar to the
729 non-cache functions, except that they take a new first parameter, $secs2cache.
730 <p>
731   An example of use is the following: 
732 <pre>
733 <b>include</b>('adodb.inc.php'); # load code common to ADODB
734 $ADODB_CACHE_DIR = '/usr/adodb_cache';
735 $<font color="#663300">conn</font> = &amp;ADONewConnection('mysql');  # create a connection
736 $<font color="#663300">conn</font>->PConnect('localhost','userid','','agora');# connect to MySQL, agora db
737 <font color="#000000">$<font color="#663300">sql</font> = 'select CustomerName, CustomerID from customers';
738 $<font color="#663300">rs</font> = $<font color="#663300">conn</font>->CacheExecute(15,$sql);
739 </font></pre>
740 <font color="#000000"> The first parameter is the number of seconds to cache the 
741 query. Subsequent calls to that query will used the cached version stored in $ADODB_CACHE_DIR. 
742 To force a query and flush the cache, call CacheExecute() with the first parameter 
743 set to zero. Alternatively, use CacheFlush($sql) call.
744 <p>Windows Note: flock() is buggy in PHP 4.0.5 and earlier on Windows. So we use 
745   a non-blocking technique with rename(). 
746 <hr>
747 <h1>Class Reference<a name="Ref"></a></h1>
748 <p>Function parameters with [ ] around them are optional.</p>
749 <a name=adodb_fetch_mode>
750 <h2>$ADODB_FETCH_MODE</h2>
751 <p>This is a global variable that determines how arrays are retrieved by Execute( 
752   ). You can change this variable between invocations of Execute( ) and the fetch 
753   mode will be modified.</p>
754 <p>The following constants are defined:</p>
755   </font>
756 <p><font color="#000000">define('ADODB_FETCH_DEFAULT',0);<br>
757   define('ADODB_FETCH_NUM',1);<br>
758   define('ADODB_FETCH_ASSOC',2);<br>
759   define('ADODB_FETCH_BOTH',3); </font><font color="#000000"></font></p>
760 <font color="#000000">
761 <p>
762 An example of usage:
763 <pre>
764         $<b>ADODB_FETCH_MODE</b> = ADODB_FETCH_NUM;
765         $rs1 = $db->Execute('select * from table');
766         $<b>ADODB_FETCH_MODE</b> = ADODB_FETCH_ASSOC;
767         $rs2 = $db->Execute('select * from table');
768         print_r($rs1->fields); // shows <i>array([0]=>'v0',[1] =>'v1')</i>
769         print_r($rs2->fields); // shows <i>array(['col1']=>'v0',['col2'] =>'v1')</i>
770 </pre>
771 <p>
772 As you can see in the above example, both recordsets store and use different fetch modes
773 based on the $ADODB_FETCH_MODE setting when the recordset was created by Execute().</p>
774 <h2>ADOConnection<a name="ADOConnection"></a></h2>
775 <p>Object that performs the connection to the database, executes SQL statements 
776   and has a set of utility functions for standardising the format of SQL statements 
777   for issues such as concatenation and date formats.</p>
778 <hr>
779 <h3>ADOConnection Fields</h3>
780 <p><b>databaseType</b>: Name of the database system we are connecting to. Eg. 
781   <b>odbc</b> or <b>mssql</b> or <b>mysql</b>.</p>
782 <p><b>dataProvider</b>: The underlying mechanism used to connect to the database. 
783   Normally set to <b>native</b>, unless using <b>odbc</b> or <b>ado</b>.</p>
784 <p><b>host: </b>Name of server or data source name (DSN) to connect to.</p>
785 <p><b>database</b>: Name of the database or to connect to. If ado is used, it 
786   will hold the ado data provider.</p>
787 <p><b>user</b>: Login id to connect to database. Password is not saved for security 
788   reasons.</p>
789 <p><b>raiseErrorFn</b>: Allows you to define an error handling function. 
790 See adodb-errorhandler.inc.php for an example.</p>
791 <p><b>debug</b>: Set to <i>true</i> to make debug statements to appear.</p>
792 <p><b>concat_operator</b>: Set to '+' or '||' normally. The operator used to concatenate 
793   strings in SQL. Used by the <b><a href="#concat">Concat</a></b> function.</p>
794 <p><b>fmtDate</b>: The format used by the <b><a href="#dbdate">DBDate</a></b> 
795   function to send dates to the database. is '#Y-m-d#' for Microsoft Access, and 
796   '\'Y-m-d\'' for MySQL.</p>
797 <p><b>fmtTimeStamp: </b>The format used by the <b><a href="#dbtimestamp">DBTimeStamp</a></b> 
798   function to send timestamps to the database. </p>
799 <p><b>true</b>: The value used to represent true.Eg. '.T.'. for Foxpro, '1' for 
800   Microsoft SQL.</p>
801 <p><b>false: </b> The value used to represent false. Eg. '.F.'. for Foxpro, '0' 
802   for Microsoft SQL.</p>
803 <p><b>replaceQuote</b>: The string used to escape quotes. Eg. double single-quotes 
804   for Microsoft SQL, and backslash-quote for MySQL. Used by <a href="#qstr">qstr</a>.</p>
805 <p><b>autoCommit</b>: indicates whether automatic commit is enabled. Default is 
806   true.</p>
807 <p><b>charSet</b>: set the default charset to use. Currently only interbase supports 
808   this. </p>
809 <p><b>metaTablesSQL</b>: SQL statement to return a list of available tables. Eg. 
810   <i>SHOW TABLES</i> in MySQL.</p>
811 <p><b>genID</b>: The latest id generated by GenID() if supported by the database.</p>
812 <hr>
813 <h3>ADOConnection Main Functions</h3>
814 <p><b>ADOConnection( )</b></p>
815 <p>Constructor function. Do not call this directly. Use ADONewConnection( ) instead.</p>
816 <p><b>Connect<a name="Connect"></a>($host,[$user],[$password],[$database])</b></p>
817 <p>Non-persistent connect to data source or server $<b>host</b>, using userid 
818   $<b>user </b>and password $<b>password</b>. If the server supports multiple 
819   databases, connect to database $<b>database</b>. </p>
820  <p>Returns true/false depending on connection.</p>
821 <p>ADO Note: If you are using a Microsoft ADO and not OLEDB, you can set the $database 
822   parameter to the OLEDB data provider you are using.</p>
823 <p>PostgreSQL: An alternative way of connecting to the database is to pass the 
824   standard PostgreSQL connection string in the first parameter $host, and the 
825   other parameters will be ignored.</p>
826 <p>For Oracle and Oci8, there are two ways to connect. First is to use the TNS name
827 defined in your local tnsnames.ora. Place the name in the $database field, and set the
828 $host field to false. Alternatively, set $host to the server, and $database to the
829 database SID, this bypassed tnsnames.ora.
830 <p>Examples:
831  <pre> $conn->Connect(false, 'scott', 'tiger', 'name_in_tnsnames'); # use tnsnames.ora
832  $conn->Connect('server:1521', 'scott', 'tiger', 'OracleSID'); # bypass tnsnames.ora</pre>
833 <p>There are many examples of connecting to a database at 
834 <a href="http://php.weblogs.com/adodb">php.weblogs.com/adodb</a>, and in the 
835 testdatabases.inc.php file included in the release.</p>
836 <p><b>PConnect<a name="PConnect"></a>($host,[$user],[$password],[$database])</b></p>
837 <p>Persistent connect to data source or server $<b>host</b>, using userid $<b>user</b> 
838   and password $<b>password</b>. If the server supports multiple databases, connect 
839   to database $<b>database</b>.</p>
840 <p>Returns true/false depending on connection. See Connect( ) above for more info.</p>
841 <p><b>Execute<a name="Execute"></a>($sql,$inputarr=false)</b></p>
842 <p>Execute SQL statement $<b>sql</b> and return derived class of ADORecordSet 
843   if successful. Note that a record set is always returned on success, even if we are executing 
844   an insert or update statement.</p>
845 <p>Returns derived class of ADORecordSet. Eg. if connecting via mysql, then ADORecordSet_mysql 
846   would be returned. False is returned if there was an error in executing the sql.</p>
847 <p>The $inputarr parameter can be used for binding variables to parameters. Below 
848   is an Oracle example:</p>
849 <pre>
850  $conn->Execute("SELECT * FROM TABLE WHERE COND=:val", array('val'=> $val));
851  </pre>
852 <p>Another example, using ODBC,which uses the ? convention:</p>
853 <pre>
854   $conn->Execute("SELECT * FROM TABLE WHERE COND=?", array($val));
855 </pre>
856 <i>Binding variables</i><br>
857 Variable binding speeds the compilation and caching of SQL statements, leading 
858 to higher performance. Currently Oracle and ODBC support variable binding. ODBC 
859 style ? binding is emulated in databases that do not support binding. 
860 <p> Variable binding in ODBC: 
861 <pre>
862 $rs = $db->Execute('select * from table where val=?', array('10'));
863 </pre>
864 Variable binding in Oracle: 
865 <pre>
866 $rs = $db->Execute('select name from table where val=:key', 
867   array('key' => 10));
868 </pre>
869 <p><b>CacheExecute<a name="CacheExecute"></a>($secs2cache,$sql,$inputarr=false)</b></p>
870 <p>Similar to Execute, except that the recordset is cached for $secs2cache seconds 
871   in the $ADODB_CACHE_DIR directory. If CacheExecute() is called again with the 
872   same parameters, same database, same userid, same password, and the cached recordset 
873   has not expired, the cached recordset is returned. 
874 <pre>
875   include('adodb.inc.php'); 
876   include('tohtml.inc.php');
877   $<b>ADODB_CACHE_DIR</b> = '/usr/local/adodbcache';
878   $conn = &ADONewConnection('mysql'); 
879   $conn->PConnect('localhost','userid','password','database');
880   $rs = $conn-><b>CacheExecute</b>(15, 'select * from table'); # cache 15 secs
881   rs2html($rs); /* recordset to html table */  
882 </pre>
883 <p></p>
884 <p> If multiple calls to CacheExecute() are made and the recordset is still cached, 
885   the $secs2cache parameter does not prolong the time the recordset is cached 
886   (it is ignored). Use CacheExecute() only with SELECT statements.</p>
887 <p>Performance note: I have done some benchmarks and found that they vary so greatly 
888   that it's better to talk about when caching is of benefit. When your database 
889   server is <i>much slower </i>than your Web server or the database is <i>very 
890   overloaded </i>then ADODB's caching is good because it reduces the load on your 
891   database server. If your database server is lightly loaded or much faster than 
892   your Web server, then caching could actually reduce performance. </p>
893 <p><b>SelectLimit<a name="SelectLimit"></a>($sql,$numrows=-1,$offset=-1,$inputarr=false)</b></p>
894 <p>Returns a recordset if successful. Returns false otherwise. Performs a select 
895   statement, simulating PostgreSQL's SELECT statement, LIMIT $numrows OFFSET $offset 
896   clause.</p>
897 <p>In PostgreSQL, SELECT * FROM TABLE LIMIT 3 will return the first 3 records 
898   only. The equivalent is <code>$connection->SelectLimit('SELECT * FROM TABLE',3)</code>. 
899   This functionality is simulated for databases that do not possess this feature.</p>
900 <p>And SELECT * FROM TABLE LIMIT 3 OFFSET 2 will return records 3, 4 and 5 (eg. 
901   after record 2, return 3 rows). The equivalent in ADODB is <code>$connection->SelectLimit('SELECT 
902   * FROM TABLE',3,2)</code>.</p>
903 <p>Note that this is the <i>opposite</i> of MySQL's LIMIT clause. You can also 
904   set <code>$connection->SelectLimit('SELECT * FROM TABLE',-1,10)</code> to get 
905   rows 11 to the last row.</p>
906 <p>The last parameter $inputarr is for databases that support variable binding 
907   such as Oracle oci8. This substantially reduces SQL compilation overhead. Below 
908   is an Oracle example:</p>
909 <pre>
910  $conn->SelectLimit("SELECT * FROM TABLE WHERE COND=:val", 100,-1,array('val'=> $val));
911  </pre>
912 <p>The oci8po driver (oracle portable driver) uses the more standard bind variable of ?:
913 <pre>
914  $conn->SelectLimit("SELECT * FROM TABLE WHERE COND=?", 100,-1,array('val'=> $val));
915  </pre>
916
917 <p>Ron Wilson reports that SelectLimit does not work with UNIONs and suggested 
918   the following solution for mssql: 
919 <pre>
920 >In addition, I found a way to structure the Select Union so that it will
921 > work with the optimization in place.  It works under MS-SQL, don't know
922 > about the others...  When updating the help file, you could use this as an
923 > example of how to structure the SQL --
924 <i>No it doesn't work with MySQL.</i>
925
926 > Change:
927 >  Select column1 From table1
928 >  Union
929 >  Select column2 From table2
930
931 > To:
932 >  Select * From (
933 >   Select column1 From table1
934 >   Union
935 >   Select column2 From table2
936 >   )
937 >  As dummytable
938
939 > Ron
940
941 </pre>
942 <p><b>CacheSelectLimit<a name="CacheSelectLimit"></a>($secs2cache,$sql,$numrows=-1,$offset=-1,$inputarr=false)</b></p>
943 <p>Similar to SelectLimit, except that the recordset returned is cached for $secs2cache 
944   seconds in the $ADODB_CACHE_DIR directory. </p>
945 <p><b>CacheFlush<a name="CacheFlush"></a>($sql)</b></p>
946 <p>Flush (delete) any cached recordsets of the SQL statement $sql in $ADODB_CACHE_DIR.</p>
947 <p><b>ErrorMsg<a name="ErrorMsg"></a>()</b></p>
948 <p>Returns the last status or error message. This can return a string even if 
949   no error occurs. In general you do not need to call this function unless an ADODB function
950   returns false on an error. </p>
951 <p>Note: If <b>debug</b> is enabled, the SQL error message is always displayed 
952   when the <b>Execute</b> function is called.</p>
953 <p><b>ErrorNo<a name="errorno"></a>()</b></p>
954 <p>Returns the last error number. Note that old versions of PHP (pre 4.0.6) do not support
955 error number for ODBC. In general you do not need to call this function unless an ADODB function
956   returns false on an error.</p>
957 <p><b>GenID<a name="genid"></a>($seqName = 'adodbseq',$startID=1)</b></p>
958 <p>Generate a sequence number (an integer except for mssql). Works for interbase, mysql, postgresql, oci8,
959 oci8po, mssql drivers 
960   currently. Uses $seqName as the name of the sequence. GenID() will automatically create
961   the sequence for you if it does not exist (provided the userid has permission to do so).  
962   The MySQL implementation creates a table for each sequence. If the sequence has not been
963   defined earlier, it is created with the starting value set in $startID.</p>
964 <p>Note that GenID() now generates uniqueidentifiers for MSSQL; these are 16 byte GUID's.</p>
965 <p><b>UpdateBlob<a name="updateblob"></a>($table,$column,$val,$where,$blobtype='BLOB')</b></p>
966 Allows you to store a blob (in $val) into $table into $column in a row at $where. 
967 The $blobtype is an optional parameter, only useful for oci8 and oci8po; legal values for 
968 oci8 and oci8po are 'CLOB' and 'BLOB'. 
969 <p> Usage: 
970 <p> 
971 <pre>
972         $conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)');
973         $conn->UpdateBlob('blobtable','blobcol',$blobvalue,'id=1');
974 </pre>
975 <p> Returns true if succesful, false otherwise. Supported by MySQL, PostgreSQL, Oci8, Oci8po
976   and Interbase drivers. Other drivers might work.</p>
977 <p>Note that when an Interbase blob is retrieved using SELECT, it still needs to be decoded 
978 using $connection->DecodeBlob($blob); to derive the original value.
979 <p><b>GetUpdateSQL<a name="getupdatesql"></a>(&$rs, $arrFields, $forceUpdate=false,$magicq=false)</b></p>
980 <p>Generate SQL to update a table given a recordset $rs, and the modified fields 
981   of the array $arrFields (which must be an associative array holding the column 
982   names and the new values) are compared with the current recordset. If $forceUpdate 
983   is true, then we also generate the SQL even if $arrFields is identical to $rs-&gt;fields.     
984   Requires the recordset to be associative. $magicq is used to indicate whether magic quotes
985   are enabled (see qstr()).</p>
986 <p><b>GetInsertSQL<a name="getinsertsql"></a>(&$rs, $arrFields,$magicq=false)</b></p>
987 <p>Generate SQL to insert into a table given a recordset $rs. Requires the query 
988   to be associative. $magicq is used to indicate whether magic quotes
989   are enabled (for qstr()).</p>
990 <b>PageExecute<a name="pageexecute"></a>($sql, $nrows, $page, $inputarr=false)</b> 
991 <p>Used for pagination of recordset. $page is 1-based. See <a href="#ex8">Example 
992   8</a>.</p>
993 </font> 
994 <p><font color="#000000"><b>CachePageExecute<a name="cachepageexecute"></a>($secs2cache, 
995   $sql, $nrows, $page, $inputarr=false)</b> </font></p>
996 <p><font color="#000000">Used for pagination of recordset. $page is 1-baed. See 
997   <a href="#ex8">Example 8</a>. Caching version of PageExecute.</font></p>
998 <font color="#000000"> 
999 <p></p>
1000 <p><b>Close<a name="Close"></a>( )</b></p>
1001 <p>Close the database connection. PHP4 proudly states that we no longer have to 
1002   clean up at the end of the connection because the reference counting mechanism 
1003   of PHP4 will automatically clean up for us.</p>
1004 <p><b>BeginTrans<a name="Begintrans"></a>( )</b></p>
1005 <p>Begin a transaction. Turns off autoCommit. Returns true if successful. Some 
1006   databases will always return false if transaction support is not available. 
1007   Interbase, Oracle and MSSQL support transactions. Note that transaction support 
1008   is not available for Microsoft ADO due to some bugs in PHP 4.02. Use the native 
1009   transaction support of your RDBMS. Any open transactions will be rolled back 
1010   when the connection is closed.</p>
1011 <p><b>CommitTrans<a name="CommitTrans"></a>( )</b></p>
1012 <p>End a transaction successfully. Returns true if successful. If the database 
1013   does not support transactions, will return true also as data is always committed. 
1014 </p>
1015 <p><b>RollbackTrans<a name="RollbackTrans"></a>( )</b></p>
1016 <p>End a transaction, rollback all changes. Returns true if successful. If the 
1017   database does not support transactions, will return false as data is never rollbacked. 
1018 </p>
1019 <hr>
1020 <h3>ADOConnection Utility Functions</h3>
1021 <p><b>BlankRecordSet<a name="blankrecordset"></a>([$queryid])</b></p>
1022 <p>Returns an empty recordset. This is useful if you require the use of some ADORecordSet 
1023   utility function such as UnixDate.</p>
1024 <p><b>Concat<a name="Concat"></a>($s1,$s2,....)</b></p>
1025 <p>Generates the sql string used to concatenate $s1, $s2, etc together. Uses the 
1026   string in the concat_operator field to generate the concatenation. Override 
1027   this function if a concatenation operator is not used, eg. MySQL.</p>
1028 <p>Returns the concatenated string.</p>
1029 <p><b>DBDate<a name="DBDate"></a>($date)</b></p>
1030 <p>Format the $<b>date</b> in the format the database accepts; this can be a
1031 Unix timestamp or an ISO format Y-m-d. Uses the fmtDate 
1032   field, which holds the format to use. If null or false or '' is passed
1033   in, it will be converted to an SQL null.</p>
1034 <p>Returns the date as a quoted string.</p>
1035 <p><b>DBTimeStamp<a name="DBTimeStamp"></a>($ts)</b></p>
1036 <p>Format the timestamp $<b>ts</b> in the format the database accepts; this can be a
1037 Unix timestamp or an ISO format Y-m-d H:i:s. Uses the 
1038   fmtTimeStamp field, which holds the format to use. If null or false or '' is passed
1039   in, it will be converted to an SQL null.</p>
1040 <p>Returns the timestamp as a quoted string.</p>
1041 <p><b>qstr<a name="qstr"></a>($s,[$magic_quotes_enabled</b>=false]<b>)</b></p>
1042 <p>Quotes a string to be sent to the database. The $<b>magic_quotes_enabled</b> 
1043   parameter may look funny, but the idea is if you are quoting a string extracted 
1044   from a POST/GET variable, then pass get_magic_quotes_gpc() as the second parameter. 
1045   This will ensure that the variable is not quoted twice, once by <i>qstr</i> 
1046   and once by the <i>magic_quotes_gpc</i>.</p>
1047 <p>Eg.<font face="Courier New, Courier, mono"> $s = $db-&gt;qstr(HTTP_GET_VARS['name'],get_magic_quotes_gpc());</font></p>
1048 <p>Returns the quoted string.</p>
1049 <p><b>Affected_Rows<a name="Affected_Rows"></a>( )</b></p>
1050 <p>Returns the number of rows affected by a update or delete statement. Returns 
1051   false if function not supported.</p>
1052 <p>Only supported for PostgreSQL, MySQL, MSSQL and ODBC currently. This function might only 
1053   give accurate results if you perform it in a transaction if you are using persistent 
1054   connections. This is because the connection you are assigned for one Execute(&nbsp;) 
1055   might differ from the next Execute(&nbsp;).</p>
1056 <p><b>Insert_ID<a name="Inserted_ID"></a>( )</b></p>
1057 <p>Returns the last autonumbering ID inserted. Returns false if function not supported. 
1058 </p>
1059 <p>Only supported for PostgreSQL, MySQL and MSSQL currently. PostgreSQL returns 
1060   the OID, which can change on a database reload. This function might only give 
1061   accurate results if you perform it in a transaction if you are using persistent 
1062   connections. This is because the connection you are assigned for one Execute(&nbsp;) 
1063   might differ from the next Execute(&nbsp;).</p>
1064 <p><b>MetaDatabases<a name="metadatabases"></a>()</b></p>
1065 <p>Returns a list of databases available on the server as an array. You have to 
1066   connect to the server first. Only available for ODBC, MySQL and ADO.</p>
1067 <p><b>MetaTables<a name="metatables"></a>()</b></p>
1068 <p>Returns an array of tables and views for the current database as an array. 
1069   The array should exclude system catalog tables if possible.</p>
1070 <p><b>MetaColumns<a name="metacolumns"></a>($table)</b></p>
1071 <p>Returns an array of ADOFieldObject's, one field object for every column of 
1072   $table. Currently Sybase does not recognise date types, and ADO cannot identify 
1073   the correct data type (so we default to varchar).. </p>
1074 <hr>
1075 <h2>ADORecordSet<a name="ADORecordSet"></a></h2>
1076 <p>When an SQL statement successfully is executed by <font face="Courier New, Courier, mono">ADOConnection-&gt;Execute($sql),</font>an 
1077   ADORecordSet object is returned. This object contains a virtual cursor so we 
1078   can move from row to row, functions to obtain information about the columns 
1079   and column types, and helper functions to deal with formating the results to 
1080   show to the user.</p>
1081 <h3>ADORecordSet Fields</h3>
1082 <p><b>fields: </b>Array containing the current row. This is not associative, but 
1083   is an indexed array from 0 to columns-1. See also the function <b><a href="#fields">Fields</a></b>, 
1084   which behaves like an associative array.</p>
1085 <p><b>dataProvider</b>: The underlying mechanism used to connect to the database. 
1086   Normally set to <b>native</b>, unless using <b>odbc</b> or <b>ado</b>.</p>
1087 <p><b>blobSize</b>: Maximum size of a char, string or varchar object before it 
1088   is treated as a Blob (Blob's should be shown with textarea's). See the <a href="#metatype">MetaType</a> 
1089   function.</p>
1090 <p><b>sql</b>: Holds the sql statement used to generate this record set.</p>
1091 <p><b>canSeek</b>: Set to true if Move( ) function works.</p>
1092 <p><b>EOF</b>: True if we have scrolled the cursor past the last record.</p>
1093 <h3>ADORecordSet Functions</h3>
1094 <p><b>ADORecordSet( )</b></p>
1095 <p>Constructer. Normally you never call this function yourself.</p>
1096 <p><b>GetAssoc<a name="GetAssoc"></a>([$force_array])</b></p>
1097 <p>Generates an associative array from the recordset if the number of columns 
1098   is greater than 2. The array is generated from the current cursor position till 
1099   EOF. The first column of the recordset becomes the key to the rest of the array. 
1100   If the columns is equal to two, then the key directly maps to the value unless 
1101   $force_array is set to true, when an array is created for each key. Inspired 
1102   by PEAR's getAssoc.</p>
1103 <p>Example:</p>
1104 <p>We have the following data in a recordset:</p>
1105 <p>row1: Apple, Fruit, Edible<br>
1106   row2: Cactus, Plant, Inedible<br>
1107   row3: Rose, Flower, Edible</p>
1108 <p>GetAssociation will generate the following associative array:</p>
1109 <p>Apple =&gt; [Fruit, Edible]<br>
1110   Cactus =&gt; [Plant, Inedible]<br>
1111   Rose =&gt; [Flower,Edible]</p>
1112 <p>Returns:</p>
1113 <p>The associative array, or false if an error occurs.</p>
1114 <p><b>GetArray<a name="GetArray"></a>([$number_of_rows])</b></p>
1115 <p>Generate an array from the current cursor position, indexed from 0 to $number_of_rows 
1116   - 1. If $number_of_rows is undefined, till EOF.</p>
1117 <p><b>GetRows<a name="GetRows"></a>([$number_of_rows])</b></p>
1118 <p>Synonym for GetArray() for compatibility with Microsoft ADO.</p>
1119 <p> <b>GetMenu<a name="GetMenu"></a>($name, [$default_str=''], [$blank1stItem=true], 
1120   [$multiple_select=false], [$size=0], [$moreAttr=''])</b></p>
1121 <p>Generate a HTML menu (&lt;select&gt;&lt;option&gt;&lt;option&gt;&lt;/select&gt;). 
1122   The first column of the recordset (fields[0]) will hold the string to display 
1123   in the option tags. If the recordset has more than 1 column, the second column 
1124   (fields[1]) is the value to send back to the web server.. The menu will be given 
1125   the name $<i>name</i>. 
1126 <p> If $<i>default_str</i> is defined, then if $<i>default_str</i> == fields[0], 
1127   that field is selected. If $<i>blank1stItem</i> is true, the first option is 
1128   empty. $<i>Default_str</i> can be array for a multiple select listbox.</p>
1129 <p>To get a listbox, set the $<i>size</i> to a non-zero value (or pass $default_str 
1130   as an array). If $<i>multiple_select</i> is true then a listbox will be generated 
1131   with $<i>size</i> items (or if $size==0, then 5 items) visible, and we will 
1132   return an array to a server. Lastly use $<i>moreAttr </i> to add additional 
1133   attributes such as javascript or styles. </p>
1134 <p>Menu Example 1: <code>GetMenu('menu1','A',true)</code> will generate a menu: 
1135   <select name='menu1'>
1136     <option> 
1137     <option value=1 selected>A 
1138     <option value=2>B 
1139     <option value=3>C 
1140   </select>
1141   for the data (A,1), (B,2), (C,3). Also see <a href="#ex5">example 5</a>.</p>
1142 <p>Menu Example 2: For the same data, <code>GetMenu('menu1',array('A','B'),false)</code> 
1143   will generate a menu with both A and B selected: <br>
1144   <select name='menu1' multiple size=3>
1145     <option value=1 selected>A 
1146     <option value=2 selected>B 
1147     <option value=3>C 
1148   </select>
1149 <p> <b>GetMenu2<a name="GetMenu2"></a>($name, [$default_str=''], [$blank1stItem=true], 
1150   [$multiple_select=false], [$size=0], [$moreAttr=''])</b></p>
1151 <p>This is nearly identical to GetMenu, except that the $<i>default_str</i> is 
1152   matched to fields[1] (the option values).</p>
1153 <p>Menu Example 3: Given the data in menu example 2, <code>GetMenu2('menu1',array('1','2'),false)</code> 
1154   will generate a menu with both A and B selected in menu example 2, but this 
1155   time the selection is based on the 2nd column, which holds the values to return 
1156   to the Web server. 
1157 <p><b>UserDate<a name="UserDate"></a>($str, [$fmt])</b></p>
1158 <p>Converts the date string $<b>str</b> to another format.UserDate calls UnixDate 
1159   to parse $<b>str</b>, and $<b>fmt</b> defaults to Y-m-d if not defined.</p>
1160 <p><b>UserTimeStamp<a name="UserTimeStamp"></a>($str, [$fmt])</b></p>
1161 <p>Converts the timestamp string $<b>str</b> to another format. UserTimeStamp 
1162   calls UnixTimeStamp to parse $<b>str</b>, and $<b>fmt</b> defaults to Y-m-d 
1163   H:i:s if not defined.</p>
1164 <p><b>UnixDate<a name="unixdate"></a>($str)</b></p>
1165 <p>Parses the date string $<b>str</b> and returns it in unix mktime format (eg. 
1166   a number indicating the seconds after January 1st, 1970). Expects the date to 
1167   be in Y-m-d h:i:s format, except for Sybase and Microsoft SQL Server, where 
1168   M d Y is also accepted (the 3 letter month strings are controlled by a global 
1169   array, which might need localisation).</p>
1170 <p><b>UnixTimeStamp<a name="unixtimestamp"></a>($str)</b></p>
1171 <p>Parses the timestamp string $<b>str</b> and returns it in unix mktime format 
1172   (eg. a number indicating the seconds after January 1st, 1970). Expects the date 
1173   to be in Y-m-d H:i:s format, except for Sybase and Microsoft SQL Server, where 
1174   M d Y h:i:sA is also accepted (the 3 letter month strings are controlled by 
1175   a global array, which might need localisation)..</p>
1176 <p><b>MoveNext<a name="MoveNext"></a>( )</b></p>
1177 <p>Move the internal cursor to the next row. The <b>fields</b> array is automatically 
1178   updated. Return false if unable to do so, otherwise true.. </p>
1179 <p><b>Move<a name="Move"></a>($to)</b></p>
1180 <p>Moves the internal cursor to a specific row $<b>to</b>. Rows are zero-based 
1181   eg. 0 is the first row. The <b>fields</b> array is automatically updated. For 
1182   databases that do not support scrolling internally, ADODB will simulate forward 
1183   scrolling. Some databases do not support backward scrolling. If the $<b>to</b> 
1184   position is after the EOF, $<b>to</b> will move to the end of the RecordSet 
1185   for most databases. Some obscure databases using odbc might not behave this 
1186   way.</p>
1187 <p>Note: This function uses <i>absolute positioning</i>, unlike Microsoft's ADO.</p>
1188 <p>Returns true or false. If false, the internal cursor is not moved in most implementations, 
1189   so AbsolutePosition( ) will return the last cursor position before the Move( 
1190   ). </p>
1191 <p><b>MoveFirst<a name="MoveFirst"></a>()</b></p>
1192 <p>Internally calls Move(0). Note that some databases do not support this function.</p>
1193 <p><b>MoveLast<a name="MoveLast"></a>()</b></p>
1194 <p>Internally calls Move(RecordCount()-1). Note that some databases do not support 
1195   this function.</p>
1196 <p><b>GetRowAssoc</b><a name="getrowassoc"></a>($toUpper=true)</p>
1197 <p>The above function is no longer the prefered way of getting associative arrays. 
1198 Use the <a href=#adodb_fetch_mode>$ADODB_FETCH_MODE</a> variable instead. </p>
1199 <p>Returns an associative array containing the current row. The keys to the array 
1200   are the column names. The column names are upper-cased for easy access. To get 
1201   the next row, you will still need to call MoveNext(). </p>
1202 <p>For example:<br>
1203   Array ( [ID] => 1 [FIRSTNAME] => Caroline [LASTNAME] => Miranda [CREATED] => 
1204   2001-07-05 ) </p>
1205 <p>Note: do not use GetRowAssoc() with $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC. Because
1206 they have the same functionality, they will interfere with each other.</p>
1207 </font>
1208 <p><font color="#000000"><b>AbsolutePage<a name="absolutepage"></a>($page=-1) </b></font></p>
1209 <p>Returns the current page. Requires PageExecute()/CachePageExecute() to be called. See <a href=#ex8>Example 8</a>.</p>
1210 <font color="#000000"> 
1211 <p><b>AtFirstPage<a name="AtFirstPage">($status='')</a></b></p>
1212 <p>Returns true if at first page (1-based). Requires PageExecute()/CachePageExecute() to be called. See <a href=#ex8>Example 8</a>.</p>
1213 <p><b>AtLastPage<a name="AtLastPage">($status='')</a></b></p>
1214 <p>Returns true if at last page (1-based). Requires PageExecute()/CachePageExecute() to be called. See <a href=#ex8>Example 8</a>.</p>
1215 <p><b>Fields</b><a name="fields"></a>(<b>$colname</b>)</p>
1216 <p>Some database extensions (eg. MySQL) return arrays that are both associative 
1217   and indexed if you use the native extensions. GetRowAssoc() does not return 
1218   arrays that combine associative and indexed elements.</p>
1219 <p>Returns the value of the associated column $<b>colname</b> for the current 
1220   row. The column name is case-insensitive.</p>
1221 <p><b>FetchField<a name="FetchField"></a>($column_number)</b></p>
1222 <p>Returns an object containing the <b>name</b>, <b>type</b> and <b>max_length</b> 
1223   of the associated field. If the max_length cannot be determined reliably, it 
1224   will be set to -1. The column numbers are zero-based. See <a href="#ex2">example 
1225   2.</a></p>
1226 <p><b>FieldCount<a name="FieldCount"></a>( )</b></p>
1227 <p>Returns the number of fields (columns) in the record set.</p>
1228 <p><b>RecordCount<a name="RecordCount"></a>( )</b></p>
1229 <p>Returns the number of rows in the record set. Note that some databases do not 
1230   support this, and will return -1. RowCount is a synonym for RecordCount.</p>
1231 <p>The following databases are known to return -1. Oci8, Oci8po, Oracle, Interbase.</p>
1232 <p><b>FetchObject<a name="FetchObject"></a>($toupper=true)</b></p>
1233 <p>Returns the current row as an object. If you set $toupper to true, then the 
1234   object fields are set to upper-case. Note: The newer FetchNextObject() is the 
1235   recommended way of accessing rows as objects. See below.</p>
1236 <p><b>FetchNextObject<a name="FetchNextObject"></a>($toupper=true)</b></p>
1237 <p>Gets the current row as an object and moves to the next row automatically. 
1238   Returns false if at end-of-file. If you set $toupper to true, then the object 
1239   fields are set to upper-case.</p>
1240 <pre>
1241 $rs = $db->Execute('select firstname,lastname from table');
1242 if ($rs) {
1243         while ($o = $rs->FetchNextObject()) {
1244                 print "$o->FIRSTNAME, $o->LASTNAME&lt;BR>";
1245         }
1246 }
1247 </pre>
1248 <p>There is some trade-off in speed in using FetchNextObject(). If performance 
1249   is important, you should access rows with the <code>fields[]</code> array. 
1250 <p> 
1251 <p><b>CurrentRow<a name="CurrentRow"></a>( )</b></p>
1252 <p>Returns the current row of the record set. 0 is the first row.</p>
1253 <p><b>AbsolutePosition<a name="abspos"></a>( )</b></p>
1254 <p>Synonym for <b>CurrentRow</b> for compatibility with ADO. Returns the current 
1255   row of the record set. 0 is the first row.</p>
1256 <p><b>MetaType<a name="MetaType"></a>($nativeDBType[,$field_max_length],[$fieldobj])</b></p>
1257 <p>Determine what <i>generic</i> meta type a database field type is given its 
1258   native type $<b>nativeDBType</b> and the length of the field $<b>field_max_length</b>. 
1259   Note that field_max_length can be -1 if it is not known. The field object returned 
1260   by the database driver can be passed in $<b>fieldobj</b>. This is useful for 
1261   databases such as <i>mysql</i> which has additional properties in the field 
1262   object such as <i>primary_key</i>.</p>
1263 <p>Uses the field <b>blobSize</b> and compares it with $<b>field_max_length</b> 
1264   to determine whether the character field is actually a blob.</p>
1265 <p>Returns:</p>
1266 <ul>
1267   <li><b>C</b>: Character fields that should be shown in a &lt;input type=&quot;text&quot;&gt; 
1268     tag. </li>
1269   <li><b>B</b>: Blob, or large text fields that should be shown in a &lt;textarea&gt;</li>
1270   <li><b>D</b>: Date field</li>
1271   <li><b>T</b>: Timestamp field</li>
1272   <li><b>L</b>: Logical field (boolean or bit-field)</li>
1273   <li><b>N</b>: Numeric field. Includes decimal, numeric, floating point, and 
1274     real. </li>
1275   <li><b>I</b>: Integer field. </li>
1276   <li><b>R</b>: Counter or Autoincrement field. Must be numeric.</li>
1277 </ul>
1278 <p><b>Close( )<a name="rsclose"></a></b></p>
1279 <p>Close the recordset.</p>
1280 <hr>
1281 <h3>function rs2html<a name="rs2html"></a>($adorecordset,[$tableheader_attributes], 
1282   [$col_titles])</h3>
1283 <p>This is a standalone function (rs2html = recordset to html) that is similar 
1284   to PHP's <i>odbc_result_all</i> function, it prints a ADORecordSet, $<b>adorecordset</b> 
1285   as a HTML table. $<b>tableheader_attributes</b> allow you to control the table 
1286   <i>cellpadding</i>, <i>cellspacing</i> and <i>border</i> attributes. Lastly 
1287   you can replace the database column names with your own column titles with the 
1288   array $<b>col_titles</b>. This is designed more as a quick debugging mechanism, 
1289   not a production table recordset viewer.</p>
1290 <p>You will need to include the file <i>tohtml.inc.php</i>.</p>
1291 <p>Example of rs2html:<b><font color="#336600"><a name="exrs2html"></a></font></b></p>
1292 <pre><b><font color="#336600">&lt;?
1293 include('tohtml.inc.php')</font></b>; # load code common to ADODB 
1294 <b>include</b>('adodb.inc.php'); # load code common to ADODB 
1295 $<font color="#663300">conn</font> = &amp;ADONewConnection('mysql');   # create a connection 
1296 $<font color="#663300">conn</font>->PConnect('localhost','userid','','agora');# connect to MySQL, agora db
1297 <font color="#000000">$<font color="#663300">sql</font> = 'select CustomerName, CustomerID from customers'; 
1298 $<font color="#663300">rs</font>   = $<font color="#663300">conn</font>->Execute($sql); 
1299 <font color="#336600"><b>rs2html</b></font><b>($<font color="#663300">rs</font>,'<i>border=2 cellpadding=3</i>',array('<i>Customer Name','Customer ID</i>'));
1300 ?&gt;</b></font></pre>
1301 <hr>
1302 <h3>Differences Between this ADODB library and Microsoft ADO<a name="adodiff"></a></h3>
1303 <ol>
1304   <li>ADODB only supports recordsets created by a connection object. Recordsets 
1305     cannot be created independently.</li>
1306   <li>ADO properties are implemented as functions in ADODB. This makes it easier 
1307     to implement any enhanced ADO functionality in the future.</li>
1308   <li>ADODB's <font face="Courier New, Courier, mono">ADORecordSet-&gt;Move()</font> 
1309     uses absolute positioning, not relative. Bookmarks are not supported.</li>
1310   <li><font face="Courier New, Courier, mono">ADORecordSet-&gt;AbsolutePosition() 
1311     </font>cannot be used to move the record cursor.</li>
1312   <li>ADO Parameter objects are not supported.</li>
1313   <li>Recordset properties for paging records are available, but implemented as in <a href=#ex8>Example 8</a>.</li>
1314 </ol>
1315 <hr>
1316 <h1>Database Driver Guide<a name="DriverGuide"></a></h1>
1317 <p>This describes how to create a class to connect to a new database. To ensure 
1318   there is no duplication of work, kindly email me at jlim#natsoft.com.my if you 
1319   decide to create such a class.</p>
1320 <p>First decide on a name in lower case to call the database type. Let's say we 
1321   call it xbase. </p>
1322 <p>Then we need to create two classes ADOConnection_xbase and ADORecordSet_xbase 
1323   in the file adodb-xbase.inc.php.</p>
1324 <p>The simplest form of database driver is an adaptation of an existing ODBC driver. 
1325   Then we just need to create the class <i>ADOConnection_xbase extends ADOConnection_odbc</i> 
1326   to support the new <b>date</b> and <b>timestamp</b> formats, the <b>concatenation</b> 
1327   operator used, <b>true</b> and <b>false</b>. For the<i> ADORecordSet_xbase extends 
1328   ADORecordSet_odbc </i>we need to change the <b>MetaType</b> function. See<b> 
1329   adodb-vfp.inc.php</b> as an example.</p>
1330 <p>More complicated is a totally new database driver that connects to a new PHP 
1331   extension. Then you will need to implement several functions. Fortunately, you 
1332   do not have to modify most of the complex code. You only need to override a 
1333   few stub functions. See <b>adodb-mysql.inc.php</b> for example.</p>
1334 <p>The default date format of ADODB internally is YYYY-MM-DD (Ansi-92). All dates 
1335   should be converted to that format when passing to an ADODB date function. See 
1336   Oracle for an example how we use ALTER SESSION to change the default date format 
1337   in _pconnect _connect.</p>
1338 <p><b>ADOConnection Functions to Override</b></p>
1339 <p>Defining a constructor for your ADOConnection derived function is optional. 
1340   There is no need to call the base class constructor.</p>
1341 <p>_<b>connect</b>: Low level implementation of Connect. Returns true or false. 
1342   Should set the _<b>connectionID</b>.</p>
1343 <p>_<b>pconnect:</b> Low level implemention of PConnect. Returns true or false. 
1344   Should set the _<b>connectionID</b>.</p>
1345 <p>_<b>query</b>: Execute a query. Returns the queryID, or false.</p>
1346 <p>_<b>close: </b>Close the connection -- PHP should clean up all recordsets. 
1347 </p>
1348 <p><b>ErrorMsg</b>: Stores the error message in the private variable _errorMsg. 
1349 </p>
1350 <p>The ADOConnection functions BeginTrans( ), CommitTrans( ), RollbackTrans( ) 
1351   are reserved for future expansion.</p>
1352 <p><b>ADOConnection Fields to Set</b></p>
1353 <p>_<b>bindInputArray</b>: Set to true if binding of parameters for SQL inserts 
1354   and updates is allowed using ?, eg. as with ODBC.</p>
1355 <p><b>fmtDate</b></p>
1356 <p><b>fmtTimeStamp</b></p>
1357 <p><b>true</b></p>
1358 <p><b>false</b></p>
1359 <p><b>concat_operator</b></p>
1360 <p><b>replaceQuote</b></p>
1361 <p><b>hasLimit</b> support SELECT * FROM TABLE LIMIT 10 of MySQL.</p>
1362 <p><b>hasTop</b> support Microsoft style SELECT TOP 10 * FROM TABLE.</p>
1363 <p><b>ADORecordSet Functions to Override</b></p>
1364 <p>You will need to define a constructor for your ADORecordSet derived class that 
1365   calls the parent class constructor.</p>
1366 <p><b>FetchField: </b> as documented above in ADORecordSet</p>
1367 <p>_<b>initrs</b>: low level initialization of the recordset: setup the _<b>numOfRows</b> 
1368   and _<b>numOfFields</b> fields -- called by the constructor.</p>
1369 <p>_<b>seek</b>: seek to a particular row. Do not load the data into the fields 
1370   array. This is done by _fetch. Returns true or false. Note that some implementations 
1371   such as Interbase do not support seek. Set canSeek to false.</p>
1372 <p>_<b>fetch</b>: fetch a row using the database extension function and then move 
1373   to the next row. Sets the <b>fields</b> array. If the parameter $ignore_fields 
1374   is true then there is no need to populate the <b>fields</b> array, just move 
1375   to the next row. then Returns true or false.</p>
1376 <p>_<b>close</b>: close the recordset</p>
1377 <p><b>Fields</b>: If the array row returned by the PHP extension is not an associative 
1378   one, you will have to override this. See adodb-odbc.inc.php for an example. 
1379   For databases such as MySQL and MSSQL where an associative array is returned, 
1380   there is no need to override this function.</p>
1381 <p><b>ADOConnection Fields to Set</b></p>
1382 <p>canSeek: Set to true if the _seek function works.</p>
1383 <h2>ToDo:</h2>
1384 <p>See the <a href=http://php.weblogs.com/adodb-todo-roadmap>RoadMap</a> article.</p>
1385 <p>Also see the ADODB <a href=http://php.weblogs.com/adodb_csv>proxy</a> article for 
1386 bridging Windows and Unix databases.</p>
1387 </font>
1388
1389 Change Log<a name="Changes"></a></h2>
1390  <p><b>1.71 18 Jan 2002</b></p>
1391  <p>Sequence start id support. Now $conn->Gen_ID('seqname', 50) to start sequence from 50.
1392  <p>CSV driver fix for selectlimit, from Andreas - akaiser#vocote.de.
1393 <P>Gam3r spotted that a global variable was undefined in the session handler. 
1394 <p>Mssql date regex had error. Fixed - reported by Minh Hoang vb_user#yahoo.com.
1395 <p>DBTimeStamp() and DBDate() now accept iso dates and unix timestamps. This means
1396 that the PostgreSQL handling of dates in GetInsertSQL() and GetUpdateSQL() can
1397 be removed. Also if these functions are passed '' or null or false, we return a SQL null.
1398 <p>GetInsertSQL() and GetUpdateSQL() now accept a new parameter, $magicq to 
1399 indicate whether quotes should be inserted based on magic quote settings - suggested by
1400 dj#4ict.com.
1401 <p>Reformated docs slightly based on suggestions by Chris Small.
1402  <p><b>1.65 28 Dec 2001</b></p>
1403  <p>Fixed borland_ibase class naming bug.
1404  <p>Now instead of using $rs->fields[0] internally, we use reset($rs->fields) so 
1405  that we are compatible with ADODB_FETCH_ASSOC mode. Reported by Nico S.
1406  <p>Changed recordset constructor and _initrs() for oci8 so that it returns the field definitions even
1407  if no rows in the recordset. Reported by Rick Hickerson (rhickers#mv.mv.com).
1408  <p>Improved support for postgresql in GetInsertSQL and GetUpdateSQL by
1409   "mike" mike#partner2partner.com  and "Ryan Bailey" rebel#windriders.com
1410  <p><b>1.64 20 Dec 2001</b></p>
1411 <p>Danny Milosavljevic <danny.milo#gmx.net> added some patches for MySQL error handling
1412 and displaying default values.
1413 <p>Fixed some ADODB_FETCH_BOTH inconsistencies in odbc and interbase.
1414 <p>Added more tests to test suite to cover ADODB_FETCH_* and ADODB_ERROR_HANDLER.
1415 <p>Added firebird (ibase) driver
1416 <p>Added borland_ibase driver for interbase 6.5
1417 <p><b>1.63 13 Dec 2001</b></p>
1418 Absolute to the adodb-lib.inc.php file not set properly. Fixed.
1419
1420 <p><b>1.62 11 Dec 2001</b></p>
1421 <p>Major speedup of ADODB for low-end web sites by reducing the php code loading and compiling
1422 cycle. We conditionally compile not so common functions. 
1423 Moved csv code to adodb-csvlib.inc.php to reduce adodb.inc.php parsing. This file
1424 is loaded only when the csv/proxy driver is used, or CacheExecute() is run.
1425 Also moved PageExecute(), GetSelectSQL() and GetUpdateSQL() core code to adodb-lib.inc.php.
1426 This reduced the 70K main adodb.inc.php file to 55K, and since at least 20K of the file
1427 is comments, we have reduced 50K of code in adodb.inc.php to 35K. There
1428  should be 35% reduction in memory and thus 35% speedup in compiling the php code for the
1429 main adodb.inc.php file.
1430 <p>Highly tuned SelectLimit() for oci8 for massive speed improvements on large files. 
1431 Selecting 20 rows starting from the 20,000th row of a table is now 7 times faster. 
1432 Thx to Tomas V V Cox.
1433 <p>Allow . and # in table definitions in GetInsertSQL and GetUpdateSQL.
1434  See ADODB_TABLE_REGEX constant. Thx to Ari Kuorikoski.
1435 <p>Added ADODB_PREFETCH_ROWS constant, defaulting to 10. This determines the number
1436 of records to prefetch in a SELECT statement. Only used by oci8.</p>
1437 <p>Added high portability Oracle class called oci8po. This uses ? for bind variables, and 
1438 lower cases column names.</p>
1439 <p>Now all database drivers support $ADODB_FETCH_MODE, including interbase, ado, and odbc:
1440 ADODB_FETCH_NUM and ADODB_FETCH_ASSOC. ADODB_FETCH_BOTH is not fully implemented for all 
1441 database drivers.
1442 <p><b>1.61 Nov 2001</b></p>
1443 <p>Added PO_RecordCount() and PO_Insert_ID(). PO stands for portable. 
1444 Pablo Roca [pabloroca#mvps.org]</p>
1445
1446 <p>GenID now returns 0 if not available. Safer is that you should check $conn->hasGenID 
1447 for availability.</p>
1448
1449 <p>M'soft ADO we now correctly close recordset in _close() peterd#telephonetics.co.uk</p>
1450
1451 <p>MSSQL now supports GenID(). It generates a 16-byte GUID from mssql newid() function.</p>
1452
1453 <p>Changed ereg_replace to preg_replace in SelectLimit. This is a fix for mssql. 
1454 Ereg doesn't support \t or \n! Reported by marino Carlos xaplo#postnuke-espanol.org</p>
1455
1456 <p>Added $recordset->connection. This is the ADOConnection object for the recordset. 
1457 Works with cached and normal recordsets. Surprisingly, this had no affect on performance!</p>
1458 <p><b>1.54 15 Nov 2001</b></p>
1459 Fixed some more bugs in PageExecute().  I am getting sick of bug in this and will have to 
1460 reconsider my QA here. The main issue is that I don't use PageExecute() and 
1461 to check whether it is working requires a visual inspection of the html generated currently.
1462 It is possible to write a test script but it would be quite complicated :(<p>
1463 More speedups of SelectLimit() for DB2, Oci8, access, vfp, mssql.<p>
1464
1465 <p><b>1.53 7 Nov 2001</b></p>
1466 Added support for ADODB_FETCH_ASSOC for ado and odbc drivers.<p>
1467 Tuned GetRowAssoc(false) in postgresql and mysql.<p>
1468 Stephen Van Dyke contributed adodb icon, accepted with some minor mods.<p>
1469 Enabled Affected_Rows() for postgresql<p>
1470 Speedup for Concat() using implode() - Benjamin Curtis ben_curtis#yahoo.com<p>
1471 Fixed some more bugs in PageExecute() to prevent infinite loops<p>
1472 <p><b>1.52 5 Nov 2001</b></p>
1473 Spelling error in CacheExecute() caused it to fail. $ql should be $sql in line 625!<p>
1474 Added fixes for parsing [ and ] in GetUpdateSQL().
1475 <p><b>1.51 5 Nov 2001</b></p>
1476 <p>Oci8 SelectLimit() speedup by using OCIFetch().
1477 <p>Oci8 was mistakenly reporting errors when $db->debug = true.
1478 <p>If a connection failed with ODBC, it was not correctly reported - fixed.
1479 <p>_connectionID was inited to -1, changed to false.
1480 <p>Added $rs->FetchRow(), to simplify API, ala PEAR DB
1481 <p>Added PEAR DB compat mode, which is still faster than PEAR! See adodb-pear.inc.php.
1482 <p>Removed postgres pconnect debugging statement.
1483 <p><b>1.50 31 Oct 2001</b></p>
1484 <p>ADODBConnection renamed to ADOConnection, and ADODBFieldObject to ADOFieldObject.
1485 <p>PageExecute() now checks for empty $rs correctly, and the errors in the docs on this subject have been fixed.
1486 <p>odbc_error() does not return 6 digit error correctly at times. Implemented workaround.
1487 <p>Added ADORecordSet_empty class. This will speedup INSERTS/DELETES/UPDATES because the return
1488 object created is much smaller.
1489 <p>Added Prepare() to odbc, and oci8 (but doesn't work properly for oci8 still).
1490 <p>Made pgsql a synonym for postgre7, and changed SELECT LIMIT to use OFFSET for compat with 
1491 postgres 7.2.
1492 <p>Revised adodb-cryptsession.php thanks to Ari.
1493 <p>Set resources to false on _close, to force freeing of resources.
1494 <p>Added adodb-errorhandler.inc.php, adodb-errorpear.inc.php and raiseErrorFn on Freek's urging.
1495 <p>GetRowAssoc($toUpper=true): $toUpper added as default.
1496 <p>Errors when connecting to a database were not captured formerly. Now we do it correctly.
1497 <p><b>1.40 19 September 2001</b></p>
1498 <p>PageExecute() to implement page scrolling added. Code and idea by Iván Oliva.</p>
1499 <p>Some minor postgresql fixes.</p>
1500 <p>Added sequence support using GenID() for postgresql, oci8, mysql, interbase.</p>
1501 <p>Added UpdateBlob support for interbase (untested).</p>
1502 <p>Added encrypted sessions (see adodb-cryptsession.php). By Ari Kuorikoski <kuoriari#finebyte.com></p>
1503 <p><b>1.31 21 August 2001</b></p>
1504 <p>Many bug fixes thanks to "GaM3R (Cameron)" <gamr#outworld.cx>. Some session changes due to Gam3r.
1505 <p>Fixed qstr() to quote \ also.
1506 <p>rs2html() now pretty printed.
1507 <p>Jonathan Younger jyounger#unilab.com contributed the great idea GetUpdateSQL() and GetInsertSQL() which
1508 generates SQL to update and insert into a table from a recordset. Modify the recordset fields
1509 array, then can this function to generate the SQL (the SQL is not executed).
1510 <p>"Nicola Fankhauser" <nicola.fankhauser#couniq.com> found some bugs in date handling for mssql.</p>
1511 <p>Added minimal Oracle support for LOBs. Still under development.</p>
1512 Added $ADODB_FETCH_MODE so you can control whether recordsets return arrays which are
1513 numeric, associative or both. This is a global variable you set. Currently only MySQL, Oci8, Postgres
1514 drivers support this.
1515 <p>PostgreSQL properly closes recordsets now. Reported by several people.
1516 <p>
1517 Added UpdateBlob() for Oracle. A hack to make it easier to save blobs.
1518 <p>
1519 Oracle timestamps did not display properly. Fixed.
1520 <p><b>1.20 6 June 2001</b></p>
1521 <p>Now Oracle can connect using tnsnames.ora or server and service name</p>
1522 <p>Extensive Oci8 speed optimizations. 
1523 Oci8 code revised to support variable binding, and /*+ FIRST_ROWS */ hint.</p>
1524 <p>Worked around some 4.0.6 bugs in odbc_fetch_into().</p>
1525 <p>Paolo S. Asioli paolo.asioli#libero.it suggested GetRowAssoc().</p>
1526 <p>Escape quotes for oracle wrongly set to \'. Now '' is used.</p>
1527 <p>Variable binding now works in ODBC also.</p>
1528 <p>Jumped to version 1.20 because I don't like 13 :-)</p>
1529 <p><b>1.12 6 June 2001</b></p>
1530 <p>Changed $ADODB_DIR to ADODB_DIR constant to plug a security loophole.</p>
1531 <p>Changed _close() to close persistent connections also. Prevents connection leaks.</p>
1532 <p>Major revision of oracle and oci8 drivers. 
1533 Added OCI_RETURN_NULLS and OCI_RETURN_LOBS to OCIFetchInto(). BLOB, CLOB and VARCHAR2 recognition
1534 in MetaType() improved. MetaColumns() returns columns in correct sort order.</p>
1535 <p>Interbase timestamp input format was wrong. Fixed.</p>
1536 <p><b>1.11 20 May 2001</b></p>
1537 <p>Improved file locking for Windows.</p>
1538 <p>Probabilistic flushing of cache to avoid avalanche updates when cache timeouts.</p>
1539 <p>Cached recordset timestamp not saved in some scenarios. Fixed.</p>
1540 <p><b>1.10 19 May 2001</b></p>
1541 <p>Added caching. CacheExecute() and CacheSelectLimit().
1542 <p>Added csv driver. See <a href=http://php.weblogs.com/adodb_csv>http://php.weblogs.com/adodb_csv</a>.
1543 <p>Fixed SelectLimit(), SELECT TOP not working under certain circumstances.
1544 <p>Added better Frontbase support of MetaTypes() by Frank M. Kromann.
1545 <p><b>1.01 24 April 2001</b></p>
1546 <p>Fixed SelectLimit bug. \ not quoted properly.
1547 <p>SelectLimit: SELECT TOP -1 * FROM TABLE not support by Microsoft. Fixed.</p>
1548 <p>GetMenu improved by glen.davies#cce.ac.nz to support multiple hilited items<p>
1549 <p>FetchNextObject() did not work with only 1 record returned. Fixed bug reported by $tim#orotech.net</p>
1550 <p>Fixed mysql field max_length problem. Fix suggested by Jim Nicholson (jnich#att.com)</p>
1551 <p><b>1.00 16 April 2001</b></p>
1552 <p>Given some brilliant suggestions on how to simplify ADODB by akul. You no longer need to
1553 setup $ADODB_DIR yourself, and ADOLoadCode() is automatically called by ADONewConnection(), 
1554 simplifying the startup code.</p>
1555 <p>FetchNextObject() added. Suggested by Jakub Marecek. This makes FetchObject() obsolete, as
1556 this is more flexible and powerful.</p>
1557 <p>Misc fixes to SelectLimit() to support Access (top must follow distinct) and Fields() 
1558 in the array recordset. From Reinhard Balling.</p>
1559 <p><b>0.96 27 Mar 2001</b></p>
1560 <p>ADOConnection Close() did not return a value correctly. Thanks to akul#otamedia.com.</p>
1561 <p>When the horrible magic_quotes is enabled, back-slash (\) is changed to double-backslash (\\).
1562 This doesn't make sense for Microsoft/Sybase databases. We fix this in qstr().</p>
1563 <p>Fixed Sybase date problem in UnixDate() thanks to Toni Tunkkari. Also fixed MSSQL problem
1564 in UnixDate() - thanks to milhouse31#hotmail.com.</p>
1565 <p>MoveNext() moved to leaf classes for speed in MySQL/PostgreSQL. 10-15% speedup.</p>
1566 <p>Added null handling in bindInputArray in Execute() -- Ron Baldwin suggestion.</p>
1567 <p>Fixed some option tags. Thanks to john#jrmstudios.com.</p>
1568 <p><b>0.95 13 Mar 2001</b></p>
1569 <p>Added postgres7 database driver which supports LIMIT and other version 7 stuff in the future.</p>
1570 <p>Added SelectLimit to ADOConnection to simulate PostgreSQL's "select * from table limit 10 offset 3".
1571 Added helper function GetArrayLimit() to ADORecordSet.</p>
1572 <p>Fixed mysql metacolumns bug. Thanks to Freek Dijkstra (phpeverywhere#macfreek.com).</p>
1573 <p>Also many PostgreSQL changes by Freek. He almost rewrote the whole PostgreSQL driver!</p>
1574 <p>Added fix to input parameters in Execute for non-strings by Ron Baldwin.</p>
1575 <p>Added new metatype, X for TeXt. Formerly, metatype B for Blob also included
1576 text fields. Now 'B' is for binary/image data. 'X' for textual data.</p>
1577 <p>Fixed $this->GetArray() in GetRows().</p>
1578 <p>Oracle and OCI8: 1st parameter is always blank -- now warns if it is filled.</p>
1579 <p>Now <i>hasLimit</i> and <i>hasTop</i> added to indicate whether 
1580 SELECT * FROM TABLE LIMIT 10 or SELECT TOP 10 * FROM TABLE are supported.</p>
1581 <p><b>0.94 04 Feb 2001</b></p>
1582 <p>Added ADORecordSet::GetRows() for compatibility with Microsoft ADO. Synonym for GetArray().</p>
1583 <p>Added new metatype 'R' to represent autoincrement numbers.</p>
1584 <p>Added ADORecordSet.FetchObject() to return a row as an object.</p>
1585 <p>Finally got a Linux box to test PostgreSql. Many fixes.</p>
1586 <p>Fixed copyright misspellings in 0.93.</p>
1587 <p>Fixed mssql MetaColumns type bug.</p>
1588 <p>Worked around odbc bug in PHP4 for sessions.</p>
1589 <p>Fixed many documentation bugs (affected_rows, metadatabases, qstr).</p>
1590 <p>Fixed MySQL timestamp format (removed comma).</p>
1591 <p>Interbase driver did not call ibase_pconnect(). Fixed.</p>
1592 <p><b>0.93 18 Jan 2001</b></p>
1593 <p>Fixed GetMenu bug.</p>
1594 <p>Simplified Interbase commit and rollback.</p>
1595 <p>Default behaviour on closing a connection is now to rollback all active transactions.</p>
1596 <p>Added field object handling for array recordset for future XML compatibility.</p>
1597 <p>Added arr2html() to convert array to html table.</p>
1598 <p><b>0.92 2 Jan 2001</b></p>
1599 <p>Interbase Commit and Rollback should be working again.</p>
1600 <p>Changed initialisation of ADORecordSet. This is internal and should not affect users. We
1601 are doing this to support cached recordsets in the future.</p>
1602 <p>Implemented ADORecordSet_array class. This allows you to simulate a database recordset
1603 with an array.</p>
1604 <p>Added UnixDate() and UnixTimeStamp() to ADORecordSet.</p>
1605 <p><b>0.91 21 Dec 2000</b></p>
1606 <p>Fixed ODBC so ErrorMsg() is working.</p>
1607 <p>Worked around ADO unrecognised null (0x1) value problem in COM.</p>
1608 <p>Added Sybase support for FetchField() type</p>
1609 <p>Removed debugging code and unneeded html from various files</p>
1610 <p>Changed to javadoc style comments to adodb.inc.php.</p>
1611 <p>Added maxsql as synonym for mysqlt</p>
1612 <p>Now ODBC downloads first 8K of blob by default
1613 <p><b>0.90 15 Nov 2000</b></p>
1614 <p>Lots of testing of Microsoft ADO. Should be more stable now.</p>
1615 <p>Added $ADODB_COUNTREC. Set to false for high speed selects.</p>
1616 <p>Added Sybase support. Contributed by Toni Tunkkari (toni.tunkkari#finebyte.com). Bug in Sybase 
1617   API: GetFields is unable to determine date types.</p>
1618 <p>Changed behaviour of RecordSet.GetMenu() to support size parameter (listbox) properly.</p>
1619 <p>Added emptyDate and emptyTimeStamp to RecordSet class that defines how to represent 
1620   empty dates.</p>
1621 <p>Added MetaColumns($table) that returns an array of ADOFieldObject's listing 
1622   the columns of a table.</p>
1623 <p>Added transaction support for PostgresSQL -- thanks to "Eric G. Werk" egw#netguide.dk.</p>
1624 <p>Added adodb-session.php for session support.</p>
1625 <p><b>0.80 30 Nov 2000</b></p>
1626 <p>Added support for charSet for interbase. Implemented MetaTables for most databases. 
1627   PostgreSQL more extensively tested.</p>
1628 <p><b>0.71 22 Nov 2000</b></p>
1629 <p>Switched from using require_once to include/include_once for backward compatability with PHP 4.02 and earlier.</p>
1630 <p><b>0.70 15 Nov 2000</b></p>
1631 <p>Calls by reference have been removed (call_time_pass_reference=Off) to ensure compatibility with future versions of PHP, 
1632 except in Oracle 7 driver due to a bug in php_oracle.dll.</p>
1633 <p>PostgreSQL database driver contributed by Alberto Cerezal (acerezalp#dbnet.es). 
1634 </p>
1635 <p>Oci8 driver for Oracle 8 contributed by George Fourlanos (fou#infomap.gr).</p>
1636 <p>Added <i>mysqlt</i> database driver to support MySQL 3.23 which has transaction 
1637  support. </p>
1638 <p>Oracle default date format (DD-MON-YY) did not match ADODB default date format (which is YYYY-MM-DD). Use ALTER SESSION to force the default date.</p>
1639 <p>Error message checking is now included in test suite.</p>
1640 <p>MoveNext() did not check EOF properly -- fixed.</p>
1641 <p><b>0.60 Nov 8 2000</b></p>
1642 <p>Fixed some constructor bugs in ODBC and ADO. Added ErrorNo function to ADOConnection 
1643  class. </p>
1644 <p><b>0.51 Oct 18 2000</b></p>
1645 <p>Fixed some interbase bugs.</p>
1646 <p><b>0.50 Oct 16 2000</b></p>
1647 <p>Interbase commit/rollback changed to be compatible with PHP 4.03. </p>
1648 <p>CommitTrans( ) will now return true if transactions not supported. </p>
1649 <p>Conversely RollbackTrans( ) will return false if transactions not supported. 
1650 </p>
1651 <p><b>0.46 Oct 12</b></p>
1652 Many Oracle compatibility issues fixed. 
1653 <p><b>0.40 Sept 26</b></p>
1654 <p>Many bug fixes</p>
1655 <p>Now Code for BeginTrans, CommitTrans and RollbackTrans is working. So is the Affected_Rows
1656 and Insert_ID. Added above functions to test.php.</p>
1657 <p>ADO type handling was busted in 0.30. Fixed.</p>
1658 <p>Generalised Move( ) so it works will all databases, including ODBC.</p>
1659 <p><b>0.30 Sept 18</b></p>
1660 <p>Renamed ADOLoadDB to ADOLoadCode. This is clearer.</p>
1661 <p>Added BeginTrans, CommitTrans and RollbackTrans functions.</p>
1662 <p>Added Affected_Rows() and Insert_ID(), _affectedrows() and _insertID(), ListTables(), 
1663  ListDatabases(), ListColumns().</p>
1664 <p>Need to add New_ID() and hasInsertID and hasAffectedRows, autoCommit </p>
1665 <p><b>0.20 Sept 12</b></p>
1666 <p>Added support for Microsoft's ADO.</p>
1667 <p>Added new field to ADORecordSet -- canSeek</p>
1668 <p>Added new parameter to _fetch($ignore_fields = false). Setting to true will 
1669  not update fields array for faster performance.</p>
1670 <p>Added new field to ADORecordSet/ADOConnection -- dataProvider to indicate whether 
1671  a class is derived from odbc or ado.</p>
1672 <p>Changed class ODBCFieldObject to ADOFieldObject -- not documented currently.</p>
1673 <p>Added benchmark.php and testdatabases.inc.php to the test suite.</p>
1674 <p>Added to ADORecordSet FastForward( ) for future high speed scrolling. Not documented.</p>
1675 <p>Realised that ADO's Move( ) uses relative positioning. ADODB uses absolute. 
1676 </p>
1677 <p><b>0.10 Sept 9 2000</b></p>
1678 <p>First release</p>
1679 </body>
1680 </html>