1 <html xmlns:v="urn:schemas-microsoft-com:vml"
2 xmlns:o="urn:schemas-microsoft-com:office:office"
3 xmlns:w="urn:schemas-microsoft-com:office:word"
4 xmlns:st1="urn:schemas-microsoft-com:office:smarttags"
5 xmlns="http://www.w3.org/TR/REC-html40">
8 <meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
9 <meta name=ProgId content=Word.Document>
10 <meta name=Generator content="Microsoft Word 11">
11 <meta name=Originator content="Microsoft Word 11">
12 <link rel=File-List href="docs-adodb_files/filelist.xml">
13 <link rel=Edit-Time-Data href="docs-adodb_files/editdata.mso">
16 v\:* {behavior:url(#default#VML);}
17 o\:* {behavior:url(#default#VML);}
18 w\:* {behavior:url(#default#VML);}
19 .shape {behavior:url(#default#VML);}
22 <title>ADODB Manual</title>
23 <o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
25 <o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
27 <o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
29 <o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
30 name="country-region"/>
31 <o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
33 <o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
35 <!--[if gte mso 9]><xml>
36 <o:DocumentProperties>
37 <o:Author>John</o:Author>
38 <o:LastAuthor>John</o:LastAuthor>
39 <o:Revision>3</o:Revision>
40 <o:TotalTime>3</o:TotalTime>
41 <o:Created>2008-12-24T10:43:00Z</o:Created>
42 <o:LastSaved>2008-12-24T10:46:00Z</o:LastSaved>
44 <o:Words>30239</o:Words>
45 <o:Characters>172366</o:Characters>
46 <o:Company> </o:Company>
47 <o:Lines>1436</o:Lines>
48 <o:Paragraphs>404</o:Paragraphs>
49 <o:CharactersWithSpaces>202201</o:CharactersWithSpaces>
50 <o:Version>11.9999</o:Version>
51 </o:DocumentProperties>
52 </xml><![endif]--><!--[if gte mso 9]><xml>
56 <w:ValidateAgainstSchemas/>
57 <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
58 <w:IgnoreMixedContent>false</w:IgnoreMixedContent>
59 <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
60 <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
62 </xml><![endif]--><!--[if gte mso 9]><xml>
63 <w:LatentStyles DefLockedState="false" LatentStyleCount="156">
65 </xml><![endif]--><!--[if !mso]><object
66 classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id=ieooui></object>
68 st1\:*{behavior:url(#ieooui) }
76 /* Font Definitions */
78 {font-family:Helvetica;
79 panose-1:2 11 6 4 2 2 2 2 2 4;
81 mso-generic-font-family:swiss;
82 mso-font-format:other;
83 mso-font-pitch:variable;
84 mso-font-signature:3 0 0 0 1 0;}
87 panose-1:2 7 4 9 2 2 5 2 4 4;
89 mso-generic-font-family:modern;
90 mso-font-format:other;
92 mso-font-signature:3 0 0 0 1 0;}
94 {font-family:"Tms Rmn";
95 panose-1:2 2 6 3 4 5 5 2 3 4;
97 mso-generic-font-family:roman;
98 mso-font-format:other;
99 mso-font-pitch:variable;
100 mso-font-signature:3 0 0 0 1 0;}
103 panose-1:2 11 6 4 2 2 2 3 2 4;
105 mso-generic-font-family:swiss;
106 mso-font-format:other;
107 mso-font-pitch:variable;
108 mso-font-signature:3 0 0 0 1 0;}
110 {font-family:"New York";
111 panose-1:2 4 5 3 6 5 6 2 3 4;
113 mso-generic-font-family:roman;
114 mso-font-format:other;
115 mso-font-pitch:variable;
116 mso-font-signature:3 0 0 0 1 0;}
119 panose-1:0 0 0 0 0 0 0 0 0 0;
121 mso-generic-font-family:swiss;
122 mso-font-format:other;
123 mso-font-pitch:variable;
124 mso-font-signature:3 0 0 0 1 0;}
126 {font-family:Wingdings;
127 panose-1:5 0 0 0 0 0 0 0 0 0;
129 mso-generic-font-family:auto;
130 mso-font-pitch:variable;
131 mso-font-signature:0 268435456 0 0 -2147483648 0;}
133 {font-family:"MS Mincho";
134 panose-1:2 2 6 9 4 2 5 8 3 4;
135 mso-font-alt:"\FF2D\FF33 \660E\671D";
136 mso-font-charset:128;
137 mso-generic-font-family:roman;
138 mso-font-format:other;
139 mso-font-pitch:fixed;
140 mso-font-signature:1 134676480 16 0 131072 0;}
143 panose-1:2 3 6 0 0 1 1 1 1 1;
144 mso-font-alt:\BC14\D0D5;
145 mso-font-charset:129;
146 mso-generic-font-family:auto;
147 mso-font-format:other;
148 mso-font-pitch:fixed;
149 mso-font-signature:1 151388160 16 0 524288 0;}
152 panose-1:2 1 6 0 3 1 1 1 1 1;
153 mso-font-alt:\5B8B\4F53;
154 mso-font-charset:134;
155 mso-generic-font-family:auto;
156 mso-font-format:other;
157 mso-font-pitch:variable;
158 mso-font-signature:1 135135232 16 0 262144 0;}
160 {font-family:PMingLiU;
161 panose-1:2 2 3 0 0 0 0 0 0 0;
162 mso-font-alt:\65B0\7D30\660E\9AD4;
163 mso-font-charset:136;
164 mso-generic-font-family:auto;
165 mso-font-format:other;
166 mso-font-pitch:variable;
167 mso-font-signature:1 134742016 16 0 1048576 0;}
169 {font-family:"MS Gothic";
170 panose-1:2 11 6 9 7 2 5 8 2 4;
171 mso-font-alt:"\FF2D\FF33 \30B4\30B7\30C3\30AF";
172 mso-font-charset:128;
173 mso-generic-font-family:modern;
174 mso-font-format:other;
175 mso-font-pitch:fixed;
176 mso-font-signature:1 134676480 16 0 131072 0;}
179 panose-1:2 11 6 0 0 1 1 1 1 1;
180 mso-font-alt:\B3CB\C6C0;
181 mso-font-charset:129;
182 mso-generic-font-family:modern;
183 mso-font-format:other;
184 mso-font-pitch:fixed;
185 mso-font-signature:1 151388160 16 0 524288 0;}
188 panose-1:2 1 6 0 3 1 1 1 1 1;
189 mso-font-alt:\9ED1\4F53;
190 mso-font-charset:134;
191 mso-generic-font-family:modern;
192 mso-font-format:other;
193 mso-font-pitch:fixed;
194 mso-font-signature:1 135135232 16 0 262144 0;}
196 {font-family:MingLiU;
197 panose-1:2 2 3 9 0 0 0 0 0 0;
198 mso-font-alt:\7D30\660E\9AD4;
199 mso-font-charset:136;
200 mso-generic-font-family:modern;
201 mso-font-format:other;
202 mso-font-pitch:fixed;
203 mso-font-signature:1 134742016 16 0 1048576 0;}
206 panose-1:2 2 6 9 4 3 5 8 3 5;
207 mso-font-alt:\660E\671D;
208 mso-font-charset:128;
209 mso-generic-font-family:roman;
210 mso-font-format:other;
211 mso-font-pitch:fixed;
212 mso-font-signature:1 134676480 16 0 131072 0;}
215 panose-1:2 11 6 0 0 1 1 1 1 1;
216 mso-font-alt:\AD74\B9BC;
217 mso-font-charset:129;
218 mso-generic-font-family:roman;
219 mso-font-format:other;
220 mso-font-pitch:fixed;
221 mso-font-signature:1 151388160 16 0 524288 0;}
223 {font-family:Century;
224 panose-1:2 4 6 4 5 5 5 2 3 4;
226 mso-generic-font-family:roman;
227 mso-font-format:other;
228 mso-font-pitch:variable;
229 mso-font-signature:3 0 0 0 1 0;}
231 {font-family:"Angsana New";
232 panose-1:2 2 6 3 5 4 5 2 3 4;
233 mso-font-charset:222;
234 mso-generic-font-family:roman;
235 mso-font-format:other;
236 mso-font-pitch:variable;
237 mso-font-signature:16777217 0 0 0 65536 0;}
239 {font-family:"Cordia New";
240 panose-1:2 11 3 4 2 2 2 2 2 4;
241 mso-font-charset:222;
242 mso-generic-font-family:roman;
243 mso-font-format:other;
244 mso-font-pitch:variable;
245 mso-font-signature:16777217 0 0 0 65536 0;}
248 panose-1:0 0 4 0 0 0 0 0 0 0;
250 mso-generic-font-family:roman;
251 mso-font-format:other;
252 mso-font-pitch:variable;
253 mso-font-signature:32768 0 0 0 0 0;}
256 panose-1:2 0 4 0 0 0 0 0 0 0;
258 mso-generic-font-family:roman;
259 mso-font-format:other;
260 mso-font-pitch:variable;
261 mso-font-signature:1048576 0 0 0 0 0;}
263 {font-family:Sylfaen;
264 panose-1:1 10 5 2 5 3 6 3 3 3;
266 mso-generic-font-family:roman;
267 mso-font-format:other;
268 mso-font-pitch:variable;
269 mso-font-signature:16778883 0 512 0 13 0;}
272 panose-1:0 0 4 0 0 0 0 0 0 0;
274 mso-generic-font-family:roman;
275 mso-font-format:other;
276 mso-font-pitch:variable;
277 mso-font-signature:0 0 0 0 0 0;}
280 panose-1:2 0 5 0 0 0 0 0 0 0;
282 mso-generic-font-family:roman;
283 mso-font-format:other;
284 mso-font-pitch:variable;
285 mso-font-signature:0 0 0 0 0 0;}
288 panose-1:2 0 5 0 0 0 0 0 0 0;
290 mso-generic-font-family:roman;
291 mso-font-format:other;
292 mso-font-pitch:variable;
293 mso-font-signature:0 0 0 0 0 0;}
295 {font-family:Sendnya;
296 panose-1:0 0 4 0 0 0 0 0 0 0;
298 mso-generic-font-family:roman;
299 mso-font-format:other;
300 mso-font-pitch:variable;
301 mso-font-signature:0 0 0 0 0 0;}
303 {font-family:Gautami;
304 panose-1:2 0 5 0 0 0 0 0 0 0;
306 mso-generic-font-family:roman;
307 mso-font-format:other;
308 mso-font-pitch:variable;
309 mso-font-signature:0 0 0 0 0 0;}
312 panose-1:0 0 4 0 0 0 0 0 0 0;
314 mso-generic-font-family:roman;
315 mso-font-format:other;
316 mso-font-pitch:variable;
317 mso-font-signature:0 0 0 0 0 0;}
319 {font-family:"Estrangelo Edessa";
320 panose-1:0 0 0 0 0 0 0 0 0 0;
322 mso-generic-font-family:roman;
323 mso-font-format:other;
324 mso-font-pitch:variable;
325 mso-font-signature:0 0 0 0 0 0;}
327 {font-family:Kartika;
328 panose-1:1 1 1 0 1 1 1 1 1 1;
330 mso-generic-font-family:roman;
331 mso-font-format:other;
332 mso-font-pitch:variable;
333 mso-font-signature:0 0 0 0 0 0;}
335 {font-family:"Arial Unicode MS";
336 panose-1:2 11 6 4 2 2 2 2 2 4;
338 mso-generic-font-family:roman;
339 mso-font-format:other;
340 mso-font-pitch:variable;
341 mso-font-signature:3 0 0 0 1 0;}
344 panose-1:2 11 6 4 3 5 4 4 2 4;
346 mso-generic-font-family:swiss;
347 mso-font-format:other;
348 mso-font-pitch:variable;
349 mso-font-signature:3 0 0 0 1 0;}
350 /* Style Definitions */
351 p.MsoNormal, li.MsoNormal, div.MsoNormal
352 {mso-style-parent:"";
354 margin-bottom:.0001pt;
355 mso-pagination:widow-orphan;
357 font-family:"Times New Roman";
358 mso-fareast-font-family:"Times New Roman";
361 {mso-margin-top-alt:auto;
363 mso-margin-bottom-alt:auto;
365 mso-pagination:widow-orphan;
368 font-family:"Times New Roman";
372 {mso-margin-top-alt:auto;
374 mso-margin-bottom-alt:auto;
376 mso-pagination:widow-orphan;
379 font-family:"Times New Roman";
383 {mso-margin-top-alt:auto;
385 mso-margin-bottom-alt:auto;
387 mso-pagination:widow-orphan;
390 font-family:"Times New Roman";
394 {mso-margin-top-alt:auto;
396 mso-margin-bottom-alt:auto;
398 mso-pagination:widow-orphan;
401 font-family:"Times New Roman";
404 a:link, span.MsoHyperlink
406 text-decoration:underline;
407 text-underline:single;}
408 a:visited, span.MsoHyperlinkFollowed
410 text-decoration:underline;
411 text-underline:single;}
414 font-family:"Times New Roman";
415 mso-fareast-font-family:"Times New Roman";
418 {font-family:"Courier New";
419 mso-ascii-font-family:"Courier New";
420 mso-fareast-font-family:"Times New Roman";
421 mso-hansi-font-family:"Courier New";
422 mso-bidi-font-family:"Courier New";}
425 margin-bottom:.0001pt;
426 mso-pagination:widow-orphan;
427 tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
430 mso-border-alt:solid #DDDDDD .75pt;
432 mso-padding-alt:9.0pt 18.0pt 9.0pt 18.0pt;
434 font-family:"Courier New";
435 mso-fareast-font-family:"Times New Roman";
438 {mso-style-type:export-only;
440 text-decoration:underline;
441 text-underline:single;
444 {mso-style-type:export-only;
446 text-decoration:line-through;
449 {mso-style-type:export-only;
452 {size:612.0pt 792.0pt;
453 margin:72.0pt 90.0pt 72.0pt 90.0pt;
454 mso-header-margin:35.4pt;
455 mso-footer-margin:35.4pt;
459 /* List Definitions */
461 {mso-list-id:3098366;
462 mso-list-template-ids:-1654113918;}
464 {mso-level-number-format:bullet;
465 mso-level-text:\F0B7;
466 mso-level-tab-stop:36.0pt;
467 mso-level-number-position:left;
469 mso-ansi-font-size:10.0pt;
472 {mso-list-id:118686534;
473 mso-list-template-ids:1789952844;}
475 {mso-level-number-format:bullet;
476 mso-level-text:\F0B7;
477 mso-level-tab-stop:36.0pt;
478 mso-level-number-position:left;
480 mso-ansi-font-size:10.0pt;
483 {mso-list-id:325595838;
484 mso-list-template-ids:-924547596;}
486 {mso-level-number-format:bullet;
487 mso-level-text:\F0B7;
488 mso-level-tab-stop:36.0pt;
489 mso-level-number-position:left;
491 mso-ansi-font-size:10.0pt;
494 {mso-list-id:577053254;
495 mso-list-template-ids:1006266472;}
497 {mso-level-number-format:bullet;
498 mso-level-text:\F0B7;
499 mso-level-tab-stop:36.0pt;
500 mso-level-number-position:left;
502 mso-ansi-font-size:10.0pt;
505 {mso-list-id:584261941;
506 mso-list-template-ids:1672376844;}
508 {mso-level-number-format:bullet;
509 mso-level-text:\F0B7;
510 mso-level-tab-stop:36.0pt;
511 mso-level-number-position:left;
513 mso-ansi-font-size:10.0pt;
516 {mso-list-id:678311197;
517 mso-list-template-ids:-1025849406;}
519 {mso-level-number-format:bullet;
520 mso-level-text:\F0B7;
521 mso-level-tab-stop:36.0pt;
522 mso-level-number-position:left;
524 mso-ansi-font-size:10.0pt;
527 {mso-list-id:993068284;
528 mso-list-template-ids:-1149100626;}
530 {mso-level-number-format:bullet;
531 mso-level-text:\F0B7;
532 mso-level-tab-stop:36.0pt;
533 mso-level-number-position:left;
535 mso-ansi-font-size:10.0pt;
538 {mso-list-id:1120344907;
539 mso-list-template-ids:-1732590280;}
541 {mso-level-number-format:bullet;
542 mso-level-text:\F0B7;
543 mso-level-tab-stop:36.0pt;
544 mso-level-number-position:left;
546 mso-ansi-font-size:10.0pt;
549 {mso-list-id:1134718884;
550 mso-list-template-ids:-1854392276;}
552 {mso-level-number-format:bullet;
553 mso-level-text:\F0B7;
554 mso-level-tab-stop:36.0pt;
555 mso-level-number-position:left;
557 mso-ansi-font-size:10.0pt;
560 {mso-list-id:1289897560;
561 mso-list-template-ids:-1284101662;}
563 {mso-level-number-format:bullet;
564 mso-level-text:\F0B7;
565 mso-level-tab-stop:36.0pt;
566 mso-level-number-position:left;
568 mso-ansi-font-size:10.0pt;
571 {mso-list-id:1461026030;
572 mso-list-template-ids:65944450;}
574 {mso-list-id:1566380536;
575 mso-list-template-ids:395727058;}
577 {mso-level-number-format:bullet;
578 mso-level-text:\F0B7;
579 mso-level-tab-stop:36.0pt;
580 mso-level-number-position:left;
582 mso-ansi-font-size:10.0pt;
592 /* Style Definitions */
594 {mso-style-name:"Table Normal";
595 mso-tstyle-rowband-size:0;
596 mso-tstyle-colband-size:0;
597 mso-style-noshow:yes;
599 mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
601 mso-para-margin-bottom:.0001pt;
602 mso-pagination:widow-orphan;
604 font-family:"Times New Roman";
605 mso-ansi-language:#0400;
606 mso-fareast-language:#0400;
607 mso-bidi-language:#0400;}
609 <![endif]--><!--[if gte mso 9]><xml>
610 <o:shapedefaults v:ext="edit" spidmax="1026"/>
611 </xml><![endif]--><!--[if gte mso 9]><xml>
612 <o:shapelayout v:ext="edit">
613 <o:idmap v:ext="edit" data="1"/>
614 </o:shapelayout></xml><![endif]-->
617 <body bgcolor=white lang=EN-US link=blue vlink=blue style='tab-interval:36.0pt'>
621 <h2>ADOdb Library for PHP</h2>
623 <p>V5.18 3 Sep 2012 (c) 2000-2012 John Lim (jlim#natsoft.com)</p>
625 <p><span style='font-size:7.5pt'>This software is dual licensed using BSD-Style
626 and LGPL. This means you can use it in compiled proprietary and commercial
629 <p>Useful ADOdb links: <a href="http://adodb.sourceforge.net/#download">Download</a>
630 <a href="http://adodb.sourceforge.net/#docs">Other Docs</a> </p>
632 <p><a href="#intro"><b>Introduction</b></a><b><br>
633 <a href="#features">Unique Features</a><br>
634 <a href="#users">How People are using ADOdb</a><br>
635 <a href="#bugs">Feature Requests and Bug Reports</a><br>
636 <a href="#install">Installation</a><br>
637 <a href="#mininstall">Minimum Install</a><br>
638 <a href="#coding">Initializing Code and Connectioning to Databases</a><br>
639 </b><span style='font-size:10.0pt'> <a href="#dsnsupport">Data Source
640 Name (DSN) Support</a></span> <a href="#connect_ex">Connection Examples</a>
642 <b><a href="#speed">High Speed ADOdb - tuning tips</a></b><br>
643 <b><a href="#hack">Hacking and Modifying ADOdb Safely</a><br>
644 <a href="#php5">PHP5 Features</a></b><br>
645 <span style='font-size:10.0pt'><a href="#php5iterators">foreach iterators</a> <a
646 href="#php5exceptions">exceptions</a></span><br>
647 <b><a href="#drivers">Supported Databases</a></b><br>
648 <b><a href="#quickstart">Tutorials</a></b><br>
649 <a href="#ex1">Example 1: Select</a><br>
650 <a href="#ex2">Example 2: Advanced Select</a><br>
651 <a href="#ex3">Example 3: Insert</a><br>
652 <a href="#ex4">Example 4: Debugging</a> <a href="#exrs2html">rs2html
654 <a href="#ex5">Example 5: MySQL and Menus</a><br>
655 <a href="#ex6">Example 6: Connecting to Multiple Databases at once</a> <br>
656 <a href="#ex7">Example 7: Generating Update and Insert SQL</a> <br>
657 <a href="#ex8">Example 8: Implementing Scrolling with Next and Previous</a><br>
658 <a href="#ex9">Example 9: Exporting in CSV or Tab-Delimited Format</a> <br>
659 <a href="#ex10">Example 10: Custom filters</a><br>
660 <a href="#ex11">Example 11: Smart Transactions</a><br>
662 <b><a href="#errorhandling">Using Custom Error Handlers and PEAR_Error</a><br>
663 <a href="#DSN">Data Source Names</a><br>
664 <a href="#caching">Caching</a></b><br>
665 <a href="#memcache">MemCache</a><br>
666 <a href="#cacheapi">Caching API</a><br>
667 <b><a href="#pivot">Pivot Tables</a></b> </p>
669 <p><a href="#ref"><b>REFERENCE</b></a> </p>
671 <p><span style='font-size:10.0pt'>Variables: <a href="#adodb_countrecs">$ADODB_COUNTRECS</a>
672 <a href="#adodb_ansi_padding_off">$ADODB_ANSI_PADDING_OFF</a> <a
673 href="#adodb_cache_dir">$ADODB_CACHE_DIR</a> <br>
674 <a href="#force_type">$ADODB_FORCE_TYPE</a> <a
675 href="#adodb_fetch_mode">$ADODB_FETCH_MODE</a> <a href="#adodb_lang">$ADODB_LANG</a>
676 <a href="#adodb_auto_quote">ADODB_QUOTE_FIELDNAMES</a> <br>
677 Constants: <a href="#adodb_assoc_case">ADODB_ASSOC_CASE</a> </span><br>
678 <a href="#ADOConnection"><b>ADOConnection</b></a><br>
679 <span style='font-size:10.0pt'>Connections: <a href="#connect">Connect</a> <a
680 href="#pconnect">PConnect</a> <a href="#nconnect">NConnect</a> <a
681 href="#isconnected">IsConnected</a><br>
682 Executing SQL: <a href="#execute">Execute</a> <a href="#cacheexecute"><i>CacheExecute</i></a>
683 <a href="#selectlimit">SelectLimit</a> <a href="#cacheSelectLimit"><i>CacheSelectLimit</i></a>
684 <a href="#param">Param</a> <a href="#prepare">Prepare</a> <a href="#preparesp">PrepareSP</a>
685 <a href="#inparameter">InParameter</a> <a href="#outparameter">OutParameter</a>
686 <a href="#autoexecute">AutoExecute</a> <br>
687 <a
688 href="#getone">GetOne</a> <a href="#cachegetone"><i>CacheGetOne</i></a> <a
689 href="#getrow">GetRow</a> <a href="#cachegetrow"><i>CacheGetRow</i></a> <a
690 href="#getall">GetAll</a> <a href="#cachegetall"><i>CacheGetAll</i></a> <a
691 href="#getcol">GetCol</a> <a href="#cachegetcol"><i>CacheGetCol</i></a> <a
692 href="#getassoc1">GetAssoc</a> <a href="#cachegetassoc"><i>CacheGetAssoc</i></a>
693 <a href="#replace">Replace</a> <a href="#getmedian">GetMedian</a> <br>
694 <a
695 href="#executecursor">ExecuteCursor</a> (oci8 only)<br>
696 Generates SQL strings: <a href="#getupdatesql">GetUpdateSQL</a> <a
697 href="#getinsertsql">GetInsertSQL</a> <a href="#concat">Concat</a> <a
698 href="#ifnull">IfNull</a> <a href="#length">length</a> <a href="#random">random</a>
699 <a href="#substr">substr</a> <a href="#qstr">qstr</a> <a href="#param">Param</a>
700 <a href="#OffsetDate">OffsetDate</a> <a href="#sqldate">SQLDate</a> <a
701 href="#dbdate">DBDate</a> <a href="#dbtimestamp">DBTimeStamp</a> <a
702 href="#binddate">BindDate</a> <a href="#bindtimestamp">BindTimeStamp</a> <br>
703 Blobs: <a href="#updateblob">UpdateBlob</a> <a href="#updateclob">UpdateClob</a>
704 <a href="#updateblobfile">UpdateBlobFile</a> <a href="#blobencode">BlobEncode</a>
705 <a href="#blobdecode">BlobDecode</a><br>
706 Paging/Scrolling: <a href="#pageexecute">PageExecute</a> <a
707 href="#cachepageexecute">CachePageExecute</a><br>
708 Cleanup: <a href="#cacheflush">CacheFlush</a> <a href="#Close">Close</a><br>
709 Transactions: <a href="#starttrans">StartTrans</a> <a href="#completetrans">CompleteTrans</a>
710 <a href="#failtrans">FailTrans</a> <a href="#hasfailedtrans">HasFailedTrans</a>
711 <a href="#begintrans">BeginTrans</a> <a href="#committrans">CommitTrans</a> <a
712 href="#rollbacktrans">RollbackTrans</a> <a href="#SetTransactionMode">SetTransactionMode</a><br>
713 Fetching Data: <a href="#setfetchmode">SetFetchMode</a><br>
714 Strings: <a href="#concat">concat</a> <a href="#length">length</a> <a
715 href="#qstr">qstr</a> <a href="#quote">quote</a> <a href="#substr">substr</a><br>
716 Dates: <a href="#dbdate">DBDate</a> <a href="#dbtimestamp">DBTimeStamp</a> <a
717 href="#unixdate">UnixDate</a> <a href="#binddate">BindDate</a> <a
718 href="#bindtimestamp">BindTimeStamp</a> <a href="#unixtimestamp">UnixTimeStamp</a>
719 <a href="#OffsetDate">OffsetDate</a> <a href="#SQLDate">SQLDate</a> <br>
720 Row Management: <a href="#affected_rows">Affected_Rows</a> <a
721 href="#inserted_id">Insert_ID</a> <a href="#rowlock">RowLock</a> <a
722 href="#genid">GenID</a> <a href="#createseq">CreateSequence</a> <a
723 href="#dropseq">DropSequence</a> <br>
724 Error Handling: <a href="#errormsg">ErrorMsg</a> <a href="#errorno">ErrorNo</a>
725 <a href="#metaerror">MetaError</a> <a href="#metaerrormsg">MetaErrorMsg</a> <a
726 href="#ignoreerrors">IgnoreErrors</a><br>
727 Data Dictionary (metadata): <a href="#metadatabases">MetaDatabases</a> <a
728 href="#metatables">MetaTables</a> <a href="#metacolumns">MetaColumns</a> <a
729 href="#metacolumnames">MetaColumnNames</a> <a href="#metaprimarykeys">MetaPrimaryKeys</a>
730 <a href="#metaforeignkeys">MetaForeignKeys</a> <a href="#serverinfo">ServerInfo</a> <a href="#setcharset">SetCharSet</a>
732 Statistics and Query-Rewriting: <a href="#logsql">LogSQL</a> <a
733 href="#fnexecute">fnExecute and fnCacheExecute</a><br>
734 Deprecated: <a href="#bind">Bind</a> <a href="#blankrecordset">BlankRecordSet</a>
735 <a href="#parameter">Parameter</a></span> <a href="#adorecordSet"><b><br>
736 ADORecordSet</b></a><br>
737 <span style='font-size:10.0pt'>Returns one field: <a href="#fields">Fields</a><br>
738 Returns one row:<a href="#fetchrow">FetchRow</a> <a href="#fetchinto">FetchInto</a>
739 <a href="#fetchobject">FetchObject</a> <a href="#fetchnextobject">FetchNextObject</a>
740 <a href="#fetchobj">FetchObj</a> <a href="#fetchnextobj">FetchNextObj</a> <a
741 href="#getrowassoc">GetRowAssoc</a> <br>
742 Returns all rows:<a href="#getarray">GetArray</a> <a href="#getrows">GetRows</a>
743 <a href="#getassoc">GetAssoc</a><br>
744 Scrolling:<a href="#move">Move</a> <a href="#movenext">MoveNext</a> <a
745 href="#movefirst">MoveFirst</a> <a href="#movelast">MoveLast</a> <a
746 href="#abspos">AbsolutePosition</a> <a href="#currentrow">CurrentRow</a> <a
747 href="#atfirstpage">AtFirstPage</a> <a href="#atlastpage">AtLastPage</a> <a
748 href="#absolutepage">AbsolutePage</a> <br>
749 Menu generation:<a href="#getmenu">GetMenu</a> <a href="#getmenu2">GetMenu2</a><br>
750 Dates:<a href="#userdate">UserDate</a> <a href="#usertimestamp">UserTimeStamp</a>
751 <a href="#unixdate">UnixDate</a> <a href="#unixtimestamp">UnixTimeStamp<br>
752 </a>Recordset Info:<a href="#recordcount">RecordCount</a> <a
753 href="#po_recordcount">PO_RecordCount</a> <a href="#nextrecordset">NextRecordSet</a><br>
754 Field Info:<a href="#fieldcount">FieldCount</a> <a href="#fetchfield">FetchField</a>
755 <a href="#metatype">MetaType</a><br>
756 Cleanup: <a href="#rsclose">Close</a></span> </p>
758 <p><span style='font-size:10.0pt'><a href="#rs2html"><b>rs2html</b></a> <a
759 href="#exrs2html">example</a></span><br>
760 <a href="#adodiff">Differences between ADOdb and ADO</a><br>
761 <a href="#driverguide"><b>Database Driver Guide<br>
762 </b></a><b><a href="#changes">Change Log</a></b></p>
764 <h2>Introduction<a name=intro></a></h2>
766 <p>PHP's database access functions are not standardised. This creates a need
767 for a database class library to hide the differences between the different
768 database API's (encapsulate the differences) so we can easily switch databases.
769 PHP 4.0.5 or later is now required (because we use array-based str_replace).</p>
771 <p>We currently support MySQL, Oracle, Microsoft SQL Server, Sybase, Sybase SQL
772 Anywhere, Informix, PostgreSQL, FrontBase, SQLite, Interbase (Firebird and
773 Borland variants), Foxpro, Access, <st1:City w:st="on"><st1:place w:st="on">ADO</st1:place></st1:City>,
774 DB2, SAP DB and ODBC. We have had successful reports of connecting to Progress
775 and CacheLite via ODBC. We hope more people will contribute drivers to support
778 <p>PHP4 supports session variables. You can store your session information
779 using ADOdb for true portability and scalability. See adodb-session.php for
780 more information.</p>
782 <p>Also read <a href="http://phplens.com/lens/adodb/tips_portable_sql.htm">tips_portable_sql.htm</a>
783 for tips on writing portable SQL.</p>
785 <h2>Unique Features of ADOdb<a name=features></a></h2>
788 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
789 mso-list:l2 level1 lfo1;tab-stops:list 36.0pt'><b>Easy for Windows
790 programmers</b> to adapt to because many of the conventions are similar to
791 Microsoft's <st1:City w:st="on"><st1:place w:st="on">ADO</st1:place></st1:City>.</li>
792 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
793 mso-list:l2 level1 lfo1;tab-stops:list 36.0pt'>Unlike other PHP database
794 classes which focus only on select statements, <b>we provide support code
795 to handle inserts and updates which can be adapted to multiple databases
796 quickly.</b> Methods are provided for date handling, string concatenation
797 and string quoting characters for differing databases.</li>
798 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
799 mso-list:l2 level1 lfo1;tab-stops:list 36.0pt'>A<b> metatype system </b>is
800 built in so that we can figure out that types such as CHAR, TEXT and
801 STRING are equivalent in different databases.</li>
802 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
803 mso-list:l2 level1 lfo1;tab-stops:list 36.0pt'><b>Easy to port</b> because
804 all the database dependant code are stored in stub functions. You do not
805 need to port the core logic of the classes.</li>
806 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
807 mso-list:l2 level1 lfo1;tab-stops:list 36.0pt'><b>Portable table and index
808 creation</b> with the <a href="docs-datadict.htm">datadict</a> classes. </li>
809 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
810 mso-list:l2 level1 lfo1;tab-stops:list 36.0pt'><b>Database performance
811 monitoring and SQL tuning</b> with the <a href="docs-perf.htm">performance
812 monitoring</a> classes. </li>
813 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
814 mso-list:l2 level1 lfo1;tab-stops:list 36.0pt'><b>Database-backed sessions</b>
815 with the <a href="docs-session.htm">session management</a> classes.
816 Supports session expiry notification. </li>
817 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
818 mso-list:l2 level1 lfo1;tab-stops:list 36.0pt'><b>Object-Relational
819 Mapping</b> using <a href="docs-active-record.htm">ADOdb_Active_Record</a>
823 <h2>How People are using ADOdb<a name=users></a></h2>
825 <p class=MsoNormal>Here are some examples of how people are using ADOdb (for a
826 much longer list, visit <a
827 href="http://phplens.com/phpeverywhere/adodb-cool-apps">adodb-cool-apps</a>): </p>
830 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
831 mso-list:l4 level1 lfo2;tab-stops:list 36.0pt'><a
832 href="http://phplens.com/">PhpLens</a> is a commercial data grid component
833 that allows both cool Web designers and serious unshaved programmers to
834 develop and maintain databases on the Web easily. Developed by the author
836 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
837 mso-list:l4 level1 lfo2;tab-stops:list 36.0pt'><a
838 href="http://www.interakt.ro/phakt/">PHAkt: PHP Extension for DreamWeaver
839 Ultradev</a> allows you to script PHP in the popular Web page editor.
840 Database handling provided by ADOdb.</li>
841 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
842 mso-list:l4 level1 lfo2;tab-stops:list 36.0pt'><a
843 href="http://www.andrew.cmu.edu/%7Erdanyliw/snort/snortacid.html">Analysis
844 Console for Intrusion Databases</a> (ACID): PHP-based analysis engine to
845 search and process a database of security incidents generated by
846 security-related software such as IDSes and firewalls (e.g. Snort,
847 ipchains). By Roman Danyliw.</li>
848 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
849 mso-list:l4 level1 lfo2;tab-stops:list 36.0pt'><a
850 href="http://www.postnuke.com/">PostNuke</a> is a very popular free
851 content management system and weblog system. It offers full CSS support,
852 HTML 4.01 transitional compliance throughout, an advanced blocks system,
853 and is fully multi-lingual enabled. </li>
854 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
855 mso-list:l4 level1 lfo2;tab-stops:list 36.0pt'><a
856 href="http://www.auto-net.no/easypublish.php?page=index&lang_id=2">EasyPublish
857 CMS</a> is another free content management system for managing information
858 and integrated modules on your internet, intranet- and extranet-sites.
859 From <st1:country-region w:st="on"><st1:place w:st="on">Norway</st1:place></st1:country-region>.</li>
860 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
861 mso-list:l4 level1 lfo2;tab-stops:list 36.0pt'><a
862 href="http://nola.noguska.com/">NOLA</a> is a full featured accounting,
863 inventory, and job tracking application. It is licensed under the GPL, and
864 developed by Noguska. </li>
867 <h2>Feature Requests and Bug Reports<a name=bugs></a></h2>
869 <p>Feature requests and bug reports can be emailed to <a
870 href="mailto:jlim#natsoft.com">jlim#natsoft.com</a> or posted to the ADOdb Help
871 forums at <a href="http://phplens.com/lens/lensforum/topics.php?id=4">http://phplens.com/lens/lensforum/topics.php?id=4</a>.</p>
873 <h2>Installation Guide<a name=install></a></h2>
875 <p>Make sure you are running PHP 4.0.5 or later. Unpack all the files into a
876 directory accessible by your webserver.</p>
878 <p>To test, try modifying some of the tutorial examples. Make sure you
879 customize the connection settings correctly. You can debug using <i>$db->debug
880 = true</i> as shown below:</p>
882 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
883 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
884 style='background:#EEEEEE'><?php<br>
885 <span style='mso-tab-count:1'> </span>include('adodb/adodb.inc.php');<br>
886 <span style='mso-tab-count:1'> </span>$db = <a href="#adonewconnection">ADONewConnection</a>($dbdriver); # eg 'mysql' or 'postgres'<br>
887 <span style='mso-tab-count:1'> </span>$db->debug = true;<br>
888 <span style='mso-tab-count:1'> </span>$db-><a href="#connect">Connect</a>($server, $user, $password, $database);<br>
889 <span style='mso-tab-count:1'> </span>$rs = $db-><a href="#execute">Execute</a>('select * from some_small_table');<br>
890 <span style='mso-tab-count:1'> </span>print "<pre>";<br>
891 <span style='mso-tab-count:1'> </span>print_r($rs-><a href="#getrows">GetRows</a>());<br>
892 <span style='mso-tab-count:1'> </span>print "</pre>";<br>
895 <h3>Minimum Install<a name=mininstall></a></h3>
897 <p>For developers who want to release a minimal install of ADOdb, you will
901 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
902 mso-list:l9 level1 lfo3;tab-stops:list 36.0pt'>adodb.inc.php </li>
903 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
904 mso-list:l9 level1 lfo3;tab-stops:list 36.0pt'>adodb-lib.inc.php </li>
905 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
906 mso-list:l9 level1 lfo3;tab-stops:list 36.0pt'>adodb-time.inc.php </li>
907 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
908 mso-list:l9 level1 lfo3;tab-stops:list 36.0pt'>drivers/adodb-$database.inc.php
910 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
911 mso-list:l9 level1 lfo3;tab-stops:list 36.0pt'>license.txt (for legal
913 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
914 mso-list:l9 level1 lfo3;tab-stops:list 36.0pt'>adodb-php4.inc.php </li>
915 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
916 mso-list:l9 level1 lfo3;tab-stops:list 36.0pt'>adodb-iterator.inc.php
917 (php5 functionality) </li>
920 <p class=MsoNormal>Optional: </p>
923 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
924 mso-list:l3 level1 lfo4;tab-stops:list 36.0pt'>adodb-error.inc.php and
925 lang/adodb-$lang.inc.php (if you use MetaError()) </li>
926 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
927 mso-list:l3 level1 lfo4;tab-stops:list 36.0pt'>adodb-csvlib.inc.php (if
928 you use cached recordsets - CacheExecute(), etc) </li>
929 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
930 mso-list:l3 level1 lfo4;tab-stops:list 36.0pt'>adodb-exceptions.inc.php
931 and adodb-errorhandler.inc.php (if you use adodb error handler or php5
933 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
934 mso-list:l3 level1 lfo4;tab-stops:list 36.0pt'>adodb-active-record.inc.php
935 if you use <a href="docs-active-record.htm">Active Records</a>. </li>
938 <h3>Code Initialization Examples<a name=coding></a></h3>
940 <p>When running ADOdb, at least two files are loaded. First is
941 adodb/adodb.inc.php, which contains all functions used by all database classes.
942 The code specific to a particular database is in the
943 adodb/driver/adodb-????.inc.php file.</p>
945 <p><a name=adonewconnection></a>For example, to connect to a mysql database:</p>
947 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
948 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
949 style='background:#EEEEEE'>include('/path/to/set/here/adodb.inc.php');<br>
950 $conn = &ADONewConnection('mysql');</pre></div>
952 <p>Whenever you need to connect to a database, you create a Connection object
953 using the <b>ADONewConnection</b>($driver) function. <b>NewADOConnection</b>($driver)
954 is an alternative name for the same function.</p>
956 <p>At this point, you are not connected to the database (no longer true if you
957 pass in a <a href="#dsnsupport">dsn</a>). You will first need to decide whether
958 to use <i>persistent</i> or <i>non-persistent</i> connections. The advantage of
959 <i>persistent</i> connections is that they are faster, as the database
960 connection is never closed (even when you call Close()). <i>Non-persistent </i>connections
961 take up much fewer resources though, reducing the risk of your database and
962 your web-server becoming overloaded. </p>
964 <p>For persistent connections, use $conn-><a href="#pconnect">PConnect()</a>,
965 or $conn-><a href="#connect">Connect()</a> for non-persistent connections.
966 Some database drivers also support <a href="#nconnect">NConnect()</a>, which
967 forces the creation of a new connection. <a name="connection_gotcha"></a></p>
969 <p><b>Connection Gotcha</b>: If you create two connections, but both use the
970 same userid and password, PHP will share the same connection. This can cause
971 problems if the connections are meant to different databases. The solution is
972 to always use different userid's for different databases, or use NConnect(). <a
973 name=dsnsupport></a></p>
975 <h3>Data Source Name (DSN) Support</h3>
977 <p>Since ADOdb 4.51, you can connect to a database by passing a dsn to
978 NewADOConnection() (or ADONewConnection, which is the same function). The dsn
981 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
982 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
983 style='background:#EEEEEE'><span style='mso-tab-count:1'> </span>$driver://$username:$password@hostname/$database?options[=value]</pre></div>
985 <p>NewADOConnection() calls Connect() or PConnect() internally for you. If the
986 connection fails, false is returned. </p>
988 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
989 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span
990 style='mso-tab-count:1'> </span><span style='color:green'># non-persistent connection</span></pre><pre><span
991 style='mso-tab-count:1'> </span>$dsn = 'mysql://root:pwd@localhost/mydb'; </pre><pre><span
992 style='mso-tab-count:1'> </span>$db = NewADOConnection($dsn);</pre><pre><span
993 style='mso-tab-count:1'> </span>if (!$db) die("Connection failed");<span style='mso-spacerun:yes'> </span></pre><pre><span
994 style='mso-tab-count:1'> </span></pre><pre><span style='mso-tab-count:
995 1'> </span><span style='color:green'># no need to call connect/pconnect!</span></pre><pre><span
996 style='mso-tab-count:1'> </span>$arr = $db->GetArray("select * from table");</pre><pre><span
997 style='mso-tab-count:1'> </span></pre><pre><span style='mso-tab-count:
998 1'> </span><span style='color:green'># persistent connection</span></pre>
1000 style='mso-tab-count:1'> </span>$dsn2 = 'mysql://root:pwd@localhost/mydb?persist';
1002 style='mso-tab-count:1'></span></pre>
1003 <pre><span style='mso-tab-count:
1004 1'> </span><span style='color:green'># non-persistent connection on port 3000</span></pre>
1006 style='mso-tab-count:1'> </span>$dsn2 = 'mysqli://root:pwd@localhost/mydb?persist=0&port=3000';</pre>
1009 <p>If you have special characters such as /:?_ in your dsn, then you need to
1010 rawurlencode them first: </p>
1012 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
1013 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span
1014 style='mso-tab-count:1'> </span>$pwd = rawurlencode($pwd);<br>
1015 <span style='mso-tab-count:1'> </span>$dsn = "mysql://root:$pwd@localhost/mydb";</pre><pre
1016 style='background:#EEEEEE'><span style='mso-tab-count:1'> </span>$dsn2=rawurlencode("sybase_ase")."://user:pass@host/path?query";</pre></div>
1018 <p>Legal options are: </p>
1022 <table class=MsoNormalTable border=1 cellpadding=0 style='mso-cellspacing:1.5pt'>
1023 <tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes'>
1024 <td style='padding:.75pt .75pt .75pt .75pt'>
1025 <p class=MsoNormal>For all drivers</p>
1027 <td style='padding:.75pt .75pt .75pt .75pt'>
1028 <p class=MsoNormal>'persist', 'persistent', 'debug', 'fetchmode', 'new' , 'cachesecs', 'memcache'</p>
1031 <tr style='mso-yfti-irow:1'>
1032 <td style='padding:.75pt .75pt .75pt .75pt'>
1033 <p class=MsoNormal>Interbase/Firebird </p>
1035 <td style='padding:.75pt .75pt .75pt .75pt'>
1036 <p class=MsoNormal>'dialect','charset','buffers','role' </p>
1039 <tr style='mso-yfti-irow:2'>
1040 <td style='padding:.75pt .75pt .75pt .75pt'>
1041 <p class=MsoNormal>M'soft <st1:City w:st="on"><st1:place w:st="on">ADO</st1:place></st1:City></p>
1043 <td style='padding:.75pt .75pt .75pt .75pt'>
1044 <p class=MsoNormal>'charpage' </p>
1047 <tr style='mso-yfti-irow:3'>
1048 <td style='padding:.75pt .75pt .75pt .75pt'>
1049 <p class=MsoNormal>MySQL</p>
1051 <td style='padding:.75pt .75pt .75pt .75pt'>
1052 <p class=MsoNormal>'clientflags' </p>
1055 <tr style='mso-yfti-irow:4'>
1056 <td style='padding:.75pt .75pt .75pt .75pt'>
1057 <p class=MsoNormal>MySQLi</p>
1059 <td style='padding:.75pt .75pt .75pt .75pt'>
1060 <p class=MsoNormal>'port', 'socket', 'clientflags' </p>
1063 <tr style='mso-yfti-irow:5;mso-yfti-lastrow:yes'>
1064 <td style='padding:.75pt .75pt .75pt .75pt'>
1065 <p class=MsoNormal>Oci8</p>
1067 <td style='padding:.75pt .75pt .75pt .75pt'>
1068 <p class=MsoNormal>'nls_date_format','charset' </p>
1075 <p>For all drivers, when the options <i>persist</i> or <i>persistent</i> are
1076 set, a persistent connection is forced; similarly, when <i>new</i> is set, then
1077 a new connection will be created using NConnect if the underlying driver
1078 supports it. The <i>debug</i> option enables debugging. The <i>fetchmode</i>
1079 calls <a href="#setfetchmode">SetFetchMode()</a>. If no value is defined for an
1080 option, then the value is set to 1. </p>
1082 <p>Since ADOdb 5.09, we added 2 new parameters:</p>
1084 <li class=MsoNormal><i>cachesecs</i> which globally determines how many seconds to cache recordsets (default is 3600 secs if not defined) when
1085 CacheExecute() and CacheSelectLimit() are called and no cache-time parameter is passed into these functions.
1086 <li class=MsoNormal><i>memcache</i> which defines the memcache host, port and whether to use compression. For example:
1088 # we have a memcache server at 10.1.1.22 using default port 11211, no compression
1089 $dsn = 'mysql://user:pwd@localhost/mydb?memcache=10.1.1.22';
1091 # we have a memcache server 10.1.1.22 port 8888, compression=on
1092 $dsn = 'mysql://user:pwd@localhost/mydb?memcache=10.1.1.22:8888:1';
1094 # we have a memcache servers mem1,mem2 on port 8888, compression=off
1095 $dsn = 'mysql://user:pwd@localhost/mydb?memcache=mem1,mem2:8888:0';
1097 # we have a memcache servers mem1,mem2 on port 8888, compression=off and cachesecs=120
1098 $dsn = 'mysql://user:pwd@localhost/mydb?memcache=mem1,mem2:8888:0&cachesecs=120';
1102 <p>ADOdb DSN's are compatible with version 1.0 of PEAR DB's DSN format. <a
1103 name="connect_ex"></a></p>
1105 <h3><span style='mso-bookmark:connect_ex'>Examples of Connecting to Databases</span></h3>
1107 <h4><span style='mso-bookmark:connect_ex'>MySQL and Most Other Database Drivers</span></h4>
1109 <p><span style='mso-bookmark:connect_ex'>MySQL connections are very
1110 straightforward, and the parameters are identical to mysql_connect:</span></p>
1112 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
1113 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span
1114 style='mso-bookmark:connect_ex'><span style='mso-tab-count:1'> </span>$conn = &ADONewConnection('mysql'); <br>
1115 <span style='mso-tab-count:1'> </span>$conn->PConnect('localhost','userid','password','database');<br>
1116 <span style='mso-tab-count:1'> </span><br>
1117 <span style='mso-tab-count:1'> </span></span><span style='mso-bookmark:
1118 connect_ex'><span style='color:green'># or dsn </span></span></pre><pre><span
1119 style='mso-bookmark:connect_ex'><span style='mso-tab-count:1'> </span>$dsn = 'mysql://user:pwd@localhost/mydb'; </span></pre><pre><span
1120 style='mso-bookmark:connect_ex'><span style='mso-tab-count:1'> </span>$conn = ADONewConnection($dsn);<span style='mso-spacerun:yes'> </span># no need for Connect()</span></pre><pre><span
1121 style='mso-bookmark:connect_ex'><span style='mso-tab-count:1'> </span></span></pre><pre><span
1122 style='mso-bookmark:connect_ex'><span style='mso-tab-count:1'> </span></span><span
1123 style='mso-bookmark:connect_ex'><span style='color:green'># or persistent dsn</span></span></pre><pre><span
1124 style='mso-bookmark:connect_ex'><span style='mso-tab-count:1'> </span>$dsn = 'mysql://user:pwd@localhost/mydb?persist'; </span></pre><pre><span
1125 style='mso-bookmark:connect_ex'><span style='mso-tab-count:1'> </span>$conn = ADONewConnection($dsn);<span style='mso-spacerun:yes'> </span># no need for PConnect()</span></pre><pre><span
1126 style='mso-bookmark:connect_ex'><span style='mso-tab-count:1'> </span></span></pre><pre><span
1127 style='mso-bookmark:connect_ex'><span style='mso-tab-count:1'> </span></span><span
1128 style='mso-bookmark:connect_ex'><span style='color:green'># a more complex example:</span></span></pre><pre><span
1129 style='mso-bookmark:connect_ex'><span style='mso-tab-count:1'> </span>$pwd = urlencode($pwd);</span></pre><pre><span
1130 style='mso-bookmark:connect_ex'><span style='mso-tab-count:1'> </span>$flags =<span style='mso-spacerun:yes'> </span>MYSQL_CLIENT_COMPRESS;</span></pre><pre><span
1131 style='mso-bookmark:connect_ex'><span style='mso-tab-count:1'> </span>$dsn = "mysql://user:$pwd@localhost/mydb?persist&clientflags=$flags";</span></pre><pre><span
1132 style='mso-bookmark:connect_ex'><span style='mso-tab-count:1'> </span>$conn = ADONewConnection($dsn);<span style='mso-spacerun:yes'> </span># no need for PConnect()</span></pre><pre
1133 style='background:#EEEEEE'><span style='mso-bookmark:connect_ex'> </span></pre></div>
1135 <p><span style='mso-bookmark:connect_ex'>For most drivers, you can use the
1136 standard function: Connect($server, $user, $password, $database), or a </span><a
1137 href="dsnsupport">DSN</a> since ADOdb 4.51. Exceptions to this are listed
1140 <h4><a name=pdo>PDO</a></h4>
1142 <p><span style='mso-bookmark:pdo'>PDO, which only works with PHP5, accepts a
1143 driver specific connection string: </span></p>
1145 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
1146 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span
1147 style='mso-bookmark:pdo'><o:p> </o:p></span></pre><pre><span
1148 style='mso-bookmark:pdo'><span style='mso-tab-count:1'> </span>$conn =& NewADConnection('pdo');</span></pre><pre><span
1149 style='mso-bookmark:pdo'><span style='mso-tab-count:1'> </span>$conn->Connect('mysql:host=localhost',$user,$pwd,$mydb);</span></pre><pre><span
1150 style='mso-bookmark:pdo'><span style='mso-tab-count:1'> </span>$conn->Connect('mysql:host=localhost;dbname=mydb',$user,$pwd);</span></pre><pre><span
1151 style='mso-bookmark:pdo'><span style='mso-tab-count:1'> </span>$conn->Connect("mysql:host=localhost;dbname=mydb;username=$user;password=$pwd");</span></pre></div>
1153 <p><span style='mso-bookmark:pdo'>The DSN mechanism is also supported: </span></p>
1155 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
1156 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span
1157 style='mso-bookmark:pdo'><o:p> </o:p></span></pre><pre><span
1158 style='mso-bookmark:pdo'><span style='mso-tab-count:1'> </span>$conn =& NewADConnection("pdo_mysql://user:pwd@localhost/mydb?persist"); # persist is optional</span></pre></div>
1160 <h4><span style='mso-bookmark:pdo'>PostgreSQL</span></h4>
1162 <p><span style='mso-bookmark:pdo'>PostgreSQL 7 and 8 accepts connections using:
1165 <p><span style='mso-bookmark:pdo'>a. the standard connection string:</span></p>
1167 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
1168 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
1169 style='background:#EEEEEE'><span style='mso-bookmark:pdo'><span
1170 style='mso-tab-count:1'> </span>$conn = &ADONewConnection('postgres');<span style='mso-spacerun:yes'> </span><br>
1171 <span style='mso-tab-count:1'> </span>$conn->PConnect('host=localhost port=5432 dbname=mary');</span></pre></div>
1173 <p><span style='mso-bookmark:pdo'>b. the classical 4 parameters:</span></p>
1175 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
1176 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
1177 style='background:#EEEEEE'><span style='mso-bookmark:pdo'><span
1178 style='mso-tab-count:1'> </span>$conn->PConnect('localhost','userid','password','database');<br>
1179 <span style='mso-spacerun:yes'> </span></span></pre></div>
1181 <p><span style='mso-bookmark:pdo'>c. dsn: </span></p>
1183 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
1184 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span
1185 style='mso-bookmark:pdo'><span style='mso-tab-count:1'> </span>$dsn = 'postgres://user:pwd@localhost/mydb?persist';<span style='mso-spacerun:yes'> </span># persist is optional</span></pre><pre
1186 style='background:#EEEEEE'><span style='mso-bookmark:pdo'><span
1187 style='mso-tab-count:1'> </span>$conn = ADONewConnection($dsn);<span style='mso-spacerun:yes'> </span># no need for Connect/PConnect</span></pre></div>
1189 <span style='mso-bookmark:pdo'></span>
1191 <h4><a name=ldap></a>LDAP</h4>
1193 <p>Here is an example of querying a LDAP server. Thanks to Josh Eldridge for
1194 the driver and this example: </p>
1196 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
1197 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><o:p> </o:p></pre><pre>require('/path/to/adodb.inc.php');</pre><pre><o:p> </o:p></pre><pre>/* Make sure to set this BEFORE calling Connect() */</pre><pre>$LDAP_CONNECT_OPTIONS = Array(</pre><pre><span
1198 style='mso-tab-count:1'> </span>Array ("OPTION_NAME"=>LDAP_OPT_DEREF, "OPTION_VALUE"=>2),</pre><pre><span
1199 style='mso-tab-count:1'> </span>Array ("OPTION_NAME"=>LDAP_OPT_SIZELIMIT,"OPTION_VALUE"=>100),</pre><pre><span
1200 style='mso-tab-count:1'> </span>Array ("OPTION_NAME"=>LDAP_OPT_TIMELIMIT,"OPTION_VALUE"=>30),</pre><pre><span
1201 style='mso-tab-count:1'> </span>Array ("OPTION_NAME"=>LDAP_OPT_PROTOCOL_VERSION,"OPTION_VALUE"=>3),</pre><pre><span
1202 style='mso-tab-count:1'> </span>Array ("OPTION_NAME"=>LDAP_OPT_ERROR_NUMBER,"OPTION_VALUE"=>13),</pre><pre><span
1203 style='mso-tab-count:1'> </span>Array ("OPTION_NAME"=>LDAP_OPT_REFERRALS,"OPTION_VALUE"=>FALSE),</pre><pre><span
1204 style='mso-tab-count:1'> </span>Array ("OPTION_NAME"=>LDAP_OPT_RESTART,"OPTION_VALUE"=>FALSE)</pre><pre>);</pre><pre>$host = 'ldap.baylor.edu';</pre><pre>$ldapbase = 'ou=People,o=<st1:place
1205 w:st="on"><st1:PlaceName w:st="on">Baylor</st1:PlaceName> <st1:PlaceType w:st="on">University</st1:PlaceType></st1:place>,c=US';</pre><pre><o:p> </o:p></pre><pre>$ldap = NewADOConnection( 'ldap' );</pre><pre>$ldap->Connect( $host, $user_name='', $password='', $ldapbase );</pre><pre><o:p> </o:p></pre><pre>echo "<pre>";</pre><pre><o:p> </o:p></pre><pre>print_r( $ldap->ServerInfo() );</pre><pre>$ldap->SetFetchMode(ADODB_FETCH_ASSOC);</pre><pre>$userName = 'eldridge';</pre><pre>$filter="(|(CN=$userName*)(sn=$userName*)(givenname=$userName*)(uid=$userName*))";</pre><pre><o:p> </o:p></pre><pre>$rs = $ldap->Execute( $filter );</pre><pre>if ($rs)</pre><pre><span
1206 style='mso-tab-count:1'> </span>while ($arr = $rs->FetchRow()) {</pre><pre><span
1207 style='mso-tab-count:1'> </span><span style='mso-spacerun:yes'> </span>print_r($arr);<span
1208 style='mso-tab-count:1'> </span></pre><pre><span style='mso-tab-count:
1209 1'> </span>}</pre><pre><o:p> </o:p></pre><pre>$rs = $ldap->Execute( $filter );</pre><pre>if ($rs) </pre><pre><span
1210 style='mso-tab-count:1'> </span>while (!$rs->EOF) {</pre><pre> <span
1211 style='mso-tab-count:2'> </span>print_r($rs->fields);<span
1212 style='mso-tab-count:1'> </span></pre><pre><span style='mso-tab-count:2'> </span>$rs->MoveNext();</pre><pre><span
1213 style='mso-tab-count:1'> </span>} </pre><pre><span style='mso-tab-count:
1214 1'> </span></pre><pre>print_r( $ldap->GetArray( $filter ) );</pre><pre>print_r( $ldap->GetRow( $filter ) );</pre><pre><o:p> </o:p></pre><pre>$ldap->Close();</pre><pre>echo "</pre>";</pre></div>
1218 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
1219 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><o:p> </o:p></pre><pre>$dsn = "ldap://ldap.baylor.edu/ou=People,o=<st1:place
1220 w:st="on"><st1:PlaceName w:st="on">Baylor</st1:PlaceName> <st1:PlaceType w:st="on">University</st1:PlaceType></st1:place>,c=US";</pre><pre>$db = NewADOConnection($dsn);</pre></div>
1222 <h4>Interbase/Firebird</h4>
1224 <p class=MsoNormal>You define the database in the $host parameter: </p>
1226 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
1227 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
1228 style='background:#EEEEEE'><span style='mso-tab-count:1'> </span>$conn = &ADONewConnection('ibase'); <br>
1229 <span style='mso-tab-count:1'> </span>$conn->PConnect('localhost:c:\ibase\employee.gdb','sysdba','masterkey');</pre></div>
1233 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
1234 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
1235 style='background:#EEEEEE'><span style='mso-tab-count:1'> </span>$dsn = 'firebird://user:pwd@localhost/mydb?persist&dialect=3';<span style='mso-spacerun:yes'> </span># persist is optional<br>
1236 <span style='mso-tab-count:1'> </span>$conn = ADONewConnection($dsn);<span style='mso-spacerun:yes'> </span># no need for Connect/PConnect</pre></div>
1240 <p class=MsoNormal>Sqlite will create the database file if it does not exist. </p>
1242 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
1243 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span
1244 style='mso-tab-count:1'> </span>$conn = &ADONewConnection('sqlite');</pre><pre
1245 style='background:#EEEEEE'><span style='mso-tab-count:1'> </span>$conn->PConnect('c:\path\to\sqlite.db'); # sqlite will create if does not exist</pre></div>
1249 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
1250 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span
1251 style='mso-tab-count:1'> </span>$path = urlencode('c:\path\to\sqlite.db');</pre><pre><span
1252 style='mso-tab-count:1'> </span>$dsn = "sqlite://$path/?persist";<span style='mso-spacerun:yes'> </span># persist is optional</pre><pre
1253 style='background:#EEEEEE'><span style='mso-tab-count:1'> </span>$conn = ADONewConnection($dsn);<span style='mso-spacerun:yes'> </span># no need for Connect/PConnect</pre></div>
1255 <h4>Oracle (oci8)</h4>
1257 <p>With oci8, you can connect in multiple ways. Note that oci8 works fine with
1258 newer versions of the Oracle, eg. 9i and 10g.</p>
1260 <p>a. PHP and Oracle reside on the same machine, use default SID.</p>
1262 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
1263 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
1264 style='background:#EEEEEE'><span style='mso-tab-count:1'> </span>$conn->Connect(false, 'scott', 'tiger');</pre></div>
1266 <p>b. TNS Name defined in tnsnames.ora (or ONAMES or HOSTNAMES), eg. 'myTNS'</p>
1268 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
1269 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
1270 style='background:#EEEEEE'><span style='mso-tab-count:1'> </span>$conn->PConnect(false, 'scott', 'tiger', 'myTNS');</pre></div>
1274 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
1275 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
1276 style='background:#EEEEEE'><span style='mso-spacerun:yes'> </span><span
1277 style='mso-tab-count:1'> </span>$conn->PConnect('myTNS', 'scott', 'tiger');</pre></div>
1279 <p>c. Host Address and SID</p>
1281 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
1282 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><o:p> </o:p></pre><pre><span
1283 style='mso-tab-count:1'> </span># with adodb 5.06 or 4.991 and later</pre><pre><span
1284 style='mso-tab-count:1'> </span>$conn->Connect('192.168.0.1', 'scott', 'tiger', "SID=$SID");</pre><pre><span
1285 style='mso-tab-count:1'> </span></pre><pre><span style='mso-tab-count:
1286 1'> </span># OR with all versions of ADOdb</pre><pre><span
1287 style='mso-tab-count:1'> </span>$conn->connectSID = true;</pre><pre><span
1288 style='mso-tab-count:1'> </span>$conn->Connect('192.168.0.1', 'scott', 'tiger', $SID);</pre><pre
1289 style='background:#EEEEEE'><span style='mso-tab-count:1'> </span></pre></div>
1291 <p>d. Host Address and Service Name</p>
1293 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
1294 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
1295 style='background:#EEEEEE'><span style='mso-tab-count:1'> </span>$conn->Connect('192.168.0.1', 'scott', 'tiger', 'servicename');</pre></div>
1297 <p>e. Oracle connection string: </p>
1299 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
1300 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
1301 style='background:#EEEEEE'><span style='mso-tab-count:1'> </span>$cstr = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=$host)(PORT=$port))<br>
1302 <span style='mso-tab-count:3'> </span>(CONNECT_DATA=(SID=$sid)))";<br>
1303 <span style='mso-tab-count:1'> </span>$conn->Connect($cstr, 'scott', 'tiger');</pre></div>
1305 <p>f. ADOdb dsn: </p>
1307 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
1308 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
1309 style='background:#EEEEEE'><span style='mso-tab-count:1'> </span>$dsn = 'oci8://user:pwd@tnsname/?persist';<span style='mso-spacerun:yes'> </span># persist is optional<br>
1310 <span style='mso-tab-count:1'> </span>$conn = ADONewConnection($dsn);<span style='mso-spacerun:yes'> </span># no need for Connect/PConnect<br>
1311 <span style='mso-tab-count:1'> </span><br>
1312 <span style='mso-tab-count:1'> </span>$dsn = 'oci8://user:pwd@host/sid';<br>
1313 <span style='mso-tab-count:1'> </span>$conn = ADONewConnection($dsn);<br>
1314 <span style='mso-tab-count:1'> </span><br>
1315 <span style='mso-tab-count:1'> </span>$dsn = 'oci8://user:pwd@/';<span style='mso-spacerun:yes'> </span># oracle on local machine<br>
1316 <span style='mso-tab-count:1'> </span>$conn = ADONewConnection($dsn);</pre></div>
1318 <p>You can also set the charSet for Oracle 9.2 and later, supported since PHP
1319 4.3.2, ADOdb 4.54: </p>
1321 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
1322 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
1323 style='background:#EEEEEE'><span style='mso-tab-count:1'> </span>$conn->charSet = 'we8iso8859p1';<br>
1324 <span style='mso-tab-count:1'> </span>$conn->Connect(...);<br>
1325 <span style='mso-tab-count:1'> </span><br>
1326 <span style='mso-tab-count:1'> </span># or<br>
1327 <span style='mso-tab-count:1'> </span>$dsn = 'oci8://user:pwd@tnsname/?charset=WE8MSWIN1252';<br>
1328 <span style='mso-tab-count:1'> </span>$db = ADONewConnection($dsn);</pre></div>
1330 <h4><a name=dsnless></a>DSN-less ODBC ( Access, MSSQL and DB2 examples)</h4>
1332 <p>ODBC DSN's can be created in the ODBC control panel, or you can use a
1333 DSN-less connection.To use DSN-less connections with ODBC you need PHP 4.3 or
1336 <p>For Microsoft Access:</p>
1338 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
1339 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span
1340 style='mso-tab-count:1'> </span>$db =& ADONewConnection('access');<br>
1341 <span style='mso-tab-count:1'> </span>$dsn = <strong><span
1342 style='font-family:"Courier New"'>"Driver={Microsoft Access Driver (*.mdb)};Dbq=d:\\northwind.mdb;Uid=Admin;Pwd=;";</span></strong></pre><pre><span
1343 style='mso-tab-count:1'> </span>$db->Connect($dsn);</pre></div>
1345 <p class=MsoNormal>For Microsoft SQL Server: </p>
1347 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
1348 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
1349 style='background:#EEEEEE'><span style='mso-tab-count:1'> </span>$db =& ADONewConnection('odbc_mssql');<br>
1350 <span style='mso-tab-count:1'> </span>$dsn = <strong><span
1351 style='font-family:"Courier New"'>"Driver={SQL Server};Server=localhost;Database=northwind;"</span></strong>;<br>
1352 <span style='mso-tab-count:1'> </span>$db->Connect($dsn,'userid','password');</pre></div>
1354 <p class=MsoNormal>or if you prefer to use the mssql extension (which is
1355 limited to mssql 6.5 functionality): </p>
1357 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
1358 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
1359 style='background:#EEEEEE'><span style='mso-tab-count:1'> </span>$db =& ADONewConnection('mssql');<br>
1360 <span style='mso-tab-count:1'> </span>$db->Execute('localhost', 'userid', 'password', 'northwind');</pre></div>
1362 <p class=MsoNormal>For DB2: </p>
1364 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
1365 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><o:p> </o:p></pre><pre><span
1366 style='mso-tab-count:1'> </span>$dbms = 'db2'; # or 'odbc_db2' if db2 extension not available</pre><pre><span
1367 style='mso-tab-count:1'> </span>$db =& ADONewConnection($dbms);</pre><pre><span
1368 style='mso-tab-count:1'> </span>$dsn = "driver={IBM db2 odbc DRIVER};Database=sample;hostname=localhost;port=50000;protocol=TCPIP;".</pre><pre><span
1369 style='mso-tab-count:4'> </span>"uid=root; pwd=secret";<br>
1370 <span style='mso-tab-count:1'> </span>$db->Connect($dsn);<br>
1371 # or connect and set schema
1372 $db->Connect($dsn,null,null,$schema);</pre>
1375 <p class=MsoNormal><b>DSN-less Connections with <st1:City w:st="on">ADO</st1:City></b><br>
1376 If you are using versions of PHP earlier than PHP 4.3.0, DSN-less connections
1377 only work with Microsoft's <st1:City w:st="on"><st1:place w:st="on">ADO</st1:place></st1:City>,
1378 which is Microsoft's COM based API. An example using the ADOdb library and
1379 Microsoft's <st1:City w:st="on"><st1:place w:st="on">ADO</st1:place></st1:City>:
1382 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
1383 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><?php<br>
1384 <span style='mso-tab-count:1'> </span>include('adodb.inc.php'); <br>
1385 <span style='mso-tab-count:1'> </span>$db = &ADONewConnection("ado_mssql");<br>
1386 <span style='mso-tab-count:1'> </span>print "<h1>Connecting DSN-less $db->databaseType...</h1>";<br>
1387 <span style='mso-tab-count:2'> </span><br>
1388 <span style='mso-tab-count:1'> </span><b>$myDSN="PROVIDER=MSDASQL;DRIVER={SQL Server};"<br>
1389 <span style='mso-tab-count:2'> </span>. "SERVER=flipper;DATABASE=ai;UID=sa;PWD=;"<span style='mso-spacerun:yes'> </span>;</b></pre><pre><span
1390 style='mso-tab-count:1'> </span>$db->Connect($myDSN);</pre><pre><span
1391 style='mso-tab-count:1'> </span></pre><pre><span style='mso-tab-count:
1392 1'> </span>$rs = $db->Execute("select * from table");</pre><pre><span
1393 style='mso-tab-count:1'> </span>$arr = $rs->GetArray();</pre><pre><span
1394 style='mso-tab-count:1'> </span>print_r($arr);</pre><pre>?></pre></div>
1396 <h2><a name=speed></a>High Speed ADOdb - tuning tips</h2>
1398 <p>ADOdb is a big class library, yet it <a href="http://phplens.com/lens/adodb/">consistently
1399 beats</a> all other PHP class libraries in performance. This is because it is
1400 designed in a layered fashion, like an onion, with the fastest functions in the
1401 innermost layer. Stick to the following functions for best performance:</p>
1405 <table class=MsoNormalTable border=1 cellpadding=0 width="40%"
1406 style='width:40.0%;mso-cellspacing:1.5pt'>
1407 <tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes'>
1408 <td style='padding:.75pt .75pt .75pt .75pt'>
1409 <p class=MsoNormal align=center style='text-align:center'><b>Innermost Layer</b></p>
1412 <tr style='mso-yfti-irow:1;mso-yfti-lastrow:yes'>
1413 <td style='padding:.75pt .75pt .75pt .75pt'>
1414 <p align=center style='text-align:center'>Connect, PConnect, NConnect<br>
1415 Execute, CacheExecute<br>
1416 SelectLimit, CacheSelectLimit<br>
1417 MoveNext, Close <br>
1418 qstr, Affected_Rows, Insert_ID</p>
1425 <p>The fastest way to access the field data is by accessing the array
1426 $recordset->fields directly. Also set the global variables <a
1427 href="#adodb_fetch_mode">$ADODB_FETCH_MODE</a> = ADODB_FETCH_NUM, and (for
1428 oci8, ibase/firebird and odbc) <a href="#adodb_countrecs">$ADODB_COUNTRECS</a>
1429 = false before you connect to your database.</p>
1431 <p>Consider using bind parameters if your database supports it, as it improves
1432 query plan reuse. Use ADOdb's performance tuning system to identify bottlenecks
1433 quickly. At the time of writing (Dec 2003), this means oci8 and odbc drivers.</p>
1435 <p>Lastly make sure you have a PHP accelerator cache installed such as APC,
1436 Turck MMCache, Zend Accelerator or ionCube.</p>
1438 <p>Some examples:</p>
1442 <table class=MsoNormalTable border=1 cellpadding=0 style='mso-cellspacing:1.5pt'>
1443 <tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes'>
1444 <td style='padding:.75pt .75pt .75pt .75pt'>
1445 <p class=MsoNormal><b>Fastest data retrieval using PHP</b></p>
1447 <td style='padding:.75pt .75pt .75pt .75pt'>
1448 <p class=MsoNormal><b>Fastest data retrieval using ADOdb extension</b></p>
1451 <tr style='mso-yfti-irow:1;mso-yfti-lastrow:yes'>
1452 <td style='padding:.75pt .75pt .75pt .75pt'>
1453 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;
1454 mso-border-alt:solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;
1455 background:#EEEEEE'><pre style='background:#EEEEEE'>$rs =& $rs->Execute($sql);<br>
1456 while (!$rs->EOF) {<br>
1457 <span style='mso-tab-count:1'> </span>var_dump($rs->fields);<br>
1458 <span style='mso-tab-count:1'> </span>$rs->MoveNext();<br>
1461 <td style='padding:.75pt .75pt .75pt .75pt'>
1462 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;
1463 mso-border-alt:solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;
1464 background:#EEEEEE'><pre style='margin-bottom:12.0pt;background:#EEEEEE'>$rs =& $rs->Execute($sql);<br>
1465 $array = adodb_getall($rs);<br>
1466 var_dump($array);<br style='mso-special-character:line-break'>
1467 <![if !supportLineBreakNewLine]><br style='mso-special-character:line-break'>
1468 <![endif]></pre></div>
1475 <p><b>Advanced Tips</b> </p>
1477 <p>If you have the <a href="http://adodb.sourceforge.net/#extension">ADOdb C
1478 extension</a> installed, you can replace your calls to $rs->MoveNext() with
1479 adodb_movenext($rs). This doubles the speed of this operation. For retrieving
1480 entire recordsets at once, use GetArray(), which uses the high speed extension
1481 function adodb_getall($rs) internally. </p>
1483 <p>Execute() is the default way to run queries. You can use the low-level
1484 functions _Execute() and _query() to reduce query overhead. Both these
1485 functions share the same parameters as Execute(). </p>
1487 <p>If you do not have any bind parameters or your database supports binding
1488 (without emulation), then you can call _Execute() directly. Calling this
1489 function bypasses bind emulation. Debugging is still supported in _Execute(). </p>
1491 <p>If you do not require debugging facilities nor emulated binding, and do not
1492 require a recordset to be returned, then you can call _query. This is great for
1493 inserts, updates and deletes. Calling this function bypasses emulated binding,
1494 debugging, and recordset handling. Either the resultid, true or false are
1495 returned by _query(). </p>
1497 <p>For Informix, you can disable scrollable cursors with $db->cursorType =
1500 <h2><a name=hack></a>Hacking ADOdb Safely</h2>
1502 <p>You might want to modify ADOdb for your own purposes. Luckily you can still
1503 maintain backward compatibility by sub-classing ADOdb and using the
1504 $ADODB_NEWCONNECTION variable. $ADODB_NEWCONNECTION allows you to override the
1505 behaviour of ADONewConnection(). ADOConnection() checks for this variable and
1506 will call the function-name stored in this variable if it is defined. </p>
1508 <p>In the following example, new functionality for the connection object is
1509 placed in the <i>hack_mysql</i> and <i>hack_postgres7</i> classes. The
1510 recordset class naming convention can be controlled using $rsPrefix. Here we
1511 set it to 'hack_rs_', which will make ADOdb use <i>hack_rs_mysql</i> and <i>hack_rs_postgres7</i>
1512 as the recordset classes. </p>
1514 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
1515 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
1516 style='background:#EEEEEE'>class hack_mysql extends adodb_mysql {<br>
1517 var $rsPrefix = 'hack_rs_';<br>
1518 <span style='mso-spacerun:yes'> </span>/* Your mods here */<br>
1521 class hack_rs_mysql extends ADORecordSet_mysql {<br>
1522 <span style='mso-tab-count:1'> </span><span style='mso-spacerun:yes'> </span>/* Your mods here */<br>
1525 class hack_postgres7 extends adodb_postgres7 {<br>
1526 var $rsPrefix = 'hack_rs_';<br>
1527 <span style='mso-spacerun:yes'> </span>/* Your mods here */<br>
1530 class hack_rs_postgres7 extends ADORecordSet_postgres7 {<br>
1531 <span style='mso-spacerun:yes'> </span>/* Your mods here */<br>
1534 $ADODB_NEWCONNECTION = 'hack_factory';<br>
1536 function& hack_factory($driver)<br>
1538 <span style='mso-tab-count:1'> </span>if ($driver !== 'mysql' && $driver !== 'postgres7') return false;<br>
1539 <span style='mso-tab-count:1'> </span><br>
1540 <span style='mso-tab-count:1'> </span>$driver = 'hack_'.$driver;<br>
1541 <span style='mso-tab-count:1'> </span>$obj = new $driver();<br>
1542 <span style='mso-tab-count:1'> </span>return $obj;<br>
1545 include_once('adodb.inc.php');</pre></div>
1547 <p>Don't forget to call the constructor of the parent class in your
1548 constructor. If you want to use the default ADOdb drivers return false in the
1549 above hack_factory() function. Also you can define your own
1550 ADORecordSet_empty() class, by defining a class $$this->rsPrefix.'empty'
1551 since 4.96/5.02. <a name=php5></a></p>
1553 <h2>PHP5 Features</h2>
1555 <p class=MsoNormal>ADOdb 4.02 or later will transparently determine which
1556 version of PHP you are using. If PHP5 is detected, the following features become
1560 <li class=MsoNormal style='mso-margin-top-alt:auto;margin-bottom:12.0pt;
1561 mso-list:l11 level1 lfo5;tab-stops:list 36.0pt'><b>PDO</b>: PDO drivers
1562 are available. See the <a href="#pdo">connection examples</a>. Currently
1563 PDO drivers are not as powerful as native drivers, and should be treated
1564 as experimental.<a name=php5iterators></a></li>
1565 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
1566 mso-list:l11 level1 lfo5;tab-stops:list 36.0pt'><b>Foreach iterators</b>:
1567 This is a very natural way of going through a recordset: </li>
1570 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
1571 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE;
1572 margin-left:36.0pt;margin-right:0cm'><pre style='background:#EEEEEE'><span
1573 style='mso-tab-count:1'> </span>$ADODB_FETCH_MODE = ADODB_FETCH_NUM;<br>
1574 <span style='mso-tab-count:1'> </span>$rs = $db->Execute($sql);<br>
1575 <span style='mso-tab-count:1'> </span>foreach($rs as $k => $row) {<br>
1576 <span style='mso-tab-count:2'> </span>echo "r1=".$row[0]." r2=".$row[1]."<br>";<br>
1577 <span style='mso-tab-count:1'> </span>}</pre></div>
1580 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
1581 mso-list:l11 level1 lfo5;tab-stops:list 36.0pt'><a name=php5exceptions></a><b>Exceptions</b>:
1582 Just include <i>adodb-exceptions.inc.php</i> and you can now catch
1583 exceptions on errors as they occur. </li>
1586 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
1587 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE;
1588 margin-left:36.0pt;margin-right:0cm'><pre style='background:#EEEEEE'><span
1589 style='mso-tab-count:1'> </span><b>include("../adodb-exceptions.inc.php");</b> <br>
1590 <span style='mso-tab-count:1'> </span>include("../adodb.inc.php");<span
1591 style='mso-tab-count:1'> </span> <br>
1592 <span style='mso-tab-count:1'> </span>try { <br>
1593 <span style='mso-tab-count:2'> </span>$db = NewADOConnection("oci8"); <br>
1594 <span style='mso-tab-count:2'> </span>$db->Connect('','scott','bad-password'); <br>
1595 <span style='mso-tab-count:1'> </span>} catch (exception $e) { <br>
1596 <span style='mso-tab-count:2'> </span>var_dump($e); <br>
1597 <span style='mso-tab-count:2'> </span>adodb_backtrace($e->gettrace());<br>
1598 <span style='mso-tab-count:1'> </span>} </pre></div>
1600 <p style='margin-left:36.0pt'>Note that reaching EOF is <b>not</b> considered
1601 an error nor an exception. </p>
1603 <h3><a name=drivers></a>Databases Supported</h3>
1605 <p class=MsoNormal>The <i>name</i> below is the value you pass to
1606 NewADOConnection($name) to create a connection object for that database. </p>
1608 <table class=MsoNormalTable border=1 cellpadding=0 width="100%"
1609 style='width:100.0%;mso-cellspacing:1.5pt'>
1610 <tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes'>
1611 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1612 <p class=MsoNormal><b>Name</b></p>
1614 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1615 <p class=MsoNormal><b>Tested</b></p>
1617 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1618 <p class=MsoNormal><b>Database</b></p>
1620 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1621 <p class=MsoNormal><b><span style='font-size:10.0pt'>RecordCount() usable</span></b></p>
1623 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1624 <p class=MsoNormal><b>Prerequisites</b></p>
1626 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1627 <p class=MsoNormal><b>Operating Systems</b></p>
1630 <tr style='mso-yfti-irow:1'>
1631 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1632 <p class=MsoNormal><b><span style='font-size:10.0pt'>access</span></b></p>
1634 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1635 <p class=MsoNormal><span style='font-size:10.0pt'>B</span></p>
1637 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1638 <p class=MsoNormal><span style='font-size:10.0pt'>Microsoft Access/Jet. You
1639 need to create an ODBC DSN.</span></p>
1641 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1642 <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
1644 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1645 <p class=MsoNormal><span style='font-size:10.0pt'>ODBC </span></p>
1647 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1648 <p class=MsoNormal><span style='font-size:10.0pt'>Windows only</span></p>
1651 <tr style='mso-yfti-irow:2'>
1652 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1653 <p class=MsoNormal><b><span style='font-size:10.0pt'>ado</span></b></p>
1655 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1656 <p class=MsoNormal><span style='font-size:10.0pt'>B</span></p>
1658 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1659 <p><span style='font-size:10.0pt'>Generic <st1:City w:st="on"><st1:place
1660 w:st="on">ADO</st1:place></st1:City>, not tuned for specific databases.
1661 Allows DSN-less connections. For best performance, use an OLEDB provider.
1662 This is the base class for all ado drivers.</span></p>
1663 <p><span style='font-size:10.0pt'>You can set $db->codePage before
1664 connecting.</span></p>
1666 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1667 <p class=MsoNormal><span style='font-size:10.0pt'>? depends on database</span></p>
1669 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1670 <p class=MsoNormal><st1:City w:st="on"><st1:place w:st="on"><span
1671 style='font-size:10.0pt'>ADO</span></st1:place></st1:City><span
1672 style='font-size:10.0pt'> or OLEDB provider</span></p>
1674 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1675 <p class=MsoNormal><span style='font-size:10.0pt'>Windows only</span></p>
1678 <tr style='mso-yfti-irow:3'>
1679 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1680 <p class=MsoNormal><b><span style='font-size:10.0pt'>ado_access</span></b></p>
1682 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1683 <p class=MsoNormal><span style='font-size:10.0pt'>B</span></p>
1685 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1686 <p class=MsoNormal><span style='font-size:10.0pt'>Microsoft Access/Jet using <st1:City
1687 w:st="on"><st1:place w:st="on">ADO</st1:place></st1:City>. Allows DSN-less
1688 connections. For best performance, use an OLEDB provider.</span></p>
1690 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1691 <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
1693 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1694 <p class=MsoNormal><st1:City w:st="on"><st1:place w:st="on"><span
1695 style='font-size:10.0pt'>ADO</span></st1:place></st1:City><span
1696 style='font-size:10.0pt'> or OLEDB provider</span></p>
1698 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1699 <p class=MsoNormal><span style='font-size:10.0pt'>Windows only</span></p>
1702 <tr style='mso-yfti-irow:4'>
1703 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1704 <p class=MsoNormal><b><span style='font-size:10.0pt'>ado_mssql</span></b></p>
1706 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1707 <p class=MsoNormal><span style='font-size:10.0pt'>B</span></p>
1709 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1710 <p class=MsoNormal><span style='font-size:10.0pt'>Microsoft SQL Server using <st1:City
1711 w:st="on"><st1:place w:st="on">ADO</st1:place></st1:City>. Allows DSN-less
1712 connections. For best performance, use an OLEDB provider.</span></p>
1714 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1715 <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
1717 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1718 <p class=MsoNormal><st1:City w:st="on"><st1:place w:st="on"><span
1719 style='font-size:10.0pt'>ADO</span></st1:place></st1:City><span
1720 style='font-size:10.0pt'> or OLEDB provider</span></p>
1722 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1723 <p class=MsoNormal><span style='font-size:10.0pt'>Windows only</span></p>
1726 <tr style='mso-yfti-irow:5;height:40.5pt'>
1727 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
1728 <p class=MsoNormal><b><span style='font-size:10.0pt'>db2</span></b></p>
1730 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
1731 <p class=MsoNormal><span style='font-size:10.0pt'>B</span></p>
1733 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
1734 <p class=MsoNormal><span style='font-size:10.0pt'>Uses PHP's db2-specific
1735 extension for better performance.</span></p>
1737 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
1738 <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
1740 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
1741 <p class=MsoNormal><span style='font-size:10.0pt'>DB2 CLI/ODBC interface</span></p>
1743 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
1744 <p><span style='font-size:10.0pt'>Unix and Windows. Requires IBM DB2
1745 Universal Database client.</span></p>
1749 <tr style='mso-yfti-irow:5;height:40.5pt'>
1750 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
1751 <p class=MsoNormal><b><span style='font-size:10.0pt'>db2oci</span></b></p>
1753 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
1754 <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
1756 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
1757 <p class=MsoNormal><span style='font-size:10.0pt'>Based on db2 driver. Allows use of oracle style :0, :1, :2 bind variables. Used with DB2 9.7 or later with PL/SQL mode turned on.</span></p>
1759 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
1760 <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
1762 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
1763 <p class=MsoNormal><span style='font-size:10.0pt'>DB2 CLI/ODBC interface</span></p>
1765 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
1766 <p><span style='font-size:10.0pt'>Unix and Windows. Requires IBM DB2
1767 Universal Database client.</span></p>
1771 <tr style='mso-yfti-irow:6;height:40.5pt'>
1772 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
1773 <p class=MsoNormal><b><span style='font-size:10.0pt'>odbc_db2</span></b></p>
1775 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
1776 <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
1778 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
1779 <p class=MsoNormal><span style='font-size:10.0pt'>Connects to DB2 using
1780 generic ODBC extension.</span></p>
1782 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
1783 <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
1785 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
1786 <p class=MsoNormal><span style='font-size:10.0pt'>DB2 CLI/ODBC interface</span></p>
1788 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
1789 <p><span style='font-size:10.0pt'>Unix and Windows. <a
1790 href="http://www.faqts.com/knowledge_base/view.phtml/aid/6283/fid/14">Unix
1791 install hints</a>. I have had reports that the $host and $database params
1792 have to be reversed in Connect() when using the CLI interface.</span></p>
1795 <tr style='mso-yfti-irow:7'>
1796 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1797 <p class=MsoNormal><b><span style='font-size:10.0pt'>vfp</span></b></p>
1799 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1800 <p class=MsoNormal><span style='font-size:10.0pt'>A</span></p>
1802 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1803 <p class=MsoNormal><span style='font-size:10.0pt'>Microsoft Visual FoxPro.
1804 You need to create an ODBC DSN.</span></p>
1806 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1807 <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
1809 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1810 <p class=MsoNormal><span style='font-size:10.0pt'>ODBC</span></p>
1812 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1813 <p class=MsoNormal><span style='font-size:10.0pt'>Windows only</span></p>
1816 <tr style='mso-yfti-irow:8'>
1817 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1818 <p class=MsoNormal><b><span style='font-size:10.0pt'>fbsql</span></b></p>
1820 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1821 <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
1823 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1824 <p class=MsoNormal><span style='font-size:10.0pt'>FrontBase. </span></p>
1826 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1827 <p class=MsoNormal><span style='font-size:10.0pt'>Y</span></p>
1829 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1830 <p class=MsoNormal><span style='font-size:10.0pt'>?</span></p>
1832 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1833 <p><span style='font-size:10.0pt'>Unix and Windows</span></p>
1836 <tr style='mso-yfti-irow:9'>
1837 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1838 <p class=MsoNormal><b><span style='font-size:10.0pt'>ibase</span></b></p>
1840 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1841 <p class=MsoNormal><span style='font-size:10.0pt'>B</span></p>
1843 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1844 <p class=MsoNormal><span style='font-size:10.0pt'>Interbase 6 or earlier.
1845 Some users report you might need to use this<br>
1846 $db->PConnect('localhost:c:/ibase/employee.gdb', "sysdba",
1847 "masterkey") to connect. Lacks Affected_Rows currently.<br>
1849 You can set $db->role, $db->dialect, $db->buffers and
1850 $db->charSet before connecting.</span></p>
1852 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1853 <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
1855 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1856 <p class=MsoNormal><span style='font-size:10.0pt'>Interbase client</span></p>
1858 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1859 <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows</span></p>
1862 <tr style='mso-yfti-irow:10'>
1863 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1864 <p class=MsoNormal><b><i><span style='font-size:10.0pt'>firebird</span></i></b></p>
1866 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1867 <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
1869 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1870 <p class=MsoNormal><span style='font-size:10.0pt'>Firebird version of
1871 interbase.</span></p>
1873 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1874 <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
1876 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1877 <p class=MsoNormal><span style='font-size:10.0pt'>Interbase client</span></p>
1879 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1880 <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows</span></p>
1883 <tr style='mso-yfti-irow:11'>
1884 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1885 <p class=MsoNormal><b><i><span style='font-size:10.0pt'>borland_ibase</span></i></b></p>
1887 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1888 <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
1890 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1891 <p class=MsoNormal><span style='font-size:10.0pt'>Borland version of
1892 Interbase 6.5 or later. Very sad that the forks differ.</span></p>
1894 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1895 <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
1897 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1898 <p class=MsoNormal><span style='font-size:10.0pt'>Interbase client</span></p>
1900 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1901 <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows</span></p>
1904 <tr style='mso-yfti-irow:12'>
1905 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1906 <p class=MsoNormal><b><span style='font-size:10.0pt'>informix</span></b></p>
1908 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1909 <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
1911 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1912 <p class=MsoNormal><span style='font-size:10.0pt'>Generic informix driver.
1913 Use this if you are using Informix 7.3 or later.</span></p>
1915 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1916 <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
1918 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1919 <p class=MsoNormal><span style='font-size:10.0pt'>Informix client</span></p>
1921 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1922 <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows</span></p>
1925 <tr style='mso-yfti-irow:13'>
1926 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1927 <p class=MsoNormal><b><span style='font-size:10.0pt'>informix72</span></b></p>
1929 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1930 <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
1932 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1933 <p class=MsoNormal><span style='font-size:10.0pt'>Informix databases before
1934 Informix 7.3 that do no support SELECT FIRST.</span></p>
1936 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1937 <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
1939 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1940 <p class=MsoNormal><span style='font-size:10.0pt'>Informix client</span></p>
1942 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1943 <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows</span></p>
1946 <tr style='mso-yfti-irow:14'>
1947 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1948 <p class=MsoNormal><b><span style='font-size:10.0pt'>ldap</span></b></p>
1950 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1951 <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
1953 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1954 <p class=MsoNormal><span style='font-size:10.0pt'>LDAP driver. See this
1955 example for usage information.</span></p>
1957 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1958 <p class=MsoNormal> </p>
1960 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1961 <p class=MsoNormal><span style='font-size:10.0pt'>LDAP extension</span></p>
1963 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
1964 <p class=MsoNormal><span style='font-size:10.0pt'>?</span></p>
1967 <tr style='mso-yfti-irow:15;height:54.75pt'>
1968 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:54.75pt'>
1969 <p class=MsoNormal><b><span style='font-size:10.0pt'>mssql</span></b></p>
1971 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:54.75pt'>
1972 <p class=MsoNormal><span style='font-size:10.0pt'>A</span></p>
1974 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:54.75pt'>
1975 <p><span style='font-size:10.0pt'>Microsoft SQL Server 7 and later. Works
1976 with Microsoft SQL Server 2000 also. Note that date formating is problematic
1977 with this driver. For example, the PHP mssql extension does not return the
1978 seconds for datetime!</span></p>
1980 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:54.75pt'>
1981 <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
1983 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:54.75pt'>
1984 <p class=MsoNormal><span style='font-size:10.0pt'>Mssql client</span></p>
1986 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:54.75pt'>
1987 <p><span style='font-size:10.0pt'>Unix and Windows. <br>
1988 <a href="http://phpbuilder.com/columns/alberto20000919.php3">Unix install
1990 href="http://linuxjournal.com/article.php?sid=6636&mode=thread&order=0">another
1991 one</a>. </span></p>
1994 <tr style='mso-yfti-irow:16;height:54.75pt'>
1995 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:54.75pt'>
1996 <p class=MsoNormal><b><span style='font-size:10.0pt'>mssqlpo</span></b></p>
1998 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:54.75pt'>
1999 <p class=MsoNormal><span style='font-size:10.0pt'>A</span></p>
2001 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:54.75pt'>
2002 <p><span style='font-size:10.0pt'>Portable mssql driver. Identical to above mssql
2003 driver, except that '||', the concatenation operator, is converted to '+'.
2004 Useful for porting scripts from most other sql variants that use ||.</span></p>
2006 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:54.75pt'>
2007 <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
2009 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:54.75pt'>
2010 <p class=MsoNormal><span style='font-size:10.0pt'>Mssql client</span></p>
2012 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:54.75pt'>
2013 <p><span style='font-size:10.0pt'>Unix and Windows. <a
2014 href="http://phpbuilder.com/columns/alberto20000919.php3"><br>
2015 Unix install howto</a>.</span></p>
2018 <tr style='mso-yfti-irow:17;height:54.75pt'>
2019 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:54.75pt'>
2020 <p class=MsoNormal><b><span style='font-size:10.0pt'>mssqlnative</span></b></p>
2022 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:54.75pt'>
2023 <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
2025 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:54.75pt'>
2026 <p><span style='font-size:10.0pt'>Native mssql driver from M'soft. Use with PHP 5.3 or later. </span></p>
2028 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:54.75pt'>
2029 <p class=MsoNormal><span style='font-size:10.0pt'>?</span></p>
2031 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:54.75pt'>
2032 <p class=MsoNormal><span style='font-size:10.0pt'>?</span></p>
2034 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:54.75pt'>
2035 <p><span style='font-size:10.0pt'>Windows. Tq Garrett Serack of M'soft.</span></p>
2038 <tr style='mso-yfti-irow:18'>
2039 <td style='padding:.75pt .75pt .75pt .75pt'>
2040 <p class=MsoNormal><o:p> </o:p></p>
2042 <td style='border:none;padding:.75pt .75pt .75pt .75pt'>
2043 <p class=MsoNormal><span style='font-size:10.0pt;color:windowtext'><o:p> </o:p></span></p>
2045 <td style='border:none;padding:.75pt .75pt .75pt .75pt'>
2046 <p class=MsoNormal><span style='font-size:10.0pt;color:windowtext'><o:p> </o:p></span></p>
2048 <td style='border:none;padding:.75pt .75pt .75pt .75pt'>
2049 <p class=MsoNormal><span style='font-size:10.0pt;color:windowtext'><o:p> </o:p></span></p>
2051 <td style='border:none;padding:.75pt .75pt .75pt .75pt'>
2052 <p class=MsoNormal><span style='font-size:10.0pt;color:windowtext'><o:p> </o:p></span></p>
2054 <td style='border:none;padding:.75pt .75pt .75pt .75pt'>
2055 <p class=MsoNormal><span style='font-size:10.0pt;color:windowtext'><o:p> </o:p></span></p>
2058 <tr style='mso-yfti-irow:19'>
2059 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2060 <p class=MsoNormal><b><span style='font-size:10.0pt'>mysql</span></b></p>
2062 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2063 <p class=MsoNormal><span style='font-size:10.0pt'>A</span></p>
2065 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2066 <p class=MsoNormal><span style='font-size:10.0pt'>MySQL without transaction
2067 support. You can also set $db->clientFlags before connecting.</span></p>
2069 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2070 <p class=MsoNormal><span style='font-size:10.0pt'>Y</span></p>
2072 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2073 <p class=MsoNormal><span style='font-size:10.0pt'>MySQL client</span></p>
2075 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2076 <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows</span></p>
2079 <tr style='mso-yfti-irow:20'>
2080 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2081 <p class=MsoNormal><b><span style='font-size:10.0pt'>mysqlt</span></b><span
2082 style='font-size:10.0pt'> or <b>maxsql</b></span></p>
2084 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2085 <p class=MsoNormal><span style='font-size:10.0pt'>A</span></p>
2087 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2088 <p><span style='font-size:10.0pt'>MySQL with transaction support. We
2089 recommend using || as the concat operator for best portability. This can be
2090 done by running MySQL using: <br>
2091 <i>mysqld --ansi</i> or <i>mysqld --sql-mode=PIPES_AS_CONCAT</i></span></p>
2093 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2094 <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
2096 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2097 <p class=MsoNormal><span style='font-size:10.0pt'>MySQL client</span></p>
2099 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2100 <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows</span></p>
2103 <tr style='mso-yfti-irow:21'>
2104 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2105 <p class=MsoNormal><b><span style='font-size:10.0pt'>oci8</span></b></p>
2107 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2108 <p class=MsoNormal><span style='font-size:10.0pt'>A</span></p>
2110 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2111 <p class=MsoNormal><span style='font-size:10.0pt'>Oracle 8/9. Has more
2112 functionality than <i>oracle</i> driver (eg. Affected_Rows). You might have
2113 to putenv('ORACLE_HOME=...') before Connect/PConnect. </span></p>
2114 <p><span style='font-size:10.0pt'>There are 2 ways of connecting - with
2115 server IP and service name: <br>
2116 <i>PConnect('serverip:1521','scott','tiger','service'</i>)<br>
2117 or using an entry in TNSNAMES.ORA or ONAMES or HOSTNAMES: <br>
2118 <i>PConnect(false, 'scott', 'tiger', $oraname)</i>. </span></p>
2119 <p><span style='font-size:10.0pt'>Since 2.31, we support Oracle REF cursor
2120 variables directly (see <a href="#executecursor">ExecuteCursor</a>).</span> </p>
2122 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2123 <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
2125 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2126 <p class=MsoNormal><span style='font-size:10.0pt'>Oracle client</span></p>
2128 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2129 <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows</span></p>
2132 <tr style='mso-yfti-irow:22'>
2133 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2134 <p class=MsoNormal><b><span style='font-size:10.0pt'>oci805</span></b></p>
2136 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2137 <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
2139 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2140 <p class=MsoNormal><span style='font-size:10.0pt'>Supports reduced Oracle
2141 functionality for Oracle 8.0.5. SelectLimit is not as efficient as in the
2142 oci8 or oci8po drivers.</span></p>
2144 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2145 <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
2147 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2148 <p class=MsoNormal><span style='font-size:10.0pt'>Oracle client</span></p>
2150 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2151 <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows</span></p>
2154 <tr style='mso-yfti-irow:23'>
2155 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2156 <p class=MsoNormal><b><span style='font-size:10.0pt'>oci8po</span></b></p>
2158 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2159 <p class=MsoNormal><span style='font-size:10.0pt'>A</span></p>
2161 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2162 <p class=MsoNormal><span style='font-size:10.0pt'>Oracle 8/9 portable driver.
2163 This is nearly identical with the oci8 driver except (a) bind variables in
2164 Prepare() use the ? convention, instead of :bindvar, (b) field names use the
2165 more common PHP convention of lowercase names. </span></p>
2166 <p><span style='font-size:10.0pt'>Use this driver if porting from other
2167 databases is important. Otherwise the oci8 driver offers better performance. </span></p>
2169 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2170 <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
2172 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2173 <p class=MsoNormal><span style='font-size:10.0pt'>Oracle client</span></p>
2175 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2176 <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows</span></p>
2179 <tr style='mso-yfti-irow:24'>
2180 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2181 <p class=MsoNormal><b><span style='font-size:10.0pt'>odbc</span></b></p>
2183 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2184 <p class=MsoNormal><span style='font-size:10.0pt'>A</span></p>
2186 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2187 <p class=MsoNormal><span style='font-size:10.0pt'>Generic ODBC, not tuned for
2188 specific databases. To connect, use <br>
2189 PConnect('DSN','user','pwd'). This is the base class for all odbc derived
2192 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2193 <p class=MsoNormal><span style='font-size:10.0pt'>? depends on database</span></p>
2195 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2196 <p class=MsoNormal><span style='font-size:10.0pt'>ODBC</span></p>
2198 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2199 <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows. <a
2200 href="http://phpbuilder.com/columns/alberto20000919.php3?page=4">Unix hints.</a></span></p>
2203 <tr style='mso-yfti-irow:25'>
2204 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2205 <p class=MsoNormal><b><span style='font-size:10.0pt'>odbc_mssql</span></b></p>
2207 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2208 <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
2210 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2211 <p class=MsoNormal><span style='font-size:10.0pt'>Uses ODBC to connect to
2214 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2215 <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
2217 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2218 <p class=MsoNormal><span style='font-size:10.0pt'>ODBC</span></p>
2220 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2221 <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows. </span></p>
2224 <tr style='mso-yfti-irow:26'>
2225 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2226 <p class=MsoNormal><b><span style='font-size:10.0pt'>odbc_oracle</span></b></p>
2228 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2229 <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
2231 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2232 <p class=MsoNormal><span style='font-size:10.0pt'>Uses ODBC to connect to
2235 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2236 <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
2238 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2239 <p class=MsoNormal><span style='font-size:10.0pt'>ODBC</span></p>
2241 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2242 <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows. </span></p>
2245 <tr style='mso-yfti-irow:27'>
2246 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2247 <p class=MsoNormal><b><span style='font-size:10.0pt'>odbtp</span></b></p>
2249 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2250 <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
2252 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2253 <p class=MsoNormal><span style='font-size:10.0pt'>Generic odbtp driver. <a
2254 href="http://odbtp.sourceforge.net/">Odbtp</a> is a software for accessing
2255 Windows ODBC data sources from other operating systems.</span></p>
2257 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2258 <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
2260 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2261 <p class=MsoNormal><span style='font-size:10.0pt'>odbtp</span></p>
2263 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2264 <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows</span></p>
2267 <tr style='mso-yfti-irow:28'>
2268 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2269 <p class=MsoNormal><b><span style='font-size:10.0pt'>odbtp_unicode</span></b></p>
2271 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2272 <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
2274 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2275 <p class=MsoNormal><span style='font-size:10.0pt'>Odtbp with unicode support</span></p>
2277 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2278 <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
2280 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2281 <p class=MsoNormal><span style='font-size:10.0pt'>odbtp</span></p>
2283 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2284 <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows</span></p>
2287 <tr style='mso-yfti-irow:29;height:25.5pt'>
2288 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:25.5pt'>
2289 <p class=MsoNormal><b><span style='font-size:10.0pt'>oracle</span></b></p>
2291 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:25.5pt'>
2292 <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
2294 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:25.5pt'>
2295 <p class=MsoNormal><span style='font-size:10.0pt'>Implements old Oracle 7
2296 client API. Use oci8 driver if possible for better performance.</span></p>
2298 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:25.5pt'>
2299 <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
2301 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:25.5pt'>
2302 <p class=MsoNormal><span style='font-size:10.0pt'>Oracle client</span></p>
2304 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:25.5pt'>
2305 <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows</span></p>
2308 <tr style='mso-yfti-irow:30;height:25.5pt'>
2309 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:25.5pt'>
2310 <p class=MsoNormal><b><span style='font-size:10.0pt'>netezza</span></b></p>
2312 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:25.5pt'>
2313 <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
2315 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:25.5pt'>
2316 <p class=MsoNormal><span style='font-size:10.0pt'>Netezza driver. Netezza is
2317 based on postgres code-base.</span></p>
2319 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:25.5pt'>
2320 <p class=MsoNormal><span style='font-size:10.0pt'>Y</span></p>
2322 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:25.5pt'>
2323 <p class=MsoNormal><span style='font-size:10.0pt'>?</span></p>
2325 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:25.5pt'>
2326 <p class=MsoNormal><span style='font-size:10.0pt'>?</span></p>
2329 <tr style='mso-yfti-irow:31'>
2330 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2331 <p class=MsoNormal><b><span style='font-size:10.0pt'>pdo</span></b></p>
2333 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2334 <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
2336 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2337 <p class=MsoNormal><span style='font-size:10.0pt'>Generic PDO driver for
2340 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2341 <p class=MsoNormal><span style='font-size:10.0pt'>Y</span></p>
2343 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2344 <p class=MsoNormal><span style='font-size:10.0pt'>PDO extension and database
2345 specific drivers</span></p>
2347 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2348 <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows. </span></p>
2351 <tr style='mso-yfti-irow:32'>
2352 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2353 <p class=MsoNormal><b><span style='font-size:10.0pt'>postgres</span></b></p>
2355 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2356 <p class=MsoNormal><span style='font-size:10.0pt'>A</span></p>
2358 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2359 <p class=MsoNormal><span style='font-size:10.0pt'>Generic PostgreSQL driver.
2360 Currently identical to postgres7 driver.</span></p>
2362 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2363 <p class=MsoNormal><span style='font-size:10.0pt'>Y</span></p>
2365 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2366 <p class=MsoNormal><span style='font-size:10.0pt'>PostgreSQL client</span></p>
2368 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2369 <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows. </span></p>
2372 <tr style='mso-yfti-irow:33'>
2373 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2374 <p class=MsoNormal><b><span style='font-size:10.0pt'>postgres64</span></b></p>
2376 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2377 <p class=MsoNormal><span style='font-size:10.0pt'>A</span></p>
2379 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2380 <p class=MsoNormal><span style='font-size:10.0pt'>For PostgreSQL 6.4 and
2381 earlier which does not support LIMIT internally.</span></p>
2383 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2384 <p class=MsoNormal><span style='font-size:10.0pt'>Y</span></p>
2386 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2387 <p class=MsoNormal><span style='font-size:10.0pt'>PostgreSQL client</span></p>
2389 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2390 <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows. </span></p>
2393 <tr style='mso-yfti-irow:34'>
2394 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2395 <p class=MsoNormal><b><span style='font-size:10.0pt'>postgres7</span></b></p>
2397 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2398 <p class=MsoNormal><span style='font-size:10.0pt'>A</span></p>
2400 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2401 <p class=MsoNormal><span style='font-size:10.0pt'>PostgreSQL which supports
2402 LIMIT and other version 7 functionality.</span></p>
2404 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2405 <p class=MsoNormal><span style='font-size:10.0pt'>Y</span></p>
2407 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2408 <p class=MsoNormal><span style='font-size:10.0pt'>PostgreSQL client</span></p>
2410 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2411 <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows. </span></p>
2414 <tr style='mso-yfti-irow:35'>
2415 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2416 <p class=MsoNormal><b><span style='font-size:10.0pt'>postgres8</span></b></p>
2418 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2419 <p class=MsoNormal><span style='font-size:10.0pt'>A</span></p>
2421 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2422 <p class=MsoNormal><span style='font-size:10.0pt'>PostgreSQL which supports
2423 version 8 functionality.</span></p>
2425 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2426 <p class=MsoNormal><span style='font-size:10.0pt'>Y</span></p>
2428 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2429 <p class=MsoNormal><span style='font-size:10.0pt'>PostgreSQL client</span></p>
2431 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2432 <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows. </span></p>
2435 <tr style='mso-yfti-irow:35'>
2436 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2437 <p class=MsoNormal><b><span style='font-size:10.0pt'>postgres9</span></b></p>
2439 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2440 <p class=MsoNormal><span style='font-size:10.0pt'>A</span></p>
2442 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2443 <p class=MsoNormal><span style='font-size:10.0pt'>PostgreSQL which supports
2444 version 9 functionality.</span></p>
2446 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2447 <p class=MsoNormal><span style='font-size:10.0pt'>Y</span></p>
2449 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2450 <p class=MsoNormal><span style='font-size:10.0pt'>PostgreSQL client</span></p>
2452 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2453 <p class=MsoNormal><span style='font-size:10.0pt'>Unix and Windows. </span></p>
2456 <tr style='mso-yfti-irow:36'>
2457 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2458 <p class=MsoNormal><b><span style='font-size:10.0pt'>sapdb</span></b></p>
2460 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2461 <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
2463 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2464 <p class=MsoNormal><span style='font-size:10.0pt'>SAP DB. Should work
2465 reliably as based on ODBC driver.</span></p>
2467 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2468 <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
2470 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2471 <p class=MsoNormal><span style='font-size:10.0pt'>SAP ODBC client</span></p>
2473 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2474 <p><span style='font-size:10.0pt'>?</span></p>
2477 <tr style='mso-yfti-irow:37'>
2478 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2479 <p class=MsoNormal><b><span style='font-size:10.0pt'>sqlanywhere</span></b></p>
2481 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2482 <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
2484 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2485 <p class=MsoNormal><span style='font-size:10.0pt'>Sybase SQL Anywhere. Should
2486 work reliably as based on ODBC driver.</span></p>
2488 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2489 <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
2491 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2492 <p class=MsoNormal><span style='font-size:10.0pt'>SQL Anywhere ODBC client</span></p>
2494 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2495 <p><span style='font-size:10.0pt'>?</span></p>
2498 <tr style='mso-yfti-irow:38;height:40.5pt'>
2499 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
2500 <p class=MsoNormal><b><span style='font-size:10.0pt'>sqlite</span></b></p>
2502 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
2503 <p class=MsoNormal><span style='font-size:10.0pt'>B</span></p>
2505 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
2506 <p class=MsoNormal><span style='font-size:10.0pt'>SQLite.</span></p>
2508 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
2509 <p class=MsoNormal><span style='font-size:10.0pt'>Y</span></p>
2511 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
2512 <p class=MsoNormal><span style='font-size:10.0pt'>-</span></p>
2514 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
2515 <p><span style='font-size:10.0pt'>Unix and Windows.</span></p>
2518 <tr style='mso-yfti-irow:39;height:40.5pt'>
2519 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
2520 <p class=MsoNormal><b><span style='font-size:10.0pt'>sqlitepo</span></b></p>
2522 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
2523 <p class=MsoNormal><span style='font-size:10.0pt'>B</span></p>
2525 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
2526 <p class=MsoNormal><span style='font-size:10.0pt'>Portable SQLite driver. This
2527 is because assoc mode does not work like other drivers in sqlite. Namely,
2528 when selecting (joining) multiple tables, the table names are included in the
2529 assoc keys in the "sqlite" driver.</span></p>
2530 <p><span style='font-size:10.0pt'>In "sqlitepo" driver, the table
2531 names are stripped from the returned column names. When this results in a
2532 conflict, the first field get preference. </span></p>
2534 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
2535 <p class=MsoNormal><span style='font-size:10.0pt'>Y</span></p>
2537 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
2538 <p class=MsoNormal><span style='font-size:10.0pt'>-</span></p>
2540 <td valign=top style='padding:.75pt .75pt .75pt .75pt;height:40.5pt'>
2541 <p><span style='font-size:10.0pt'>Unix and Windows.</span></p>
2544 <tr style='mso-yfti-irow:40'>
2545 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2546 <p class=MsoNormal><b><span style='font-size:10.0pt'>sybase</span></b></p>
2548 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2549 <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
2551 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2552 <p class=MsoNormal><span style='font-size:10.0pt'>Sybase. </span></p>
2554 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2555 <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
2557 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2558 <p class=MsoNormal><span style='font-size:10.0pt'>Sybase client</span></p>
2560 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2561 <p><span style='font-size:10.0pt'>Unix and Windows.</span></p>
2564 <tr style='mso-yfti-irow:41;mso-yfti-lastrow:yes'>
2565 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2566 <p class=MsoNormal><b><span style='font-size:10.0pt'>sybase_ase</span></b></p>
2568 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2569 <p class=MsoNormal><span style='font-size:10.0pt'>C</span></p>
2571 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2572 <p class=MsoNormal><span style='font-size:10.0pt'>Sybase ASE. </span></p>
2574 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2575 <p class=MsoNormal><span style='font-size:10.0pt'>Y/N</span></p>
2577 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2578 <p class=MsoNormal><span style='font-size:10.0pt'>Sybase client</span></p>
2580 <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
2581 <p><span style='font-size:10.0pt'>Unix and Windows.</span></p>
2586 <p>The "Tested" column indicates how extensively the code has been
2587 tested and used. <br>
2588 A = well tested and used by many people<br>
2589 B = tested and usable, but some features might not be implemented<br>
2590 C = user contributed or experimental driver. Might not fully support all of the
2591 latest features of ADOdb. </p>
2593 <p>The column "RecordCount() usable" indicates whether RecordCount()
2594 return the number of rows, or returns -1 when a SELECT statement is executed.
2595 If this column displays Y/N then the RecordCount() is emulated when the global
2596 variable $ADODB_COUNTRECS=true (this is the default). Note that for large
2597 recordsets, it might be better to disable RecordCount() emulation because
2598 substantial amounts of memory are required to cache the recordset for counting.
2599 Also there is a speed penalty of 40-50% if emulation is required. This is
2600 emulated in most databases except for PostgreSQL and MySQL. This variable is
2601 checked every time a query is executed, so you can selectively choose which
2602 recordsets to count.</p>
2604 <div class=MsoNormal align=center style='text-align:center'>
2606 <hr size=2 width="100%" align=center>
2610 <h1>Tutorials<a name=quickstart></a></h1>
2612 <h3>Example 1: Select Statement<a name=ex1></a></h3>
2614 <p>Task: Connect to the Access Northwind DSN, display the first 2 columns of
2617 <p>In this example, we create a ADOConnection object, which represents the
2618 connection to the database. The connection is initiated with <a href="#pconnect"><span
2619 style='font-family:"Courier New"'>PConnect</span></a>, which is a persistent
2620 connection. Whenever we want to query the database, we call the <span
2621 style='font-family:"Courier New"'>ADOConnection.<a href="#execute">Execute</a>()</span>
2622 function. This returns an ADORecordSet object which is actually a cursor that
2623 holds the current row in the array <span style='font-family:"Courier New"'>fields[]</span>.
2624 We use <span style='font-family:"Courier New"'><a href="#movenext">MoveNext</a>()</span>
2625 to move from row to row.</p>
2627 <p>NB: A useful function that is not used in this example is <span
2628 style='font-family:"Courier New"'><a href="#selectlimit">SelectLimit</a></span>,
2629 which allows us to limit the number of rows shown. </p>
2631 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
2632 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><?<br>
2633 <b>include</b>('adodb.inc.php');<span style='mso-tab-count:1'> </span><span style='mso-spacerun:yes'> </span># load code common to ADOdb<br>
2634 $<span style='color:#660000'>conn</span> = &ADONewConnection('access');<span
2635 style='mso-tab-count:1'> </span># create a connection<br>
2636 $<span style='color:#660000'>conn</span>->PConnect('northwind');<span style='mso-spacerun:yes'> </span># connect to MS-Access, northwind DSN<br>
2637 $<span style='color:#660000'>recordSet</span> = &$<span style='color:#660000'>conn</span>->Execute('select * from products');<br>
2638 if (!$<span style='color:#660000'>recordSet</span>) <br>
2639 <span style='mso-tab-count:1'> </span>print $<span style='color:#660000'>conn</span>->ErrorMsg();<br>
2641 <b>while</b> (!$<span style='color:#660000'>recordSet</span>->EOF) {<br>
2642 <span style='mso-tab-count:1'> </span><b>print</b> $<span
2643 style='color:#660000'>recordSet</span>->fields[0].' '.$<span
2644 style='color:#660000'>recordSet</span>->fields[1].'<BR>';<br>
2645 <span style='mso-tab-count:1'> </span>$<span style='color:#660000'>recordSet</span>->MoveNext();<br>
2646 }</pre><pre><o:p> </o:p></pre><pre>$<span style='color:#660000'>recordSet</span>->Close(); # optional<br>
2647 $<span style='color:#660000'>conn</span>->Close(); # optional<br
2648 style='mso-special-character:line-break'>
2649 <![if !supportLineBreakNewLine]><br style='mso-special-character:line-break'>
2650 <![endif]></pre><pre>?></pre></div>
2652 <p>The $<span style='font-family:"Courier New"'>recordSet</span> returned
2653 stores the current row in the <span style='font-family:"Courier New"'>$recordSet->fields</span>
2654 array, indexed by column number (starting from zero). We use the <span
2655 style='font-family:"Courier New"'><a href="#movenext">MoveNext</a>()</span>
2656 function to move to the next row. The <span style='font-family:"Courier New"'>EOF</span>
2657 property is set to true when end-of-file is reached. If an error occurs in
2658 Execute(), we return false instead of a recordset.</p>
2660 <p>The <code><span style='font-size:10.0pt'>$recordSet->fields[]</span></code>
2661 array is generated by the PHP database extension. Some database extensions only
2662 index by number and do not index the array by field name. To force indexing by
2663 name - that is associative arrays - use the SetFetchMode function. Each
2664 recordset saves and uses whatever fetch mode was set when the recordset was
2665 created in Execute() or SelectLimit(). </p>
2667 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
2668 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span
2669 style='mso-tab-count:1'> </span>$db->SetFetchMode(ADODB_FETCH_NUM);<br>
2670 <span style='mso-tab-count:1'> </span>$rs1 = $db->Execute('select * from table');<br>
2671 <span style='mso-tab-count:1'> </span>$db->SetFetchMode(ADODB_FETCH_ASSOC);<br>
2672 <span style='mso-tab-count:1'> </span>$rs2 = $db->Execute('select * from table');<br>
2673 <span style='mso-tab-count:1'> </span>print_r($rs1->fields); # shows <i>array([0]=>'v0',[1] =>'v1')</i></pre><pre><span
2674 style='mso-tab-count:1'> </span>print_r($rs2->fields); # shows <i>array(['col1']=>'v0',['col2'] =>'v1')</i></pre></div>
2676 <p>To get the number of rows in the select statement, you can use <span
2677 style='font-family:"Courier New"'>$recordSet-><a href="#recordcount">RecordCount</a>()</span>.
2678 Note that it can return -1 if the number of rows returned cannot be determined.</p>
2680 <h3>Example 2: Advanced Select with Field Objects<a name=ex2></a></h3>
2682 <p>Select a table, display the first two columns. If the second column is a
2683 date or timestamp, reformat the date to <st1:country-region w:st="on"><st1:place
2684 w:st="on">US</st1:place></st1:country-region> format.</p>
2686 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
2687 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><?<br>
2688 <b>include</b>('adodb.inc.php');<span style='mso-tab-count:1'> </span><span style='mso-spacerun:yes'> </span># load code common to ADOdb<br>
2689 $<span style='color:#660000'>conn</span> = &ADONewConnection('access');<span
2690 style='mso-tab-count:1'> </span># create a connection<br>
2691 $<span style='color:#660000'>conn</span>->PConnect('northwind');<span style='mso-spacerun:yes'> </span># connect to MS-Access, northwind dsn<br>
2692 $<span style='color:#660000'>recordSet</span> = &$<span style='color:#660000'>conn</span>->Execute('select CustomerID,OrderDate from Orders');<br>
2693 if (!$<span style='color:#660000'>recordSet</span>) <br>
2694 <span style='mso-tab-count:1'> </span>print $<span style='color:#660000'>conn</span>->ErrorMsg();<br>
2696 <b>while</b> (!$<span style='color:#660000'>recordSet</span>->EOF) {<br>
2697 <span style='mso-tab-count:1'> </span>$<span style='color:#660000'>fld</span> = <b><span
2698 style='color:#336600'>$</span></b><span style='color:#660000'>recordSet</span><b><span
2699 style='color:#336600'>->FetchField</span></b><span style='color:#006600'>(</span>1<span
2700 style='color:#006600'>);</span></pre><pre><span style='mso-tab-count:1'> </span>$<span
2701 style='color:#660000'>type</span> = <b><span style='color:#336600'>$</span></b><span
2702 style='color:#660000'>recordSet</span><b><span style='color:#336600'>->MetaType</span></b>($fld->type);<br>
2704 <span style='mso-tab-count:1'> </span><b>if</b> ( $<span
2705 style='color:#660000'>type</span> == 'D' || $<span style='color:#660000'>type</span> == 'T') <br>
2706 <span style='mso-tab-count:2'> </span><b>print</b> $<span
2707 style='color:#660000'>recordSet</span>->fields[0].' '.<br>
2708 <span style='mso-tab-count:3'> </span><b><span
2709 style='color:#336600'>$</span></b><span style='color:#660000'>recordSet</span><b><span
2710 style='color:#336600'>->UserDate</span></b>($<span style='color:#660000'>recordSet</span>->fields[1],'<b>m/d/Y</b>').'<BR>';<br>
2711 <span style='mso-tab-count:1'> </span><b>else </b></pre><pre><span
2712 style='mso-tab-count:2'> </span><b>print</b> $<span
2713 style='color:#660000'>recordSet</span>->fields[0].' '.$<span
2714 style='color:#660000'>recordSet</span>->fields[1].'<BR>';<br>
2716 <span style='mso-tab-count:1'> </span>$<span style='color:#660000'>recordSet</span>->MoveNext();<br>
2717 }</pre><pre>$<span style='color:#660000'>recordSet</span>->Close(); # optional<br>
2718 $<span style='color:#660000'>conn</span>->Close(); # optional<br
2719 style='mso-special-character:line-break'>
2720 <![if !supportLineBreakNewLine]><br style='mso-special-character:line-break'>
2721 <![endif]></pre><pre>?></pre></div>
2723 <p>In this example, we check the field type of the second column using <span
2724 style='font-family:"Courier New"'><a href="#fetchfield">FetchField</a>().</span>
2725 This returns an object with at least 3 fields.</p>
2728 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
2729 mso-list:l6 level1 lfo6;tab-stops:list 36.0pt'><b>name</b>: name of column</li>
2730 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
2731 mso-list:l6 level1 lfo6;tab-stops:list 36.0pt'><b>type</b>: native field
2733 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
2734 mso-list:l6 level1 lfo6;tab-stops:list 36.0pt'><b>max_length</b>: maximum
2735 length of field. Some databases such as MySQL do not return the maximum
2736 length of the field correctly. In these cases max_length will be set to
2740 <p>We then use <span style='font-family:"Courier New"'><a href="#metatype">MetaType</a>()</span>
2741 to translate the native type to a <i>generic</i> type. Currently the following <i>generic</i>
2742 types are defined:</p>
2745 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
2746 mso-list:l0 level1 lfo7;tab-stops:list 36.0pt'><b>C</b>: character fields
2747 that should be shown in a <input type="text"> tag.</li>
2748 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
2749 mso-list:l0 level1 lfo7;tab-stops:list 36.0pt'><b>X</b>: TeXt, large text
2750 fields that should be shown in a <textarea></li>
2751 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
2752 mso-list:l0 level1 lfo7;tab-stops:list 36.0pt'><b>B</b>: Blobs, or Binary
2753 Large Objects. Typically images. </li>
2754 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
2755 mso-list:l0 level1 lfo7;tab-stops:list 36.0pt'><b>D</b>: Date field</li>
2756 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
2757 mso-list:l0 level1 lfo7;tab-stops:list 36.0pt'><b>T</b>: Timestamp field</li>
2758 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
2759 mso-list:l0 level1 lfo7;tab-stops:list 36.0pt'><b>L</b>: Logical field
2760 (boolean or bit-field)</li>
2761 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
2762 mso-list:l0 level1 lfo7;tab-stops:list 36.0pt'><b>I</b>: Integer
2764 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
2765 mso-list:l0 level1 lfo7;tab-stops:list 36.0pt'><b>N</b>: Numeric field.
2766 Includes autoincrement, numeric, floating point, real and integer. </li>
2767 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
2768 mso-list:l0 level1 lfo7;tab-stops:list 36.0pt'><b>R</b>: Serial field.
2769 Includes serial, autoincrement integers. This works for selected
2773 <p>If the metatype is of type date or timestamp, then we print it using the
2774 user defined date format with <span style='font-family:"Courier New"'><a
2775 href="#userdate">UserDate</a>(),</span> which converts the PHP SQL date string
2776 format to a user defined one. Another use for <span style='font-family:"Courier New"'><a
2777 href="#metatype">MetaType</a>()</span> is data validation before doing an SQL
2778 insert or update.</p>
2780 <h3>Example 3: Inserting<a name=ex3></a></h3>
2782 <p>Insert a row to the Orders table containing dates and strings that need to
2783 be quoted before they can be accepted by the database, eg: the single-quote in
2784 the word <i>John's</i>.</p>
2786 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
2787 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
2788 style='background:#EEEEEE'><?<br>
2789 <b>include</b>('adodb.inc.php');<span style='mso-tab-count:1'> </span><span style='mso-spacerun:yes'> </span># load code common to ADOdb<br>
2790 $<span style='color:#660000'>conn</span> = &ADONewConnection('access');<span
2791 style='mso-tab-count:1'> </span># create a connection<br>
2793 $<span style='color:#660000'>conn</span>->PConnect('northwind');<span style='mso-spacerun:yes'> </span># connect to MS-Access, northwind dsn<br>
2794 $<span style='color:#660000'>shipto</span> = <b><span style='color:#006600'>$conn->qstr</span></b>("<i>John's Old Shoppe</i>");<br>
2796 $<span style='color:#660000'>sql</span> = "insert into orders (customerID,EmployeeID,OrderDate,ShipName) ";<br>
2797 $<span style='color:#660000'>sql</span> .= "values ('ANATR',2,".<b><span
2798 style='color:#006600'>$conn->DBDate(</span>time()</b><b><span
2799 style='color:#006600'>)</span></b><span style='color:#006600'>.</span>",$<span
2800 style='color:#660000'>shipto</span>)";<br>
2802 <b>if</b> ($<span style='color:#660000'>conn</span>->Execute($<span
2803 style='color:#660000'>sql</span>) <b><span style='color:#336600'>=== false</span></b>) {<br>
2804 <span style='mso-tab-count:1'> </span><b>print</b> 'error inserting: '.<b><span
2805 style='color:#336600'>$conn->ErrorMsg()</span></b>.'<BR>';<br>
2809 <p>In this example, we see the advanced date and quote handling facilities of
2810 ADOdb. The unix timestamp (which is a long integer) is appropriately formated
2811 for Access with <span style='font-family:"Courier New"'><a href="#dbdate">DBDate</a>()</span>,
2812 and the right escape character is used for quoting the <i>John's Old Shoppe</i>,
2813 which is<b> </b><i>John'<b>'</b>s Old Shoppe</i> and not PHP's default <i>John<b>'</b>s
2814 Old Shoppe</i> with <span style='font-family:"Courier New"'><a href="#qstr">qstr</a>()</span>.
2817 <p>Observe the error-handling of the Execute statement. False is returned by<span
2818 style='font-family:"Courier New"'> <a href="#execute">Execute</a>() </span>if
2819 an error occured. The error message for the last error that occurred is
2820 displayed in <span style='font-family:"Courier New"'><a href="#errormsg">ErrorMsg</a>()</span>.
2821 Note: <i>php_track_errors</i> might have to be enabled for error messages to be
2824 <h3>Example 4: Debugging<a name=ex4></a></h3>
2826 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
2827 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><?<br>
2828 <b>include</b>('adodb.inc.php');<span style='mso-tab-count:1'> </span><span style='mso-spacerun:yes'> </span># load code common to ADOdb<br>
2829 $<span style='color:#663300'>conn</span> = &ADONewConnection('access');<span
2830 style='mso-tab-count:1'> </span># create a connection<br>
2831 $<span style='color:#663300'>conn</span>->PConnect('northwind');<span style='mso-spacerun:yes'> </span># connect to MS-Access, northwind dsn<br>
2832 $<span style='color:#663300'>shipto</span> = <b>$conn->qstr</b>("John's Old Shoppe");<br>
2833 $<span style='color:#663300'>sql</span> = "insert into orders (customerID,EmployeeID,OrderDate,ShipName) ";<br>
2834 $<span style='color:#663300'>sql</span> .= "values ('ANATR',2,".$<span
2835 style='color:#663300'>conn</span>->FormatDate(time()).",$shipto)";<br>
2836 <b><span style='color:#336600'>$</span></b><b><span style='color:#663300'>conn</span></b><b><span
2837 style='color:#336600'>->debug = true;</span></b></pre><pre><b>if</b> ($<span
2838 style='color:#663300'>conn</span>->Execute($sql) <b>=== false</b>) <b>print</b> 'error inserting';</pre><pre>?></pre></div>
2840 <p>In the above example, we have turned on debugging by setting <b>debug = true</b>.
2841 This will display the SQL statement before execution, and also show any error
2842 messages. There is no need to call <span style='font-family:"Courier New"'><a
2843 href="#errormsg">ErrorMsg</a>()</span> in this case. For displaying the
2844 recordset, see the <span style='font-family:"Courier New"'><a href="#exrs2html">rs2html</a>()
2847 <p>Also see the section on <a href="#errorhandling">Custom Error Handlers</a>.</p>
2849 <h3>Example 5: MySQL and Menus<a name=ex5></a></h3>
2851 <p>Connect to MySQL database <i>agora</i>, and generate a <select> menu
2852 from an SQL statement where the <option> captions are in the 1st column,
2853 and the value to send back to the server is in the 2nd column.</p>
2855 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
2856 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
2857 style='background:#EEEEEE'><?<br>
2858 <b>include</b>('adodb.inc.php'); # load code common to ADOdb<br>
2859 $<span style='color:#663300'>conn</span> = &ADONewConnection('mysql');<span style='mso-spacerun:yes'> </span># create a connection<br>
2860 $<span style='color:#663300'>conn</span>->PConnect('localhost','userid','','agora');# connect to MySQL, agora db<br>
2861 $<span style='color:#663300'>sql</span> = 'select CustomerName, CustomerID from customers';<br>
2862 $<span style='color:#663300'>rs</span> = $<span style='color:#663300'>conn</span>->Execute($sql);<br>
2863 <b>print</b> <b><span style='color:#336600'>$</span></b><b><span
2864 style='color:#663300'>rs</span></b><b><span style='color:#336600'>->GetMenu('GetCust','Mary Rosli');<br>
2865 ?></span></b></pre></div>
2867 <p>Here we define a menu named GetCust, with the menu option 'Mary Rosli'
2868 selected. See <a href="#getmenu"><span style='font-family:"Courier New"'>GetMenu</span></a><span
2869 style='font-family:"Courier New"'>()</span>. We also have functions that return
2870 the recordset as an array: <span style='font-family:"Courier New"'><a
2871 href="#getarray">GetArray</a>()</span>, and as an associative array with the
2872 key being the first column: <a href="#getassoc1">GetAssoc</a>().</p>
2874 <h3>Example 6: Connecting to 2 Databases At Once<a name=ex6></a></h3>
2876 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
2877 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
2878 style='background:#EEEEEE'><?<br>
2879 <b>include</b>('adodb.inc.php');<span style='mso-tab-count:1'> </span> # load code common to ADOdb<br>
2880 $<span style='color:#663300'>conn1</span> = &ADONewConnection('mysql');<span style='mso-spacerun:yes'> </span># create a mysql connection<br>
2881 $<span style='color:#663300'>conn2</span> = &ADONewConnection('oracle');<span style='mso-spacerun:yes'> </span># create a oracle connection<br>
2883 $conn1->PConnect($server, $userid, $password, $database);<br>
2884 $conn2->PConnect(false, $ora_userid, $ora_pwd, $oraname);<br>
2886 $conn1->Execute('insert ...');<br>
2887 $conn2->Execute('update ...');<br>
2890 <h3>Example 7: Generating Update and Insert SQL<a name=ex7></a></h3>
2892 <p>Since ADOdb 4.56, we support <a
2893 href="reference.functions.getupdatesql.html#autoexecute">AutoExecute()</a>,
2894 which simplifies things by providing an advanced wrapper for GetInsertSQL() and
2895 GetUpdateSQL(). For example, an INSERT can be carried out with: </p>
2897 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
2898 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><o:p> </o:p></pre><pre><span style='mso-spacerun:yes'> </span>$record["firstname"] = "Bob"; </pre><pre><span style='mso-spacerun:yes'> </span>$record["lastname"] = "Smith"; </pre><pre><span style='mso-spacerun:yes'> </span>$record["created"] = time(); </pre><pre><span style='mso-spacerun:yes'> </span>$insertSQL = $conn->AutoExecute($rs, $record, 'INSERT'); </pre></div>
2900 <p class=MsoNormal>and an UPDATE with: </p>
2902 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
2903 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><o:p> </o:p></pre><pre><span style='mso-spacerun:yes'> </span>$record["firstname"] = "Caroline"; </pre><pre><span style='mso-spacerun:yes'> </span>$record["lastname"] = "Smith"; # Update Caroline's lastname from Miranda to Smith </pre><pre><span style='mso-spacerun:yes'> </span>$insertSQL = $conn->AutoExecute($rs, $record, 'UPDATE', 'id = 1'); </pre></div>
2905 <p>The rest of this section is out-of-date: </p>
2907 <p>ADOdb 1.31 and later supports two new recordset functions: GetUpdateSQL( )
2908 and GetInsertSQL( ). This allow you to perform a "SELECT * FROM table
2909 query WHERE...", make a copy of the $rs->fields, modify the fields, and
2910 then generate the SQL to update or insert into the table automatically. </p>
2912 <p>We show how the functions can be used when accessing a table with the
2913 following fields: (ID, FirstName, LastName, Created). </p>
2915 <p>Before these functions can be called, you need to initialize the recordset by
2916 performing a select on the table. Idea and code by Jonathan Younger
2917 jyounger#unilab.com. Since ADOdb 2.42, you can pass a table name instead of a
2918 recordset into GetInsertSQL (in $rs), and it will generate an insert statement
2919 for that table. </p>
2921 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
2922 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
2923 style='background:#EEEEEE'><?<br>
2924 #==============================================<br>
2925 # SAMPLE GetUpdateSQL() and GetInsertSQL() code<br>
2926 #==============================================<br>
2927 include('adodb.inc.php');<br>
2928 include('tohtml.inc.php');<br>
2930 #==========================<br>
2931 # This code tests an insert<br>
2933 $sql = "SELECT * FROM ADOXYZ WHERE id = -1"; <br>
2934 # Select an empty record from the database<br>
2936 $conn = &ADONewConnection("mysql");<span style='mso-spacerun:yes'> </span># create a connection<br>
2937 $conn->debug=1;<br>
2938 $conn->PConnect("localhost", "admin", "", "test"); # connect to MySQL, testdb<br>
2939 $rs = $conn->Execute($sql); # Execute the query and get the empty recordset<br>
2941 $record = array(); # Initialize an array to hold the record data to insert<br>
2943 # Set the values for the fields in the record<br>
2944 # Note that field names are case-insensitive<br>
2945 $record["firstname"] = "Bob";<br>
2946 $record["lastNamE"] = "Smith";<br>
2947 $record["creaTed"] = time();<br>
2949 # Pass the empty recordset and the array containing the data to insert<br>
2950 # into the GetInsertSQL function. The function will process the data and return<br>
2951 # a fully formatted insert sql statement.<br>
2952 $insertSQL = $conn->GetInsertSQL($rs, $record);<br>
2954 $conn->Execute($insertSQL); # Insert the record into the database<br>
2956 #==========================<br>
2957 # This code tests an update<br>
2959 $sql = "SELECT * FROM ADOXYZ WHERE id = 1"; <br>
2960 # Select a record to update<br>
2962 $rs = $conn->Execute($sql); # Execute the query and get the existing record to update<br>
2964 $record = array(); # Initialize an array to hold the record data to update<br>
2966 # Set the values for the fields in the record<br>
2967 # Note that field names are case-insensitive<br>
2968 $record["firstname"] = "Caroline";<br>
2969 $record["LasTnAme"] = "Smith"; # Update Caroline's lastname from Miranda to Smith<br>
2971 # Pass the single record recordset and the array containing the data to update<br>
2972 # into the GetUpdateSQL function. The function will process the data and return<br>
2973 # a fully formatted update sql statement with the correct WHERE clause.<br>
2974 # If the data has not changed, no recordset is returned<br>
2975 $updateSQL = $conn->GetUpdateSQL($rs, $record);<br>
2977 $conn->Execute($updateSQL); # Update the record in the database<br>
2978 $conn->Close();<br>
2981 <p class=MsoNormal><a name="ADODB_FORCE_TYPE"></a><b>$ADODB_FORCE_TYPE</b></p>
2983 <p>The behaviour of AutoExecute(), GetUpdateSQL() and GetInsertSQL() when
2984 converting empty or null PHP variables to SQL is controlled by the global
2985 $ADODB_FORCE_TYPE variable. Set it to one of the values below. Default is
2986 ADODB_FORCE_VALUE (3): </p>
2988 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
2989 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
2990 style='background:#EEEEEE'>0 = ignore empty fields. All empty fields in array are ignored.<br>
2991 1 = force null. All empty, php null and string 'null' fields are changed to sql NULL values.<br>
2992 2 = force empty. All empty, php null and string 'null' fields are changed to sql empty '' or 0 values.<br>
2993 3 = force value. Value is left as it is. Php null and string 'null' are set to sql NULL values and <br>
2994 <span style='mso-spacerun:yes'> </span>empty fields '' are set to empty '' sql values.<br>
2996 define('ADODB_FORCE_IGNORE',0);<br>
2997 define('ADODB_FORCE_NULL',1);<br>
2998 define('ADODB_FORCE_EMPTY',2);<br>
2999 define('ADODB_FORCE_VALUE',3);</pre></div>
3001 <p>Thanks to Niko (nuko#mbnet.fi) for the $ADODB_FORCE_TYPE code. </p>
3003 <p>Note: the constant ADODB_FORCE_NULLS is obsolete since 4.52 and is ignored.
3004 Set $ADODB_FORCE_TYPE = ADODB_FORCE_NULL for equivalent behaviour. </p>
3006 <p>Since 4.62, the table name to be used can be overridden by setting
3007 $rs->tableName before AutoExecute(), GetInsertSQL() or GetUpdateSQL() is
3010 <h3>Example 8: Implementing Scrolling with Next and Previous<a name=ex8></a></h3>
3012 <p>The following code creates a very simple recordset pager, where you can
3013 scroll from page to page of a recordset.</p>
3015 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
3016 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
3017 style='background:#EEEEEE'>include_once('../adodb.inc.php');<br>
3018 include_once('../adodb-pager.inc.php');<br>
3019 session_start();<br>
3021 $db = NewADOConnection('mysql');<br>
3023 $db->Connect('localhost','root','','xphplens');<br>
3025 $sql = "select * from adoxyz ";<br>
3027 $pager = new ADODB_Pager($db,$sql);<br>
3028 $pager->Render($rows_per_page=5);</pre></div>
3030 <p>This will create a basic record pager that looks like this: <a name=scr></a></p>
3032 <table class=MsoNormalTable border=1 cellpadding=0 style='mso-cellspacing:1.5pt;
3034 <tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes'>
3035 <td style='padding:.75pt .75pt .75pt .75pt'>
3036 <p class=MsoNormal><a href="#scr"><code><span style='font-size:10.0pt'>|<</span></code></a>
3037 <a href="#scr"><code><span style='font-size:10.0pt'><<</span></code></a>
3038 <a href="#scr"><code><span style='font-size:10.0pt'>>></span></code></a>
3039 <a href="#scr"><code><span style='font-size:10.0pt'>>|</span></code></a>
3043 <tr style='mso-yfti-irow:1'>
3044 <td style='padding:.75pt .75pt .75pt .75pt'>
3045 <table class=MsoNormalTable border=1 cellpadding=0 width="100%"
3046 style='width:100.0%;mso-cellspacing:1.5pt;background:white' cols=4>
3047 <tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes'>
3048 <td style='padding:.75pt .75pt .75pt .75pt'>
3049 <p class=MsoNormal align=center style='text-align:center'><b>ID<o:p></o:p></b></p>
3051 <td style='padding:.75pt .75pt .75pt .75pt'>
3052 <p class=MsoNormal align=center style='text-align:center'><b>First Name<o:p></o:p></b></p>
3054 <td style='padding:.75pt .75pt .75pt .75pt'>
3055 <p class=MsoNormal align=center style='text-align:center'><b>Last Name<o:p></o:p></b></p>
3057 <td style='padding:.75pt .75pt .75pt .75pt'>
3058 <p class=MsoNormal align=center style='text-align:center'><b>Date Created<o:p></o:p></b></p>
3061 <tr style='mso-yfti-irow:1'>
3062 <td style='padding:.75pt .75pt .75pt .75pt'>
3063 <p class=MsoNormal align=right style='text-align:right'>36 </p>
3065 <td style='padding:.75pt .75pt .75pt .75pt'>
3066 <p class=MsoNormal>Alan </p>
3068 <td style='padding:.75pt .75pt .75pt .75pt'>
3069 <p class=MsoNormal>Turing </p>
3071 <td style='padding:.75pt .75pt .75pt .75pt'>
3072 <p class=MsoNormal>Sat 06, Oct 2001 </p>
3075 <tr style='mso-yfti-irow:2'>
3076 <td style='padding:.75pt .75pt .75pt .75pt'>
3077 <p class=MsoNormal align=right style='text-align:right'>37 </p>
3079 <td style='padding:.75pt .75pt .75pt .75pt'>
3080 <p class=MsoNormal>Serena </p>
3082 <td style='padding:.75pt .75pt .75pt .75pt'>
3083 <p class=MsoNormal>Williams </p>
3085 <td style='padding:.75pt .75pt .75pt .75pt'>
3086 <p class=MsoNormal>Sat 06, Oct 2001 </p>
3089 <tr style='mso-yfti-irow:3'>
3090 <td style='padding:.75pt .75pt .75pt .75pt'>
3091 <p class=MsoNormal align=right style='text-align:right'>38 </p>
3093 <td style='padding:.75pt .75pt .75pt .75pt'>
3094 <p class=MsoNormal>Yat Sun </p>
3096 <td style='padding:.75pt .75pt .75pt .75pt'>
3097 <p class=MsoNormal>Sun </p>
3099 <td style='padding:.75pt .75pt .75pt .75pt'>
3100 <p class=MsoNormal>Sat 06, Oct 2001 </p>
3103 <tr style='mso-yfti-irow:4'>
3104 <td style='padding:.75pt .75pt .75pt .75pt'>
3105 <p class=MsoNormal align=right style='text-align:right'>39 </p>
3107 <td style='padding:.75pt .75pt .75pt .75pt'>
3108 <p class=MsoNormal>Wai Hun </p>
3110 <td style='padding:.75pt .75pt .75pt .75pt'>
3111 <p class=MsoNormal>See </p>
3113 <td style='padding:.75pt .75pt .75pt .75pt'>
3114 <p class=MsoNormal>Sat 06, Oct 2001 </p>
3117 <tr style='mso-yfti-irow:5;mso-yfti-lastrow:yes'>
3118 <td style='padding:.75pt .75pt .75pt .75pt'>
3119 <p class=MsoNormal align=right style='text-align:right'>40 </p>
3121 <td style='padding:.75pt .75pt .75pt .75pt'>
3122 <p class=MsoNormal>Steven </p>
3124 <td style='padding:.75pt .75pt .75pt .75pt'>
3125 <p class=MsoNormal>Oey </p>
3127 <td style='padding:.75pt .75pt .75pt .75pt'>
3128 <p class=MsoNormal>Sat 06, Oct 2001 </p>
3132 <p class=MsoNormal><o:p></o:p></p>
3135 <tr style='mso-yfti-irow:2;mso-yfti-lastrow:yes'>
3136 <td style='padding:.75pt .75pt .75pt .75pt'>
3137 <p class=MsoNormal><span style='font-size:10.0pt'>Page 8/10</span></p>
3142 <p>The number of rows to display at one time is controled by the Render($rows)
3143 method. If you do not pass any value to Render(), ADODB_Pager will default to
3144 10 records per page. </p>
3146 <p>You can control the column titles by modifying your SQL (supported by most
3149 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
3150 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
3151 style='background:#EEEEEE'>$sql = 'select id as "ID", firstname as "First Name", <br>
3152 <span style='mso-tab-count:2'> </span><span style='mso-spacerun:yes'> </span>lastname as "Last Name", created as "Date Created" <br>
3153 <span style='mso-tab-count:2'> </span>from adoxyz';</pre></div>
3155 <p>The above code can be found in the <i>adodb/tests/testpaging.php</i> example
3156 included with this release, and the class ADODB_Pager in <i>adodb/adodb-pager.inc.php</i>.
3157 The ADODB_Pager code can be adapted by a programmer so that the text links can
3158 be replaced by images, and the dull white background be replaced with more
3159 interesting colors. </p>
3161 <p>You can also allow display of html by setting $pager->htmlSpecialChars =
3164 <p>Some of the code used here was contributed by Iván Oliva and Cornel G. </p>
3166 <h3><a name=ex9></a>Example 9: Exporting in CSV or Tab-Delimited Format</h3>
3168 <p>We provide some helper functions to export in comma-separated-value (CSV)
3169 and tab-delimited formats:</p>
3171 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
3172 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><b>include_once('/path/to/adodb/toexport.inc.php');</b><br>
3173 include_once('/path/to/adodb/adodb.inc.php');<br style='mso-special-character:
3175 <![if !supportLineBreakNewLine]><br style='mso-special-character:line-break'>
3176 <![endif]></pre><pre style='background:#EEEEEE'>$db = &NewADOConnection('mysql');<br>
3177 $db->Connect($server, $userid, $password, $database);<br>
3179 $rs = $db->Execute('select fname as "First Name", surname as "Surname" from table');<br>
3181 print "<pre>";<br>
3182 print <b>rs2csv</b>($rs); # return a string, CSV format</pre>
3184 <p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
3185 background:#EEEEEE;border:none;mso-border-alt:solid #DDDDDD .75pt;padding:0cm;
3186 mso-padding-alt:9.0pt 18.0pt 9.0pt 18.0pt'><span style='font-size:9.0pt;
3187 font-family:"Courier New"'>print '<hr>';<br>
3189 $rs->MoveFirst(); # note, some databases do not support MoveFirst<br>
3190 print <b>rs2tab</b>($rs,<i>false</i>); # return a string, tab-delimited<br>
3191 <span style='mso-tab-count:6'> </span><span
3192 style='mso-spacerun:yes'> </span># false == suppress field names in first line<o:p></o:p></span></p>
3194 <pre style='background:#EEEEEE'>print '<hr>';<br>
3195 $rs->MoveFirst();<br>
3196 <b>rs2tabout</b>($rs); # send to stdout directly (there is also an rs2csvout function)<br>
3197 print "</pre>";<br>
3199 $rs->MoveFirst();<br>
3200 $fp = fopen($path, "w");<br>
3202 <span style='mso-spacerun:yes'> </span><b>rs2csvfile</b>($rs, $fp); # write to file (there is also an rs2tabfile function)<br>
3203 <span style='mso-spacerun:yes'> </span>fclose($fp);<br>
3206 <p>Carriage-returns or newlines are converted to spaces. Field names are
3207 returned in the first line of text. Strings containing the delimiter character
3208 are quoted with double-quotes. Double-quotes are double-quoted again. This
3209 conforms to Excel import and export guide-lines. </p>
3211 <p>All the above functions take as an optional last parameter, $addtitles which
3212 defaults to <i>true</i>. When set to <i>false</i> field names in the first line
3213 are suppressed. </p>
3215 <h3>Example 10: Recordset Filters<a name=ex10></a></h3>
3217 <p>Sometimes we want to pre-process all rows in a recordset before we use it.
3218 For example, we want to ucwords all text in recordset. </p>
3220 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
3221 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
3222 style='background:#EEEEEE'>include_once('adodb/rsfilter.inc.php');<br>
3223 include_once('adodb/adodb.inc.php');<br>
3225 // ucwords() every element in the recordset<br>
3226 function do_ucwords(&$arr,$rs)<br>
3228 <span style='mso-tab-count:1'> </span>foreach($arr as $k => $v) {<br>
3229 <span style='mso-tab-count:2'> </span>$arr[$k] = ucwords($v);<br>
3230 <span style='mso-tab-count:1'> </span>}<br>
3233 $db = NewADOConnection('mysql');<br>
3234 $db->PConnect('server','user','pwd','db');<br>
3236 $rs = $db->Execute('select ... from table');<br>
3237 $rs = <b>RSFilter</b>($rs,'do_ucwords');</pre></div>
3239 <p>The <i>RSFilter</i> function takes 2 parameters, the recordset, and the name
3240 of the <i>filter</i> function. It returns the processed recordset scrolled to
3241 the first record. The <i>filter</i> function takes two parameters, the current
3242 row as an array, and the recordset object. For future compatibility, you should
3243 not use the original recordset object. </p>
3245 <h3>Example 11:<a name=ex11></a> Smart Transactions</h3>
3247 <p class=MsoNormal>The old way of doing transactions required you to use </p>
3249 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
3250 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
3251 style='background:#EEEEEE'>$conn-><b>BeginTrans</b>();<br>
3252 $ok = $conn->Execute($sql);<br>
3253 if ($ok) $ok = $conn->Execute($sql2);<br>
3254 if (!$ok) $conn-><b>RollbackTrans</b>();<br>
3255 else $conn-><b>CommitTrans</b>();</pre></div>
3257 <p class=MsoNormal>This is very complicated for large projects because you have
3258 to track the error status. Smart Transactions is much simpler. You start a
3259 smart transaction by calling StartTrans(): </p>
3261 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
3262 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
3263 style='background:#EEEEEE'>$conn-><b>StartTrans</b>();<br>
3264 $conn->Execute($sql);<br>
3265 $conn->Execute($Sql2);<br>
3266 $conn-><b>CompleteTrans</b>();</pre></div>
3268 <p class=MsoNormal>CompleteTrans() detects when an SQL error occurs, and will
3269 Rollback/Commit as appropriate. To specificly force a rollback even if no error
3270 occured, use FailTrans(). Note that the rollback is done in CompleteTrans(),
3271 and not in FailTrans(). </p>
3273 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
3274 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
3275 style='background:#EEEEEE'>$conn-><b>StartTrans</b>();<br>
3276 $conn->Execute($sql);<br>
3277 if (!CheckRecords()) $conn-><strong><span style='font-family:"Courier New"'>FailTrans</span></strong>();<br>
3278 $conn->Execute($Sql2);<br>
3279 $conn-><b>CompleteTrans</b>();</pre></div>
3281 <p>You can also check if a transaction has failed, using HasFailedTrans(),
3282 which returns true if FailTrans() was called, or there was an error in the SQL
3283 execution. Make sure you call HasFailedTrans() before you call CompleteTrans(),
3284 as it is only works between StartTrans/CompleteTrans. </p>
3286 <p>Lastly, StartTrans/CompleteTrans is nestable, and only the outermost block
3287 is executed. In contrast, BeginTrans/CommitTrans/RollbackTrans is NOT nestable.
3290 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
3291 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre>$conn-><strong><span
3292 style='font-family:"Courier New"'>StartTrans</span></strong>();<br>
3293 $conn->Execute($sql);<br>
3294 <span style='mso-spacerun:yes'> </span>$conn-><strong><span
3295 style='font-family:"Courier New"'>StartTrans</span></strong>();<span style='mso-spacerun:yes'> </span><span
3296 style='color:#006600'># ignored</span></pre><pre><span style='mso-spacerun:yes'> </span>if (!CheckRecords()) $conn->FailTrans();</pre><pre><span style='mso-spacerun:yes'> </span>$conn-><strong><span
3297 style='font-family:"Courier New"'>CompleteTrans</span></strong>(); <span
3298 style='color:#006600'># ignored</span></pre><pre>$conn->Execute($Sql2);</pre><pre
3299 style='background:#EEEEEE'>$conn-><strong><span style='font-family:"Courier New"'>CompleteTrans</span></strong>();</pre></div>
3301 <p>Note: Savepoints are currently not supported. </p>
3303 <h2><a name=errorhandling></a>Using Custom Error Handlers and PEAR_Error</h2>
3305 <p>ADOdb supports PHP5 exceptions. Just include <i>adodb-exceptions.inc.php</i>
3306 and you can now catch exceptions on errors as they occur. </p>
3308 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
3309 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
3310 style='background:#EEEEEE'><span style='mso-tab-count:1'> </span><b>include("../adodb-exceptions.inc.php");</b> <br>
3311 <span style='mso-tab-count:1'> </span>include("../adodb.inc.php");<span
3312 style='mso-tab-count:1'> </span> <br>
3313 <span style='mso-tab-count:1'> </span>try { <br>
3314 <span style='mso-tab-count:2'> </span>$db = NewADOConnection("oci8://scott:bad-password@mytns/"); <br>
3315 <span style='mso-tab-count:1'> </span>} catch (exception $e) { <br>
3316 <span style='mso-tab-count:2'> </span>var_dump($e); <br>
3317 <span style='mso-tab-count:2'> </span>adodb_backtrace($e->gettrace());<br>
3318 <span style='mso-tab-count:1'> </span>} </pre></div>
3320 <p>ADOdb also provides two custom handlers which you can modify for your needs.
3321 The first one is in the <b>adodb-errorhandler.inc.php</b> file. This makes use
3322 of the standard PHP functions <a href="http://php.net/error_reporting">error_reporting</a>
3323 to control what error messages types to display, and <a
3324 href="http://php.net/trigger_error">trigger_error</a> which invokes the default
3325 PHP error handler. </p>
3327 <p>Including the above file will cause <i>trigger_error($errorstring,E_USER_ERROR)</i>
3328 to be called when<br>
3329 (a) Connect() or PConnect() fails, or <br>
3330 (b) a function that executes SQL statements such as Execute() or SelectLimit()
3332 (c) GenID() appears to go into an infinite loop. </p>
3334 <p>The $errorstring is generated by ADOdb and will contain useful debugging
3335 information similar to the error.log data generated below. This file
3336 adodb-errorhandler.inc.php should be included before you create any
3337 ADOConnection objects. </p>
3339 <p>If you define error_reporting(0), no errors will be passed to the error
3340 handler. If you set error_reporting(E_ALL), all errors will be passed to the
3341 error handler. You still need to use <b>ini_set("display_errors",
3342 "0" or "1")</b> to control the display of errors. </p>
3344 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
3345 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><?php<br>
3346 <b>error_reporting(E_ALL); # pass any error messages triggered to error handler<br>
3347 include('adodb-errorhandler.inc.php');</b></pre><pre>include('adodb.inc.php');</pre><pre>include('tohtml.inc.php');</pre><pre>$c = NewADOConnection('mysql');</pre><pre>$c->PConnect('localhost','root','','northwind');</pre><pre>$rs=$c->Execute('select * from productsz'); #invalid table productsz');</pre><pre>if ($rs) rs2html($rs);</pre><pre>?></pre></div>
3349 <p>If you want to log the error message, you can do so by defining the
3350 following optional constants ADODB_ERROR_LOG_TYPE and ADODB_ERROR_LOG_DEST.
3351 ADODB_ERROR_LOG_TYPE is the error log message type (see <a
3352 href="http://php.net/error_log">error_log</a> in the PHP manual). In this case
3353 we set it to 3, which means log to the file defined by the constant
3354 ADODB_ERROR_LOG_DEST. </p>
3356 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
3357 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><?php<br>
3358 <b>error_reporting(E_ALL); # report all errors<br>
3359 ini_set("display_errors", "0"); # but do not echo the errors<br>
3360 define('ADODB_ERROR_LOG_TYPE',3);<br>
3361 define('ADODB_ERROR_LOG_DEST','C:/errors.log');<br>
3362 include('adodb-errorhandler.inc.php');</b></pre><pre>include('adodb.inc.php');</pre><pre>include('tohtml.inc.php');</pre><pre><o:p> </o:p></pre><pre>$c = NewADOConnection('mysql');</pre><pre>$c->PConnect('localhost','root','','northwind');</pre><pre>$rs=$c->Execute('select * from productsz'); ## invalid table productsz</pre><pre>if ($rs) rs2html($rs);</pre><pre>?></pre></div>
3364 <p class=MsoNormal>The following message will be logged in the error.log file: </p>
3366 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
3367 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
3368 style='background:#EEEEEE'>(2001-10-28 14:20:38) mysql error: [1146: Table 'northwind.productsz' doesn't exist] in<br>
3369 <span style='mso-spacerun:yes'> </span>EXECUTE("select * from productsz")</pre></div>
3373 <p class=MsoNormal>The second error handler is <b>adodb-errorpear.inc.php</b>.
3374 This will create a PEAR_Error derived object whenever an error occurs. The last
3375 PEAR_Error object created can be retrieved using ADODB_Pear_Error(). </p>
3377 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
3378 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><?php<br>
3379 <b>include('adodb-errorpear.inc.php');</b></pre><pre>include('adodb.inc.php');</pre><pre>include('tohtml.inc.php');</pre><pre>$c = NewADOConnection('mysql');</pre><pre>$c->PConnect('localhost','root','','northwind');</pre><pre>$rs=$c->Execute('select * from productsz'); #invalid table productsz');</pre><pre>if ($rs) rs2html($rs);</pre><pre>else {</pre><pre><span
3380 style='mso-tab-count:1'> </span><b>$e = ADODB_Pear_Error();<br>
3381 <span style='mso-tab-count:1'> </span>echo '<p>',$e->message,'</p>';</b></pre><pre>}</pre><pre>?></pre></div>
3383 <p>You can use a PEAR_Error derived class by defining the constant
3384 ADODB_PEAR_ERROR_CLASS before the adodb-errorpear.inc.php file is included. For
3385 easy debugging, you can set the default error handler in the beginning of the
3386 PHP script to PEAR_ERROR_DIE, which will cause an error message to be printed,
3387 then halt script execution: </p>
3389 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
3390 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
3391 style='background:#EEEEEE'>include('PEAR.php');<br>
3392 PEAR::setErrorHandling('PEAR_ERROR_DIE');</pre></div>
3394 <p>Note that we do not explicitly return a PEAR_Error object to you when an
3395 error occurs. We return false instead. You have to call ADODB_Pear_Error() to
3396 get the last error or use the PEAR_ERROR_DIE technique. </p>
3398 <h3>MetaError and MetaErrMsg</h3>
3400 <p>If you need error messages that work across multiple databases, then use <a
3401 href="#metaerror">MetaError()</a>, which returns a virtualized error number,
3402 based on PEAR DB's error number system, and <a href="#metaerrmsg">MetaErrMsg()</a>.
3405 <h4>Error Messages</h4>
3407 <p>Error messages are outputted using the static method
3408 ADOConnnection::outp($msg,$newline=true). By default, it sends the messages to
3409 the client. You can override this to perform error-logging. </p>
3411 <h2><a name=dsn></a>Data Source Names</h2>
3413 <p>We now support connecting using PEAR style DSN's. A DSN is a connection
3414 string of the form:</p>
3416 <p>$dsn = <i>"$driver://$username:$password@$hostname/$databasename"</i>;</p>
3420 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
3421 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
3422 style='background:#EEEEEE'><span style='mso-spacerun:yes'> </span>$username = 'root';<br>
3423 <span style='mso-spacerun:yes'> </span>$password = '';<br>
3424 <span style='mso-spacerun:yes'> </span>$hostname = 'localhost';<br>
3425 <span style='mso-spacerun:yes'> </span>$databasename = 'xphplens';<br>
3426 <span style='mso-spacerun:yes'> </span>$driver = 'mysql';<br>
3427 <span style='mso-spacerun:yes'> </span>$dsn = "$driver://$username:$password@$hostname/$databasename"<br>
3428 <span style='mso-spacerun:yes'> </span>$db = NewADOConnection(); <br>
3429 <span style='mso-spacerun:yes'> </span># DB::Connect($dsn) also works if you include 'adodb/adodb-pear.inc.php' at the top<br>
3430 <span style='mso-spacerun:yes'> </span>$rs = $db->query('select firstname,lastname from adoxyz');<br>
3431 <span style='mso-spacerun:yes'> </span>$cnt = 0;<br>
3432 <span style='mso-spacerun:yes'> </span>while ($arr = $rs->fetchRow()) {<br>
3433 <span style='mso-tab-count:2'> </span>print_r($arr); print "<br>";<br>
3434 <span style='mso-spacerun:yes'> </span>}</pre></div>
3436 <p><a href="#dsnsupport">More info and connection examples</a> on the DSN
3439 <h2><a name=pear></a>PEAR Compatibility</h2>
3441 <p class=MsoNormal>We support DSN's (see above), and the following functions: </p>
3443 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
3444 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><b><span style='mso-spacerun:yes'> </span>DB_Common</b></pre><pre> <span
3445 style='mso-tab-count:1'> </span>query - returns PEAR_Error on error</pre><pre><span
3446 style='mso-tab-count:1'> </span>limitQuery - return PEAR_Error on error</pre><pre><span
3447 style='mso-tab-count:1'> </span>prepare - does not return PEAR_Error on error</pre><pre><span
3448 style='mso-tab-count:1'> </span>execute - does not return PEAR_Error on error</pre><pre><span
3449 style='mso-tab-count:1'> </span>setFetchMode - supports ASSOC and ORDERED</pre><pre><span
3450 style='mso-tab-count:1'> </span>errorNative</pre><pre><span
3451 style='mso-tab-count:1'> </span>quote</pre><pre><span style='mso-tab-count:
3452 1'> </span>nextID</pre><pre><span style='mso-tab-count:1'> </span>disconnect</pre><pre><span
3453 style='mso-tab-count:1'> </span></pre><pre><span style='mso-tab-count:
3454 1'> </span>getOne</pre><pre><span style='mso-tab-count:1'> </span>getAssoc</pre><pre><span
3455 style='mso-tab-count:1'> </span>getRow</pre><pre><span
3456 style='mso-tab-count:1'> </span>getCol</pre><pre><span
3457 style='mso-tab-count:1'> </span></pre><pre><b> DB_Result</b></pre><pre> <span
3458 style='mso-tab-count:1'> </span>numRows - returns -1 if not supported</pre><pre><span
3459 style='mso-tab-count:1'> </span>numCols</pre><pre><span
3460 style='mso-tab-count:1'> </span>fetchInto - does not support passing of fetchmode</pre><pre><span
3461 style='mso-tab-count:1'> </span>fetchRows - does not support passing of fetchmode</pre><pre><span
3462 style='mso-tab-count:1'> </span>free</pre></div>
3464 <h2><a name=caching></a>Caching of Recordsets</h2>
3466 <p>ADOdb now supports caching of recordsets in the file system using the
3467 CacheExecute( ), CachePageExecute( ) and CacheSelectLimit( ) functions. There
3468 are similar to the non-cache functions, except that they take a new first
3469 parameter, $secs2cache. </p>
3473 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
3474 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
3475 style='background:#EEEEEE'><b>include</b>('adodb.inc.php'); # load code common to ADOdb<br>
3476 $ADODB_CACHE_DIR = '/usr/ADODB_cache';<br>
3477 $<span style='color:#663300'>conn</span> = &ADONewConnection('mysql');<span style='mso-spacerun:yes'> </span># create a connection<br>
3478 $<span style='color:#663300'>conn</span>->PConnect('localhost','userid','','agora');# connect to MySQL, agora db<br>
3479 $<span style='color:#663300'>sql</span> = 'select CustomerName, CustomerID from customers';<br>
3480 $<span style='color:#663300'>rs</span> = $<span style='color:#663300'>conn</span>->CacheExecute(15,$sql);</pre></div>
3482 <p>The first parameter is the number of seconds to cache the query. Subsequent
3483 calls to that query will used the cached version stored in $ADODB_CACHE_DIR. To
3484 force a query to execute and flush the cache, call CacheExecute() with the
3485 first parameter set to zero. Alternatively, use the CacheFlush($sql) call. </p>
3487 <p>For the sake of security, we recommend you set <i>register_globals=off</i> in
3488 php.ini if you are using $ADODB_CACHE_DIR.</p>
3490 <p>In ADOdb 1.80 onwards, the secs2cache parameter is optional in
3491 CacheSelectLimit() and CacheExecute(). If you leave it out, it will use the
3492 $connection->cacheSecs parameter, which defaults to 60 minutes. The following
3493 are equivalent: </p>
3495 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
3496 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><o:p> </o:p></pre><pre><span style='mso-spacerun:yes'> </span># (1)</pre><pre><span style='mso-spacerun:yes'> </span>$rs = $db->SelectLimit(30, 'select * from table', 10);</pre><pre><span style='mso-spacerun:yes'> </span></pre><pre><span style='mso-spacerun:yes'> </span># (2)</pre><pre><span style='mso-spacerun:yes'> </span>$db->cacheSsecs = 30;</pre><pre><span style='mso-spacerun:yes'> </span>$rs = $db->SelectLimit('select * from table', 10);</pre><pre
3497 style='background:#EEEEEE'><span style='mso-spacerun:yes'> </span></pre><pre><span
3498 style='mso-tab-count:1'> </span>$conn->Connect(...);<br>
3499 <span style='mso-tab-count:1'> </span>$conn->cacheSecs = 3600*24; # cache 24 hours<br>
3500 <span style='mso-tab-count:1'> </span>$rs = $conn->CacheExecute('select * from table');</pre></div>
3502 <p>Please note that magic_quotes_runtime should be turned off. Do not change
3503 $ADODB_FETCH_MODE (or SetFetchMode) as the cached recordset will use the
3504 $ADODB_FETCH_MODE set when the query was executed. <a name=memcache></a></p>
3506 <h3><span style='mso-bookmark:memcache'>MemCache support</span></h3>
3508 <p><span style='mso-bookmark:memcache'>You can also share cached recordsets on
3509 a memcache server. The memcache API supports one or more pooled hosts. Only if
3510 none of the pooled servers can be contacted will a connect error be generated.
3511 Example below: </span></p>
3513 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
3514 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span
3515 style='mso-bookmark:memcache'><o:p> </o:p></span></pre><pre><span
3516 style='mso-bookmark:memcache'>$db = NewADOConnection($driver='mysql');</span></pre><pre><span
3517 style='mso-bookmark:memcache'>$db->memCache = true;</span></pre><pre><span
3518 style='mso-bookmark:memcache'>$db->memCacheHost = array($ip1, $ip2, $ip3); /// $db->memCacheHost = $ip1; will work too</span></pre><pre><span
3519 style='mso-bookmark:memcache'>$db->memCachePort = 11211; /// this is default memCache port</span></pre><pre><span
3520 style='mso-bookmark:memcache'>$db->memCacheCompress = false; /// Use 'true' to store the item compressed (uses zlib)</span></pre><pre><span
3521 style='mso-bookmark:memcache'><o:p> </o:p></span></pre><pre><span
3522 style='mso-bookmark:memcache'>$db->Connect(...);</span></pre><pre><span
3523 style='mso-bookmark:memcache'>$db->CacheExecute($sql);</span></pre></div>
3525 <p><span style='mso-bookmark:memcache'>More info on memcache can be found at </span><a
3526 href="http://www.danga.com/memcached/">http://www.danga.com/memcached/</a>. <a
3527 name=cacheapi></a></p>
3529 <h3><span style='mso-bookmark:cacheapi'>Caching API</span></h3>
3531 <p><span style='mso-bookmark:cacheapi'>There is also a caching API since
3532 4.99/5.05. Two implementations of the API are already available providing file
3533 and memcache support. </span></p>
3535 <p><span style='mso-bookmark:cacheapi'>The new API for creating your custom
3536 caching class uses 2 globals: </span></p>
3539 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
3540 mso-list:l8 level1 lfo8;tab-stops:list 36.0pt'><span style='mso-bookmark:
3541 cacheapi'>$ADODB_CACHE_CLASS: name of caching class </span></li>
3542 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
3543 mso-list:l8 level1 lfo8;tab-stops:list 36.0pt'><span style='mso-bookmark:
3544 cacheapi'>$ADODB_CACHE: instance of $ADODB_CACHE_CLASS </span></li>
3547 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
3548 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span
3549 style='mso-bookmark:cacheapi'><o:p> </o:p></span></pre><pre><span
3550 style='mso-bookmark:cacheapi'>include "/path/to/adodb.inc.php";</span></pre><pre><span
3551 style='mso-bookmark:cacheapi'>$ADODB_CACHE_CLASS = 'MyCacheClass';</span></pre><pre><span
3552 style='mso-bookmark:cacheapi'><o:p> </o:p></span></pre><pre><span
3553 style='mso-bookmark:cacheapi'>class MyCacheClass extends ADODB_Cache_File</span></pre><pre><span
3554 style='mso-bookmark:cacheapi'>{</span></pre><pre><span style='mso-bookmark:
3555 cacheapi'><span style='mso-tab-count:1'> </span>var $createdir = false; // do not set this to true unless you use temp directories in cache path</span></pre><pre><span
3556 style='mso-bookmark:cacheapi'><span style='mso-tab-count:1'> </span>function writecache($filename, $contents,$debug=false){...}</span></pre><pre><span
3557 style='mso-bookmark:cacheapi'><span style='mso-tab-count:1'> </span>function &readcache($filename, &$err, $secs2cache, $rsClass){ ...}</span></pre><pre><span
3558 style='mso-bookmark:cacheapi'><span style='mso-tab-count:1'> </span> :</span></pre><pre><span
3559 style='mso-bookmark:cacheapi'>}</span></pre><pre><span style='mso-bookmark:
3560 cacheapi'><o:p> </o:p></span></pre><pre><span style='mso-bookmark:cacheapi'>$DB = NewADOConnection($driver);</span></pre><pre><span
3561 style='mso-bookmark:cacheapi'>$DB->Connect(...);<span style='mso-spacerun:yes'> </span>## MyCacheClass created here and stored in $ADODB_CACHE global variable.</span></pre><pre><span
3562 style='mso-bookmark:cacheapi'><o:p> </o:p></span></pre><pre><span
3563 style='mso-bookmark:cacheapi'>$data = $rs->CacheGetOne($sql); ## MyCacheClass is used here for caching...</span></pre></div>
3565 <span style='mso-bookmark:cacheapi'></span>
3567 <h2><a name=pivot></a>Pivot Tables</h2>
3569 <p>Since ADOdb 2.30, we support the generation of SQL to create pivot tables,
3570 also known as cross-tabulations. For further explanation read this DevShed <a
3571 href="http://www.devshed.com/Server_Side/MySQL/MySQLWiz/">Cross-Tabulation tutorial</a>.
3572 We assume that your database supports the SQL case-when expression. </p>
3574 <p>In this example, we will use the Northwind database from Microsoft. In the
3575 database, we have a products table, and we want to analyze this table by <i>suppliers
3576 versus product categories</i>. We will place the suppliers on each row, and
3577 pivot on categories. So from the table on the left, we generate the pivot-table
3582 <table class=MsoNormalTable border=0 cellpadding=0 style='mso-cellspacing:1.5pt;
3583 mso-padding-alt:1.5pt 1.5pt 1.5pt 1.5pt'>
3584 <tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes;mso-yfti-lastrow:yes'>
3585 <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
3587 <table class=MsoNormalTable border=1 cellpadding=0 width=142
3588 style='width:106.5pt;mso-cellspacing:1.5pt;mso-padding-alt:1.5pt 1.5pt 1.5pt 1.5pt'>
3589 <tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes'>
3590 <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
3591 <p class=MsoNormal><i>Supplier</i></p>
3593 <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
3594 <p class=MsoNormal><i>Category</i></p>
3597 <tr style='mso-yfti-irow:1'>
3598 <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
3599 <p class=MsoNormal>supplier1</p>
3601 <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
3602 <p class=MsoNormal>category1</p>
3605 <tr style='mso-yfti-irow:2'>
3606 <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
3607 <p class=MsoNormal>supplier2</p>
3609 <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
3610 <p class=MsoNormal>category1</p>
3613 <tr style='mso-yfti-irow:3;mso-yfti-lastrow:yes'>
3614 <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
3615 <p class=MsoNormal>supplier2</p>
3617 <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
3618 <p class=MsoNormal>category2</p>
3623 <p class=MsoNormal><o:p></o:p></p>
3625 <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
3626 <p class=MsoNormal><span style='font-family:"Courier New"'>--></span></p>
3628 <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
3630 <table class=MsoNormalTable border=1 cellpadding=0 style='mso-cellspacing:
3631 1.5pt;mso-padding-alt:1.5pt 1.5pt 1.5pt 1.5pt'>
3632 <tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes'>
3633 <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
3634 <p class=MsoNormal> </p>
3636 <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
3637 <p class=MsoNormal><i>category1</i></p>
3639 <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
3640 <p class=MsoNormal><i>category2</i></p>
3642 <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
3643 <p class=MsoNormal><i>total</i></p>
3646 <tr style='mso-yfti-irow:1'>
3647 <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
3648 <p class=MsoNormal><i>supplier1</i></p>
3650 <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
3651 <p class=MsoNormal align=right style='text-align:right'>1</p>
3653 <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
3654 <p class=MsoNormal align=right style='text-align:right'>0</p>
3656 <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
3657 <p class=MsoNormal align=right style='text-align:right'>1</p>
3660 <tr style='mso-yfti-irow:2;mso-yfti-lastrow:yes'>
3661 <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
3662 <p class=MsoNormal><i>supplier2</i></p>
3664 <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
3665 <p class=MsoNormal align=right style='text-align:right'>1</p>
3667 <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
3668 <p class=MsoNormal align=right style='text-align:right'>1</p>
3670 <td style='padding:1.5pt 1.5pt 1.5pt 1.5pt'>
3671 <p class=MsoNormal align=right style='text-align:right'>2</p>
3676 <p class=MsoNormal><o:p></o:p></p>
3683 <p>The following code will generate the SQL for a cross-tabulation: </p>
3685 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
3686 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
3687 style='background:#EEEEEE'># Query the main "product" table<br>
3688 # Set the rows to SupplierName<br>
3689 # and the columns to the values of Categories<br>
3690 # and define the joins to link to lookup tables <br>
3691 # "categories" and "suppliers"<br>
3693 <span style='mso-spacerun:yes'> </span>include "adodb/pivottable.inc.php";<br>
3694 <span style='mso-spacerun:yes'> </span>$sql = PivotTableSQL(<br>
3695 <span style='mso-spacerun:yes'> </span><span style='mso-tab-count:1'> </span>$gDB,<span style='mso-spacerun:yes'> </span># adodb connection<br>
3696 <span style='mso-spacerun:yes'> </span><span style='mso-tab-count:1'> </span>'products p ,categories c ,suppliers s',<span style='mso-spacerun:yes'> </span># tables<br>
3697 <span style='mso-tab-count:1'> </span>'SupplierName',<span style='mso-spacerun:yes'> </span># rows (multiple fields allowed)<br>
3698 <span style='mso-tab-count:1'> </span>'CategoryName',<span style='mso-spacerun:yes'> </span># column to pivot on <br>
3699 <span style='mso-tab-count:1'> </span>'p.CategoryID = c.CategoryID and s.SupplierID= p.SupplierID' # joins/where<br>
3702 <p>This will generate the following SQL:</p>
3704 <p><code><span style='font-size:10.0pt'>SELECT SupplierName, </span></code><span
3705 style='font-size:10.0pt;font-family:"Courier New"'><br>
3706 <code>SUM(CASE WHEN CategoryName='Beverages' THEN 1 ELSE 0 END) AS
3707 "Beverages", </code><br>
3708 <code>SUM(CASE WHEN CategoryName='Condiments' THEN 1 ELSE 0 END) AS
3709 "Condiments", </code><br>
3710 <code>SUM(CASE WHEN CategoryName='Confections' THEN 1 ELSE 0 END) AS
3711 "Confections", </code><br>
3712 <code>SUM(CASE WHEN CategoryName='Dairy Products' THEN 1 ELSE 0 END) AS
3713 "Dairy Products", </code><br>
3714 <code>SUM(CASE WHEN CategoryName='Grains/Cereals' THEN 1 ELSE 0 END) AS
3715 "Grains/Cereals", </code><br>
3716 <code>SUM(CASE WHEN CategoryName='Meat/Poultry' THEN 1 ELSE 0 END) AS
3717 "Meat/Poultry", </code><br>
3718 <code>SUM(CASE WHEN CategoryName='Produce' THEN 1 ELSE 0 END) AS
3719 "Produce", </code><br>
3720 <code>SUM(CASE WHEN CategoryName='Seafood' THEN 1 ELSE 0 END) AS
3721 "Seafood", </code><br>
3722 <code>SUM(1) as Total </code><br>
3723 <code>FROM products p ,categories c ,suppliers s WHERE p.CategoryID =
3724 c.CategoryID and s.SupplierID= p.SupplierID </code><br>
3725 <code>GROUP BY SupplierName</code></span></p>
3727 <p>You can also pivot on <i>numerical columns</i> and <i>generate totals</i> by
3728 using ranges. This code was revised in ADODB 2.41 and is not backward
3729 compatible. The second example shows this:</p>
3731 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
3732 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span style='mso-spacerun:yes'> </span>$sql = PivotTableSQL(<br>
3733 <span style='mso-spacerun:yes'> </span><span style='mso-tab-count:1'> </span>$gDB,<span style='mso-spacerun:yes'> </span># adodb connection<br>
3734 <span style='mso-spacerun:yes'> </span><span style='mso-tab-count:1'> </span>'products p ,categories c ,suppliers s',<span style='mso-spacerun:yes'> </span># tables<br>
3735 <span style='mso-tab-count:1'> </span>'SupplierName',<span style='mso-spacerun:yes'> </span># rows (multiple fields allowed)</pre><pre><span style='mso-spacerun:yes'> </span>array(<span style='mso-spacerun:yes'> </span><span style='mso-spacerun:yes'> </span># column ranges</pre><pre><span
3736 style='mso-tab-count:1'> </span>' 0 '<span style='mso-spacerun:yes'> </span>=> 'UnitsInStock <= 0',</pre><pre><span
3737 style='mso-tab-count:1'> </span>"1 to 5"<span style='mso-spacerun:yes'> </span>=> '0 < UnitsInStock and UnitsInStock <= 5',</pre><pre><span
3738 style='mso-tab-count:1'> </span>"6 to 10"<span style='mso-spacerun:yes'> </span>=> '5 < UnitsInStock and UnitsInStock <= 10',</pre><pre><span
3739 style='mso-tab-count:1'> </span>"11 to 15" => '10 < UnitsInStock and UnitsInStock <= 15',</pre><pre><span
3740 style='mso-tab-count:1'> </span>"16+"<span style='mso-spacerun:yes'> </span>=> '15 < UnitsInStock'</pre><pre><span
3741 style='mso-tab-count:1'> </span>),</pre><pre><span style='mso-tab-count:
3742 1'> </span>' p.CategoryID = c.CategoryID and s.SupplierID= p.SupplierID', # joins/where</pre><pre><span
3743 style='mso-tab-count:1'> </span>'UnitsInStock',<span style='mso-spacerun:yes'> </span># sum this field</pre><pre><span
3744 style='mso-tab-count:1'> </span>'Sum '<span style='mso-spacerun:yes'> </span># sum label prefix</pre><pre>);</pre></div>
3746 <p>Which generates: </p>
3748 <p><code><span style='font-size:10.0pt'>SELECT SupplierName, </span></code><span
3749 style='font-size:10.0pt;font-family:"Courier New"'><br>
3750 <code>SUM(CASE WHEN UnitsInStock <= 0 THEN UnitsInStock ELSE 0 END) AS
3751 "Sum 0 ", </code><br>
3752 <code>SUM(CASE WHEN 0 < UnitsInStock and UnitsInStock <= 5 THEN
3753 UnitsInStock ELSE 0 END) AS "Sum 1 to 5",</code><br>
3754 <code>SUM(CASE WHEN 5 < UnitsInStock and UnitsInStock <= 10 THEN UnitsInStock
3755 ELSE 0 END) AS "Sum 6 to 10",</code><br>
3756 <code>SUM(CASE WHEN 10 < UnitsInStock and UnitsInStock <= 15 THEN
3757 UnitsInStock ELSE 0 END) AS "Sum 11 to 15", </code><br>
3758 <code>SUM(CASE WHEN 15 < UnitsInStock THEN UnitsInStock ELSE 0 END) AS
3759 "Sum 16+", </code><br>
3760 <code>SUM(UnitsInStock) AS "Sum UnitsInStock", </code><br>
3761 <code>SUM(1) as Total,</code><br>
3762 <code>FROM products p ,categories c ,suppliers s WHERE p.CategoryID =
3763 c.CategoryID and s.SupplierID= p.SupplierID </code><br>
3764 <code>GROUP BY SupplierName</code></span></p>
3766 <div class=MsoNormal align=center style='text-align:center'>
3768 <hr size=2 width="100%" align=center>
3772 <h1>Class Reference<a name=ref></a></h1>
3774 <p>Function parameters with [ ] around them are optional.</p>
3776 <h2>Global Variables</h2>
3778 <h3><a name="adodb_countrecs"></a>$ADODB_COUNTRECS</h3>
3780 <p>If the database driver API does not support counting the number of records
3781 returned in a SELECT statement, the function RecordCount() is emulated when the
3782 global variable $ADODB_COUNTRECS is set to true, which is the default. We
3783 emulate this by buffering the records, which can take up large amounts of
3784 memory for big recordsets. Set this variable to false for the best performance.
3785 This variable is checked every time a query is executed, so you can selectively
3786 choose which recordsets to count.</p>
3788 <h3><a name="adodb_cache_dir"></a>$ADODB_CACHE_DIR</h3>
3790 <p>If you are using recordset caching, this is the directory to save your
3791 recordsets in. Define this before you call any caching functions such as
3792 CacheExecute( ). We recommend setting <i>register_globals=off</i> in php.ini if
3793 you use this feature for security reasons.</p>
3795 <p>If you are using Unix and apache, you might need to set your cache directory
3796 permissions to something similar to the following:</p>
3798 <p>chown -R apache /path/to/adodb/cache<br>
3799 chgrp -R apache /path/to/adodb/cache </p>
3801 <h3><a name="adodb_ansi_padding_off"></a>$ADODB_ANSI_PADDING_OFF</h3>
3803 <p>Determines whether to right trim CHAR fields (and also VARCHAR for
3804 ibase/firebird). Set to true to trim. Default is false. Currently works for
3805 oci8po, ibase and firebird drivers. Added in ADOdb 4.01. </p>
3807 <h3><a name="adodb_lang"></a>$ADODB_LANG</h3>
3809 <p>Determines the language used in MetaErrorMsg(). The default is 'en', for
3810 English. To find out what languages are supported, see the files in
3811 adodb/lang/adodb-$lang.inc.php, where $lang is the supported langauge. </p>
3813 <h3><a name="adodb_fetch_mode"></a>$ADODB_FETCH_MODE</h3>
3815 <p>This is a global variable that determines how arrays are retrieved by recordsets.
3816 The recordset saves this value on creation (eg. in Execute( ) or SelectLimit(
3817 )), and any subsequent changes to $ADODB_FETCH_MODE have no affect on existing
3818 recordsets, only on recordsets created in the future.</p>
3820 <p>The following constants are defined:</p>
3822 <p>define('ADODB_FETCH_DEFAULT',0);<br>
3823 define('ADODB_FETCH_NUM',1);<br>
3824 define('ADODB_FETCH_ASSOC',2);<br>
3825 define('ADODB_FETCH_BOTH',3); </p>
3829 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
3830 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span
3831 style='mso-tab-count:1'> </span>$ADODB_<b>FETCH_MODE</b> = ADODB_FETCH_NUM;<br>
3832 <span style='mso-tab-count:1'> </span>$rs1 = $db->Execute('select * from table');<br>
3833 <span style='mso-tab-count:1'> </span>$ADODB_<b>FETCH_MODE</b> = ADODB_FETCH_ASSOC;<br>
3834 <span style='mso-tab-count:1'> </span>$rs2 = $db->Execute('select * from table');<br>
3835 <span style='mso-tab-count:1'> </span>print_r($rs1->fields); # shows <i>array([0]=>'v0',[1] =>'v1')</i></pre><pre><span
3836 style='mso-tab-count:1'> </span>print_r($rs2->fields); # shows <i>array(['col1']=>'v0',['col2'] =>'v1')</i></pre></div>
3838 <p>As you can see in the above example, both recordsets store and use different
3839 fetch modes based on the $ADODB_FETCH_MODE setting when the recordset was
3840 created by Execute().</p>
3842 <p>If no fetch mode is predefined, the fetch mode defaults to
3843 ADODB_FETCH_DEFAULT. The behaviour of this default mode varies from driver to
3844 driver, so do not rely on ADODB_FETCH_DEFAULT. For portability, we recommend
3845 sticking to ADODB_FETCH_NUM or ADODB_FETCH_ASSOC. Many drivers do not support
3846 ADODB_FETCH_BOTH.</p>
3848 <p><strong>SetFetchMode Function</strong></p>
3850 <p>If you have multiple connection objects, and want to have different fetch
3851 modes for each connection, then use <a href="#setfetchmode">SetFetchMode</a>.
3852 Once this function is called for a connection object, that connection object
3853 will ignore the global variable $ADODB_FETCH_MODE and will use the internal
3854 fetchMode property exclusively.</p>
3856 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
3857 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span
3858 style='mso-tab-count:1'> </span>$db->SetFetchMode(ADODB_FETCH_NUM);<br>
3859 <span style='mso-tab-count:1'> </span>$rs1 = $db->Execute('select * from table');<br>
3860 <span style='mso-tab-count:1'> </span>$db->SetFetchMode(ADODB_FETCH_ASSOC);<br>
3861 <span style='mso-tab-count:1'> </span>$rs2 = $db->Execute('select * from table');<br>
3862 <span style='mso-tab-count:1'> </span>print_r($rs1->fields); # shows <i>array([0]=>'v0',[1] =>'v1')</i></pre><pre
3863 style='background:#EEEEEE'><span style='mso-tab-count:1'> </span>print_r($rs2->fields); # shows <i>array(['col1']=>'v0',['col2'] =>'v1')</i></pre></div>
3865 <p>To retrieve the previous fetch mode, you can use check the $db->fetchMode
3866 property, or use the return value of SetFetchMode( ). </p>
3868 <p><a name="adodb_assoc_case"></a><strong>ADODB_ASSOC_CASE</strong></p>
3870 <p>You can control the associative fetch case for certain drivers which behave
3871 differently. For the sybase, oci8po, mssql, odbc and ibase drivers and all
3872 drivers derived from them, ADODB_ASSOC_CASE will by default generate recordsets
3873 where the field name keys are lower-cased. Use the constant ADODB_ASSOC_CASE to
3874 change the case of the keys. There are 3 possible values:</p>
3876 <p>0 = assoc lowercase field names. $rs->fields['orderid']<br>
3877 1 = assoc uppercase field names. $rs->fields['ORDERID']<br>
3878 2 = use native-case field names. $rs->fields['OrderID'] -- this is the
3879 default since ADOdb 2.90</p>
3881 <p>To use it, declare it before you incldue adodb.inc.php.</p>
3883 <p>define('ADODB_ASSOC_CASE', 2); # use native-case for ADODB_FETCH_ASSOC<br>
3884 include('adodb.inc.php'); </p>
3886 <h3><a name="force_type"></a>$ADODB_FORCE_TYPE</h3>
3888 <p>See the <a href="#ADODB_FORCE_TYPE">GetUpdateSQL tutorial</a>. </p>
3890 <h3><a name="adodb_auto_quote"></a>$ADODB_QUOTE_FIELDNAMES</h3>
3892 <p>Auto-quotes field names when using AutoExecute() when set to true. </p>
3893 <p>Since 5.13, if $ADODB_QUOTE_FIELDNAMES is set to:
3895 <li>'UPPER' or true: uppercase field names. This is the default.
3896 <li>'NATIVE' : use native case.
3897 <li>'LOWER': lowercase field names.
3901 <div class=MsoNormal align=center style='text-align:center'>
3903 <hr size=2 width="100%" align=center>
3907 <h2>ADOConnection<a name=adoconnection></a></h2>
3909 <p>Object that performs the connection to the database, executes SQL statements
3910 and has a set of utility functions for standardising the format of SQL
3911 statements for issues such as concatenation and date formats.</p>
3913 <h3>ADOConnection Fields</h3>
3915 <p><b>databaseType</b>: Name of the database system we are connecting to. Eg. <b>odbc</b>
3916 or <b>mssql</b> or <b>mysql</b>.</p>
3918 <p><b>dataProvider</b>: The underlying mechanism used to connect to the
3919 database. Normally set to <b>native</b>, unless using <b>odbc</b> or <b>ado</b>.</p>
3921 <p><b>host: </b>Name of server or data source name (DSN) to connect to.</p>
3923 <p><b>database</b>: Name of the database or to connect to. If ado is used, it
3924 will hold the ado data provider.</p>
3926 <p><b>user</b>: Login id to connect to database. Password is not saved for
3927 security reasons.</p>
3929 <p><b>raiseErrorFn</b>: Allows you to define an error handling function. See
3930 adodb-errorhandler.inc.php for an example.</p>
3932 <p><b>debug</b>: Set to <i>true</i> to make debug statements. Set to -99 to only display errors. Set to 99 to display debug statements and add a backtrace.</p>
3934 <p><b>concat_operator</b>: Set to '+' or '||' normally. The operator used to
3935 concatenate strings in SQL. Used by the <b><a href="#concat">Concat</a></b>
3938 <p><b>fmtDate</b>: The format used by the <b><a href="#dbdate">DBDate</a></b>
3939 function to send dates to the database. is '#Y-m-d#' for Microsoft Access, and
3940 ''Y-m-d'' for MySQL.</p>
3942 <p><b>fmtTimeStamp: </b>The format used by the <b><a href="#dbtimestamp">DBTimeStamp</a></b>
3943 function to send timestamps to the database. </p>
3945 <p><b>true</b>: The value used to represent true.Eg. '.T.'. for Foxpro, '1' for
3948 <p><b>false: </b>The value used to represent false. Eg. '.F.'. for Foxpro, '0'
3949 for Microsoft SQL.</p>
3951 <p><b>replaceQuote</b>: The string used to escape quotes. Eg. double
3952 single-quotes for Microsoft SQL, and backslash-quote for MySQL. Used by <a
3953 href="#qstr">qstr</a>.</p>
3955 <p><b>autoCommit</b>: indicates whether automatic commit is enabled. Default is
3958 <p><b>charSet</b>: set the default charset to use. Currently only
3959 interbase/firebird supports this.</p>
3961 <p><b>dialect</b>: set the default sql dialect to use. Currently only interbase/firebird
3964 <p><b>role</b>: set the role. Currently only interbase/firebird supports this.</p>
3966 <p><b>metaTablesSQL</b>: SQL statement to return a list of available tables.
3967 Eg. <i>SHOW TABLES</i> in MySQL.</p>
3969 <p><b>genID</b>: The latest id generated by GenID() if supported by the
3972 <p><b>cacheSecs</b>: The number of seconds to cache recordsets if
3973 CacheExecute() or CacheSelectLimit() omit the $secs2cache parameter. Defaults
3976 <p><b>sysDate</b>: String that holds the name of the database function to call
3977 to get the current date. Useful for inserts and updates.</p>
3979 <p><b>sysTimeStamp</b>: String that holds the name of the database function to
3980 call to get the current timestamp/datetime value.</p>
3982 <p><b>leftOuter</b>: String that holds operator for left outer join, if known.
3983 Otherwise set to false.</p>
3985 <p><b>rightOuter</b>: String that holds operator for left outer join, if known.
3986 Otherwise set to false.</p>
3988 <p><b>ansiOuter</b>: Boolean that if true indicates that ANSI style outer joins
3989 are permitted. Eg. <i>select * from table1 left join table2 on p1=p2.</i></p>
3991 <p><b>connectSID</b>: Boolean that indicates whether to treat the $database
3992 parameter in connects as the SID for the oci8 driver. Defaults to false. Useful
3993 for Oracle 8.0.5 and earlier.</p>
3995 <p><b>autoRollback</b>: Persistent connections are auto-rollbacked in PConnect(
3996 ) if this is set to true. Default is false.</p>
3998 <div class=MsoNormal align=center style='text-align:center'>
4000 <hr size=2 width="100%" align=center>
4004 <h3>ADOConnection Main Functions</h3>
4006 <p><b>ADOConnection( )</b></p>
4008 <p>Constructor function. Do not call this directly. Use ADONewConnection( )
4011 <p><b>Connect<a name=connect></a>($host,[$user],[$password],[$database])</b></p>
4013 <p>Non-persistent connect to data source or server $<b>host</b>, using userid $<b>user
4014 </b>and password $<b>password</b>. If the server supports multiple databases,
4015 connect to database $<b>database</b>. </p>
4017 <p>Returns true/false depending on connection success. Since 4.23, null is
4018 returned if the extension is not loaded.</p>
4020 <p><st1:City w:st="on"><st1:place w:st="on">ADO</st1:place></st1:City> Note: If
4021 you are using a Microsoft ADO and not OLEDB, you can set the $database
4022 parameter to the OLEDB data provider you are using.</p>
4024 <p>PostgreSQL: An alternative way of connecting to the database is to pass the
4025 standard PostgreSQL connection string in the first parameter $host, and the
4026 other parameters will be ignored.</p>
4028 <p>For Oracle and Oci8, there are two ways to connect. First is to use the TNS
4029 name defined in your local tnsnames.ora (or ONAMES or HOSTNAMES). Place the
4030 name in the $database field, and set the $host field to false. Alternatively,
4031 set $host to the server, and $database to the database SID, this bypassed
4036 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
4037 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
4038 style='background:#EEEEEE'><span style='mso-spacerun:yes'> </span># $oraname in tnsnames.ora/ONAMES/HOSTNAMES<br>
4039 <span style='mso-spacerun:yes'> </span>$conn->Connect(false, 'scott', 'tiger', $oraname); <br>
4040 <span style='mso-spacerun:yes'> </span>$conn->Connect('server:1521', 'scott', 'tiger', 'ServiceName'); # bypass tnsnames.ora</pre></div>
4042 <p>There are many examples of connecting to a database. See <a
4043 href="#connect_ex">Connection Examples</a> for many examples. </p>
4045 <p><b>PConnect<a name=pconnect></a>($host,[$user],[$password],[$database])</b></p>
4047 <p>Persistent connect to data source or server $<b>host</b>, using userid $<b>user</b>
4048 and password $<b>password</b>. If the server supports multiple databases,
4049 connect to database $<b>database</b>.</p>
4051 <p>We now perform a rollback on persistent connection for selected databases
4052 since 2.21, as advised in the PHP manual. See change log or source code for
4053 which databases are affected. </p>
4055 <p>Returns true/false depending on connection. Since 4.23, 0 is returned if the
4056 extension is not loaded. See Connect( ) above for more info.</p>
4058 <p>Since ADOdb 2.21, we also support autoRollback. If you set:</p>
4060 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
4061 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
4062 style='background:#EEEEEE'><span style='mso-spacerun:yes'> </span>$conn = &NewADOConnection('mysql');<br>
4063 <span style='mso-spacerun:yes'> </span>$conn->autoRollback = true; # default is false<br>
4064 <span style='mso-spacerun:yes'> </span>$conn->PConnect(...); # rollback here</pre></div>
4066 <p>Then when doing a persistent connection with PConnect( ), ADOdb will perform
4067 a rollback first. This is because it is documented that PHP is not guaranteed
4068 to rollback existing failed transactions when persistent connections are used.
4069 This is implemented in Oracle, MySQL, PgSQL, MSSQL, ODBC currently. </p>
4071 <p>Since ADOdb 3.11, you can force non-persistent connections even if PConnect
4072 is called by defining the constant ADODB_NEVER_PERSIST before you call
4075 <p>Since 4.23, null is returned if the extension is not loaded. </p>
4077 <p><b>NConnect<a name=nconnect></a>($host,[$user],[$password],[$database])</b></p>
4079 <p>Always force a new connection. In contrast, PHP sometimes reuses connections
4080 when you use Connect() or PConnect(). Currently works only on mysql (PHP 4.3.0
4081 or later), postgresql and oci8-derived drivers. For other drivers, NConnect()
4082 works like Connect().</p>
4084 <p><b>IsConnected( )</b><a name=isconnected></a></p>
4086 <p>Returns true if connected to database. Added in 4.53. </p>
4088 <p><b>Execute<a name=execute></a>($sql,$inputarr=false)</b></p>
4090 <p>Execute SQL statement $<b>sql</b> and return derived class of ADORecordSet
4091 if successful. Note that a record set is always returned on success, even if we
4092 are executing an insert or update statement. You can also pass in $sql a
4093 statement prepared in <a href="#prepare">Prepare()</a>.</p>
4095 <p>Returns derived class of ADORecordSet. Eg. if connecting via mysql, then
4096 ADORecordSet_mysql would be returned. False is returned if there was an error
4097 in executing the sql.</p>
4099 <p>The $inputarr parameter can be used for binding variables to parameters.
4100 Below is an Oracle example:</p>
4102 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
4103 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
4104 style='background:#EEEEEE'><span style='mso-spacerun:yes'> </span>$conn->Execute("SELECT * FROM TABLE WHERE COND=:val", array('val'=> $val));<br>
4105 <span style='mso-spacerun:yes'> </span></pre></div>
4107 <p>Another example, using ODBC,which uses the ? convention:</p>
4109 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
4110 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
4111 style='background:#EEEEEE'><span style='mso-spacerun:yes'> </span>$conn->Execute("SELECT * FROM TABLE WHERE COND=?", array($val));</pre></div>
4113 <p class=MsoNormal><a name=binding></a><i>Binding variables</i></p>
4115 <p>Variable binding speeds the compilation and caching of SQL statements,
4116 leading to higher performance. Currently Oracle, Interbase and ODBC supports
4117 variable binding. Interbase/ODBC style ? binding is emulated in databases that
4118 do not support binding. Note that you do not have to quote strings if you use
4121 <p>Variable binding in the odbc, interbase and oci8po drivers. </p>
4123 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
4124 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
4125 style='background:#EEEEEE'>$rs = $db->Execute('select * from table where val=?', array('10'));</pre></div>
4127 <p class=MsoNormal>Variable binding in the oci8 driver: </p>
4129 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
4130 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
4131 style='background:#EEEEEE'>$rs = $db->Execute('select name from table where val=:key', <br>
4132 <span style='mso-spacerun:yes'> </span>array('key' => 10));</pre></div>
4134 <p class=MsoNormal><a name=bulkbind></a><i>Bulk binding</i> </p>
4136 <p>Since ADOdb 3.80, we support bulk binding in Execute(), in which you pass in
4137 a 2-dimensional array to be bound to an INSERT/UPDATE or DELETE statement. And since ADOdb 5.11 this is
4138 disabled by default due to security issues. To enable, set $conn->bulkBind = true. </p>
4140 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
4141 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
4142 style='background:#EEEEEE'>$arr = array(<br>
4143 <span style='mso-tab-count:1'> </span>array('Ahmad',32),<br>
4144 <span style='mso-tab-count:1'> </span>array('Zulkifli', 24),<br>
4145 <span style='mso-tab-count:1'> </span>array('Rosnah', 21)<br>
4146 <span style='mso-tab-count:1'> </span>);<br>
4147 $ok = $db->Execute('insert into table (name,age) values (?,?)',$arr);</pre></div>
4149 <p>This provides very high performance as the SQL statement is prepared first.
4150 The prepared statement is executed repeatedly for each array row until all rows
4151 are completed, or until the first error. Very useful for importing data. </p>
4153 <p><b>CacheExecute<a name=cacheexecute></a>([$secs2cache,]$sql,$inputarr=false)</b></p>
4155 <p>Similar to Execute, except that the recordset is cached for $secs2cache
4156 seconds in the $ADODB_CACHE_DIR directory, and $inputarr only accepts
4157 1-dimensional arrays. If CacheExecute() is called again with the same $sql,
4158 $inputarr, and also the same database, same userid, and the cached recordset
4159 has not expired, the cached recordset is returned. </p>
4161 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
4162 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
4163 style='background:#EEEEEE'><span style='mso-spacerun:yes'> </span>include('adodb.inc.php'); <br>
4164 <span style='mso-spacerun:yes'> </span>include('tohtml.inc.php');<br>
4165 <span style='mso-spacerun:yes'> </span>$ADODB_<b>CACHE_DIR</b> = '/usr/local/ADOdbcache';<br>
4166 <span style='mso-spacerun:yes'> </span>$conn = &ADONewConnection('mysql'); <br>
4167 <span style='mso-spacerun:yes'> </span>$conn->PConnect('localhost','userid','password','database');<br>
4168 <span style='mso-spacerun:yes'> </span>$rs = $conn-><b>CacheExecute</b>(15, 'select * from table'); # cache 15 secs<br>
4169 <span style='mso-spacerun:yes'> </span>rs2html($rs); /* recordset to html table */<span style='mso-spacerun:yes'> </span></pre></div>
4171 <p>Alternatively, since ADOdb 1.80, the $secs2cache parameter is optional:</p>
4173 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
4174 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
4175 style='background:#EEEEEE'><span style='mso-tab-count:1'> </span>$conn->Connect(...);<br>
4176 <span style='mso-spacerun:yes'> </span><span style='mso-tab-count:1'> </span>$conn->cacheSecs = 3600*24; // cache 24 hours<br>
4177 <span style='mso-tab-count:1'> </span>$rs = $conn->CacheExecute('select * from table');</pre></div>
4179 <p class=MsoNormal>If $secs2cache is omitted, we use the value in
4180 $connection->cacheSecs (default is 3600 seconds, or 1 hour). Use
4181 CacheExecute() only with SELECT statements. </p>
4183 <p>Performance note: I have done some benchmarks and found that they vary so
4184 greatly that it's better to talk about when caching is of benefit. When your
4185 database server is <i>much slower </i>than your Web server or the database is <i>very
4186 overloaded </i>then ADOdb's caching is good because it reduces the load on your
4187 database server. If your database server is lightly loaded or much faster than
4188 your Web server, then caching could actually reduce performance. </p>
4190 <p><b>ExecuteCursor<a name=executecursor></a>($sql,$cursorName='rs',$parameters=false)</b></p>
4192 <p>Execute an Oracle stored procedure, and returns an Oracle REF cursor
4193 variable as a regular ADOdb recordset. Does not work with any other database
4194 except oci8. Thanks to Robert Tuttle for the design. </p>
4196 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
4197 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
4198 style='background:#EEEEEE'><span style='mso-spacerun:yes'> </span>$db = ADONewConnection("oci8"); <br>
4199 <span style='mso-spacerun:yes'> </span>$db->Connect("foo.com:1521", "uid", "pwd", "FOO"); <br>
4200 <span style='mso-spacerun:yes'> </span>$rs = $db->ExecuteCursor("begin :cursorvar := getdata(:param1); end;", <br>
4201 <span style='mso-tab-count:5'> </span>'cursorvar',<br>
4202 <span style='mso-tab-count:5'> </span>array('param1'=>10)); <br>
4203 <span style='mso-spacerun:yes'> </span># $rs is now just like any other ADOdb recordset object<br>
4204 <span style='mso-spacerun:yes'> </span>rs2html($rs);</pre></div>
4206 <p>ExecuteCursor() is a helper function that does the following internally: </p>
4208 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
4209 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
4210 style='background:#EEEEEE'><span style='mso-tab-count:1'> </span>$stmt = $db->Prepare("begin :cursorvar := getdata(:param1); end;", true); <br>
4211 <span style='mso-tab-count:1'> </span>$db->Parameter($stmt, $cur, 'cursorvar', false, -1, OCI_B_CURSOR);<br>
4212 <span style='mso-tab-count:1'> </span>$rs = $db->Execute($stmt,$bindarr);</pre></div>
4214 <p>ExecuteCursor only accepts 1 out parameter. So if you have 2 out parameters,
4217 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
4218 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
4219 style='background:#EEEEEE'><span style='mso-tab-count:1'> </span>$vv = 'A%';<br>
4220 <span style='mso-tab-count:1'> </span>$stmt = $db->PrepareSP("BEGIN list_tabs(:crsr,:tt); END;");<br>
4221 <span style='mso-tab-count:1'> </span>$db->OutParameter($stmt, $cur, 'crsr', -1, OCI_B_CURSOR);<br>
4222 <span style='mso-tab-count:1'> </span>$db->OutParameter($stmt, $vv, 'tt', 32); # return varchar(32)<br>
4223 <span style='mso-tab-count:1'> </span>$arr = $db->GetArray($stmt);<br>
4224 <span style='mso-tab-count:1'> </span>print_r($arr);<br>
4225 <span style='mso-tab-count:1'> </span>echo " val = $vv"; ## outputs 'TEST'</pre></div>
4227 <p class=MsoNormal>for the following PL/SQL: </p>
4229 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
4230 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
4231 style='background:#EEEEEE'><span style='mso-tab-count:1'> </span>TYPE TabType IS REF CURSOR RETURN TAB%ROWTYPE;<br>
4233 <span style='mso-tab-count:1'> </span>PROCEDURE list_tabs(tabcursor IN OUT TabType,tablenames IN OUT VARCHAR) IS<br>
4234 <span style='mso-tab-count:1'> </span>BEGIN<br>
4235 <span style='mso-tab-count:2'> </span>OPEN tabcursor FOR SELECT * FROM TAB WHERE tname LIKE tablenames;<br>
4236 <span style='mso-tab-count:2'> </span>tablenames := 'TEST';<br>
4237 <span style='mso-tab-count:1'> </span>END list_tabs;</pre></div>
4239 <p><b>SelectLimit<a name=selectlimit></a>($sql,$numrows=-1,$offset=-1,$inputarr=false)</b></p>
4241 <p>Returns a recordset if successful. Returns false otherwise. Performs a
4242 select statement, simulating PostgreSQL's SELECT statement, LIMIT $numrows
4243 OFFSET $offset clause.</p>
4245 <p>In PostgreSQL, SELECT * FROM TABLE LIMIT 3 will return the first 3 records
4246 only. The equivalent is <code><span style='font-size:10.0pt'>$connection->SelectLimit('SELECT
4247 * FROM TABLE',3)</span></code>. This functionality is simulated for databases
4248 that do not possess this feature.</p>
4250 <p>And SELECT * FROM TABLE LIMIT 3 OFFSET 2 will return records 3, 4 and 5 (eg.
4251 after record 2, return 3 rows). The equivalent in ADOdb is <code><span
4252 style='font-size:10.0pt'>$connection->SelectLimit('SELECT * FROM TABLE',3,2)</span></code>.</p>
4254 <p>Note that this is the <i>opposite</i> of MySQL's LIMIT clause. You can also
4255 set <code><span style='font-size:10.0pt'>$connection->SelectLimit('SELECT *
4256 FROM TABLE',-1,10)</span></code> to get rows 11 to the last row.</p>
4258 <p>The last parameter $inputarr is for databases that support variable binding
4259 such as Oracle oci8. This substantially reduces SQL compilation overhead. Below
4260 is an Oracle example:</p>
4262 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
4263 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
4264 style='background:#EEEEEE'><span style='mso-spacerun:yes'> </span>$conn->SelectLimit("SELECT * FROM TABLE WHERE COND=:val", 100,-1,array('val'=> $val));<br>
4265 <span style='mso-spacerun:yes'> </span></pre></div>
4267 <p>The oci8po driver (oracle portable driver) uses the more standard bind
4270 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
4271 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
4272 style='background:#EEEEEE'><span style='mso-spacerun:yes'> </span>$conn->SelectLimit("SELECT * FROM TABLE WHERE COND=?", 100,-1,array('val'=> $val));</pre></div>
4274 <p>Ron Wilson reports that SelectLimit does not work with UNIONs. </p>
4276 <p><b>CacheSelectLimit<a name=cacheselectlimit></a>([$secs2cache,] $sql,
4277 $numrows=-1,$offset=-1,$inputarr=false)</b></p>
4279 <p>Similar to SelectLimit, except that the recordset returned is cached for
4280 $secs2cache seconds in the $ADODB_CACHE_DIR directory. </p>
4282 <p>Since 1.80, $secs2cache has been optional, and you can define the caching
4283 time in $connection->cacheSecs.</p>
4285 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
4286 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
4287 style='background:#EEEEEE'><span style='mso-tab-count:1'> </span>$conn->Connect(...);<br>
4288 <span style='mso-spacerun:yes'> </span>$conn->cacheSecs = 3600*24; // cache 24 hours<br>
4289 <span style='mso-tab-count:1'> </span>$rs = $conn->CacheSelectLimit('select * from table',10);</pre></div>
4291 <p><b>CacheFlush<a name=cacheflush></a>($sql=false,$inputarr=false)</b></p>
4293 <p>Flush (delete) any cached recordsets for the SQL statement $sql in
4294 $ADODB_CACHE_DIR. </p>
4296 <p>If no parameter is passed in, then all adodb_*.cache files are deleted. </p>
4298 <p>CacheSelectLimit() rewrites the SQL query, so you won't be able to pass the
4299 SQL to CacheFlush. In this case, to flush the cached SQL recordset returned by
4300 CacheSelectLimit(), set $secs2cache to -1: </p>
4302 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
4303 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><o:p> </o:p></pre><pre><span
4304 style='mso-tab-count:1'> </span>$db->CacheSelectLimit(-1, $sql, $nrows);</pre></div>
4306 <p>If you want to flush all cached recordsets manually, execute the following
4307 PHP code (works only under Unix): <br>
4308 <code><span style='font-size:10.0pt'> system("rm -f `find
4309 ".$ADODB_CACHE_DIR." -name adodb_*.cache`");</span></code></p>
4311 <p>For general cleanup of all expired files, you should use <a
4312 href="http://www.superscripts.com/tutorial/crontab.html">crontab</a> on Unix,
4313 or at.exe on Windows, and a shell script similar to the following:<span
4314 style='font-family:"Courier New"'><br>
4315 #------------------------------------------------------ <br>
4316 # This particular example deletes files in the TMPPATH <br>
4317 # directory with the string ".cache" in their name that <br>
4318 # are more than 7 days old. <br>
4319 #------------------------------------------------------ <br>
4321 find ${TMPPATH} -mtime +$AGED | grep "\.cache" | xargs rm -f </span></p>
4323 <p><b>MetaError<a name=metaerror></a>($errno=false)</b></p>
4325 <p>Returns a virtualized error number, based on PEAR DB's error number system.
4326 You might need to include adodb-error.inc.php before you call this function.
4327 The parameter $errno is the native error number you want to convert. If you do
4328 not pass any parameter, MetaError will call ErrorNo() for you and convert it.
4329 If the error number cannot be virtualized, MetaError will return -1 (DB_ERROR).</p>
4331 <p><b>MetaErrorMsg<a name=metaerrormsg></a>($errno)</b></p>
4333 <p>Pass the error number returned by MetaError() for the equivalent textual
4336 <p><b>ErrorMsg<a name=errormsg></a>()</b></p>
4338 <p>Returns the last status or error message. The error message is reset after
4339 every call to Execute(). </p>
4341 <p>This can return a string even if no error occurs. In general you do not need
4342 to call this function unless an ADOdb function returns false on an error. </p>
4344 <p>Note: If <b>debug</b> is enabled, the SQL error message is always displayed
4345 when the <b>Execute</b> function is called.</p>
4347 <p><b>ErrorNo<a name=errorno></a>()</b></p>
4349 <p>Returns the last error number. The error number is reset after every call to
4350 Execute(). If 0 is returned, no error occurred. </p>
4352 <p>Note that old versions of PHP (pre 4.0.6) do not support error number for
4353 ODBC. In general you do not need to call this function unless an ADOdb function
4354 returns false on an error.</p>
4356 <p><b>IgnoreErrors<a name=ignoreerrors></a>($saveErrHandlers)</b></p>
4358 <p>Allows you to ignore errors so that StartTrans()/CompleteTrans() is not
4359 affected, nor is the default error handler called if an error occurs. Useful
4360 when you want to check if a field or table exists in a database without
4361 invoking an error if it does not exist. </p>
4365 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
4366 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><o:p> </o:p></pre><pre>$saveErrHandlers = $conn->IgnoreErrors();</pre><pre>$rs = $conn->Execute("select field from some_table_that_might_not_exist");</pre><pre>$conn->IgnoreErrors($saveErrHandlers);</pre></div>
4368 <p>Warning: do not call StartTrans()/CompleteTrans() inside a code block that
4369 is using IgnoreErrors(). </p>
4371 <p><b>SetFetchMode<a name=setfetchmode></a>($mode)</b></p>
4373 <p>Sets the current fetch mode for the connection and stores it in
4374 $db->fetchMode. Legal modes are ADODB_FETCH_ASSOC and ADODB_FETCH_NUM. For
4375 more info, see <a href="#adodb_fetch_mode">$ADODB_FETCH_MODE</a>.</p>
4377 <p>Returns the previous fetch mode, which could be false if SetFetchMode( ) has
4378 not been called before.</p>
4380 <p><b>CreateSequence<a name=createseq></a>($seqName = 'adodbseq',$startID=1)</b></p>
4382 <p>Create a sequence. The next time GenID( ) is called, the value returned will
4383 be $startID. Added in 2.60. </p>
4385 <p><b>DropSequence<a name=dropseq></a>($seqName = 'adodbseq')</b></p>
4387 <p>Delete a sequence. Added in 2.60. </p>
4389 <p><b>GenID<a name=genid></a>($seqName = 'adodbseq',$startID=1)</b></p>
4391 <p>Generate a sequence number . Works for interbase, mysql, postgresql, oci8,
4392 oci8po, mssql, ODBC based (access,vfp,db2,etc) drivers currently. Uses $seqName
4393 as the name of the sequence. GenID() will automatically create the sequence for
4394 you if it does not exist (provided the userid has permission to do so).
4395 Otherwise you will have to create the sequence yourself. </p>
4397 <p>If your database driver emulates sequences, the name of the table is the
4398 sequence name. The table has one column, "id" which should be of type
4399 integer, or if you need something larger - numeric(16). </p>
4401 <p>For ODBC and databases that do not support sequences natively (eg mssql,
4402 mysql), we create a table for each sequence. If the sequence has not been
4403 defined earlier, it is created with the starting value set in $startID.</p>
4405 <p>Note that the mssql driver's GenID() before 1.90 used to generate 16 byte
4408 <p><b>UpdateBlob<a name=updateblob></a>($table,$column,$val,$where)</b></p>
4410 <p class=MsoNormal>Allows you to store a blob (in $val) into $table into
4411 $column in a row at $where. </p>
4415 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
4416 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
4417 style='background:#EEEEEE'><span style='mso-tab-count:1'> </span># for oracle<br>
4418 <span style='mso-tab-count:1'> </span>$conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, empty_blob())');<br>
4419 <span style='mso-tab-count:1'> </span>$conn->UpdateBlob('blobtable','blobcol',$blobvalue,'id=1');<br>
4420 <span style='mso-tab-count:1'> </span><br>
4421 <span style='mso-tab-count:1'> </span># non oracle databases<br>
4422 <span style='mso-tab-count:1'> </span>$conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)');<br>
4423 <span style='mso-tab-count:1'> </span>$conn->UpdateBlob('blobtable','blobcol',$blobvalue,'id=1');</pre></div>
4425 <p>Returns true if succesful, false otherwise. Supported by MySQL, PostgreSQL,
4426 Oci8, Oci8po and Interbase drivers. Other drivers might work, depending on the
4427 state of development.</p>
4429 <p>Note that when an Interbase blob is retrieved using SELECT, it still needs
4430 to be decoded using $connection->DecodeBlob($blob); to derive the original
4431 value in versions of PHP before 4.1.0. </p>
4433 <p>For PostgreSQL, you can store your blob using blob oid's or as a bytea field.
4434 You can use bytea fields but not blob oid's currently with UpdateBlob( ).
4435 Conversely UpdateBlobFile( ) supports oid's, but not bytea data.<br>
4437 If you do not pass in an oid, then UpdateBlob() assumes that you are storing in
4440 <p>If you do not have any blob fields, you can improve you can improve general
4441 SQL query performance by disabling blob handling with
4442 $connection->disableBlobs = true. </p>
4444 <p><b>UpdateClob<a name=updateclob></a>($table,$column,$val,$where)</b></p>
4446 <p class=MsoNormal>Allows you to store a clob (in $val) into $table into
4447 $column in a row at $where. Similar to UpdateBlob (see above), but for
4448 Character Large OBjects. </p>
4452 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
4453 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
4454 style='background:#EEEEEE'><span style='mso-tab-count:1'> </span># for oracle<br>
4455 <span style='mso-tab-count:1'> </span>$conn->Execute('INSERT INTO clobtable (id, clobcol) VALUES (1, empty_clob())');<br>
4456 <span style='mso-tab-count:1'> </span>$conn->UpdateBlob('clobtable','clobcol',$clobvalue,'id=1');<br>
4457 <span style='mso-tab-count:1'> </span><br>
4458 <span style='mso-tab-count:1'> </span># non oracle databases<br>
4459 <span style='mso-tab-count:1'> </span>$conn->Execute('INSERT INTO clobtable (id, clobcol) VALUES (1, null)');<br>
4460 <span style='mso-tab-count:1'> </span>$conn->UpdateBlob('clobtable','clobcol',$clobvalue,'id=1');</pre></div>
4462 <p><b>UpdateBlobFile<a name=updateblobfile></a>($table,$column,$path,$where,$blobtype='BLOB')</b></p>
4464 <p>Similar to UpdateBlob, except that we pass in a file path to where the blob
4467 <p>For PostgreSQL, if you are using blob oid's, use this interface. This
4468 interface does not support bytea fields. </p>
4470 <p>Returns true if successful, false otherwise. </p>
4472 <p><b>BlobEncode<a name=blobencode id=blobencode></a>($blob)</b> </p>
4474 <p>Some databases require blob's to be encoded manually before upload. Note if
4475 you use UpdateBlob( ) or UpdateBlobFile( ) the conversion is done automatically
4476 for you and you do not have to call this function. For PostgreSQL, currently,
4477 BlobEncode() can only be used for bytea fields. </p>
4479 <p>Returns the encoded blob value. </p>
4481 <p>Note that there is a connection property called <em>blobEncodeType</em>
4482 which has 3 legal values: </p>
4484 <p>false - no need to perform encoding or decoding.<br>
4485 'I' - blob encoding required, and returned encoded blob is a numeric value (no
4487 'C' - blob encoding required, and returned encoded blob is a character value
4488 (requires quoting). </p>
4490 <p>This is purely for documentation purposes, so that programs that accept
4491 multiple database drivers know what is the right thing to do when processing
4494 <p><strong>BlobDecode<a name=blobdecode></a>($blob, $maxblobsize = false)</strong>
4497 <p>Some databases require blob's to be decoded manually after doing a select
4498 statement. If the database does not require decoding, then this function will
4499 return the blob unchanged. Currently BlobDecode is only required for one
4500 database, PostgreSQL, and only if you are using blob oid's (if you are using
4501 bytea fields, we auto-decode for you). The default maxblobsize is set in
4502 $connection->maxblobsize, which is set to 256K in adodb 4.54. </p>
4504 <p>In ADOdb 4.54 and later, the blob is the return value. In earlier versions,
4505 the blob data is sent to stdout.</p>
4507 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
4508 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
4509 style='background:#EEEEEE'>$rs = $db->Execute("select bloboid from postgres_table where id=$key");<br>
4510 $blob = $db->BlobDecode( reset($rs->fields) );</pre></div>
4512 <p><b>Replace<a name=replace></a>($table, $arrFields,
4513 $keyCols,$autoQuote=false)</b></p>
4515 <p>Try to update a record, and if the record is not found, an insert statement
4516 is generated and executed. Returns 0 on failure, 1 if update statement worked,
4517 2 if no record was found and the insert was executed successfully. This differs
4518 from MySQL's replace which deletes the record and inserts a new record. This
4519 also means you cannot update the primary key. The only exception to this is
4520 Interbase and its derivitives, which uses delete and insert because of some
4521 Interbase API limitations. </p>
4523 <p>The parameters are $table which is the table name, the $arrFields which is
4524 an associative array where the keys are the field names, and $keyCols is the
4525 name of the primary key, or an array of field names if it is a compound key. If
4526 $autoQuote is set to true, then Replace() will quote all values that are
4527 non-numeric; auto-quoting will not quote nulls. Note that auto-quoting will not
4528 work if you use SQL functions or operators. </p>
4532 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
4533 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
4534 style='background:#EEEEEE'># single field primary key<br>
4535 $ret = $db->Replace('atable', <br>
4536 <span style='mso-tab-count:1'> </span>array('id'=>1000,'firstname'=>'Harun','lastname'=>'Al-Rashid'),<br>
4537 <span style='mso-tab-count:1'> </span>'id',$autoquote = true);<span
4538 style='mso-tab-count:1'> </span><br>
4539 # generates UPDATE atable SET firstname='Harun',lastname='Al-Rashid' WHERE id=1000<br>
4540 # or INSERT INTO atable (id,firstname,lastname) VALUES (1000,'Harun','Al-Rashid')<br>
4543 $ret = $db->Replace('atable2', <br>
4544 <span style='mso-tab-count:1'> </span>array('firstname'=>'Harun','lastname'=>'Al-Rashid', 'age' => 33, 'birthday' => 'null'),<br>
4545 <span style='mso-tab-count:1'> </span>array('lastname','firstname'),<br>
4546 <span style='mso-tab-count:1'> </span>$autoquote = true);<br>
4548 # no auto-quoting<br>
4549 $ret = $db->Replace('atable2', <br>
4550 <span style='mso-tab-count:1'> </span>array('firstname'=>"'Harun'",'lastname'=>"'Al-Rashid'", 'age' => 'null'),<br>
4551 <span style='mso-tab-count:1'> </span>array('lastname','firstname'));<span
4552 style='mso-tab-count:1'> </span></pre></div>
4554 <p><b>AutoExecute<a name=autoexecute></a>($table, $arrFields, $mode,
4555 $where=false, $forceUpdate=true,$magicq=false)</b></p>
4557 <p>Since ADOdb 4.56, you can automatically generate and execute INSERTs and
4558 UPDATEs on a given table with this function, which is a wrapper for
4559 GetInsertSQL() and GetUpdateSQL(). </p>
4561 <p>AutoExecute() inserts or updates $table given an array of $arrFields, where
4562 the keys are the field names and the array values are the field values to
4563 store. Note that there is some overhead because the table is first queried to
4564 extract key information before the SQL is generated. We generate an INSERT or
4565 UPDATE based on $mode (see below). </p>
4567 <p>Legal values for $mode are </p>
4570 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
4571 mso-list:l5 level1 lfo9;tab-stops:list 36.0pt'>'INSERT' or 1 or DB_AUTOQUERY_INSERT
4573 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
4574 mso-list:l5 level1 lfo9;tab-stops:list 36.0pt'>'UPDATE' or 2 or
4575 DB_AUTOQUERY_UPDATE </li>
4578 <p>You have to define the constants DB_AUTOQUERY_UPDATE and DB_AUTOQUERY_INSERT
4579 yourself or include adodb-pear.inc.php. </p>
4581 <p>The $where clause is required if $mode == 'UPDATE'. If $forceUpdate=false
4582 then we will query the database first and check if the field value returned by
4583 the query matches the current field value; only if they differ do we update
4586 <p>Returns true on success, false on error. </p>
4588 <p>An example of its use is: </p>
4590 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
4591 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><o:p> </o:p></pre><pre>$record["firstName"] = "Carol";</pre><pre>$record["lasTname"] = "Smith"; </pre><pre>$conn->AutoExecute($table,$record,'INSERT');</pre><pre># executes <i>"INSERT INTO $table (firstName,lasTname) values ('Carol',Smith')"</i>;</pre><pre><o:p> </o:p></pre><pre>$record["firstName"] = "Carol";</pre><pre>$record["lasTname"] = "Jones"; </pre><pre>$conn->AutoExecute($table,$record,'UPDATE', "lastname like 'Sm%'");</pre><pre># executes <i>"UPDATE $table SET firstName='Carol',lasTname='Jones' WHERE lastname like 'Sm%'"</i>;</pre></div>
4593 <p>Note: One of the strengths of ADOdb's AutoExecute() is that only valid field
4594 names for $table are updated. If $arrFields contains keys that are invalid
4595 field names for $table, they are ignored. There is some overhead in doing this
4596 as we have to query the database to get the field names, but given that you are
4597 not directly coding the SQL yourself, you probably aren't interested in speed
4598 at all, but convenience. </p>
4600 <p>Since 4.62, the table name to be used can be overridden by setting
4601 $rs->tableName before AutoExecute(), GetInsertSQL() or GetUpdateSQL() is
4604 <p>Since 4.94, setting the global variable $ADODB_QUOTE_FIELDNAMES to true will
4605 force field names to be auto-quoted in AutoExecute(), GetInsertSQL() and
4606 GetUpdateSQL(). </p>
4608 <p><b>GetUpdateSQL<a name=getupdatesql></a>(&$rs, $arrFields,
4609 $forceUpdate=false,$magicq=false, $force=null)</b></p>
4611 <p>Generate SQL to update a table given a recordset $rs, and the modified
4612 fields of the array $arrFields (which must be an associative array holding the
4613 column names and the new values) are compared with the current recordset. If
4614 $forceUpdate is true, then we also generate the SQL even if $arrFields is
4615 identical to $rs->fields. Requires the recordset to be associative. $magicq
4616 is used to indicate whether magic quotes are enabled (see qstr()). The field
4617 names in the array are case-insensitive.</p>
4619 <p>Since 4.52, we allow you to pass the $force type parameter, and this
4620 overrides the <a href="#ADODB_FORCE_TYPE">$ADODB_FORCE_TYPE</a> global
4623 <p>Since 4.62, the table name to be used can be overridden by setting
4624 $rs->tableName before AutoExecute(), GetInsertSQL() or GetUpdateSQL() is
4627 <p><b>GetInsertSQL<a name=getinsertsql></a>(&$rs, $arrFields,$magicq=false,$force_type=false)</b></p>
4629 <p>Generate SQL to insert into a table given a recordset $rs. Requires the
4630 query to be associative. $magicq is used to indicate whether magic quotes are
4631 enabled (for qstr()). The field names in the array are case-insensitive.</p>
4633 <p>Since 2.42, you can pass a table name instead of a recordset into
4634 GetInsertSQL (in $rs), and it will generate an insert statement for that table.
4637 <p>Since 4.52, we allow you to pass the $force_type parameter, and this
4638 overrides the <a href="#ADODB_FORCE_TYPE">$ADODB_FORCE_TYPE</a> global
4641 <p>Since 4.62, the table name to be used can be overridden by setting
4642 $rs->tableName before AutoExecute(), GetInsertSQL() or GetUpdateSQL() is
4645 <p><b>PageExecute<a name=pageexecute></a>($sql, $nrows, $page, $inputarr=false)</b>
4648 <p>Used for pagination of recordset. $page is 1-based. See <a href="#ex8">Example
4651 <p><b>CachePageExecute<a name=cachepageexecute></a>($secs2cache, $sql, $nrows,
4652 $page, $inputarr=false)</b> </p>
4654 <p>Used for pagination of recordset. $page is 1-based. See <a href="#ex8">Example
4655 8</a>. Caching version of PageExecute.</p>
4657 <p><b>Close<a name=close></a>( )</b></p>
4659 <p>Close the database connection. PHP4 proudly states that we no longer have to
4660 clean up at the end of the connection because the reference counting mechanism
4661 of PHP4 will automatically clean up for us.</p>
4663 <p><b>StartTrans<a name=starttrans></a>( )</b></p>
4665 <p>Start a monitored transaction. As SQL statements are executed, ADOdb will
4666 monitor for SQL errors, and if any are detected, when CompleteTrans() is
4667 called, we auto-rollback. </p>
4669 <p>To understand why StartTrans() is superior to BeginTrans(), let us examine a
4670 few ways of using BeginTrans(). The following is the wrong way to use
4673 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
4674 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
4675 style='background:#EEEEEE'>$DB->BeginTrans();<br>
4676 $DB->Execute("update table1 set val=$val1 where id=$id");<br>
4677 $DB->Execute("update table2 set val=$val2 where id=$id");<br>
4678 $DB->CommitTrans();</pre></div>
4680 <p>because you perform no error checking. It is possible to update table1 and
4681 for the update on table2 to fail. Here is a better way: </p>
4683 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
4684 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
4685 style='background:#EEEEEE'>$DB->BeginTrans();<br>
4686 $ok = $DB->Execute("update table1 set val=$val1 where id=$id");<br>
4687 if ($ok) $ok = $DB->Execute("update table2 set val=$val2 where id=$id");<br>
4688 if ($ok) $DB->CommitTrans();<br>
4689 else $DB->RollbackTrans();</pre></div>
4691 <p>Another way is (since ADOdb 2.0): </p>
4693 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
4694 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
4695 style='background:#EEEEEE'>$DB->BeginTrans();<br>
4696 $ok = $DB->Execute("update table1 set val=$val1 where id=$id");<br>
4697 if ($ok) $ok = $DB->Execute("update table2 set val=$val2 where id=$id");<br>
4698 $DB->CommitTrans($ok);</pre></div>
4700 <p>Now it is a headache monitoring $ok all over the place. StartTrans() is an
4701 improvement because it monitors all SQL errors for you. This is particularly
4702 useful if you are calling black-box functions in which SQL queries might be
4703 executed. Also all BeginTrans, CommitTrans and RollbackTrans calls inside a
4704 StartTrans block will be disabled, so even if the black box function does a
4705 commit, it will be ignored. </p>
4707 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
4708 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
4709 style='background:#EEEEEE'>$DB->StartTrans();<br>
4711 $DB->Execute("update table1 set val=$val1 where id=$id");<br>
4712 $DB->Execute("update table2 set val=$val2 where id=$id");<br>
4713 $DB->CompleteTrans();</pre></div>
4715 <p>Note that a StartTrans blocks are nestable, the inner blocks are ignored. </p>
4717 <p><b>CompleteTrans<a name=completetrans></a>($autoComplete=true)</b></p>
4719 <p>Complete a transaction called with StartTrans(). This function monitors for
4720 SQL errors, and will commit if no errors have occured, otherwise it will
4721 rollback. Returns true on commit, false on rollback. If the parameter
4722 $autoComplete is true monitor sql errors and commit and rollback as
4723 appropriate. Set $autoComplete to false to force rollback even if no SQL error
4726 <p><b>FailTrans<a name=failtrans></a>( )</b></p>
4728 <p>Fail a transaction started with StartTrans(). The rollback will only occur
4729 when CompleteTrans() is called. </p>
4731 <p><b>HasFailedTrans<a name=hasfailedtrans></a>( )</b></p>
4733 <p>Check whether smart transaction has failed, eg. returns true if there was an
4734 error in SQL execution or FailTrans() was called. If not within smart
4735 transaction, returns false. </p>
4737 <p><b>BeginTrans<a name=begintrans></a>( )</b></p>
4739 <p>Begin a transaction. Turns off autoCommit. Returns true if successful. Some
4740 databases will always return false if transaction support is not available. Any
4741 open transactions will be rolled back when the connection is closed. Among the
4742 databases that support transactions are Oracle, PostgreSQL, Interbase, MSSQL,
4743 certain versions of MySQL, DB2, Informix, Sybase, etc.</p>
4745 <p>Note that <a href="#starttrans">StartTrans()</a> and CompleteTrans() is a
4746 superior method of handling transactions, available since ADOdb 3.40. For a
4747 explanation, see the <a href="#starttrans">StartTrans()</a> documentation. </p>
4749 <p>You can also use the ADOdb <a href="#errorhandling">error handler</a> to die
4750 and rollback your transactions for you transparently. Some buggy database
4751 extensions are known to commit all outstanding tranasactions, so you might want
4752 to explicitly do a $DB->RollbackTrans() in your error handler for safety. </p>
4754 <h4>Detecting Transactions</h4>
4756 <p>Since ADOdb 2.50, you are able to detect when you are inside a transaction.
4757 Check that $connection->transCnt > 0. This variable is incremented whenever
4758 BeginTrans() is called, and decremented whenever RollbackTrans() or
4759 CommitTrans() is called. </p>
4761 <p><b>CommitTrans<a name=committrans></a>($ok=true)</b></p>
4763 <p>End a transaction successfully. Returns true if successful. If the database
4764 does not support transactions, will return true also as data is always
4767 <p>If you pass the parameter $ok=false, the data is rolled back. See example in
4770 <p><b>RollbackTrans<a name=rollbacktrans></a>( )</b></p>
4772 <p>End a transaction, rollback all changes. Returns true if successful. If the
4773 database does not support transactions, will return false as data is never
4776 <p><b>SetTransactionMode<a name=SetTransactionMode></a>($mode )</b></p>
4778 <p>SetTransactionMode allows you to pass in the transaction mode to use for all
4779 subsequent transactions. Note: if you have persistent connections and using
4780 mssql or mysql, you might have to explicitly reset your transaction mode at the
4781 beginning of each page request. This is only supported in postgresql, mssql,
4782 mysql with InnoDB and oci8 currently. For example: </p>
4784 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
4785 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><o:p> </o:p></pre><pre>$db->SetTransactionMode("SERIALIZABLE");</pre><pre>$db->BeginTrans();</pre><pre>$db->Execute(...); $db->Execute(...);</pre><pre>$db->CommiTrans();</pre><pre><o:p> </o:p></pre><pre>$db->SetTransactionMode(""); // restore to default</pre><pre>$db->StartTrans();</pre><pre>$db->Execute(...); $db->Execute(...);</pre><pre>$db->CompleteTrans();</pre></div>
4787 <p>Supported values to pass in: </p>
4790 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
4791 mso-list:l1 level1 lfo10;tab-stops:list 36.0pt'>READ UNCOMMITTED (allows
4792 dirty reads, but fastest) </li>
4793 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
4794 mso-list:l1 level1 lfo10;tab-stops:list 36.0pt'>READ COMMITTED (default
4795 postgres, mssql and oci8) </li>
4796 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
4797 mso-list:l1 level1 lfo10;tab-stops:list 36.0pt'>REPEATABLE READ (default
4799 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
4800 mso-list:l1 level1 lfo10;tab-stops:list 36.0pt'>SERIALIZABLE (slowest and
4801 most restrictive) </li>
4804 <p>You can also pass in database specific values such as 'SNAPSHOT' for mssql
4805 or 'READ ONLY' for oci8/postgres. </p>
4807 <p>See transaction levels for <a
4808 href="http://www.postgresql.org/docs/8.1/interactive/sql-set-transaction.html">PostgreSQL</a>,
4810 href="http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_10005.htm">Oracle</a>,
4811 <a href="http://dev.mysql.com/doc/refman/5.0/en/set-transaction.html">MySQL</a>,
4812 and <a href="http://msdn2.microsoft.com/en-US/ms173763.aspx">MS SQL Server</a>.
4815 <p><b>GetAssoc<a name=getassoc1></a>($sql,$inputarr=false,$force_array=false,$first2cols=false)</b></p>
4817 <p>Returns an associative array for the given query $sql with optional bind
4818 parameters in $inputarr. If the number of columns returned is greater to two, a
4819 2-dimensional array is returned, with the first column of the recordset becomes
4820 the keys to the rest of the rows. If the columns is equal to two, a 1-dimensional
4821 array is created, where the the keys directly map to the values (unless
4822 $force_array is set to true, when an array is created for each value). </p>
4824 <p>Examples:<a name=getassocex></a></p>
4826 <p>We have the following data in a recordset:</p>
4828 <p>row1: Apple, Fruit, Edible<br>
4829 row2: Cactus, Plant, Inedible<br>
4830 row3: Rose, Flower, Edible</p>
4832 <p>GetAssoc will generate the following 2-dimensional associative array:</p>
4834 <p>Apple => array[Fruit, Edible]<br>
4835 Cactus => array[Plant, Inedible]<br>
4836 Rose => array[Flower,Edible]</p>
4838 <p>If the dataset is:</p>
4840 <p>row1: Apple, Fruit<br>
4841 row2: Cactus, Plant<br>
4842 row3: Rose, Flower </p>
4844 <p>GetAssoc will generate the following 1-dimensional associative array (with
4845 $force_array==false):</p>
4847 <p>Apple => Fruit<br>
4848 Cactus=>Plant<br>
4849 Rose=>Flower </p>
4851 <p>The function returns:</p>
4853 <p>The associative array, or false if an error occurs.</p>
4855 <p><b>CacheGetAssoc<a name=cachegetassoc></a>([$secs2cache,] $sql,$inputarr=false,$force_array=false,$first2cols=false)</b></p>
4857 <p>Caching version of <a href="#getassoc1">GetAssoc</a> function above. </p>
4859 <p><b>GetMedian<a name=getmedian></a>($table, $field, $where='')</b></p>
4861 <p>Returns the median value of $field for $table. The $where clause is
4862 optional. If used, make sure the WHERE is included, as in "WHERE name >
4863 'A'". If an error occurs, false is returned. Since ADOdb 5.06 and PHP
4866 <p><b>GetOne<a name=getone></a>($sql,$inputarr=false)</b></p>
4868 <p>Executes the SQL and returns the first field of the first row. The recordset
4869 and remaining rows are discarded for you automatically. If an error occur,
4870 false is returned; use ErrorNo() or ErrorMsg() to get the error details. Since
4871 4.96/5.00, we return null if no records were found. And since 4.991/5.06, you
4872 can have change the return value if no records are found using the global
4873 variable $ADODB_GETONE_EOF: $ADODB_GETONE_EOF = false;</p>
4875 <p><b>GetRow<a name=getrow></a>($sql,$inputarr=false)</b></p>
4877 <p>Executes the SQL and returns the first row as an array. The recordset and
4878 remaining rows are discarded for you automatically. If no records are returned,
4879 an empty array is returned. If an error occurs, false is returned.</p>
4881 <p><b>GetAll<a name=getall></a>($sql,$inputarr=false)</b></p>
4883 <p>Executes the SQL and returns the all the rows as a 2-dimensional array. The
4884 recordset is discarded for you automatically. If an error occurs, false is
4885 returned. <i>GetArray</i> is a synonym for <i>GetAll</i>.</p>
4887 <p><b>GetCol<a name=getcol></a>($sql,$inputarr=false,$trim=false)</b></p>
4889 <p>Executes the SQL and returns all elements of the first column as a
4890 1-dimensional array. The recordset is discarded for you automatically. If an
4891 error occurs, false is returned.</p>
4893 <p><b>CacheGetOne<a name=cachegetone></a>([$secs2cache,] $sql,$inputarr=false),
4894 CacheGetRow<a name=cachegetrow></a>([$secs2cache,] $sql,$inputarr=false),
4895 CacheGetAll<a name=cachegetall></a>([$secs2cache,] $sql,$inputarr=false),
4896 CacheGetCol<a name=cachegetcol></a>([$secs2cache,]
4897 $sql,$inputarr=false,$trim=false)</b></p>
4899 <p>Similar to above Get* functions, except that the recordset is serialized and
4900 cached in the $ADODB_CACHE_DIR directory for $secs2cache seconds. Good for
4901 speeding up queries on rarely changing data. Note that the $secs2cache
4902 parameter is optional. If omitted, we use the value in
4903 $connection->cacheSecs (default is 3600 seconds, or 1 hour). </p>
4905 <p><b>Prepare<a name=prepare></a>($sql )</b></p>
4907 <p>Prepares (compiles) an SQL query for repeated execution. Bind parameters are
4908 denoted by ?, except for the oci8 driver, which uses the traditional Oracle
4909 :varname convention. </p>
4911 <p>Returns an array containing the original sql statement in the first array
4912 element; the remaining elements of the array are driver dependent. If there is
4913 an error, or we are emulating Prepare( ), we return the original $sql string.
4914 This is because all error-handling has been centralized in Execute( ).</p>
4916 <p>Prepare( ) cannot be used with functions that use SQL query rewriting
4917 techniques, e.g. PageExecute( ) and SelectLimit( ).</p>
4921 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
4922 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
4923 style='background:#EEEEEE'>$stmt = $DB->Prepare('insert into table (col1,col2) values (?,?)');<br>
4924 for ($i=0; $i < $max; $i++)<br>
4925 <span style='mso-tab-count:1'> </span>$DB->Execute($stmt,array((string) rand(), $i));</pre></div>
4927 <p>Also see InParameter(), OutParameter() and PrepareSP() below. Only supported
4928 internally by interbase, oci8 and selected ODBC-based drivers, otherwise it is
4929 emulated. There is no performance advantage to using Prepare() with emulation. </p>
4931 <p>Important: Due to limitations or bugs in PHP, if you are getting errors when
4932 you using prepared queries, try setting $ADODB_COUNTRECS = false before
4933 preparing. This behaviour has been observed with ODBC. </p>
4935 <p><b>IfNull<a name=ifnull></a>($field, $nullReplacementValue)</b></p>
4937 <p>Portable IFNULL function (NVL in Oracle). Returns a string that represents
4938 the function that checks whether a $field is null for the given database, and
4939 if null, change the value returned to $nullReplacementValue. Eg.</p>
4941 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
4942 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
4943 style='background:#EEEEEE'>$sql = <span style='color:#993300'>'SELECT '</span>.$db->IfNull('name', <span
4944 style='color:#993300'>"'- unknown -'"</span>).<span style='color:
4945 #993300'> ' FROM table'</span>;</pre></div>
4947 <p><b>length</b><a name=length></a></p>
4949 <p>This is not a function, but a property. Some databases have
4950 "length" and others "len" as the function to measure the
4951 length of a string. To use this property: </p>
4953 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
4954 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
4955 style='background:#EEEEEE'><span style='mso-spacerun:yes'> </span>$sql = <span
4956 style='color:#993300'>"SELECT "</span>.$db->length.<span
4957 style='color:#993300'>"(field) from table"</span>;<br>
4958 <span style='mso-spacerun:yes'> </span>$rs = $db->Execute($sql);</pre></div>
4960 <p><b>random</b><a name=random></a></p>
4962 <p>This is not a function, but a property. This is a string that holds the sql
4963 to generate a random number between 0.0 and 1.0 inclusive. </p>
4965 <p><b>substr</b><a name=substr></a></p>
4967 <p>This is not a function, but a property. Some databases have
4968 "substr" and others "substring" as the function to retrieve
4969 a sub-string. To use this property: </p>
4971 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
4972 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
4973 style='background:#EEEEEE'><span style='mso-spacerun:yes'> </span>$sql = <span
4974 style='color:#993300'>"SELECT "</span>.$db->substr.<span
4975 style='color:#993300'>"(field, $offset, $length) from table"</span>;<br>
4976 <span style='mso-spacerun:yes'> </span>$rs = $db->Execute($sql);</pre></div>
4978 <p>For all databases, the 1st parameter of <i>substr</i> is the field, the 2nd
4979 is the offset (1-based) to the beginning of the sub-string, and the 3rd is the
4980 length of the sub-string. </p>
4982 <p><b>Param<a name=param></a>($name)</b></p>
4984 <p>Generates a bind placeholder portably. For most databases, the bind
4985 placeholder is "?". However some databases use named bind parameters
4986 such as Oracle, eg ":somevar". This allows us to portably define an
4987 SQL statement with bind parameters: </p>
4989 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
4990 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
4991 style='background:#EEEEEE'>$sql = <span style='color:#993300'>'insert into table (col1,col2) values ('</span>.$DB->Param('a').<span
4992 style='color:#993300'>','</span>.$DB->Param('b').<span style='color:#993300'>')'</span>;<br>
4993 <span style='color:#006600'># generates 'insert into table (col1,col2) values (?,?)'<br>
4994 # or<span style='mso-spacerun:yes'> </span>'insert into table (col1,col2) values (:a,:b)</span>'<br>
4995 $stmt = $DB->Prepare($sql);<br>
4996 $stmt = $DB->Execute($stmt,array('one','two'));</pre></div>
4998 <p><b>PrepareSP<a name=preparesp></a>($sql, $cursor=false )</b></p>
5000 <p>When calling stored procedures in mssql and oci8 (oracle), and you might
5001 want to directly bind to parameters that return values, or for special LOB
5002 handling. PrepareSP() allows you to do so. </p>
5004 <p>Returns the same array or $sql string as Prepare( ) above. If you do not
5005 need to bind to return values, you should use Prepare( ) instead.</p>
5007 <p>The 2nd parameter, $cursor is not used except with oci8. Setting it to true
5008 will force OCINewCursor to be called; this is to support output REF CURSORs. </p>
5010 <p>For examples of usage of PrepareSP( ), see InParameter( ) below. </p>
5012 <p>Note: in the mssql driver, preparing stored procedures requires a special
5013 function call, mssql_init( ), which is called by this function. PrepareSP( ) is
5014 available in all other drivers, and is emulated by calling Prepare( ). </p>
5016 <p><b>InParameter<a name=inparameter></a>($stmt, $var, $name, $maxLen = 4000,
5017 $type = false )</b></p>
5019 <p class=MsoNormal>Binds a PHP variable as input to a stored procedure
5020 variable. The parameter <i>$stmt</i> is the value returned by PrepareSP(), <i>$var</i>
5021 is the PHP variable you want to bind, $name is the name of the stored procedure
5022 variable. Optional is <i>$maxLen</i>, the maximum length of the data to bind,
5023 and $type which is database dependant. Consult <a
5024 href="http://php.net/mssql_bind">mssql_bind</a> and <a
5025 href="http://php.net/ocibindbyname">ocibindbyname</a> docs at php.net for more
5026 info on legal values for $type. </p>
5028 <p>InParameter() is a wrapper function that calls Parameter() with
5029 $isOutput=false. The advantage of this function is that it is self-documenting,
5030 because the $isOutput parameter is no longer needed. Only for mssql and oci8
5033 <p>Here is an example using oci8: </p>
5035 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
5036 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span
5037 style='color:green'># For oracle, Prepare and PrepareSP are identical</span></pre><pre>$stmt = $db->PrepareSP(</pre><pre
5038 style='background:#EEEEEE'><span style='mso-tab-count:1'> </span><span
5039 style='color:#993300'>"declare RETVAL integer; <br>
5040 <span style='mso-tab-count:1'> </span>begin<br>
5041 <span style='mso-tab-count:1'> </span>:RETVAL := SP_RUNSOMETHING(:myid,:group);<br>
5042 <span style='mso-tab-count:1'> </span>end;"</span>);<br>
5043 $db->InParameter($stmt,$id,'myid');<br>
5044 $db->InParameter($stmt,$group,'group',64);<br>
5045 $db->OutParameter($stmt,$ret,'RETVAL');<br>
5046 $db->Execute($stmt);</pre></div>
5048 <p>The same example using mssql:</p>
5050 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
5051 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span
5052 style='color:green'># @RETVAL = SP_RUNSOMETHING @myid,@group</span></pre><pre>$stmt = $db->PrepareSP(<span
5053 style='color:#993333'>'</span><span style='color:#993300'>SP_RUNSOMETHING</span><span
5054 style='color:#993333'>'</span>); <br>
5055 <span style='color:green'># note that the parameter name does not have @ in front!</span></pre><pre>$db->InParameter($stmt,$id,'myid');</pre><pre>$db->InParameter($stmt,$group,'group',64);</pre><pre
5056 style='background:#EEEEEE'><span style='color:green'># return value in mssql - RETVAL is hard-coded name</span> <br>
5057 $db->OutParameter($stmt,$ret,'RETVAL');<br>
5058 $db->Execute($stmt); </pre></div>
5060 <p>Note that the only difference between the oci8 and mssql implementations is
5063 <p>If $type parameter is set to false, in mssql, $type will be dynamicly
5064 determined based on the type of the PHP variable passed <span style='font-family:
5065 "Courier New"'>(string => SQLCHAR, boolean =>SQLINT1, integer
5066 =>SQLINT4 or float/double=>SQLFLT8)</span>. </p>
5068 <p>In oci8, $type can be set to OCI_B_FILE (Binary-File), OCI_B_CFILE
5069 (Character-File), OCI_B_CLOB (Character-LOB), OCI_B_BLOB (Binary-LOB) and
5070 OCI_B_ROWID (ROWID). To pass in a null, use<span style='font-family:"Courier New"'>
5071 $db->Parameter($stmt, $null=null, 'param')</span>. </p>
5073 <p><b>OutParameter<a name=outparameter></a>($stmt, $var, $name, $maxLen = 4000,
5074 $type = false )</b></p>
5076 <p class=MsoNormal>Binds a PHP variable as output from a stored procedure
5077 variable. The parameter <i>$stmt</i> is the value returned by PrepareSP(), <i>$var</i>
5078 is the PHP variable you want to bind, <i>$name</i> is the name of the stored
5079 procedure variable. Optional is <i>$maxLen</i>, the maximum length of the data
5080 to bind, and <i>$type</i> which is database dependant. </p>
5082 <p>OutParameter() is a wrapper function that calls Parameter() with
5083 $isOutput=true. The advantage of this function is that it is self-documenting,
5084 because the $isOutput parameter is no longer needed. Only for mssql and oci8
5087 <p>For an example, see <a href="#inparameter">InParameter</a>. </p>
5089 <p><b>Parameter<a name=parameter></a>($stmt, $var, $name, $isOutput=false,
5090 $maxLen = 4000, $type = false )</b></p>
5092 <p>Note: This function is deprecated, because of the new InParameter() and
5093 OutParameter() functions. These are superior because they are self-documenting,
5094 unlike Parameter(). </p>
5096 <p>Adds a bind parameter suitable for return values or special data handling
5097 (eg. LOBs) after a statement has been prepared using PrepareSP(). Only for
5098 mssql and oci8 currently. The parameters are:<br>
5100 $<b><i>stmt</i></b> Statement returned by Prepare() or PrepareSP().<br>
5101 $<b><i>var</i></b> PHP variable to bind to. Make sure you pre-initialize it!<br>
5102 $<b><i>name</i></b> Name of stored procedure variable name to bind to.<br>
5103 [$<b><i>isOutput</i></b>] Indicates direction of parameter 0/false=IN 1=OUT 2=
5104 IN/OUT. This is ignored in oci8 as this driver auto-detects the direction.<br>
5105 [$<b>maxLen</b>] Maximum length of the parameter variable.<br>
5106 [$<b>type</b>] Consult <a href="http://php.net/mssql_bind">mssql_bind</a> and <a
5107 href="http://php.net/ocibindbyname">ocibindbyname</a> docs at php.net for more
5108 info on legal values for type.</p>
5110 <p>Lastly, in oci8, bind parameters can be reused without calling PrepareSP( ) or
5111 Parameters again. This is not possible with mssql. An oci8 example:</p>
5113 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
5114 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre>$id = 0; $i = 0;<br>
5115 $stmt = $db->PrepareSP( <span style='color:#993300'>"update table set val=:i where id=:id"</span>);<br>
5116 $db->Parameter($stmt,$id,'id');<br>
5117 $db->Parameter($stmt,$i, 'i');<br>
5118 for ($cnt=0; $cnt < 1000; $cnt++) {<br>
5119 <span style='mso-tab-count:1'> </span>$id = $cnt; <br>
5120 <span style='mso-tab-count:1'> </span>$i = $cnt * $cnt; <span
5121 style='color:green'># works with oci8!</span></pre><pre style='background:#EEEEEE'><span
5122 style='mso-tab-count:1'> </span>$db->Execute($stmt); <br>
5125 <p><b>Bind<a name=bind></a>($stmt, $var, $size=4001, $type=false, $name=false)</b></p>
5127 <p>This is a low-level function supported only by the oci8 driver. <b>Avoid
5128 using</b> unless you only want to support Oracle. The Parameter( ) function is
5129 the recommended way to go with bind variables.</p>
5131 <p>Bind( ) allows you to use bind variables in your sql statement. This binds a
5132 PHP variable to a name defined in an Oracle sql statement that was previously
5133 prepared using Prepare(). Oracle named variables begin with a colon, and ADOdb
5134 requires the named variables be called :0, :1, :2, :3, etc. The first
5135 invocation of Bind() will match :0, the second invocation will match :1, etc.
5136 Binding can provide 100% speedups for insert, select and update statements. </p>
5138 <p>The other variables, $size sets the buffer size for data storage, $type is
5139 the optional descriptor type OCI_B_FILE (Binary-File), OCI_B_CFILE
5140 (Character-File), OCI_B_CLOB (Character-LOB), OCI_B_BLOB (Binary-LOB) and
5141 OCI_B_ROWID (ROWID). Lastly, instead of using the default :0, :1, etc names,
5142 you can define your own bind-name using $name. </p>
5144 <p>The following example shows 3 bind variables being used: p1, p2 and p3.
5145 These variables are bound to :0, :1 and :2.</p>
5147 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
5148 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
5149 style='background:#EEEEEE'>$stmt = $DB->Prepare("insert into table (col0, col1, col2) values (:0, :1, :2)");<br>
5150 $DB->Bind($stmt, $p1);<br>
5151 $DB->Bind($stmt, $p2);<br>
5152 $DB->Bind($stmt, $p3);<br>
5153 for ($i = 0; $i < $max; $i++) { <br>
5154 <span style='mso-spacerun:yes'> </span>$p1 = ?; $p2 = ?; $p3 = ?;<br>
5155 <span style='mso-spacerun:yes'> </span>$DB->Execute($stmt);<br>
5158 <p>You can also use named variables:</p>
5160 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
5161 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
5162 style='background:#EEEEEE'>$stmt = $DB->Prepare("insert into table (col0, col1, col2) values (:name0, :name1, :name2)");<br>
5163 $DB->Bind($stmt, $p1, "name0");<br>
5164 $DB->Bind($stmt, $p2, "name1");<br>
5165 $DB->Bind($stmt, $p3, "name2");<br>
5166 for ($i = 0; $i < $max; $i++) { <br>
5167 <span style='mso-spacerun:yes'> </span>$p1 = ?; $p2 = ?; $p3 = ?;<br>
5168 <span style='mso-spacerun:yes'> </span>$DB->Execute($stmt);<br>
5171 <p><b>LogSQL($enable=true)</b><a name=logsql></a></p>
5173 <p class=MsoNormal>Call this method to install a SQL logging and timing
5174 function (using fnExecute). Then all SQL statements are logged into an
5175 adodb_logsql table in a database. If the adodb_logsql table does not exist,
5176 ADOdb will create the table if you have the appropriate permissions. Returns
5177 the previous logging value (true for enabled, false for disabled). Here are
5178 samples of the DDL for selected databases: </p>
5180 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
5181 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span
5182 style='mso-tab-count:2'> </span><b>mysql:</b></pre><pre><span
5183 style='mso-tab-count:2'> </span>CREATE TABLE adodb_logsql (</pre><pre><span
5184 style='mso-tab-count:2'> </span><span style='mso-spacerun:yes'> </span>created datetime NOT NULL,</pre><pre><span
5185 style='mso-tab-count:2'> </span><span style='mso-spacerun:yes'> </span>sql0 varchar(250) NOT NULL,</pre><pre><span
5186 style='mso-tab-count:2'> </span><span style='mso-spacerun:yes'> </span>sql1 text NOT NULL,</pre><pre><span
5187 style='mso-tab-count:2'> </span><span style='mso-spacerun:yes'> </span>params text NOT NULL,</pre><pre><span
5188 style='mso-tab-count:2'> </span><span style='mso-spacerun:yes'> </span>tracer text NOT NULL,</pre><pre><span
5189 style='mso-tab-count:2'> </span><span style='mso-spacerun:yes'> </span>timer decimal(16,6) NOT NULL</pre><pre><span
5190 style='mso-tab-count:2'> </span>)</pre><pre><span
5191 style='mso-tab-count:2'> </span></pre><pre><span
5192 style='mso-tab-count:2'> </span><b>postgres:</b></pre><pre><span
5193 style='mso-tab-count:2'> </span>CREATE TABLE adodb_logsql (</pre><pre><span
5194 style='mso-tab-count:2'> </span><span style='mso-spacerun:yes'> </span>created timestamp NOT NULL,</pre><pre><span
5195 style='mso-tab-count:2'> </span><span style='mso-spacerun:yes'> </span>sql0 varchar(250) NOT NULL,</pre><pre><span
5196 style='mso-tab-count:2'> </span><span style='mso-spacerun:yes'> </span>sql1 text NOT NULL,</pre><pre><span
5197 style='mso-tab-count:2'> </span><span style='mso-spacerun:yes'> </span>params text NOT NULL,</pre><pre><span
5198 style='mso-tab-count:2'> </span><span style='mso-spacerun:yes'> </span>tracer text NOT NULL,</pre><pre><span
5199 style='mso-tab-count:2'> </span><span style='mso-spacerun:yes'> </span>timer decimal(16,6) NOT NULL</pre><pre><span
5200 style='mso-tab-count:2'> </span>)</pre><pre><span
5201 style='mso-tab-count:2'> </span></pre><pre><span
5202 style='mso-tab-count:2'> </span><b>mssql:</b></pre><pre><span
5203 style='mso-tab-count:2'> </span>CREATE TABLE adodb_logsql (</pre><pre><span
5204 style='mso-tab-count:2'> </span><span style='mso-spacerun:yes'> </span>created datetime NOT NULL,</pre><pre><span
5205 style='mso-tab-count:2'> </span><span style='mso-spacerun:yes'> </span>sql0 varchar(250) NOT NULL,</pre><pre><span
5206 style='mso-tab-count:2'> </span><span style='mso-spacerun:yes'> </span>sql1 varchar(4000) NOT NULL,</pre><pre><span
5207 style='mso-tab-count:2'> </span><span style='mso-spacerun:yes'> </span>params varchar(3000) NOT NULL,</pre><pre><span
5208 style='mso-tab-count:2'> </span><span style='mso-spacerun:yes'> </span>tracer varchar(500) NOT NULL,</pre><pre><span
5209 style='mso-tab-count:2'> </span><span style='mso-spacerun:yes'> </span>timer decimal(16,6) NOT NULL</pre><pre><span
5210 style='mso-tab-count:2'> </span>)</pre><pre><span
5211 style='mso-tab-count:2'> </span></pre><pre><span
5212 style='mso-tab-count:2'> </span><b>oci8:</b></pre><pre><span
5213 style='mso-tab-count:2'> </span>CREATE TABLE adodb_logsql (</pre><pre><span
5214 style='mso-tab-count:2'> </span><span style='mso-spacerun:yes'> </span>created date NOT NULL,</pre><pre><span
5215 style='mso-tab-count:2'> </span><span style='mso-spacerun:yes'> </span>sql0 varchar(250) NOT NULL,</pre><pre><span
5216 style='mso-tab-count:2'> </span><span style='mso-spacerun:yes'> </span>sql1 varchar(4000) NOT NULL,</pre><pre><span
5217 style='mso-tab-count:2'> </span><span style='mso-spacerun:yes'> </span>params varchar(4000),</pre><pre><span
5218 style='mso-tab-count:2'> </span><span style='mso-spacerun:yes'> </span>tracer varchar(4000),</pre><pre><span
5219 style='mso-tab-count:2'> </span><span style='mso-spacerun:yes'> </span>timer decimal(16,6) NOT NULL</pre><pre><span
5220 style='mso-tab-count:2'> </span>)</pre></div>
5222 <p class=MsoNormal>Usage: </p>
5224 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
5225 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
5226 style='background:#EEEEEE'><span style='mso-tab-count:1'> </span>$conn->LogSQL(); // turn on logging<br>
5227 <span style='mso-tab-count:1'> </span><span style='mso-spacerun:yes'> </span>:<br>
5228 <span style='mso-tab-count:1'> </span>$conn->Execute(...);<br>
5229 <span style='mso-tab-count:1'> </span><span style='mso-spacerun:yes'> </span>:<br>
5230 <span style='mso-tab-count:1'> </span>$conn->LogSQL(false); // turn off logging<br>
5231 <span style='mso-tab-count:1'> </span><br>
5232 <span style='mso-tab-count:1'> </span># output summary of SQL logging results<br>
5233 <span style='mso-tab-count:1'> </span>$perf = NewPerfMonitor($conn);<br>
5234 <span style='mso-tab-count:1'> </span>echo $perf->SuspiciousSQL();<br>
5235 <span style='mso-tab-count:1'> </span>echo $perf->ExpensiveSQL();</pre></div>
5237 <p>One limitation of logging is that rollback also prevents SQL from being
5240 <p>If you prefer to use another name for the table used to store the SQL, you
5241 can override it by calling adodb_perf::table($tablename), where $tablename is
5242 the new table name (you will still need to manually create the table yourself).
5245 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
5246 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
5247 style='background:#EEEEEE'><span style='mso-tab-count:1'> </span>include('adodb.inc.php');<br>
5248 <span style='mso-tab-count:1'> </span>include('adodb-perf.inc.php');<br>
5249 <span style='mso-tab-count:1'> </span>adodb_perf::table('my_logsql_table');</pre></div>
5251 <p class=MsoNormal>Also see <a href="docs-perf.htm">Performance Monitor</a>. </p>
5253 <p><b>fnExecute and fnCacheExecute properties</b><a name=fnexecute
5254 id=fnexecute></a></p>
5256 <p>These two properties allow you to define bottleneck functions for all sql
5257 statements processed by ADOdb. This allows you to perform statistical analysis
5258 and query-rewriting of your sql. </p>
5260 <p><b>Examples of fnExecute</b></p>
5262 <p>Here is an example of using fnExecute, to count all cached queries and
5263 non-cached queries, you can do this:</p>
5265 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
5266 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span
5267 style='color:#006600'># $db is the connection object</span></pre><pre>function &CountExecs($db, $sql, $inputarray)</pre><pre>{</pre><pre>global $EXECS;</pre><pre><o:p> </o:p></pre><pre><span
5268 style='mso-tab-count:1'> </span>if (!is_array(inputarray)) $EXECS++;</pre><pre><span
5269 style='mso-tab-count:1'> </span><span style='color:#006600'># handle 2-dimensional input arrays</span></pre><pre><span
5270 style='mso-tab-count:1'> </span>else if (is_array(reset($inputarray))) $EXECS += sizeof($inputarray);</pre><pre><span
5271 style='mso-tab-count:1'> </span>else $EXECS++;</pre><pre><span
5272 style='mso-tab-count:1'> </span></pre><pre><span style='mso-tab-count:
5273 1'> </span><span style='color:#006600'># in PHP4.4 and PHP5, we need to return a value by reference</span></pre><pre><span
5274 style='mso-tab-count:1'> </span>$null = null;</pre><pre><span
5275 style='mso-tab-count:1'> </span>return $null;</pre><pre>}</pre><pre><o:p> </o:p></pre><pre><span
5276 style='color:#006600'># $db is the connection object</span></pre><pre>function CountCachedExecs($db, $secs2cache, $sql, $inputarray)</pre><pre
5277 style='background:#EEEEEE'>{<br>
5278 global $CACHED; $CACHED++;<br>
5281 $db = NewADOConnection('mysql');<br>
5282 $db->Connect(...);<br>
5283 $db-><strong><span style='font-family:"Courier New"'>fnExecute</span></strong> = 'CountExecs';<br>
5284 $db-><strong><span style='font-family:"Courier New"'>fnCacheExecute</span></strong> = 'CountCachedExecs';<br>
5285 <span style='mso-spacerun:yes'> </span>:<br>
5286 <span style='mso-spacerun:yes'> </span>:<br>
5287 <span style='color:#006600'># After many sql statements:</span>`<br>
5288 printf("<p>Total queries=%d; total cached=%d</p>",$EXECS+$CACHED, $CACHED);</pre></div>
5290 <p>The fnExecute function is called before the sql is parsed and executed, so
5291 you can perform a query rewrite. If you are passing in a prepared statement,
5292 then $sql is an array (see <a href="#prepare">Prepare</a>). The fnCacheExecute
5293 function is only called if the recordset returned was cached. The function
5294 parameters match the Execute and CacheExecute functions respectively, except
5295 that $this (the connection object) is passed as the first parameter.</p>
5297 <p>Since ADOdb 3.91, the behaviour of fnExecute varies depending on whether the
5298 defined function returns a value. If it does not return a value, then the $sql
5299 is executed as before. This is useful for query rewriting or counting sql
5302 <p>On the other hand, you might want to replace the Execute function with one
5303 of your own design. If this is the case, then have your function return a
5304 value. If a value is returned, that value is returned immediately, without any
5305 further processing. This is used internally by ADOdb to implement LogSQL()
5308 <div class=MsoNormal align=center style='text-align:center'>
5310 <hr size=2 width="100%" align=center>
5314 <h3>ADOConnection Utility Functions</h3>
5316 <p><b>BlankRecordSet<a name=blankrecordset></a>([$queryid])</b></p>
5318 <p>No longer available - removed since 1.99.</p>
5320 <p><b>Concat<a name=concat></a>($s1,$s2,....)</b></p>
5322 <p>Generates the sql string used to concatenate $s1, $s2, etc together. Uses
5323 the string in the concat_operator field to generate the concatenation. Override
5324 this function if a concatenation operator is not used, eg. MySQL.</p>
5326 <p>Returns the concatenated string.</p>
5328 <p><b>DBDate<a name=dbdate></a>($date)</b></p>
5330 <p>Format the $<b>date</b> in the format the database accepts - the return
5331 string is also quoted. This is used when you are sending dates to the database
5332 (eg INSERT, UPDATE or where clause of SELECT statement). The $<b>date</b>
5333 parameter can be a PHP DateTime object (since ADOdb 5.09), a Unix integer timestamp or an ISO format Y-m-d. Uses the
5334 fmtDate field, which holds the format to use. If null or false or '' is passed
5335 in, it will be converted to an SQL null.</p>
5337 <p>Returns the date as a quoted string.</p>
5339 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
5340 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><o:p> </o:p></pre><pre><span
5341 style='mso-tab-count:1'> </span>$sql = "select * from atable where created > ".$db->DBDate("$year-$month-$day");</pre><pre><span
5342 style='mso-tab-count:1'> </span>$db->Execute($sql);</pre></div>
5344 <p>Note to retrieve a date column in a specific format, use <a href="#sqldate">SQLDate</a>.
5347 <p><b>BindDate<a name=binddate></a>($date)</b></p>
5349 <p>Format the $<b>date</b> in the bind format the database accepts. Normally
5350 this means that the date string is not quoted, unlike DBDate, which quotes the
5353 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
5354 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><o:p> </o:p></pre><pre><span
5355 style='mso-tab-count:1'> </span>$sql = "select * from atable where created > ".$db->Param('0');</pre><pre><span
5356 style='mso-tab-count:1'> </span>// or</pre><pre><span style='mso-tab-count:
5357 1'> </span>$sql = "select * from atable where created > ?";</pre><pre><span
5358 style='mso-tab-count:1'> </span>$db->Execute($sql,array($db->BindDate("$year-$month-$day"));</pre></div>
5360 <p><b>DBTimeStamp<a name=dbtimestamp></a>($ts)</b></p>
5362 <p>Format the timestamp $<b>ts</b> in the format the database accepts; this can
5363 be a PHP DateTime object (since ADOdb 5.09), a Unix integer timestamp or an ISO format Y-m-d H:i:s. Uses the fmtTimeStamp
5364 field, which holds the format to use. If null or false or '' is passed in, it
5365 will be converted to an SQL null.</p>
5367 <p>Returns the timestamp as a quoted string.</p>
5369 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
5370 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><o:p> </o:p></pre><pre><span
5371 style='mso-tab-count:1'> </span>$sql = "select * from atable where created > ".$db->DBTimeStamp("$year-$month-$day $hr:$min:$secs");</pre><pre><span
5372 style='mso-tab-count:1'> </span>$db->Execute($sql);</pre></div>
5374 <p><b>BindTimeStamp<a name=bindtimestamp></a>($ts)</b></p>
5376 <p>Format the timestamp $<b>ts</b> in the bind format the database accepts.
5377 Normally this means that the timestamp string is not quoted, unlike
5378 DBTimeStamp, which quotes the string. </p>
5380 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
5381 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><o:p> </o:p></pre><pre><span
5382 style='mso-tab-count:1'> </span>$sql = "select * from atable where created > ".$db->Param('0');</pre><pre><span
5383 style='mso-tab-count:1'> </span>// or</pre><pre><span style='mso-tab-count:
5384 1'> </span>$sql = "select * from atable where created > ?";</pre><pre><span
5385 style='mso-tab-count:1'> </span>$db->Execute($sql,array($db->BindTimeStamp("$year-$month-$day $hr:$min:$secs"));</pre></div>
5387 <p><b>qstr<a name=qstr></a>($s,[$magic_quotes_enabled</b>=false]<b>)</b></p>
5389 <p>Quotes a string to be sent to the database. The $<b>magic_quotes_enabled</b>
5390 parameter may look funny, but the idea is if you are quoting a string extracted
5391 from a POST/GET variable, then pass get_magic_quotes_gpc() as the second
5392 parameter. This will ensure that the variable is not quoted twice, once by <i>qstr</i>
5393 and once by the <i>magic_quotes_gpc</i>.</p>
5395 <p>Eg.<span style='font-family:"Courier New"'> $s = $db->qstr(HTTP_GET_VARS['name'],get_magic_quotes_gpc());</span></p>
5397 <p>Returns the quoted string.</p>
5399 <p><b>Quote<a name=quote></a>($s)</b></p>
5401 <p>Quotes the string $s, escaping the database specific quote character as
5402 appropriate. Formerly checked magic quotes setting, but this was disabled since
5403 3.31 for compatibility with PEAR DB. </p>
5405 <p><b>Affected_Rows<a name="affected_rows"></a>( )</b></p>
5407 <p>Returns the number of rows affected by a update or delete statement. Returns
5408 false if function not supported.</p>
5410 <p>Not supported by interbase/firebird currently. </p>
5412 <p><b>Insert_ID<a name="inserted_id"></a>( )</b></p>
5414 <p>Returns the last autonumbering ID inserted. Returns false if function not
5417 <p>Only supported by databases that support auto-increment or object id's, such
5418 as PostgreSQL, MySQL and MS SQL Server currently. PostgreSQL returns the OID,
5419 which can change on a database reload.</p>
5421 <p><b>RowLock<a name=rowlock></a>($table,$where)</b></p>
5423 <p>Lock a table row for the duration of a transaction. For example to lock
5424 record $id in table1: </p>
5426 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
5427 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
5428 style='background:#EEEEEE'><span style='mso-tab-count:1'> </span>$DB->StartTrans();<br>
5429 <span style='mso-tab-count:1'> </span>$DB->RowLock("table1","rowid=$id");<br>
5430 <span style='mso-tab-count:1'> </span>$DB->Execute($sql1);<br>
5431 <span style='mso-tab-count:1'> </span>$DB->Execute($sql2);<br>
5432 <span style='mso-tab-count:1'> </span>$DB->CompleteTrans();</pre></div>
5434 <p>Supported in db2, interbase, informix, mssql, oci8, postgres, sybase. </p>
5436 <p><b>MetaDatabases<a name=metadatabases></a>()</b></p>
5438 <p>Returns a list of databases available on the server as an array. You have to
5439 connect to the server first. Only available for ODBC, MySQL and ADO.</p>
5441 <p><b>MetaTables<a name=metatables></a>($ttype = false, $showSchema = false,
5442 $mask=false)</b></p>
5444 <p>Returns an array of tables and views for the current database as an array.
5445 The array should exclude system catalog tables if possible. To only show
5446 tables, use $db->MetaTables('TABLES'). To show only views, use
5447 $db->MetaTables('VIEWS'). The $showSchema parameter currently works only for
5448 DB2, and when set to true, will add the schema name to the table, eg.
5449 "SCHEMA.TABLE". </p>
5451 <p>You can define a mask for matching. For example, setting $mask = 'TMP%' will
5452 match all tables that begin with 'TMP'. Currently only mssql, oci8, odbc_mssql
5453 and postgres* support $mask. </p>
5455 <p><b>MetaColumns<a name=metacolumns></a>($table,$notcasesensitive=true)</b></p>
5457 <p>Returns an array of ADOFieldObject's, one field object for every column of
5458 $table. A field object is a class instance with (name, type, max_length)
5459 defined. Currently Sybase does not recognise date types, and ADO cannot
5460 identify the correct data type (so we default to varchar). </p>
5462 <p>The $notcasesensitive parameter determines whether we uppercase or lowercase
5463 the table name to normalize it (required for some databases). Does not work
5464 with MySQL ISAM tables. </p>
5466 <p>For schema support, pass in the $table parameter,
5467 "$schema.$tablename". This is only supported for selected databases. </p>
5469 <p><b>MetaColumnNames<a name=metacolumnames></a>($table,$numericIndex=false)</b></p>
5471 <p>Returns an array of column names for $table. Since ADOdb 4.22, this is an
5472 associative array, with the keys in uppercase. Set $numericIndex=true if you
5473 want the old behaviour of numeric indexes (since 4.23). </p>
5475 <p>e.g. array('FIELD1' => 'Field1', 'FIELD2'=>'Field2') </p>
5477 <p><b>MetaPrimaryKeys<a name=metaprimarykeys></a>($table, $owner=false)</b> </p>
5479 <p>Returns an array containing column names that are the primary keys of
5480 $table. Supported by mysql, odbc (including db2, odbc_mssql, etc), mssql,
5481 postgres, interbase/firebird, oci8 currently. </p>
5483 <p>Views (and some tables) have primary keys, but sometimes this information is
5484 not available from the database. You can define a function
5485 ADODB_View_PrimaryKeys($databaseType, $database, $view, $owner) that should
5486 return an array containing the fields that make up the primary key. If that
5487 function exists, it will be called when MetaPrimaryKeys() cannot find a primary
5488 key for a table or view. </p>
5490 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
5491 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
5492 style='background:#EEEEEE'>// In this example: dbtype = 'oci8', $db = 'mydb', $view = 'dataView', $owner = false <br>
5493 function ADODB_View_PrimaryKeys($dbtype,$db,$view,$owner)<br>
5495 <span style='mso-tab-count:1'> </span>switch(strtoupper($view)) {<br>
5496 <span style='mso-tab-count:1'> </span>case 'DATAVIEW': return array('DATAID');<br>
5497 <span style='mso-tab-count:1'> </span>default: return false;<br>
5498 <span style='mso-tab-count:1'> </span>}<br>
5501 $db = NewADOConnection('oci8');<br>
5502 $db->Connect('localhost','root','','mydb'); <br>
5503 $db->MetaPrimaryKeys('dataView');</pre></div>
5505 <p><b>ServerInfo<a name=serverinfo id=serverinfo></a>()</b> </p>
5507 <p>Returns an array of containing two elements 'description' and 'version'. The
5508 'description' element contains the string description of the database. The
5509 'version' naturally holds the version number (which is also a string).</p>
5511 <p><b>SetCharSet<a name=setcharset id=setcharset></a>($charset)</b> </p>
5513 <p>Set the charset of the connection. The parameter passed in is dependent on the actual database RDBMS. e.g.
5515 $DB->SetCharSet('utf8'); // for mysql
5517 This is database driver specific and only supported for mysql, mysqlt, mysqli, and also postgres7 and later.</p>
5519 <p><b>MetaForeignKeys<a name=metaforeignkeys></a>($table, $owner=false,
5520 $upper=false)</b> </p>
5522 <p>Returns an associate array of foreign keys, or false if not supported. For
5523 example, if table employee has a foreign key where employee.deptkey points to
5524 dept_table.deptid, and employee.posn=posn_table.postionid and
5525 employee.poscategory=posn_table.category, then
5526 $conn->MetaForeignKeys('employee') will return </p>
5528 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
5529 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
5530 style='background:#EEEEEE'><span style='mso-tab-count:1'> </span>array(<br>
5531 <span style='mso-tab-count:2'> </span>'dept_table' => array('deptkey=deptid'),<br>
5532 <span style='mso-tab-count:2'> </span>'posn_table' => array('posn=positionid','poscategory=category')<br>
5533 <span style='mso-tab-count:1'> </span>)</pre></div>
5535 <p>The optional schema or owner can be defined in $owner. If $upper is true,
5536 then the table names (array keys) are upper-cased. </p>
5538 <div class=MsoNormal align=center style='text-align:center'>
5540 <hr size=2 width="100%" align=center>
5544 <h2>ADORecordSet<a name=adorecordset></a></h2>
5546 <p>When an SQL statement successfully is executed by <span style='font-family:
5547 "Courier New"'>ADOConnection->Execute($sql),</span>an ADORecordSet object is
5548 returned. This object contains a virtual cursor so we can move from row to row,
5549 functions to obtain information about the columns and column types, and helper
5550 functions to deal with formating the results to show to the user.</p>
5552 <h3>ADORecordSet Fields</h3>
5554 <p><b>fields: </b>Array containing the current row. This is not associative,
5555 but is an indexed array from 0 to columns-1. See also the function <b><a
5556 href="#fields">Fields</a></b>, which behaves like an associative array.</p>
5558 <p><b>dataProvider</b>: The underlying mechanism used to connect to the
5559 database. Normally set to <b>native</b>, unless using <b>odbc</b> or <b>ado</b>.</p>
5561 <p><b>blobSize</b>: Maximum size of a char, string or varchar object before it
5562 is treated as a Blob (Blob's should be shown with textarea's). See the <a
5563 href="#metatype">MetaType</a> function.</p>
5565 <p><b>sql</b>: Holds the sql statement used to generate this record set.</p>
5567 <p><b>canSeek</b>: Set to true if Move( ) function works.</p>
5569 <p><b>EOF</b>: True if we have scrolled the cursor past the last record.</p>
5571 <h3>ADORecordSet Functions</h3>
5573 <p><b>ADORecordSet( )</b></p>
5575 <p>Constructer. Normally you never call this function yourself.</p>
5577 <p><b>GetAssoc<a name=getassoc></a>([$force_array])</b></p>
5579 <p>Generates an associative array from the recordset. Note that is this
5580 function is also <a href="#getassoc1">available</a> in the connection object.
5581 More details can be found there.</p>
5583 <p><b>GetArray<a name=getarray></a>([$number_of_rows])</b></p>
5585 <p>Generate a 2-dimensional array of records from the current cursor position,
5586 indexed from 0 to $number_of_rows - 1. If $number_of_rows is undefined, till
5589 <p><b>GetRows<a name=getrows></a>([$number_of_rows])</b></p>
5591 <p class=MsoNormal>Generate a 2-dimensional array of records from the current
5592 cursor position. Synonym for GetArray() for compatibility with Microsoft ADO. </p>
5594 <p><b>GetMenu<a name=getmenu></a>($name, [$default_str=''],
5595 [$blank1stItem=true], [$multiple_select=false], [$size=0], [$moreAttr=''])</b></p>
5597 <p>Generate a HTML menu
5598 (<select><option><option></select>). The first column
5599 of the recordset (fields[0]) will hold the string to display in the option
5600 tags. If the recordset has more than 1 column, the second column (fields[1]) is
5601 the value to send back to the web server.. The menu will be given the name $<i>name</i>.
5604 <p>If $<i>default_str</i> is defined, then if $<i>default_str</i> == fields[0],
5605 that field is selected. If $<i>blank1stItem</i> is true, the first option is
5606 empty. You can also set the first option strings by setting $blank1stItem =
5607 "$value:$text".</p>
5609 <p>$<i>Default_str</i> can be array for a multiple select listbox.</p>
5611 <p>To get a listbox, set the $<i>size</i> to a non-zero value (or pass
5612 $default_str as an array). If $<i>multiple_select</i> is true then a listbox
5613 will be generated with $<i>size</i> items (or if $size==0, then 5 items)
5614 visible, and we will return an array to a server. Lastly use $<i>moreAttr </i>to
5615 add additional attributes such as javascript or styles. </p>
5617 <p>Menu Example 1: <code><span style='font-size:10.0pt'>GetMenu('menu1','A',true)</span></code>
5618 will generate a menu: <SELECT NAME="menu1">
5620 <OPTION SELECTED VALUE="1">A
5624 the data (A,1), (B,2), (C,3). Also see <a href="#ex5">example 5</a>.</p>
5626 <p>Menu Example 2: For the same data, <code><span style='font-size:10.0pt'>GetMenu('menu1',array('A','B'),false)</span></code>
5627 will generate a menu with both A and B selected: <br>
5628 <SELECT MULTIPLE NAME="menu1" SIZE="3">
5629 <OPTION SELECTED VALUE="1">A
5630 <OPTION SELECTED VALUE="2">B
5634 <p><b>GetMenu2<a name=getmenu2></a>($name, [$default_str=''],
5635 [$blank1stItem=true], [$multiple_select=false], [$size=0], [$moreAttr=''])</b></p>
5637 <p>This is nearly identical to GetMenu, except that the $<i>default_str</i> is
5638 matched to fields[1] (the option values).</p>
5640 <p>Menu Example 3: Given the data in menu example 2, <code><span
5641 style='font-size:10.0pt'>GetMenu2('menu1',array('1','2'),false)</span></code>
5642 will generate a menu with both A and B selected in menu example 2, but this
5643 time the selection is based on the 2nd column, which holds the values to return
5644 to the Web server. </p>
5646 <p><b>UserDate<a name=userdate></a>($str, [$fmt])</b></p>
5648 <p>Converts the date string $<i>str</i> to another format. The date format is
5649 Y-m-d, or Unix timestamp format. The default $<i>fmt</i> is Y-m-d.</p>
5651 <p><b>UserTimeStamp<a name=usertimestamp></a>($str, [$fmt])</b></p>
5653 <p>Converts the timestamp string $<b>str</b> to another format. The timestamp
5654 format is Y-m-d H:i:s, as in '2002-02-28 23:00:12', or Unix timestamp format.
5655 UserTimeStamp calls UnixTimeStamp to parse $<i>str</i>, and $<i>fmt</i>
5656 defaults to Y-m-d H:i:s if not defined. </p>
5658 <p><b>UnixDate<a name=unixdate></a>($str)</b></p>
5660 <p>Parses the date string $<b>str</b> and returns it in unix mktime format (eg.
5661 a number indicating the seconds after January 1st, 1970). Expects the date to
5662 be in Y-m-d H:i:s format, except for Sybase and Microsoft SQL Server, where M d
5663 Y is also accepted (the 3 letter month strings are controlled by a global
5664 array, which might need localisation).</p>
5666 <p>This function is available in both ADORecordSet and ADOConnection since
5669 <p><b>UnixTimeStamp<a name=unixtimestamp></a>($str)</b></p>
5671 <p>Parses the timestamp string $<b>str</b> and returns it in unix mktime format
5672 (eg. a number indicating the seconds after January 1st, 1970). Expects the date
5673 to be in "Y-m-d, H:i:s" (1970-12-24, 00:00:00) or "Y-m-d
5674 H:i:s" (1970-12-24 00:00:00) or "YmdHis" (19701225000000)
5675 format, except for Sybase and Microsoft SQL Server, where "M d Y
5676 h:i:sA" (Dec 25 1970 00:00:00AM) is also accepted (the 3 letter month
5677 strings are controlled by a global array, which might need localisation).</p>
5679 <p>This function is available in both ADORecordSet and ADOConnection since
5682 <p><b>OffsetDate<a name=OffsetDate></a>($dayFraction, $basedate=false)</b></p>
5684 <p>Returns a string with the native SQL functions to calculate future and past
5685 dates based on $basedate in a portable fashion. If $basedate is not defined,
5686 then the current date (at 12 midnight) is used. Returns the SQL string that
5687 performs the calculation when passed to Execute(). </p>
5689 <p>For example, in Oracle, to find the date and time that is 2.5 days from
5690 today, you can use:</p>
5692 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
5693 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
5694 style='background:#EEEEEE'># get date one week from now<br>
5695 $fld = $conn->OffsetDate(7); // returns "(trunc(sysdate)+7")</pre><pre># get date and time that is 60 hours from current date and time<br>
5696 $fld = $conn->OffsetDate(2.5, $conn->sysTimeStamp);<span
5697 style='mso-tab-count:1'> </span>// returns "(sysdate+2.5)"<br>
5699 $conn->Execute("UPDATE TABLE SET dodate=$fld WHERE ID=$id");</pre></div>
5701 <p>This function is available for mysql, mssql, oracle, oci8 and postgresql
5702 drivers since 2.13. It might work with other drivers provided they allow
5703 performing numeric day arithmetic on dates.</p>
5705 <p><b>SQLDate<a name=sqldate></a>($dateFormat, $basedate=false)</b></p>
5707 <p class=MsoNormal>Returns a string which contains the native SQL functions to
5708 format a date or date column $basedate. This is used when retrieving date
5709 columns in SELECT statements. For sending dates to the database (eg. in UPDATE,
5710 INSERT or the where clause of SELECT statements) use <a href="#dbdate">DBDate</a>.
5711 It uses a case-sensitive $dateFormat, which supports: </p>
5713 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
5714 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><span style='mso-spacerun:yes'> </span></pre><pre><span style='mso-spacerun:yes'> </span>Y: 4-digit Year</pre><pre><span style='mso-spacerun:yes'> </span>Q: Quarter (1-4)</pre><pre><span style='mso-spacerun:yes'> </span>M: Month (Jan-Dec)</pre><pre><span style='mso-spacerun:yes'> </span>m: Month (01-12)</pre><pre><span style='mso-spacerun:yes'> </span>d: Day (01-31)</pre><pre><span style='mso-spacerun:yes'> </span>H: Hour (00-23)</pre><pre><span style='mso-spacerun:yes'> </span>h: Hour (1-12)</pre><pre><span style='mso-spacerun:yes'> </span>i: Minute (00-59)</pre><pre><span style='mso-spacerun:yes'> </span>s: Second (00-60)</pre><pre><span style='mso-spacerun:yes'> </span>A: AM/PM indicator</pre><pre><span style='mso-spacerun:yes'> </span>w: day of week (0-6 or 1-7 depending on DB)</pre><pre><span style='mso-spacerun:yes'> </span>l: day of week (as string - lowercase L)</pre><pre><span style='mso-spacerun:yes'> </span>W: week in year (0..53 for MySQL, 1..53 for PostgreSQL and Oracle)</pre><pre
5715 style='background:#EEEEEE'><span style='mso-spacerun:yes'> </span></pre></div>
5717 <p>All other characters are treated as strings. You can also use \ to escape
5718 characters. Available on selected databases, including mysql, postgresql,
5719 mssql, oci8 and DB2. </p>
5721 <p>This is useful in writing portable sql statements that GROUP BY on dates.
5722 For example to display total cost of goods sold broken by quarter (dates are
5723 stored in a field called postdate): </p>
5725 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
5726 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
5727 style='background:#EEEEEE'><span style='mso-spacerun:yes'> </span>$sqlfn = $db->SQLDate('Y-\QQ','postdate'); # get sql that formats postdate to output 2002-Q1<br>
5728 <span style='mso-spacerun:yes'> </span>$sql = "SELECT $sqlfn,SUM(cogs) FROM table GROUP BY $sqlfn ORDER BY 1 desc";<br>
5729 <span style='mso-spacerun:yes'> </span></pre></div>
5731 <p><b>MoveNext<a name=movenext></a>( )</b></p>
5733 <p>Move the internal cursor to the next row. The <i>$this->fields</i> array
5734 is automatically updated. Returns false if unable to do so (normally because
5735 EOF has been reached), otherwise true. </p>
5737 <p>If EOF is reached, then the $this->fields array is set to false (this was
5738 only implemented consistently in ADOdb 3.30). For the pre-3.30 behaviour of
5739 $this->fields (at EOF), set the global variable $ADODB_COMPAT_FETCH = true.</p>
5743 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
5744 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
5745 style='background:#EEEEEE'>$rs = $db->Execute($sql);<br>
5747 <span style='mso-tab-count:1'> </span>while (!$rs->EOF) {<br>
5748 <span style='mso-spacerun:yes'> </span><span style='mso-tab-count:2'> </span>ProcessArray($rs->fields);<span
5749 style='mso-tab-count:1'> </span><br>
5750 <span style='mso-tab-count:2'> </span>$rs->MoveNext();<br>
5751 <span style='mso-tab-count:1'> </span>} </pre></div>
5753 <p><b>Move<a name=move></a>($to)</b></p>
5755 <p>Moves the internal cursor to a specific row $<b>to</b>. Rows are zero-based
5756 eg. 0 is the first row. The <b>fields</b> array is automatically updated. For
5757 databases that do not support scrolling internally, ADOdb will simulate forward
5758 scrolling. Some databases do not support backward scrolling. If the $<b>to</b>
5759 position is after the EOF, $<b>to</b> will move to the end of the RecordSet for
5760 most databases. Some obscure databases using odbc might not behave this way.</p>
5762 <p>Note: This function uses <i>absolute positioning</i>, unlike Microsoft's
5765 <p>Returns true or false. If false, the internal cursor is not moved in most
5766 implementations, so AbsolutePosition( ) will return the last cursor position
5767 before the Move( ). </p>
5769 <p><b>MoveFirst<a name=movefirst></a>()</b></p>
5771 <p>Internally calls Move(0). Note that some databases do not support this function.</p>
5773 <p><b>MoveLast<a name=movelast></a>()</b></p>
5775 <p>Internally calls Move(RecordCount()-1). Note that some databases do not
5776 support this function.</p>
5778 <p><b>GetRowAssoc</b><a name=getrowassoc></a>($toUpper=true)</p>
5780 <p>Returns an associative array containing the current row. The keys to the
5781 array are the column names. The column names are upper-cased for easy access.
5782 To get the next row, you will still need to call MoveNext(). </p>
5785 Array ( [ID] => 1 [FIRSTNAME] => Caroline [LASTNAME] => Miranda
5786 [CREATED] => 2001-07-05 ) </p>
5788 <p>Note: do not use GetRowAssoc() with $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC.
5789 Because they have the same functionality, they will interfere with each other.</p>
5791 <p><b>AbsolutePage<a name=absolutepage></a>($page=-1) </b></p>
5793 <p>Returns the current page. Requires PageExecute()/CachePageExecute() to be
5794 called. See <a href="#ex8">Example 8</a>.</p>
5796 <p><b>AtFirstPage<a name=atfirstpage>($status='')</a></b><span
5797 style='mso-bookmark:atfirstpage'></span></p>
5799 <p>Returns true if at first page (1-based). Requires
5800 PageExecute()/CachePageExecute() to be called. See <a href="#ex8">Example 8</a>.</p>
5802 <p><b>AtLastPage<a name=atlastpage>($status='')</a></b><span style='mso-bookmark:
5803 atlastpage'></span></p>
5805 <p>Returns true if at last page (1-based). Requires
5806 PageExecute()/CachePageExecute() to be called. See <a href="#ex8">Example 8</a>.</p>
5808 <p><b>Fields</b><a name=fields></a>(<b>$colname</b>)</p>
5810 <p>Returns the value of the associated column $<b>colname</b> for the current
5811 row. The column name is case-insensitive.</p>
5813 <p>This is a convenience function. For higher performance, use <a
5814 href="#adodb_fetch_mode">$ADODB_FETCH_MODE</a>. </p>
5816 <p><b>FetchRow</b><a name=fetchrow></a>()</p>
5818 <p>Returns array containing current row, or false if EOF. FetchRow( )
5819 internally moves to the next record after returning the current row. </p>
5821 <p>Warning: Do not mix using FetchRow() with MoveNext().</p>
5825 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
5826 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
5827 style='background:#EEEEEE'>$rs = $db->Execute($sql);<br>
5829 <span style='mso-tab-count:1'> </span>while ($arr = $rs->FetchRow()) {<br>
5830 <span style='mso-tab-count:1'> </span><span style='mso-spacerun:yes'> </span> # process $arr<span
5831 style='mso-tab-count:1'> </span><br>
5832 <span style='mso-tab-count:1'> </span>}</pre></div>
5834 <p><b>FetchInto</b><a name=fetchinto></a>(<b>&$array</b>)</p>
5836 <p>Sets $array to the current row. Returns PEAR_Error object if EOF, 1 if ok
5837 (DB_OK constant). If PEAR is undefined, false is returned when EOF. FetchInto(
5838 ) internally moves to the next record after returning the current row. </p>
5840 <p>FetchRow() is easier to use. See above.</p>
5842 <p><b>FetchField<a name=fetchfield></a>($column_number)</b></p>
5844 <p>Returns an object containing the <b>name</b>, <b>type</b> and <b>max_length</b>
5845 of the associated field. If the max_length cannot be determined reliably, it
5846 will be set to -1. The column numbers are zero-based. See <a href="#ex2">example
5849 <p><b>FieldCount<a name=fieldcount></a>( )</b></p>
5851 <p>Returns the number of fields (columns) in the record set.</p>
5853 <p><b>RecordCount<a name=recordcount></a>( )</b></p>
5855 <p>Returns the number of rows in the record set. If the number of records
5856 returned cannot be determined from the database driver API, we will buffer all
5857 rows and return a count of the rows after all the records have been retrieved.
5858 This buffering can be disabled (for performance reasons) by setting the global
5859 variable $ADODB_COUNTRECS = false. When disabled, RecordCount( ) will return -1
5860 for certain databases. See the supported databases list above for more details.
5863 <p>RowCount is a synonym for RecordCount.</p>
5865 <p><b>PO_RecordCount<a name="po_recordcount"></a>($table, $where)</b></p>
5867 <p>Returns the number of rows in the record set. If the database does not
5868 support this, it will perform a SELECT COUNT(*) on the table $table, with the
5869 given $where condition to return an estimate of the recordset size.</p>
5871 <p>$numrows = $rs->PO_RecordCount("articles_table",
5872 "group=$group");</p>
5874 <p class=MsoNormal><b>NextRecordSet<a name=nextrecordset id=nextrecordset></a>()</b>
5877 <p>For databases that allow multiple recordsets to be returned in one query,
5878 this function allows you to switch to the next recordset. Currently only
5879 supported by mssql driver.</p>
5881 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
5882 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
5883 style='background:#EEEEEE'>$rs = $db->Execute('execute return_multiple_rs');<br>
5884 $arr1 = $rs->GetArray();<br>
5885 $rs->NextRecordSet();<br>
5886 $arr2 = $rs->GetArray();</pre></div>
5888 <p><b>FetchObject<a name=fetchobject></a>($toupper=true)</b></p>
5890 <p>Returns the current row as an object. If you set $toupper to true, then the
5891 object fields are set to upper-case. Note: The newer FetchNextObject() is the
5892 recommended way of accessing rows as objects. See below.</p>
5894 <p><b>FetchNextObject<a name=fetchnextobject></a>($toupper=true)</b></p>
5896 <p>Gets the current row as an object and moves to the next row automatically.
5897 Returns false if at end-of-file. If you set $toupper to true, then the object
5898 fields are set to upper-case. Note that for some drivers such as mssql, you
5899 need to SetFetchMode(ADODB_FETCH_ASSOC) or SetFetchMode(ADODB_FETCH_BOTH).</p>
5901 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
5902 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
5903 style='background:#EEEEEE'>$rs = $db->Execute('select firstname,lastname from table');<br>
5905 <span style='mso-tab-count:1'> </span>while ($o = $rs->FetchNextObject()) {<br>
5906 <span style='mso-tab-count:2'> </span>print "$o->FIRSTNAME, $o->LASTNAME<BR>";<br>
5907 <span style='mso-tab-count:1'> </span>}<br>
5910 <p>There is some trade-off in speed in using FetchNextObject(). If performance
5911 is important, you should access rows with the <code><span style='font-size:
5912 10.0pt'>fields[]</span></code> array. <b>FetchObj<a name=fetchobj id=fetchobj></a>()</b>
5915 <p>Returns the current record as an object. Fields are not upper-cased, unlike
5918 <p><b>FetchNextObj<a name=fetchnextobj id=fetchnextobj></a>()</b> </p>
5920 <p>Returns the current record as an object and moves to the next record. If
5921 EOF, false is returned. Fields are not upper-cased, unlike FetctNextObject. </p>
5923 <p><b>CurrentRow<a name=currentrow></a>( )</b></p>
5925 <p>Returns the current row of the record set. 0 is the first row.</p>
5927 <p><b>AbsolutePosition<a name=abspos></a>( )</b></p>
5929 <p>Synonym for <b>CurrentRow</b> for compatibility with ADO. Returns the
5930 current row of the record set. 0 is the first row.</p>
5932 <p><b>MetaType<a name=metatype></a>($nativeDBType[,$field_max_length],[$fieldobj])</b></p>
5934 <p>Determine what <i>generic</i> meta type a database field type is given its
5935 native type $<b>nativeDBType</b> as a string and the length of the field $<b>field_max_length</b>.
5936 Note that field_max_length can be -1 if it is not known. The field object
5937 returned by FetchField() can be passed in $<b>fieldobj</b> or as the 1st
5938 parameter <b>$nativeDBType</b>. This is useful for databases such as <i>mysql</i>
5939 which has additional properties in the field object such as <i>primary_key</i>.
5942 <p>Uses the field <b>blobSize</b> and compares it with $<b>field_max_length</b>
5943 to determine whether the character field is actually a blob.</p>
5945 <p class=MsoNormal>For example, $db->MetaType('char') will return 'C'. </p>
5950 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
5951 mso-list:l7 level1 lfo11;tab-stops:list 36.0pt'><b>C</b>: Character fields
5952 that should be shown in a <input type="text"> tag. </li>
5953 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
5954 mso-list:l7 level1 lfo11;tab-stops:list 36.0pt'><b>X</b>: Clob (character
5955 large objects), or large text fields that should be shown in a
5956 <textarea></li>
5957 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
5958 mso-list:l7 level1 lfo11;tab-stops:list 36.0pt'><b>D</b>: Date field</li>
5959 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
5960 mso-list:l7 level1 lfo11;tab-stops:list 36.0pt'><b>T</b>: Timestamp field</li>
5961 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
5962 mso-list:l7 level1 lfo11;tab-stops:list 36.0pt'><b>L</b>: Logical field
5963 (boolean or bit-field)</li>
5964 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
5965 mso-list:l7 level1 lfo11;tab-stops:list 36.0pt'><b>N</b>: Numeric field.
5966 Includes decimal, numeric, floating point, and real. </li>
5967 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
5968 mso-list:l7 level1 lfo11;tab-stops:list 36.0pt'><b>I</b>: Integer
5970 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
5971 mso-list:l7 level1 lfo11;tab-stops:list 36.0pt'><b>R</b>: Counter or
5972 Autoincrement field. Must be numeric.</li>
5973 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
5974 mso-list:l7 level1 lfo11;tab-stops:list 36.0pt'><b>B</b>: Blob, or binary
5975 large objects. </li>
5978 <p>Since ADOdb 3.0, MetaType accepts $fieldobj as the first parameter, instead
5979 of $nativeDBType. </p>
5981 <p><b>Close( )</b><a name=rsclose></a></p>
5983 <p>Closes the recordset, cleaning all memory and resources associated with the
5986 <p>If memory management is not an issue, you do not need to call this function
5987 as recordsets are closed for you by PHP at the end of the script. SQL
5988 statements such as INSERT/UPDATE/DELETE do not really return a recordset, so you
5989 do not have to call Close() for such SQL statements.</p>
5991 <div class=MsoNormal align=center style='text-align:center'>
5993 <hr size=2 width="100%" align=center>
5997 <h3>function rs2html<a name=rs2html></a>($adorecordset,[$tableheader_attributes],
6000 <p>This is a standalone function (rs2html = recordset to html) that is similar
6001 to PHP's <i>odbc_result_all</i> function, it prints a ADORecordSet, $<b>adorecordset</b>
6002 as a HTML table. $<b>tableheader_attributes</b> allow you to control the table <i>cellpadding</i>,
6003 <i>cellspacing</i> and <i>border</i> attributes. Lastly you can replace the
6004 database column names with your own column titles with the array $<b>col_titles</b>.
6005 This is designed more as a quick debugging mechanism, not a production table
6006 recordset viewer.</p>
6008 <p>You will need to include the file <i>tohtml.inc.php</i>.</p>
6010 <p>Example of rs2html:<a name=exrs2html></a></p>
6012 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
6013 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
6014 style='background:#EEEEEE'><b><span style='color:#336600'><?<br>
6015 include('tohtml.inc.php')</span></b>; # load code common to ADOdb <br>
6016 <b>include</b>('adodb.inc.php'); # load code common to ADOdb <br>
6017 $<span style='color:#663300'>conn</span> = &ADONewConnection('mysql');<span style='mso-spacerun:yes'> </span># create a connection <br>
6018 $<span style='color:#663300'>conn</span>->PConnect('localhost','userid','','agora');# connect to MySQL, agora db<br>
6019 $<span style='color:#663300'>sql</span> = 'select CustomerName, CustomerID from customers'; <br>
6020 $<span style='color:#663300'>rs</span><span style='mso-spacerun:yes'> </span>= $<span
6021 style='color:#663300'>conn</span>->Execute($sql); <br>
6022 <b><span style='color:#336600'>rs2html</span>($</b><b><span style='color:#663300'>rs</span>,'<i>border=2 cellpadding=3</i>',array('<i>Customer Name','Customer ID</i>'));<br>
6023 ?></b></pre></div>
6025 <div class=MsoNormal align=center style='text-align:center'>
6027 <hr size=2 width="100%" align=center>
6031 <h3>Differences between this ADOdb library and Microsoft ADO<a name=adodiff></a></h3>
6034 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
6035 mso-list:l10 level1 lfo12;tab-stops:list 36.0pt'>ADOdb only supports
6036 recordsets created by a connection object. Recordsets cannot be created
6038 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
6039 mso-list:l10 level1 lfo12;tab-stops:list 36.0pt'>ADO properties are implemented
6040 as functions in ADOdb. This makes it easier to implement any enhanced ADO
6041 functionality in the future.</li>
6042 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
6043 mso-list:l10 level1 lfo12;tab-stops:list 36.0pt'>ADOdb's <span
6044 style='font-family:"Courier New"'>ADORecordSet->Move()</span> uses
6045 absolute positioning, not relative. Bookmarks are not supported.</li>
6046 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
6047 mso-list:l10 level1 lfo12;tab-stops:list 36.0pt'><span style='font-family:
6048 "Courier New"'>ADORecordSet->AbsolutePosition() </span>cannot be used
6049 to move the record cursor.</li>
6050 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
6051 mso-list:l10 level1 lfo12;tab-stops:list 36.0pt'>ADO Parameter objects are
6052 not supported. Instead we have the ADOConnection::<a href="#parameter">Parameter</a>(
6053 ) function, which provides a simpler interface for calling preparing
6054 parameters and calling stored procedures.</li>
6055 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
6056 mso-list:l10 level1 lfo12;tab-stops:list 36.0pt'>Recordset properties for
6057 paging records are available, but implemented as in <a href="#ex8">Example
6061 <div class=MsoNormal align=center style='text-align:center'>
6063 <hr size=2 width="100%" align=center>
6067 <h1>Database Driver Guide<a name=driverguide></a></h1>
6069 <p>This describes how to create a class to connect to a new database. To ensure
6070 there is no duplication of work, kindly email me at jlim#natsoft.com if you
6071 decide to create such a class.</p>
6073 <p>First decide on a name in lower case to call the database type. Let's say we
6076 <p>Then we need to create two classes ADODB_xbase and ADORecordSet_xbase in the
6077 file adodb-xbase.inc.php.</p>
6079 <p>The simplest form of database driver is an adaptation of an existing ODBC
6080 driver. Then we just need to create the class <i>ADODB_xbase extends ADODB_odbc</i>
6081 to support the new <b>date</b> and <b>timestamp</b> formats, the <b>concatenation</b>
6082 operator used, <b>true</b> and <b>false</b>. For the<i> ADORecordSet_xbase
6083 extends ADORecordSet_odbc </i>we need to change the <b>MetaType</b> function.
6084 See<b> adodb-vfp.inc.php</b> as an example.</p>
6086 <p>More complicated is a totally new database driver that connects to a new PHP
6087 extension. Then you will need to implement several functions. Fortunately, you
6088 do not have to modify most of the complex code. You only need to override a few
6089 stub functions. See <b>adodb-mysql.inc.php</b> for example.</p>
6091 <p>The default date format of ADOdb internally is YYYY-MM-DD (Ansi-92). All
6092 dates should be converted to that format when passing to an ADOdb date
6093 function. See Oracle for an example how we use ALTER SESSION to change the
6094 default date format in _pconnect _connect.</p>
6096 <p><b>ADOConnection Functions to Override</b></p>
6098 <p>Defining a constructor for your ADOConnection derived function is optional.
6099 There is no need to call the base class constructor.</p>
6101 <p>_<b>connect</b>: Low level implementation of Connect. Returns true or false.
6102 Should set the _<b>connectionID</b>.</p>
6104 <p>_<b>pconnect:</b> Low level implemention of PConnect. Returns true or false.
6105 Should set the _<b>connectionID</b>.</p>
6107 <p>_<b>query</b>: Execute a query. Returns the queryID, or false.</p>
6109 <p>_<b>close: </b>Close the connection -- PHP should clean up all recordsets. </p>
6111 <p><b>ErrorMsg</b>: Stores the error message in the private variable _errorMsg.
6114 <p><b>ADOConnection Fields to Set</b></p>
6116 <p>_<b>bindInputArray</b>: Set to true if binding of parameters for SQL inserts
6117 and updates is allowed using ?, eg. as with ODBC.</p>
6119 <p><b>fmtDate</b></p>
6121 <p><b>fmtTimeStamp</b></p>
6127 <p><b>concat_operator</b></p>
6129 <p><b>replaceQuote</b></p>
6131 <p><b>hasLimit</b> support SELECT * FROM TABLE LIMIT 10 of MySQL.</p>
6133 <p><b>hasTop</b> support Microsoft style SELECT TOP 10 * FROM TABLE.</p>
6135 <p><b>ADORecordSet Functions to Override</b></p>
6137 <p>You will need to define a constructor for your ADORecordSet derived class
6138 that calls the parent class constructor.</p>
6140 <p><b>FetchField: </b>as documented above in ADORecordSet</p>
6142 <p>_<b>initrs</b>: low level initialization of the recordset: setup the _<b>numOfRows</b>
6143 and _<b>numOfFields</b> fields -- called by the constructor.</p>
6145 <p>_<b>seek</b>: seek to a particular row. Do not load the data into the fields
6146 array. This is done by _fetch. Returns true or false. Note that some
6147 implementations such as Interbase do not support seek. Set canSeek to false.</p>
6149 <p>_<b>fetch</b>: fetch a row using the database extension function and then
6150 move to the next row. Sets the <b>fields</b> array. If the parameter
6151 $ignore_fields is true then there is no need to populate the <b>fields</b>
6152 array, just move to the next row. then Returns true or false.</p>
6154 <p>_<b>close</b>: close the recordset</p>
6156 <p><b>Fields</b>: If the array row returned by the PHP extension is not an
6157 associative one, you will have to override this. See adodb-odbc.inc.php for an
6158 example. For databases such as MySQL and MSSQL where an associative array is
6159 returned, there is no need to override this function.</p>
6161 <p><b>ADOConnection Fields to Set</b></p>
6163 <p>canSeek: Set to true if the _seek function works.</p>
6165 <h2>Optimizing PHP</h2>
6167 <p class=MsoNormal>For info on tuning PHP, read this article on <a
6168 href="http://phplens.com/lens/php-book/optimizing-debugging-php.php">Optimizing
6171 <h2>Change Log<a name=changes></a><a name=changelog></a></h2>
6172 <p><a name=5.18><b>5.18 3 Sep 2012</b>
6173 <p>datadict-postgres: Fixes bug in ALTER COL. See http://phplens.com/lens/lensforum/msgs.php?id=19202. Also fixed bugs in MetaType() checking $fieldobj properties.
6174 <p>GetRowAssoc did not work with null values. Bug in 5.17.
6175 <p>postgres9: New driver to better support PostgreSQL 9. Thx Glenn Herteg and Cacti team.
6176 <p>sqlite3: Modified to support php 5.4. Thx Günter Weber [built.development#googlemail.com]
6177 <p>adodb: When fetch mode is ADODB_FETCH_ASSOC, and we execute $db->GetAssoc("select 'a','0'"); we get an error. Fixed. See http://phplens.com/lens/lensforum/msgs.php?id=19190
6178 <p>adodb: Caching directory permissions now configurable using global variable
6179 $ADODB_CACHE_PERMS. Default value is 0771.
6180 <p>mysqli: SetCharSet() did not return true (success) or false (fail) correctly. Fixed.
6181 <p>mysqli: changed dataProvider to 'mysql' so that MetaError and other shared functions will work.
6182 <p>mssqlnative: Prepare() did not work previously. Now calling Prepare() will work but the sql is not actually compiled. Unfortunately bind params are passed to sqlsrv_prepare and not to sqlsrv_execute.
6183 make Prepare() and empty function, and we still execute the unprepared stmt.
6184 <p>mysql: FetchField(-1), turns it is is not possible to retrieve the max_length. Set to -1.
6185 <p>mysql-perf: Fixed "SHOW INNODB STATUS". Change to "SHOW ENGINE INNODB STATUS"
6186 <p><a name=5.17><b>5.17 18 May 2012</b>
6187 <p>Active Record: Removed trailing whitespace from adodb-active-record.inc.php.
6188 <p>odbc: Added support for $database parameter in odbc Connect() function. E.g. $DB->Connect($dsn_without_db, $user, $pwd, $database).
6189 Previously $database had to be left blank and the $dsn was used to pass in this parameter.
6190 <p>oci8: Added better empty($rs) error handling to metaindexes().
6191 <p>oci8: Changed to use newer oci API to support PHP 5.4.
6192 <p>adodb.inc.php: Changed GetRowAssoc to more generic code that will work in all scenarios.
6193 <p><a name=5.16><b>5.16 26 March 2012</b>
6194 <p>mysqli: extra mysqli_next_result() in close() removed. See http://phplens.com/lens/lensforum/msgs.php?id=19100
6195 <p>datadict-oci8: minor typo in create sequence trigger fixed. See http://phplens.com/lens/lensforum/msgs.php?id=18879.
6196 <p>security: safe date parsing changes. Does not impact security, these are code optimisations. Thx Saithis.
6197 <p>postgres, oci8, oci8po, db2oci: Param() function parameters inconsistent with base class. $type='C' missing. Fixed.
6198 <p>active-record: locked bug fixed. http://phplens.com/lens/lensforum/msgs.php?phplens_forummsg=new&id=19073
6199 <p>mysql, mysqli and informix: added MetaProcedures. Metaprocedures allows to retrieve an array list of all procedures in database. http://phplens.com/lens/lensforum/msgs.php?id=18414
6200 <p>Postgres7: added support for serial data type in MetaColumns().
6201 <p><a name=5.15><b>5.15 19 Jan 2012</b>
6202 <p>pdo: fix ErrorMsg() to detect errors correctly. Thx Jens.
6203 <p>mssqlnative: added another check for $this->fields array exists.
6204 <p>mssqlnative: bugs in FetchField() fixed. See http://phplens.com/lens/lensforum/msgs.php?id=19024
6205 <p>DBDate and DBTimeStamp had sql injection bug. Fixed. Thx Saithis
6206 <p>mysql and mysqli: MetaTables() now identifies views and tables correctly.
6207 <p>Added function adodb_time() to adodb-time.inc.php. Generates current time in unsigned integer format.
6208 <p><a name=5.14><b>5.14 8 Sep 2011</b>
6209 <p>mysqli: fix php compilation bug.
6210 <p>postgres: bind variables did not work properly. Fixed.
6211 <p>postgres: blob handling bug in _decode. Fixed.
6212 <p>ActiveRecord: if a null field was never updated, activerecord would still update the record. Fixed.
6213 <p>ActiveRecord: 1 char length string never quoted. Fixed.
6214 <p>LDAP: Connection string ldap:// and ldaps:// did not work. Fixed.
6215 <p><a name=5.13></a><b>5.13 15 Aug 2011</b>
6216 <p>Postgres: Fix in 5.12 was wrong. Uses pg_unescape_bytea() correctly now in _decode.
6217 <p>GetInsertSQL/GetUpdateSQL: Now $ADODB_QUOTE_FIELDNAMES allows you to define 'NATIVE', 'UPPER', 'LOWER'. If set to true, will default to 'UPPER'.
6218 <p>mysqli: added support for persistent connections 'p:'.
6219 <p>mssqlnative: ADODB_FETCH_BOTH did not work properly. Fixed.
6220 <p>mssqlnative: return values for stored procedures where not returned! Fixed. See http://phplens.com/lens/lensforum/msgs.php?id=18919
6221 <p>mssqlnative: timestamp and fetchfield bugs fixed. http ://phplens.com/lens/lensforum/msgs.php?id=18453
6222 <p><a name=5.12></a><b>5.12 30 June 2011</b> </p>
6223 <p>Postgres: Added information_schema support for postgresql.
6224 <p>Postgres: Use pg_unescape_bytea() in _decode.
6225 <p>Fix bulk binding with oci8. http://phplens.com/lens/lensforum/msgs.php?id=18786
6226 <p>oci8 perf: added wait evt monitoring. Also db cache advice now handles multiple buffer pools properly.
6227 <p>sessions2: Fixed setFetchMode problem.
6228 <p>sqlite: Some DSN connection settings were not parsed correctly.
6229 <p>mysqli: now GetOne obeys $ADODB_GETONE_EOF;
6230 <p>memcache: compress option did not work. Fixed. See http://phplens.com/lens/lensforum/msgs.php?id=18899
6231 <p><a name=5.11></a><b>5.11 5 May 2010</b> </p>
6232 <p>mysql: Fixed GetOne() to return null if no records returned.
6233 <p>oci8 perf: added stats on sga, rman, memory usage, and flash in performance tab.
6234 <p>odbtp: Now you can define password in $password field of Connect()/PConnect(), and it will add it to DSN.
6235 <p>Datadict: altering columns did not consider the scale of the column. Now it does.
6236 <p>mssql: Fixed problem with ADODB_CASE_ASSOC causing multiple versions of column name appearing in recordset fields.
6237 <p>oci8: Added missing & to refLob.
6238 <p>oci8: Added obj->scale to FetchField().
6239 <p>oci8: Now you can get column info of a table in a different schema, e.g. MetaColumns("schema.table") is supported.
6240 <p>odbc_mssql: Fixed missing $metaDatabasesSQL.
6241 <p>xmlschema: Changed declaration of create() to create($xmls) to fix compat problems. Also changed constructor adoSchema() to pass in variable instead of variable reference.
6242 <p>ado5: Fixed ado5 exceptions to only display errors when $this->debug=true;
6243 <p>Added DSN support to sessions2.inc.php.
6244 <p>adodb-lib.inc.php. Fixed issue with _adodb_getcount() not using $secs2cache parameter.
6245 <p>adodb active record. Fixed caching bug. See http://phplens.com/lens/lensforum/msgs.php?id=18288.
6246 <p>db2: fixed ServerInfo().
6247 <p>adodb_date: Added support for format 'e' for TZ as in adodb_date('e')
6248 <p>Active Record: If you have a field which is a string field (with numbers in) and you add preceding 0's to it the adodb library does not pick up the fact that the field has changed because of the way php's == works (dodgily). The end result is that it never gets updated into the database - fix by Matthew Forrester (MediaEquals). [matthew.forrester#mediaequals.com]
6250 <p>Fixes RowLock() and MetaIndexes() inconsistencies. See http://phplens.com/lens/lensforum/msgs.php?id=18236
6251 <p>Active record support for postgrseql boolean. See http://phplens.com/lens/lensforum/msgs.php?id=18246
6252 <p>By default, Execute 2D array is disabled for security reasons. Set $conn->bulkBind = true to enable. See http://phplens.com/lens/lensforum/msgs.php?id=18270. Note this breaks backward compat.
6253 <P>MSSQL: fixes for 5.2 compat. http://phplens.com/lens/lensforum/msgs.php?id=18325
6254 <p>Changed Version() to return a string instead of a float so it correctly returns 5.10 instead of 5.1.
6256 <p><a name=5.10></a><b>5.10 10 Nov 2009</b> </p>
6257 <p>Fixed memcache to properly support $rs->timeCreated.
6258 <p>adodb-ado.inc.php: Added BigInt support for PHP5. Will return float instead to support large numbers. Thx nasb#mail.goo.ne.jp.
6259 <p>adodb-mysqli.inc.php: mysqli_multi_query is now turned off by default. To turn it on, use $conn->multiQuery = true; This is because of the risks of sql injection. See http://phplens.com/lens/lensforum/msgs.php?id=18144
6260 <p>New db2oci driver for db2 9.7 when using PL/SQL mode. Allows oracle style :0, :1, :2 bind parameters which are remapped to ? ? ?.
6261 <p>adodb-db2.inc.php: fixed bugs in MetaTables. SYS owner field not checked properly. Also in $conn->Connect($dsn, null, null, $schema) and PConnect($dsn, null, null, $schema), we do a SET SCHEMA=$schema if successful connection.
6262 <p>adodb-mysqli.inc.php: Now $rs->Close() closes all pending next resultsets. Thx Clifton mesmackgod#gmail.com
6263 <p>Moved _CreateCache() from PConnect()/Connect() to CacheExecute(). Suggested by Dumka.
6264 <p>Many bug fixes to adodb-pdo_sqlite.inc.php and new datadict-sqlite.inc.php. Thx Andrei B. [andreutz#mymail.ro]
6265 <p>Removed usage of split (deprecated in php 5.3). Thx david#horizon-nigh.org.
6266 <p>Fixed RowLock() parameters to comply with PHP5 strict mode in multiple drivers.
6268 <p><a name=5.09></a><b>5.09 25 June 2009</b> </p>
6269 <p>Active Record: You can force column names to be quoted in INSERT and UPDATE statements, typically because you are using reserved words as column names by setting
6270 ADODB_Active_Record::$_quoteNames = true;
6271 <p>Added memcache and cachesecs to DSN. e.g.
6273 # we have a memcache servers mem1,mem2 on port 8888, compression=off and cachesecs=120
6274 $dsn = 'mysql://user:pwd@localhost/mydb?memcache=mem1,mem2:8888:0&cachesecs=120';
6276 <p>Fixed up MetaColumns and MetaPrimaryIndexes() for php 5.3 compat. Thx http://adodb.pastebin.com/m52082b16
6277 <p>The postgresql driver's OffsetDate() apparently does not work with postgres 8.3. Fixed.
6278 <p>Added support for magic_quotes_sybase in qstr() and addq(). Thanks Eloy and Sam Moffat.
6279 <p>The oci8 driver did not handle LOBs properly when binding. Fixed. See http://phplens.com/lens/lensforum/msgs.php?id=17991.
6280 <p>Datadict: In order to support TIMESTAMP with subsecond accuracy, added to datadict the new TS type. Supported by mssql, postgresql and oci8 (oracle).
6281 Also changed oci8 $conn->sysTimeStamp to use 'SYSTIMESTAMP' instead of 'SYSDATE'. Should be backwards compat.
6282 <p>Added support for PHP 5.1+ DateTime objects in DBDate and DBTimeStamp. This means that dates and timestamps will be managed by DateTime objects if you are running PHP 5.1+.
6283 <p>Added new property to postgres64 driver to support returning I if type is unique int called $db->uniqueIisR, defaulting to true. See http://phplens.com/lens/lensforum/msgs.php?id=17963
6284 <p>Added support for bindarray in adodb_GetActiveRecordsClass with SelectLimit in adodb-active-record.inc.php.
6285 <p>Transactions now allowed in ado_access driver. Thx to petar.petrov.georgiev#gmail.com.
6286 <p>Sessions2 garbage collection is now much more robust. We perform ORDER BY to prevent deadlock in adodb-sessions2.inc.php.
6287 <p>Fixed typo in pdo_sqlite driver.
6289 <p><a name=5.08a></a><b>5.08a 17 Apr 2009</b> </p>
6290 <p>Fixes wrong version number string.
6291 <p>Incorrect + in adodb-datadict.inc.php removed.
6292 <p>Fixes missing OffsetDate() function in pdo. Thx paul#mantisforge.org.
6294 <p><a name=5.08></a><b>5.08 17 Apr 2009</b> </p>
6295 <p>adodb-sybase.inc.php driver. Added $conn->charSet support. Thx Luis Henrique Mulinari (luis.mulinari#gmail.com)
6296 <p>adodb-ado5.inc.php. Fixed some bind param issues. Thx Jirka Novak.
6297 <p>adodb-ado5.inc.php. Now has improved error handling.
6298 <p>Fixed typo in adodb-xmlschema03.inc.php. See XMLS_EXISTING_DATA, line 1501. Thx james johnson.
6299 <p>Made $inputarr optional for _query() in all drivers.
6300 <p>Fixed spelling mistake in flushall() in adodb.inc.ophp.
6301 <p>Fixed handling of quotes in adodb_active_record::doquote. Thx Jonathan Hohle (jhohle#godaddy.com).
6302 <p>Added new index parameter to adodb_active_record::setdatabaseadaptor. Thx Jonathan Hohle
6303 <p>Fixed & readcache() reference compat problem with php 5.3 in adodb.Thx Jonathan Hohle.
6304 <p>Some minor $ADODB_CACHE_CLASS definition issues in adodb.inc.php.
6305 <p>Added Reset() function to adodb_active_record. Thx marcus.
6306 <p>Minor dsn fix for pdo_sqlite in adodb.inc.php. Thx Sergey Chvalyuk.
6307 <p>Fixed adodb-datadict _CreateSuffix() inconsistencies. Thx Chris Miller.
6308 <p>Option to delete old fields $dropOldFlds in datadict ChangeTableSQL($table, $flds, $tableOptions, $dropOldFlds=false) added. Thx Philipp Niethammer.
6309 <p>Memcache caching did not expire properly. Fixed.
6310 <p>MetaForeignKeys for postgres7 driver changed from adodb_movenext to $rs->MoveNext (also in 4.99)
6311 <p>Added support for ldap and ldaps url format in ldap driver. E.g. ldap://host:port/dn?attributes?scope?filter?extensions
6312 <p><a name=5.07></a><b>5.07 26 Dec 2008</b> </p>
6314 <p>BeginTrans/CommitTrans/RollbackTrans return true/false correctly on
6315 success/failure now for mssql, odbc, oci8, mysqlt, mysqli, postgres, pdo. </p>
6317 <p>Replace() now quotes all non-null values including numeric ones. </p>
6319 <p>Postgresql qstr() now returns booleans as <b>true</b> and <b>false</b>
6320 without quotes. </p>
6322 <p>MetaForeignKeys in mysql and mysqli drivers had this problem: A table can
6323 have two foreign keys pointing to the same column in the same table. The
6324 original code will incorrectly report only the last column. Fixed.
6325 https://sourceforge.net/tracker/index.php?func=detail&aid=2287278&group_id=42718&atid=433976
6328 <p>Passing in full ado connection string in $argHostname with ado drivers was
6329 failing in adodb5 due to bug. Fixed. </p>
6331 <p>Fixed memcachelib flushcache and flushall bugs. Also fixed possible
6332 timeCreated = 0 problem in readcache. (Also in adodb 4.992). Thanks AlexB_UK
6333 (alexbarnes#hotmail.com). </p>
6335 <p>Fixed a notice in adodb-sessions2.inc.php, in _conn(). Thx bober
6336 m.derlukiewicz#rocktech.remove_me.pl; </p>
6338 <p>ADOdb Active Record: Fixed some issues with incompatible fetch modes
6339 (ADODB_FETCH_ASSOC) causing problems in UpdateActiveTable(). </p>
6341 <p>ADOdb Active Record: Added support for functions that support predefining
6342 one-to-many relationships:<br>
6343 <i>ClassHasMany ClassBelongsTo TableHasMany TableBelongsTo
6344 TableKeyHasMany TableKeyBelongsTo</i>. <br>
6345 You can also define your child/parent class in these functions, instead of the
6346 default ADODB_Active_Record. Thx Arialdo Martini & Chris R for idea. </p>
6348 <p>ADOdb Active Record: HasMany hardcoded primary key to "id". Fixed.
6351 <p>Many pdo and pdo-sqlite fixes from Sid Dunayer [sdunayer#interserv.com]. </p>
6353 <p>CacheSelectLimit not working for mssql. Fixed. Thx AlexB. </p>
6355 <p>The rs2html function did not display hours in timestamps correctly. Now 24hr
6358 <p>Changed ereg* functions to use preg* functions as ereg* is deprecated in PHP 5.3. Modified sybase and postgresql drivers.</p>
6360 <p><a name=5.06></a><b>5.06 16 Oct 2008</b> </p>
6362 <p>Added driver adodb-pdo_sqlite.inc.php. Thanks Diogo Toscano
6363 (diogo#scriptcase.net) for the code. </p>
6365 <p>Added support for <a href="docs-active-record.htm#onetomany">one-to-many relationships</a>
6366 with BelongsTo() and HasMany() in adodb_active_record. </p>
6368 <p>Added BINARY type to mysql.inc.php (also in 4.991). </p>
6370 <p>Added support for SelectLimit($sql,-1,100) in oci8. (also in 4.991). </p>
6372 <p>New $conn->GetMedian($table, $field, $where='') to get median account no.
6373 (also in 4.991) </p>
6375 <p>The rs2html() function in tohtml.inc.php did not handle dates with ':' in it
6376 properly. Fixed. (also in 4.991) </p>
6378 <p>Added support for connecting to oci8 using $DB->Connect($ip, $user, $pwd,
6379 "SID=$sid"); (also in 4.991) </p>
6381 <p>Added mysql type 'VAR_STRING' to MetaType(). (also in 4.991) </p>
6383 <p>The session and session2 code supports setfetchmode assoc properly now (also
6386 <p>Added concat support to pdo. Thx Andrea Baron. </p>
6388 <p>Changed db2 driver to use format "Y-m-d H-i-s" for datetime
6389 instead of "Y-m-d-H-i-s" which was legacy from odbc_db2 conversion. </p>
6391 <p>Removed vestigal break on adodb_tz_offset in adodb-time.inc.php. </p>
6393 <p>MetaForeignKeys did not work for views in MySQL 5. Fixed. </p>
6395 <p>Changed error handling in GetActiveRecordsClass. </p>
6397 <p>Added better support for using existing driver when $ADODB_NEWCONNECTION
6398 function returns false. </p>
6400 <p>In _CreateSuffix in adodb-datadict.inc.php, adding unsigned variable for
6403 <p>In adodb-xmlschema03.inc.php, changed addTableOpt to include db name. </p>
6405 <p>If bytea blob in postgresql is null, empty string was formerly returned. Now
6406 null is returned. </p>
6408 <p>Changed db2 driver CreateSequence to support $start parameter. </p>
6410 <p>rs2html() now does not add nbsp to end if length of string > 0 </p>
6412 <p>The oci8po FetchField() now only lowercases field names if ADODB_ASSOC_CASE
6415 <p>New mssqlnative drivers for php. TQ Garrett Serack of M'soft. <a
6416 href="http://www.microsoft.com/downloads/details.aspx?FamilyId=61BF87E0-D031-466B-B09A-6597C21A2E2A&displaylang=en">Download</a>
6417 mssqlnative extension. Note that this is still in beta. </p>
6419 <p>Fixed bugs in memcache support. </p>
6421 <p>You can now change the return value of GetOne if no records are found using
6422 the global variable $ADODB_GETONE_EOF. The default is null. To change it back
6423 to the pre-4.99/5.00 behaviour of false, set $ADODB_GETONE_EOF = false; </p>
6425 <p>In Postgresql 8.2/8.3 MetaForeignkeys did not work. Fixed William Kolodny
6426 William.Kolodny#gt-t.net </p>
6428 <p><a name=5.05></a><b>4.990/5.05 11 Jul 2008</b> </p>
6430 <p>Added support for multiple recordsets in mysqli "Geisel Sierote"
6431 geisel#4up.com.br. See http://phplens.com/lens/lensforum/msgs.php?id=15917 </p>
6433 <p>Malcolm Cook added new Reload() function to Active Record. See
6434 http://phplens.com/lens/lensforum/msgs.php?id=17474 </p>
6436 <p>Thanks Zoltan Monori [monzol#fotoprizma.hu] for bug fixes in iterator,
6437 SelectLimit, GetRandRow, etc. </p>
6439 <p>Under heavy loads, the performance monitor for oci8 disables Ixora views. </p>
6441 <p>Fixed sybase driver SQLDate to use str_replace(). Also for adodb5, changed
6442 sybase driver UnixDate and UnixTimeStamp calls to static. </p>
6444 <p>Changed oci8 lob handler to use & reference
6445 $this->_refLOBs[$numlob]['VAR'] = &$var. </p>
6447 <p>We now strtolower the get_class() function in PEAR::isError() for php5
6450 <p>CacheExecute did not retrieve cache recordsets properly for 5.04 (worked in
6453 <p>New ADODB_Cache_File class for file caching defined in adodb.inc.php. </p>
6455 <p>Farsi language file contribution by Peyman Hooshmandi Raad
6456 (phooshmand#gmail.com) </p>
6458 <p>New API for creating your custom caching class which is stored in
6461 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
6462 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><o:p> </o:p></pre><pre>include "/path/to/adodb.inc.php";</pre><pre>$ADODB_CACHE_CLASS = 'MyCacheClass';</pre><pre><o:p> </o:p></pre><pre>class MyCacheClass extends ADODB_Cache_File</pre><pre>{</pre><pre><span
6463 style='mso-tab-count:1'> </span>function writecache($filename, $contents,$debug=false){...}</pre><pre><span
6464 style='mso-tab-count:1'> </span>function &readcache($filename, &$err, $secs2cache, $rsClass){ ...}</pre><pre><span
6465 style='mso-tab-count:1'> </span> :</pre><pre>}</pre><pre><o:p> </o:p></pre><pre>$DB = NewADOConnection($driver);</pre><pre>$DB->Connect(...);<span style='mso-spacerun:yes'> </span>## MyCacheClass created here and stored in $ADODB_CACHE global variable.</pre><pre><o:p> </o:p></pre><pre>$data = $rs->CacheGetOne($sql); ## MyCacheClass is used here for caching...</pre></div>
6467 <p>Memcache supports multiple pooled hosts now. Only if none of the pooled
6468 servers can be contacted will a connect error be generated. Usage example
6471 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
6472 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><o:p> </o:p></pre><pre>$db = NewADOConnection($driver);</pre><pre>$db->memCache = true; /// should we use memCache instead of caching in files</pre><pre>$db->memCacheHost = array($ip1, $ip2, $ip3); /// $db->memCacheHost = $ip1; still works</pre><pre>$db->memCachePort = 11211; /// this is default memCache port</pre><pre>$db->memCacheCompress = false; /// Use 'true' to store the item compressed (uses zlib)</pre><pre><o:p> </o:p></pre><pre>$db->Connect(...);</pre><pre>$db->CacheExecute($sql);</pre></div>
6474 <p><a name=4.98></a><b>4.98/5.04 13 Feb 2008</b> </p>
6476 <p>Fixed adodb_mktime problem which causes a performance bottleneck in $hrs. </p>
6478 <p>Added mysqli support to adodb_getcount(). </p>
6480 <p>Removed MYSQLI_TYPE_CHAR from MetaType(). </p>
6482 <p><a name=4.97></a><b>4.97/5.03 22 Jan 2008</b> </p>
6484 <p>Active Record: $ADODB_ASSOC_CASE=1 did not work properly. Fixed. </p>
6486 <p>Modified Fields() in recordset class to support display null fields in
6487 FetchNextObject(). </p>
6489 <p>In ADOdb5, active record implementation, we now support column names with
6490 spaces in them - we autoconvert the spaces to _ using __set(). Thx Daniel Cook.
6491 http://phplens.com/lens/lensforum/msgs.php?id=17200 </p>
6493 <p>Removed $arg3 from mysqli SelectLimit. See
6494 http://phplens.com/lens/lensforum/msgs.php?id=16243. Thx Zsolt Szeberenyi. </p>
6496 <p>Changed oci8 FetchField, which returns the max_length of BLOB/CLOB/NCLOB as
6497 4000 (incorrectly) to -1. </p>
6499 <p>CacheExecute would sometimes return an error on Windows if it was unable to
6500 lock the cache file. This is harmless and has been changed to a warning that
6501 can be ignored. Also adodb_write_file() code revised. </p>
6503 <p>ADOdb perf code changed to only log sql if execution time >= 0.05
6504 seconds. New $ADODB_PERF_MIN variable holds min sql timing. Any SQL with timing
6505 value below this and is not causing an error is not logged. </p>
6507 <p>Also adodb_backtrace() now traces 1 level deeper as sometimes actual culprit
6508 function is not displayed. </p>
6510 <p>Fixed a group by problem with adodb_getcount() for db's which are not
6511 postgres/oci8 based. </p>
6513 <p>Changed mssql driver Parameter() from SQLCHAR to SQLVARCHAR: case 'string':
6514 $type = SQLVARCHAR; break. </p>
6516 <p>Problem with mssql driver in php5 (for adodb 5.03) because some functions
6517 are not static. Fixed. </p>
6519 <p><a name=4.96></a><b>4.96/5.02 24 Sept 2007</b> </p>
6521 <p>ADOdb perf for oci8 now has non-table-locking code when clearing the sql.
6522 Slower but better transparency. Added in 4.96a and 5.02a. </p>
6524 <p>Fix adodb count optimisation. Preg_match did not work properly. Also rewrote
6525 the ORDER BY stripping code in _adodb_getcount(), adodb-lib.inc.php. </p>
6527 <p>SelectLimit for oci8 not optimal for large recordsets when offset=0. Changed
6530 <p>Active record optimizations. Added support for assoc arrays in Set(). </p>
6532 <p>Now GetOne returns null if EOF (no records found), and false if error
6533 occurs. Use ErrorMsg()/ErrorNo() to get the error. </p>
6535 <p>Also CacheGetRow and CacheGetCol will return false if error occurs, or empty
6536 array() if EOF, just like GetRow and GetCol. </p>
6538 <p>Datadict now allows changing of types which are not resizable, eg. VARCHAR
6539 to TEXT in ChangeTableSQL. -- Mateo Tibaquirá </p>
6541 <p>Added BIT data type support to adodb-ado.inc.php and adodb-ado5.inc.php. </p>
6543 <p>Ldap driver did not return actual ldap error messages. Fixed. </p>
6545 <p>Implemented GetRandRow($sql, $inputarr). Optimized for Oci8. </p>
6547 <p>Changed adodb5 active record to use static SetDatabaseAdapter() and removed
6548 php4 constructor. Bas van Beek bas.vanbeek#gmail.com. </p>
6550 <p>Also in adodb5, changed adodb-session2 to use static function declarations
6551 in class. Thx Daniel <st1:State w:st="on"><st1:place w:st="on">Berlin</st1:place></st1:State>.
6554 <p>Added "Clear SQL Log" to bottom of Performance screen. </p>
6556 <p>Sessions2 code echo'ed directly to the screen in debug mode. Now uses
6557 ADOConnection::outp(). </p>
6559 <p>In mysql/mysqli, qstr(null) will return the string "null" instead
6560 of empty quoted string "''". </p>
6562 <p>postgresql optimizeTable in perf-postgres.inc.php added by Daniel Berlin
6563 (mail#daniel-berlin.de) </p>
6565 <p>Added 5.2.1 compat code for oci8. </p>
6567 <p>Changed @@identity to SCOPE_IDENTITY() for multiple mssql drivers. Thx
6570 <p>Code sanitization introduced in 4.95 caused problems in European locales (as
6571 float 3.2 was typecast to 3,2). Now we only sanitize if is_numeric fails. </p>
6573 <p>Added support for customizing ADORecordset_empty using
6574 $this->rsPrefix.'empty'. By Josh Truwin. </p>
6576 <p>Added proper support for ALterColumnSQL for Postgresql in datadict code.
6577 Thx. Josh Truwin. </p>
6579 <p>Added better support for MetaType() in mysqli when using an array recordset.
6582 <p>Changed parser for pgsql error messages in adodb-error.inc.php to
6583 case-insensitive regex. </p>
6585 <p><a name=4.95></a><b>4.95/5.01 17 May 2007</b> </p>
6587 <p>CacheFlush debug outp() passed in invalid parameters. Fixed. </p>
6589 <p>Added Thai language file for adodb. Thx Trirat Petchsingh rosskouk#gmail.com
6592 <p>Added zerofill checking support to MetaColumns for mysql and mysqli. </p>
6594 <p>CacheFlush no longer deletes all files/directories. Only *.cache files
6597 <p>DB2 timestamp format changed to var $fmtTimeStamp =
6598 "'Y-m-d-H:i:s'";</p>
6600 <p>Added some code sanitization to AutoExecute in adodb-lib.inc.php.</p>
6602 <p>Due to typo, all connections in adodb-oracle.inc.php would become
6603 persistent, even non-persistent ones. Fixed.</p>
6605 <p>Oci8 DBTimeStamp uses 24 hour time for input now, so you can perform string
6606 comparisons between 2 DBTimeStamp values.</p>
6608 <p>Some PHP4.4 compat issues fixed in adodb-session2.inc.php</p>
6610 <p>For ADOdb 5.01, fixed some adodb-datadict.inc.php MetaType compat issues
6613 <p>The $argHostname was wiped out in adodb-ado5.inc.php. Fixed. </p>
6615 <p>Adodb5 version, added iterator support for adodb_recordset_empty. </p>
6617 <p>Adodb5 version,more error checking code now will use exceptions if
6620 <p><a name=4.94></a><b>4.94 23 Jan 2007</b> </p>
6622 <p>Active Record: $ADODB_ASSOC_CASE=2 did not work properly. Fixed. Thx
6623 gmane#auxbuss.com. </p>
6625 <p>mysqli had bugs in BeginTrans() and EndTrans(). Fixed.</p>
6627 <p>Improved error handling when no database is connected for oci8. Thx Andy
6630 <p>Names longer than 30 chars in oci8 datadict will be changed to random name.
6631 Thx Eugenio. http://phplens.com/lens/lensforum/msgs.php?id=16182 </p>
6633 <p>Added var $upperCase = 'ucase' to access and ado_access drivers. Thx Renato
6634 De Giovanni renato#cria.org.br</p>
6636 <p>Postgres64 driver, if preparing plan failed in _query, did not handle error
6637 properly. Fixed. See http://phplens.com/lens/lensforum/msgs.php?id=16131. </p>
6639 <p>Fixed GetActiveRecordsClass() reference bug. See
6640 http://phplens.com/lens/lensforum/msgs.php?id=16120 </p>
6642 <p>Added handling of nulls in adodb-ado_mssql.inc.php for qstr(). Thx to Felix
6645 <p>Adodb-dict contributions by Gaetano: <br>
6646 + Support for INDEX in data-dict. Example: idx_ev1. The ability to define
6647 indexes using the INDEX keyword was added in ADOdb 4.94. The following example
6648 features mutiple indexes, including a compound index idx_ev1. </p>
6650 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
6651 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><o:p> </o:p></pre><pre><span style='mso-spacerun:yes'> </span>event_id I(11) NOTNULL AUTOINCREMENT PRIMARY,</pre><pre><span style='mso-spacerun:yes'> </span>event_type I(4) NOTNULL<span style='mso-spacerun:yes'> </span><b>INDEX idx_evt</b>,</pre><pre><span style='mso-spacerun:yes'> </span>event_start_date T DEFAULT NULL <b>INDEX id_esd</b>,</pre><pre><span style='mso-spacerun:yes'> </span>event_end_date T DEFAULT '0000-00-00 00:00:00' <b>INDEX id_eted</b>,</pre><pre><span style='mso-spacerun:yes'> </span>event_parent I(11) UNSIGNED NOTNULL DEFAULT 0 <b>INDEX id_evp</b>,</pre><pre><span style='mso-spacerun:yes'> </span>event_owner I(11) DEFAULT 0 <b>INDEX idx_ev1</b>,</pre><pre><span style='mso-spacerun:yes'> </span>event_project I(11) DEFAULT 0 <b>INDEX idx_ev1</b>,</pre><pre><span style='mso-spacerun:yes'> </span>event_times_recuring I(11) UNSIGNED NOTNULL DEFAULT 0,</pre><pre><span style='mso-spacerun:yes'> </span>event_icon C(20) DEFAULT 'obj/event',</pre><pre><span style='mso-spacerun:yes'> </span>event_description X</pre></div>
6653 <p class=MsoNormal><br>
6654 + Prevents the generated SQL from including double drop-sequence statements for
6655 REPLACE case of tables with autoincrement columns (on those dbs that emulate it
6657 + makes any date defined as DEFAULT value for D and T columns work
6658 cross-database, not just the "sysdate" value (as long as it is
6659 specified using adodb standard format). See above example. </p>
6661 <p>Fixed pdo's GetInsertID() support. Thx Ricky Su. </p>
6663 <p>oci8 Prepare() now sets error messages if an error occurs. </p>
6665 <p>Added 'PT_BR' to SetDateLocale() -- brazilian portugese. </p>
6667 <p>charset in oci8 was not set correctly on *Connect() </p>
6669 <p>ADOConnection::Transpose() now appends as first column the field names. </p>
6671 <p>Added $ADODB_QUOTE_FIELDNAMES. If set to true, will autoquote field names in
6672 AutoExecute(),GetInsertSQL(), GetUpdateSQL(). </p>
6674 <p>Transpose now adds the field names as the first column after transposition. </p>
6676 <p>Added === check in ADODB_SetDatabaseAdapter for $db,
6677 adodb-active-record.inc.php. Thx Christian Affolter. </p>
6679 <p>Added ErrorNo() to adodb-active-record.inc.php. Thx ante#novisplet.com. </p>
6681 <p><a name=4.93></a><b>4.93 10 Oct 2006</b> </p>
6683 <p>Added support for multiple database connections in performance monitoring
6684 code (adodb-perf.inc.php). Now all sql in multiple database connections can be
6685 saved into one database ($ADODB_LOG_CONN). </p>
6687 <p>Added MetaIndexes() to odbc_mssql. </p>
6689 <p>Added connection property $db->null2null = 'null'. In
6690 autoexecute/getinsertsql/getupdatesql, this value will be converted to a null.
6691 Set this to a funny invalid value if you do not want null conversion. See
6692 http://phplens.com/lens/lensforum/msgs.php?id=15902. </p>
6694 <p>Path disclosure problem in mysqli fixed. Thx Andy. </p>
6696 <p>Fixed typo in session_schema2.xml. </p>
6698 <p>Changed INT in oci8 to return correct precision in $fld->max_length,
6699 MetaColumns(). <st1:place w:st="on"><st1:PlaceName w:st="on">Thx</st1:PlaceName>
6700 <st1:PlaceName w:st="on">Eloy</st1:PlaceName> <st1:PlaceName w:st="on">Lafuente</st1:PlaceName>
6701 <st1:PlaceType w:st="on">Plaza</st1:PlaceType></st1:place>. </p>
6703 <p>Patched postgres64 _connect to handle serverinfo(). see http://phplens.com/lens/lensforum/msgs.php?id=15887.
6706 <p>Added pdo fix for null columns. See
6707 http://phplens.com/lens/lensforum/msgs.php?id=15889 </p>
6709 <p>For stored procedures, missing connection id now passed into mssql_query().
6710 Thx Ecsy (ecsy#freemail.hu). </p>
6712 <p><a name=4.92a></a><b>4.92a 30 Aug 2006</b> </p>
6714 <p>Syntax error in postgres7 driver. <st1:place w:st="on"><st1:PlaceName w:st="on">Thx</st1:PlaceName>
6715 <st1:PlaceName w:st="on">Eloy</st1:PlaceName> <st1:PlaceName w:st="on">Lafuente</st1:PlaceName>
6716 <st1:PlaceType w:st="on">Plaza</st1:PlaceType></st1:place>. </p>
6718 <p>Minor bug fixes - adodb informix 10 types added to adodb.inc.php. Thx
6719 Fernando Ortiz. </p>
6721 <p><a name=4.92></a><b>4.92 29 Aug 2006</b> </p>
6723 <p>Better odbtp date support. </p>
6725 <p>Added IgnoreErrors() to bypass default error handling. </p>
6727 <p>The _adodb_getcount() function in adodb-lib.inc.php, some ORDER BY bug
6730 <p>For ibase and firebird, set $sysTimeStamp = "CURRENT_TIMESTAMP". </p>
6732 <p>Fixed postgres connection bug:
6733 http://phplens.com/lens/lensforum/msgs.php?id=11057. </p>
6735 <p>Changed CacheSelectLimit() to flush cache when $secs2cache==-1 due to
6736 complaints from other users. </p>
6738 <p>Added support for using memcached with CacheExecute/CacheSelectLimit.
6739 Requires memcache module PECL extension. Usage: </p>
6741 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
6742 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><o:p> </o:p></pre><pre>$db = NewADOConnection($driver);</pre><pre>$db->memCache = true; /// should we use memCache instead of caching in files</pre><pre>$db->memCacheHost = "126.0.1.1"; /// memCache host</pre><pre>$db->memCachePort = 11211; /// this is default memCache port</pre><pre>$db->memCacheCompress = false; /// Use 'true' to store the item compressed (uses zlib)</pre><pre><o:p> </o:p></pre><pre>$db->Connect(...);</pre><pre>$db->CacheExecute($sql);</pre></div>
6744 <p>Implemented Transpose() for recordsets. Recordset must be retrieved using
6745 ADODB_FETCH_NUM. First column becomes the column name. </p>
6747 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
6748 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><o:p> </o:p></pre><pre>$DB = NewADOConnection('mysql');</pre><pre>$DB->Connect(...);</pre><pre>$DB->SetFetchMode(ADODB_FETCH_NUM);</pre><pre>$rs = $DB->Execute('select productname,productid,unitprice from products limit 10');</pre><pre>$rs2 = $DB->Transpose($rs);</pre><pre>rs2html($rs2);</pre></div>
6750 <p><a name=4.91></a><b>4.91 2 Aug 2006</b> </p>
6752 <p>Major session code rewrite .... See session docs. </p>
6754 <p>PDO bindinputarray was not set properly for MySQL (changed from true to
6757 <p>Changed CacheSelectLimit() to re-cache when $secs2cache==0. This is one way
6758 to flush the cache when SelectLimit is called. </p>
6760 <p>Added to quotes to mysql and mysqli: "SHOW COLUMNS FROM `%s`"; </p>
6762 <p>Removed accidental optgroup handling in GetMenu(). Fixed ibase _BlobDecode
6763 for php5 compat, and also mem alloc issues for small blobs, thx
6764 salvatori#interia.pl </p>
6766 <p>Mysql driver OffsetDate() speedup, useful for adodb-sessions. </p>
6768 <p>Fix for GetAssoc() PHP5 compat. See
6769 http://phplens.com/lens/lensforum/msgs.php?id=15425 </p>
6771 <p>Active Record - If inserting a record and the value of a primary key field
6772 is null, then we do not insert that field in as we assume it is an
6773 auto-increment field. Needed by mssql. </p>
6775 <p>Changed postgres7 MetaForeignKeys() see http://phplens.com/lens/lensforum/msgs.php?id=15531
6778 <p>DB2 will now return db2_conn_errormsg() when it is a connection error. </p>
6780 <p><a name=4.90></a><b>4.90 8 June 2006</b> </p>
6782 <p>Changed adodb_countrec() in adodb-lib.inc.php to allow LIMIT to be used as a
6783 speedup to reduce no of records counted. </p>
6785 <p>Added support for transaction modes for postgres and oci8 with
6786 SetTransactionMode(). These transaction modes affect all subsequent
6787 transactions of that connection. </p>
6789 <p>Thanks to Halmai Csongor for suggestion. </p>
6791 <p>Removed $off = $fieldOffset - 1 line in db2 driver, FetchField(). Tx Larry
6794 <p>Added support for PHP5 objects as Execute() bind parameters using __toString
6795 (eg. Simple-XML). Thx Carl-Christian Salvesen. </p>
6797 <p>Rounding in tohtml.inc.php did not work properly. Fixed. </p>
6799 <p>MetaIndexes in postgres fails when fields are deleted then added in again
6800 because the attnum has gaps in it. See
6801 http://sourceforge.net/tracker/index.php?func=detail&aid=1451245&group_id=42718&atid=433976.
6804 <p>MetaForeignkeys in mysql and mysqli did not work when
6805 fetchMode==ADODB_FETCH_ASSOC used. Fixed. </p>
6807 <p>Reference error in AutoExecute() fixed. </p>
6809 <p>Added macaddr postgres type to MetaType. Maps to 'C'. </p>
6811 <p>Added to _connect() in adodb-ado5.inc.php support for $database and
6812 $dataProvider parameters. Thx Larry Menard. </p>
6814 <p>Added support for sequences in adodb-ado_mssql.inc.php. Thx Larry Menard. </p>
6816 <p>Added ADODB_SESSION_READONLY. </p>
6818 <p>Added session expiryref support to crc32 mode, and in LOB code. </p>
6820 <p>Clear _errorMsg in postgres7 driver, so that ErrorMsg() displays properly
6821 when no error occurs. </p>
6823 <p>Added BindDate and BindTimeStamp </p>
6825 <p><a name=4.81></a><b>4.81 3 May 2006</b> </p>
6827 <p>Fixed variable ref errors in adodb-ado5.inc.php in _query(). </p>
6829 <p>Mysqli setcharset fix using method_exists(). </p>
6831 <p>The adodb-perf.inc.php CreateLogTable() code now works for user-defined
6834 <p>Error in ibase_blob_open() fixed. See
6835 http://phplens.com/lens/lensforum/msgs.php?id=14997 </p>
6837 <p><a name=4.80></a><b>4.80 8 Mar 2006</b> </p>
6839 <p>Added activerecord support. </p>
6841 <p>Added mysql $conn->compat323 = true if you want MySQL 3.23 compat
6842 enabled. Fixes GetOne() Select-Limit problems. </p>
6844 <p>Added adodb-xmlschema03.inc.php to support XML Schema version 3 and updated
6845 adodb-datadict.htm docs. </p>
6847 <p>Better memory management in Execute. Thx Mike Fedyk. </p>
6849 <p><a name=4.72></a><b>4.72 21 Feb 2006</b> </p>
6851 <p>Added 'new' DSN parameter for NConnect(). </p>
6853 <p>Pager now sanitizes $PHP_SELF to protect against XSS. Thx to James Bercegay
6856 <p>ADOConnection::MetaType changed to setup $rs->connection correctly. </p>
6858 <p>New native DB2 driver contributed by Larry Menard, Dan Scott, Andy
6859 Staudacher, Bharat Mediratta. </p>
6861 <p>The mssql CreateSequence() did not BEGIN TRANSACTION correctly. Fixed. Thx
6864 <p>The _adodb_countrecs() function in adodb-lib.inc.php has been revised to
6865 handle more ORDER BY variations. </p>
6867 <p><a name=4.71></a><b>4.71 24 Jan 2006</b> </p>
6869 <p>Fixes postgresql security issue related to binary strings. Thx to Andy
6872 <p>Several DSN bugs found: </p>
6874 <p>1. Fix bugs in DSN connections introduced in 4.70 when underscores are found
6877 <p>2. DSN with _ did not work properly in PHP5 (fine in PHP4). Fixed. </p>
6879 <p>3. Added support for PDO DSN connections in NewADOConnection(), and database
6880 parameter in PDO::Connect(). </p>
6882 <p>The oci8 datetime flag not correctly implemented in ADORecordSet_array.
6885 <p>Added BlobDelete() to postgres, as a counterpoint to UpdateBlobFile(). </p>
6887 <p>Fixed GetInsertSQL() to support oci8po. </p>
6889 <p>Fixed qstr() issue with postgresql with \0 in strings. </p>
6891 <p>Fixed some datadict driver loading issues in _adodb_getdriver(). </p>
6893 <p>Added register shutdown function session_write_close in
6894 adodb-session.inc.php for PHP 5 compat. See
6895 http://phplens.com/lens/lensforum/msgs.php?id=14200. </p>
6897 <p><a name=4.70></a><b>4.70 6 Jan 2006</b> </p>
6899 <p>Many fixes from Danila Ulyanov to ibase, oci8, postgres, mssql, odbc_oracle,
6900 odbtp, etc drivers. </p>
6902 <p>Changed usage of binary hint in adodb-session.inc.php for mysql. See
6903 http://phplens.com/lens/lensforum/msgs.php?id=14160 </p>
6905 <p>Fixed invalid variable reference problem in undomq(), adodb-perf.inc.php. </p>
6907 <p>Fixed http://phplens.com/lens/lensforum/msgs.php?id=14254 in
6908 adodb-perf.inc.php, _DBParameter() settings of fetchmode was wrong. </p>
6910 <p>Fixed security issues in server.php and tmssql.php discussed by Andreas
6911 Sandblad in a Secunia security advisory. Added $ACCEPTIP = 127.0.0.1 and
6912 changed suggested root password to something more secure. </p>
6914 <p>Changed pager to close recordset after RenderLayout(). </p>
6916 <p><a name=4.68></a><b>4.68 25 Nov 2005</b> </p>
6918 <p>PHP 5 compat for mysqli. MetaForeignKeys repeated twice and
6919 MYSQLI_BINARY_FLAG missing. </p>
6921 <p>PHP 5.1 support for postgresql bind parameters using ? did not work if >=
6922 10 parameters. Fixed. Thx to Stanislav Shramko. </p>
6924 <p>Lots of PDO improvements. </p>
6926 <p>Spelling error fixed in mysql MetaForeignKeys, $associative parameter. </p>
6928 <p><a name=4.67></a><b>4.67 16 Nov 2005</b> </p>
6930 <p>Postgresql not_null flag not set to false correctly. Thx Cristian MARIN. </p>
6932 <p>We now check in Replace() if key is in fieldArray. Thx Sébastien Vanvelthem.
6935 <p>_file_get_contents() function was missing in xmlschema. fixed. </p>
6937 <p>Added week in year support to SQLDate(), using 'W' flag. Thx Spider. </p>
6939 <p>In sqlite metacolumns was repeated twice, causing PHP 5 problems. Fixed. </p>
6941 <p>Made debug output XHTML compliant. </p>
6943 <p><a name=4.66></a><b>4.66 28 Sept 2005</b> </p>
6945 <p>ExecuteCursor() in oci8 did not clean up properly on failure. Fixed. </p>
6947 <p>Updated xmlschema.dtd, by "Alec Smecher" asmecher#smecher.bc.ca </p>
6949 <p>Hardened SelectLimit, typecasting nrows and offset to integer. </p>
6951 <p>Fixed misc bugs in AutoExecute() and GetInsertSQL(). </p>
6953 <p>Added $conn->database as the property holding the database name. The
6954 older $conn->databaseName is retained for backward compat. </p>
6956 <p>Changed _adodb_backtrace() compat check to use function_exists(). </p>
6958 <p>Bug in postgresql MetaIndexes fixed. Thx Kevin Jamieson. </p>
6960 <p>Improved OffsetDate for MySQL, reducing rounding error. </p>
6962 <p>Metacolumns added to sqlite. Thx Mark Newnham. </p>
6964 <p>PHP 4.4 compat fixes for GetAssoc(). </p>
6966 <p>Added postgresql bind support for php 5.1. Thx Cristiano da Cunha Duarte </p>
6968 <p>OffsetDate() fixes for postgresql, typecasting strings to date or timestamp.
6971 <p>DBTimeStamp formats for mssql, odbc_mssql and postgresql made to conform
6972 with other db's. </p>
6974 <p>Changed PDO constants from PDO_ to PDO:: to support latest spec. </p>
6976 <p><a name=4.65></a><b>4.65 22 July 2005</b> </p>
6978 <p>Reverted 'X' in mssql datadict to 'TEXT' to be compat with mssql driver.
6979 However now you can set $datadict->typeX = 'varchar(4000)' or 'TEXT' or
6980 'CLOB' for mssql and oci8 drivers. </p>
6982 <p>Added charset support when using DSN for Oracle. </p>
6984 <p>_adodb_getmenu did not use fieldcount() to get number of fields. Fixed. </p>
6986 <p>MetaForeignKeys() for mysql/mysqli contributed by Juan Carlos Gonzalez. </p>
6988 <p>MetaDatabases() now correctly returns an array for mysqli driver. Thx
6989 Cristian MARIN. </p>
6991 <p>CompleteTrans(false) did not return false. Fixed. Thx to JMF. </p>
6993 <p>AutoExecute() did not work with Oracle. Fixed. Thx José Moreira. </p>
6995 <p>MetaType() added to connection object. </p>
6997 <p>More PHP 4.4 reference return fixes. Thx Ryan C Bonham and others. </p>
6999 <p><a name=4.64></a><b>4.64 20 June 2005</b> </p>
7001 <p>In datadict, if the default field value is set to '', then it is not applied
7002 when the field is created. Fixed by Eugenio. </p>
7004 <p>MetaPrimaryKeys for postgres did not work because of true/false change in
7007 <p>Tested ocifetchstatement in oci8. Rejected at the end. </p>
7009 <p>Added port to dsn handling. Supported in postgres, mysql, mysqli,ldap. </p>
7011 <p>Added 'w' and 'l' to mysqli SQLDate(). </p>
7013 <p>Fixed error handling in ldap _connect() to be more consistent. Also added
7014 ErrorMsg() handling to ldap. </p>
7016 <p>Added support for union in _adodb_getcount, adodb-lib.inc.php for postgres
7019 <p>rs2html() did not work with null dates properly. </p>
7021 <p>PHP 4.4 reference return fixes. </p>
7023 <p><a name=4.63></a><b>4.63 18 May 2005</b> </p>
7025 <p>Added $nrows<0 check to mysqli's SelectLimit().
7026 <p>Added OptimizeTable() and OptimizeTables() in adodb-perf.inc.php. By Markus Staab.
7027 <p>PostgreSQL inconsistencies fixed. true and false set to TRUE and FALSE, and boolean type in datadict-postgres.inc.php set
7028 to 'L' => 'BOOLEAN'. Thx Kevin Jamieson.
7029 <p>New adodb_session_create_table() function in adodb-session.inc.php. By Markus Staab.
7030 <p>Added null check to UserTimeStamp().
7031 <p>Fixed typo in mysqlt driver in adorecordset. Thx to Andy Staudacher.
7032 <p>GenID() had a bug in the raiseErrorFn handling. Fixed. Thx Marcos Pont.
7033 <p>Datadict name quoting now handles ( ) in index fields correctly - they aren't part of the index field. ></p>
7035 <p>Performance monitoring: (1) oci8 Ixora checks moved down; (2) expensive sql
7036 changed so that only those sql with count(*)>1 are shown; (3) changed sql1
7037 field to a length+crc32 checksum - this breaks backward compat. </p>
7039 <p>We remap firebird15 to firebird in data dictionary. </p>
7041 <p><a name=4.62></a><b>4.62 2 Apr 2005</b> </p>
7043 <p>Added 'w' (dow as 0-6 or 1-7) and 'l' (dow as string) for SQLDate for oci8,
7044 postgres and mysql. </p>
7046 <p>Rolled back MetaType() changes for mysqli done in prev version. </p>
7048 <p>Datadict change by chris, cblin#tennaxia.com data mappings from: </p>
7050 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
7051 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><o:p> </o:p></pre><pre>oci8:<span style='mso-spacerun:yes'> </span>X->varchar(4000) XL->CLOB</pre><pre>mssql: X->XL->TEXT</pre><pre>mysql: X->XL->LONGTEXT</pre><pre>fbird: X->XL->varchar(4000)</pre></div>
7055 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
7056 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre><o:p> </o:p></pre><pre>oci8:<span style='mso-spacerun:yes'> </span>X->varchar(4000) XL->CLOB</pre><pre>mssql: X->VARCHAR(4000) XL->TEXT</pre><pre>mysql: X->TEXT<span style='mso-spacerun:yes'> </span>XL->LONGTEXT</pre><pre>fbird: X->VARCHAR(4000) XL->VARCHAR(32000)</pre></div>
7058 <p>Added $connection->disableBlobs to postgresql to improve performance when
7059 no bytea is used (2-5% improvement). </p>
7061 <p>Removed all HTTP_* vars. </p>
7063 <p>Added $rs->tableName to be set before calling AutoExecute(). </p>
7065 <p>Alex Rootoff rootoff#pisem.net contributed ukrainian language file. </p>
7067 <p>Added new mysql_option() support using $conn->optionFlags array. </p>
7069 <p>Added support for ldap_set_option() using the $LDAP_CONNECT_OPTIONS global
7070 variable. Contributed by Josh Eldridge. </p>
7072 <p>Added LDAP_* constant definitions to ldap. </p>
7074 <p>Added support for boolean bind variables. We use $conn->false and
7075 $conn->true to hold values to set false/true to. </p>
7077 <p>We now do not close the session connection in adodb-session.inc.php as other
7078 objects could be using this connection. </p>
7080 <p>We now strip off \0 at end of Ixora SQL strings in $perf->tohtml() for
7083 <p><a name=4.61></a><b>4.61 23 Feb 2005</b> </p>
7085 <p>MySQLi added support for mysqli_connect_errno() and mysqli_connect_error(). </p>
7087 <p>Massive improvements to alpha PDO driver. </p>
7089 <p>Quote string bind parameters logged by performance monitor for easy type
7090 checking. Thx Jason Judge. </p>
7092 <p>Added support for $role when connecting with Interbase/firebird. </p>
7094 <p>Added support for enum recognition in MetaColumns() mysql and mysqli. Thx
7095 Amedeo Petrella. </p>
7097 <p>The sybase_ase driver contributed by Interakt Online. Thx Cristian Marin
7098 cristic#interaktonline.com. </p>
7100 <p>Removed not_null, has_default, and default_value from ADOFieldObject. </p>
7102 <p>Sessions code, fixed quoting of keys when handling LOBs in session write()
7105 <p>Sessions code, added adodb_session_regenerate_id(), to reduce risk of
7106 session hijacking by changing session cookie dynamically. Thx Joe Li. </p>
7108 <p>Perf monitor, polling for CPU did not work for PHP 4.3.10 and 5.0.0-5.0.3
7109 due to PHP bugs, so we special case these versions. </p>
7111 <p>Postgresql, UpdateBlob() added code to handle type==CLOB. </p>
7113 <p><a name=4.60></a><b>4.60 24 Jan 2005</b> </p>
7115 <p>Implemented PEAR DB's autoExecute(). Simplified design because I don't like
7116 using constants when strings work fine. </p>
7118 <p>_rs2serialize will now update $rs->sql and $rs->oldProvider. </p>
7120 <p>Added autoExecute(). </p>
7122 <p>Added support for postgres8 driver. Currently just remapped to postgres7
7125 <p>Changed oci8 _query(), so that OCIBindByName() sets the length to -1 if
7126 element size is > 4000. This provides better support for LONGs. </p>
7128 <p>Added SetDateLocale() support for <st1:country-region w:st="on"><st1:place
7129 w:st="on">netherlands</st1:place></st1:country-region> (Nl). </p>
7131 <p>Spelling error in pivot code ($iff should be $iif). </p>
7133 <p>mysql insert_id() did not work with mysql 3.x. Fixed. </p>
7135 <p>"\r\n" not converted to spaces correctly in exporting data. Fixed.
7138 <p>_nconnect() in mysqli did not return value correctly. Fixed. </p>
7140 <p>Arne Eckmann contributed danish language file. </p>
7142 <p>Added clone() support to FetchObject() for PHP5.</p>
7144 <p>Removed SQL_CUR_USE_ODBC from odbc_mssql.</p>
7146 <p><a name=4.55></a><b>4.55 5 Jan 2005</b> </p>
7148 <p>Found bug in Execute() with bind params for db's that do not support binding
7151 <p>DropSequence() now correctly uses default parameter. </p>
7153 <p>Now Execute() ignores locale for floats, so 1.23 is NEVER converted to 1,23.
7156 <p>SetFetchMode() not properly saved in adodb-perf, suspicious sql and
7157 expensive sql. Fixed. </p>
7159 <p>Added INET to postgresql metatypes. Thx motzel. </p>
7161 <p>Allow oracle hints to work when counting with _adodb_getcount in
7162 adodb-lib.inc.php. Thx Chris Wrye. </p>
7164 <p>Changed mysql insert_id() to use SELECT LAST_INSERT_ID(). </p>
7166 <p>If alter col in datadict does not modify col type/size of actual col, then
7167 it is removed from alter col code. By Mark Newham. Not perfect as MetaType()
7168 !== ActualType(). </p>
7170 <p>Added handling of view fields in metacolumns() for postgresql. Thx Renato De
7173 <p>Added to informix MetaPrimaryKeys and MetaColumns fixes for null bit. Thx to
7174 Cecilio Albero. </p>
7176 <p>Removed obsolete connection_timeout() from perf code. </p>
7178 <p>Added support for arrayClass in adodb-csv.inc.php. </p>
7180 <p>RSFilter now accepts methods of the form $array($obj, 'methodname'). Thx to
7181 blake#near-time.com. </p>
7183 <p>Changed CacheFlush to $cmd = 'rm -rf
7184 '.$ADODB_CACHE_DIR.'/[0-9a-f][0-9a-f]/'; </p>
7186 <p>For better cursor concurrency, added code to free ref cursors in oci8 when
7187 $rs->Close() is called. Note that CLose() is called internally by the Get*
7190 <p>Added IIF support for access when pivoting. Thx Volodia Krupach. </p>
7192 <p>Added mssql datadict support for timestamp. Thx Alexios. </p>
7194 <p>Informix pager fix. By Mario Ramirez. </p>
7196 <p>ADODB_TABLE_REGEX now includes ':'. By Mario Ramirez. </p>
7198 <p>Mark Newnham contributed MetaIndexes for oci8 and db2. </p>
7200 <p><a name=4.54></a><b>4.54 5 Nov 2004</b> </p>
7202 <p>Now you can set $db->charSet = ?? before doing a Connect() in oci8. </p>
7204 <p>Added adodbFetchMode to sqlite. </p>
7206 <p>Perf code, added a string typecast to substr in adodb_log_sql(). </p>
7208 <p>Postgres: Changed BlobDecode() to use po_loread, added new $maxblobsize
7209 parameter, and now it returns the blob instead of sending it to stdout - make
7210 sure to mention that as a compat warning. Also added $db->IsOID($oid)
7211 function; uses a heuristic, not guaranteed to work 100%. </p>
7213 <p>Contributed arabic language file by "El-Shamaa, Khaled"
7214 k.el-shamaa#cgiar.org </p>
7216 <p>PHP5 exceptions did not handle @ protocol properly. Fixed. </p>
7218 <p>Added ifnull handling for postgresql (using coalesce). </p>
7220 <p>Added metatables() support for Postgresql 8.0 (no longer uses pg_%
7221 dictionary tables). </p>
7223 <p>Improved Sybase ErrorMsg() function. By Gaetano Giunta. </p>
7225 <p>Improved oci8 SelectLimit() to use Prepare(). By Cristiano Duarte. </p>
7227 <p>Type-cast $row parameter in ifx_fetch_row() to int. Thx stefan bodgan. </p>
7229 <p>Ralf becker contributed improvements in postgresql, sapdb, mysql data
7230 dictionary handling:<br>
7231 - MySql and Postgres MetaType was reporting every int column which was part of
7232 a primary key and unique as serial<br>
7233 - Postgres was not reporting the scale of decimal types<br>
7234 - MaxDB was padding the defaults of none-string types with spaces<br>
7235 - MySql now correctly converts enum columns to varchar </p>
7237 <p>Ralf also changed Postgresql datadict:<br>
7238 - you cant add NOT NULL columns in postgres in one go, they need to be added as
7239 NULL and then altered to NOT NULL<br>
7240 - AlterColumnSQL could not change a varchar column with numbers into an integer
7241 column, postgres need an explicit conversation<br>
7242 - a re-created sequence was not set to the correct value, if the name was the
7243 old name (no implicit sequence), now always the new name of the implicit
7244 sequence is used</p>
7246 <p>Sergio Strampelli added extra $intoken check to Lens_ParseArgs() in datadict
7249 <p><a name=4.53></a><b>4.53 28 Sept 2004</b> </p>
7251 <p>FetchMode cached in recordset is sometimes mapped to native db fetchMode.
7252 Normally this does not matter, but when using cached recordsets, we need to
7253 switch back to using adodb fetchmode. So we cache this in
7254 $rs->adodbFetchMode if it differs from the db's fetchMode. </p>
7256 <p>For informix we now set canSeek = false driver because stefan bodgan tells
7257 me that seeking doesn't work. </p>
7259 <p>SetDateLocale() never worked till now ;-) Thx david#tomato.it </p>
7261 <p>Set $_bindInputArray = true in sapdb driver. Required for clob support. </p>
7263 <p>Fixed some PEAR::DB emulation issues with isError() and isWarning. Thx to
7264 Gert-Rainer Bitterlich. </p>
7266 <p>Empty() used in getupdatesql without strlen() check. Fixed.</p>
7268 <p>Added unsigned detection to mysql and mysqli drivers. Thx to dan cech. </p>
7270 <p>Added hungarian language file. Thx to Halászvári Gábor. </p>
7272 <p>Improved fieldname-type formatting of datadict SQL generated (adding
7273 $widespacing parameter to _GenField). </p>
7275 <p>Datadict oci8 DROP CONSTRAINTS misspelt. Fixed. Thx Mark Newnham. </p>
7277 <p>Changed odbtp to dynamically change databaseType based on connection, eg.
7278 from 'odbtp' to 'odbtp_mssql' when connecting to mssql database. </p>
7280 <p>In datadict, MySQL I4 was wrongly mapped to MEDIUMINT, which is actually I3.
7283 <p>Fixed mysqli MetaType() recognition. Mysqli returns numeric types unlike
7284 mysql extension. Thx Francesco Riosa. </p>
7286 <p>VFP odbc driver curmode set wrongly, causing problems with memo fields.
7289 <p>Odbc driver did not recognize odbc version 2 driver date types properly.
7290 Fixed. Thx Bostjan. </p>
7292 <p>ChangeTableSQL() fixes to datadict-db2.inc.php by Mark Newnham. </p>
7294 <p>Perf monitoring with odbc improved. Now we try in perf code to manually set
7295 the sysTimeStamp using date() if sysTimeStamp is empty. </p>
7297 <p>All <st1:City w:st="on"><st1:place w:st="on">ADO</st1:place></st1:City>
7298 errors are thrown as exceptions in PHP5. So we added exception handling to ado
7299 in PHP5 by creating new adodb-ado5.inc.php driver. </p>
7301 <p>Added IsConnected(). Returns true if connection object connected. By
7304 <p>"Ralf Becker" RalfBecker#digitalROCK.de contributed new sapdb
7305 data-dictionary driver and a large patch that implements field and table
7306 renaming for oracle, mssql, postgresql, mysql and sapdb. See the new RenameTableSQL()
7307 and RenameColumnSQL() functions. </p>
7309 <p>We now check ExecuteCursor to see if PrepareSP was initially called. </p>
7311 <p>Changed oci8 datadict to use MODIFY for $dd->alterCol. Thx Mark Newnham. </p>
7313 <p><a name=4.52></a><b>4.52 10 Aug 2004</b> </p>
7315 <p>Bug found in Replace() when performance logging enabled, introduced in ADOdb
7318 <p>Replace() checks update stmt. If update stmt fails, we now return
7319 immediately. Thx to alex. </p>
7321 <p>Added support for $ADODB_FORCE_TYPE in GetUpdateSQL/GetInsertSQL. Thx to
7324 <p>Added ADODB_ASSOC_CASE support to postgres/postgres7 driver. </p>
7326 <p>Support for DECLARE stmt in oci8. Thx Lochbrunner. </p>
7328 <p><a name=4.51></a><b>4.51 29 July 2004</b> </p>
7330 <p>Added adodb-xmlschema 1.0.2. Thx dan and richard. </p>
7332 <p>Added new adorecordset_ext_* classes. If ADOdb extension installed for
7333 mysql, mysqlt and oci8 (but not oci8po), we use the superfast ADOdb extension
7334 code for movenext. </p>
7336 <p>Added schema support to mssql and odbc_mssql MetaPrimaryKeys(). </p>
7338 <p>Patched MSSQL driver to support PHP NULL and Boolean values while binding
7339 the input array parameters in the _query() function. By Stephen Farmer. </p>
7341 <p>Added support for clob's for mssql, UpdateBlob(). Thx to
7342 gfran#directa.com.br </p>
7344 <p>Added normalize support for postgresql (true=lowercase table name, or
7345 false=case-sensitive table names) to MetaColumns($table, $normalize=true). </p>
7347 <p>PHP5 variant dates in <st1:City w:st="on"><st1:place w:st="on">ADO</st1:place></st1:City>
7348 not working. Fixed in adodb-ado.inc.php. </p>
7350 <p>Constant ADODB_FORCE_NULLS was not working properly for many releases (for
7351 GetUpdateSQL). Fixed. Also GetUpdateSQL strips off ORDER BY now - thx Elieser
7354 <p>Perf Monitor for oci8 now dynamically highlights optimizer_* params if too
7357 <p>Added dsn support to NewADOConnection/ADONewConnection. </p>
7359 <p>Fixed out of page bounds bug in _adodb_pageexecute_all_rows() Thx to
7360 "Sergio Strampelli" sergio#rir.it </p>
7362 <p>Speedup of movenext for mysql and oci8 drivers. </p>
7364 <p>Moved debugging code _adodb_debug_execute() to adodb-lib.inc.php. </p>
7366 <p>Fixed postgresql bytea detection bug. See
7367 http://phplens.com/lens/lensforum/msgs.php?id=9849. </p>
7369 <p>Fixed ibase datetimestamp typo in PHP5. Thx stefan. </p>
7371 <p>Removed whitespace at end of odbtp drivers. </p>
7373 <p>Added db2 metaprimarykeys fix. </p>
7375 <p>Optimizations to MoveNext() for mysql and oci8. Misc speedups to Get*
7378 <p><a name=4.50></a><b>4.50 6 July 2004</b> </p>
7380 <p>Bumped it to 4.50 to avoid confusion with PHP 4.3.x series. </p>
7382 <p>Added db2 metatables and metacolumns extensions. </p>
7384 <p>Added alpha PDO driver. Very buggy, only works with odbc. </p>
7386 <p>Tested mysqli. Set poorAffectedRows = true. Cleaned up movenext() and
7389 <p>PageExecute does not work properly with php5 (return val not a variable).
7390 Reported Dmytro Sychevsky sych#php.com.ua. Fixed. </p>
7392 <p>MetaTables() for mysql, $showschema parameter was not backward compatible
7393 with older versions of adodb. Fixed. </p>
7395 <p>Changed mysql GetOne() to work with mysql 3.23 when using with non-select
7396 stmts (e.g. SHOW TABLES). </p>
7398 <p>Changed TRIG_ prefix to a variable in datadict-oci8.inc.php. Thx to
7399 Luca.Gioppo#csi.it. </p>
7401 <p>New to adodb-time code. We allow you to define your own daylights savings
7402 function, adodb_daylight_sv for pre-1970 dates. If the function is defined
7403 (somewhere in an include), then you can correct for daylights savings. See
7404 http://phplens.com/phpeverywhere/node/view/16#daylightsavings for more info. </p>
7406 <p>New sqlitepo driver. This is because assoc mode does not work like other
7407 drivers in sqlite. Namely, when selecting (joining) multiple tables, in assoc
7408 mode the table names are included in the assoc keys in the "sqlite"
7409 driver. In "sqlitepo" driver, the table names are stripped from the
7410 returned column names. When this results in a conflict, the first field get
7411 preference. Contributed by Herman Kuiper herman#ozuzo.net </p>
7413 <p>Added $forcenull parameter to GetInsertSQL/GetUpdateSQL. Idea by Marco
7416 <p>More XHTML changes for GetMenu. By Jeremy Evans. </p>
7418 <p>Fixes some ibase date issues. Thx to stefan bogdan. </p>
7420 <p>Improvements to mysqli driver to support $ADODB_COUNTRECS. </p>
7422 <p>Fixed adodb-csvlib.inc.php problem when reading stream from socket. We need
7423 to poll stream continiously. </p>
7425 <p><a name=4.23></a><b>4.23 16 June 2004</b> </p>
7427 <p>New interbase/firebird fixes thx to Lester Caine. Driver fixes a problem
7428 with getting field names in the result array, and corrects a couple of data
7429 conversions. Also we default to dialect3 for firebird. Also ibase sysDate
7430 property was wrong. Changed to cast as timestamp. </p>
7432 <p>The datadict driver is set up to give quoted tables and fields as this was
7433 the only way round reserved words being used as field names in TikiWiki.
7434 TikiPro is tidying that up, and I hope to be able to produce a build of THAT
7435 which uses what I consider proper UPPERCASE field and table names. The
7436 conversion of TikiWiki to ADOdb helped in that, but until the database is
7437 completely tidied up in TikiPro ... </p>
7439 <p>Modified _gencachename() to include fetchmode in name hash. This means you
7440 should clear your cache directory after installing this release as the cache
7441 name algorithm has changed. </p>
7443 <p>Now Cache* functions work in safe mode, because we do not create
7444 sub-directories in the $ADODB_CACHE_DIR in safe mode. In non-safe mode we still
7445 create sub-directories. Done by modifying _gencachename(). </p>
7447 <p>Added $gmt parameter (true/false) to UserDate and UserTimeStamp in
7448 connection class, to force conversion of input (in local time) to be converted
7451 <p>Mssql datadict did not support INT types properly (no size param allowed).
7452 Added _GetSize() to datadict-mssql.inc.php. </p>
7454 <p>For borland_ibase, BeginTrans(), changed:</p>
7456 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
7457 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
7458 style='background:#EEEEEE'><span style='mso-spacerun:yes'> </span>$this->_transactionID = $this->_connectionID;</pre></div>
7460 <p class=MsoNormal>to</p>
7462 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
7463 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
7464 style='background:#EEEEEE'><span style='mso-spacerun:yes'> </span>$this->_transactionID = ibase_trans($this->ibasetrans, $this->_connectionID);</pre></div>
7466 <p>Fixed typo in mysqi_field_seek(). Thx to Sh4dow (sh4dow#php.pl). </p>
7468 <p>LogSQL did not work with Firebird/Interbase. Fixed. </p>
7470 <p>Postgres: made errorno() handling more consistent. Thx to Michael Jahn,
7471 Michael.Jahn#mailbox.tu-dresden.de. </p>
7473 <p>Added informix patch to better support metatables, metacolumns by
7474 "Cecilio Albero" c-albero#eos-i.com </p>
7476 <p>Cyril Malevanov contributed patch to oci8 to support passing of LOB
7479 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
7480 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
7481 style='background:#EEEEEE'><span style='mso-tab-count:1'> </span>$text = 'test test test';<br>
7482 <span style='mso-tab-count:1'> </span>$sql = "declare rs clob; begin :rs := lobinout(:sa0); end;";<br>
7483 <span style='mso-tab-count:1'> </span>$stmt = $conn -> PrepareSP($sql);<br>
7484 <span style='mso-tab-count:1'> </span>$conn -> InParameter($stmt,$text,'sa0', -1, OCI_B_CLOB);<br>
7485 <span style='mso-tab-count:1'> </span>$rs = '';<br>
7486 <span style='mso-tab-count:1'> </span>$conn -> OutParameter($stmt,$rs,'rs', -1, OCI_B_CLOB);<br>
7487 <span style='mso-tab-count:1'> </span>$conn -> Execute($stmt);<br>
7488 <span style='mso-tab-count:1'> </span>echo "return = ".$rs."<br>";</pre></div>
7490 <p class=MsoNormal>As he says, the LOBs limitations are: </p>
7492 <div style='mso-element:para-border-div;border:solid #DDDDDD 1.0pt;mso-border-alt:
7493 solid #DDDDDD .75pt;padding:9.0pt 18.0pt 9.0pt 18.0pt;background:#EEEEEE'><pre
7494 style='background:#EEEEEE'><span style='mso-spacerun:yes'> </span>- use OCINewDescriptor before binding<br>
7495 <span style='mso-spacerun:yes'> </span>- if Param is IN, uses save() before each execute. This is done automatically for you.<br>
7496 <span style='mso-spacerun:yes'> </span>- if Param is OUT, uses load() after each execute. This is done automatically for you.<br>
7497 <span style='mso-spacerun:yes'> </span>- when we bind $var as LOB, we create new descriptor and return it as a<br>
7498 <span style='mso-spacerun:yes'> </span><span style='mso-spacerun:yes'> </span>Bind Result, so if we want to use OUT parameters, we have to store<br>
7499 <span style='mso-spacerun:yes'> </span>somewhere &$var to load() data from LOB to it.<br>
7500 <span style='mso-spacerun:yes'> </span>- IN OUT params are not working now (should not be a big problem to fix it)<br>
7501 <span style='mso-spacerun:yes'> </span>- now mass binding not working too (I've wrote about it before)</pre></div>
7503 <p>Simplified Connect() and PConnect() error handling. </p>
7505 <p>When extension not loaded, Connect() and PConnect() will return null. On
7506 connect error, the fns will return false. </p>
7508 <p>CacheGetArray() added to code. </p>
7510 <p>Added Init() to adorecordset_empty(). </p>
7512 <p>Changed postgres64 driver, MetaColumns() to not strip off quotes in default
7513 value if :: detected (type-casting of default). </p>
7515 <p>Added test: if (!defined('ADODB_DIR')) die(). Useful to prevent hackers from
7516 detecting file paths. </p>
7518 <p>Changed metaTablesSQL to ignore Postgres 7.4 information schemas (sql_*). </p>
7520 <p>New polish language file by Grzegorz Pacan </p>
7522 <p>Added support for <st1:place w:st="on">UNION</st1:place> in
7523 _adodb_getcount(). </p>
7525 <p>Added security check for ADODB_DIR to limit path disclosure issues.
7526 Requested by postnuke team. </p>
7528 <p>Added better error message support to oracle driver. Thx to Gaetano Giunta. </p>
7530 <p>Added showSchema support to mysql. </p>
7532 <p>Bind in oci8 did not handle $name=false properly. Fixed. </p>
7534 <p>If extension not loaded, Connect(), PConnect(), NConnect() will return null.
7537 <p><b>4.22 15 Apr 2004</b> </p>
7539 <p>Moved docs to own adodb/docs folder. </p>
7541 <p>Fixed session bug when quoting compressed/encrypted data in Replace(). </p>
7543 <p>Netezza Driver and LDAP drivers contributed by Josh Eldridge. </p>
7545 <p>GetMenu now uses rtrim() on values instead of trim(). </p>
7547 <p>Changed MetaColumnNames to return an associative array, keys being the field
7548 names in uppercase. </p>
7550 <p>Suggested fix to adodb-ado.inc.php affected_rows to support PHP5 variants.
7551 Thx to Alexios Fakos. </p>
7553 <p>Contributed bulgarian language file by Valentin Sheiretsky
7554 valio#valio.eu.org. </p>
7556 <p>Contributed romanian language file by stefan bogdan. </p>
7558 <p>GetInsertSQL now checks for table name (string) in $rs, and will create a
7559 recordset for that table automatically. Contributed by Walt Boring. Also added
7560 OCI_B_BLOB in bind on Walt's request - hope it doesn't break anything :-) </p>
7562 <p>Some minor postgres speedups in _initrs(). </p>
7564 <p>ChangeTableSQL checks now if MetaColumns returns empty. Thx Jason Judge. </p>
7566 <p>Added ADOConnection::Time(), returns current database time in unix timestamp
7567 format, or false. </p>
7569 <p><b>4.21 20 Mar 2004</b> </p>
7571 <p>We no longer in SelectLimit for VFP driver add SELECT TOP X unless an ORDER
7574 <p>Pim Koeman contributed dutch language file adodb-nl.inc.php. </p>
7576 <p>Rick Hickerson added CLOB support to db2 datadict. </p>
7578 <p>Added odbtp driver. Thx to "stefan bogdan" sbogdan#rsb.ro. </p>
7580 <p>Changed PrepareSP() 2nd parameter, $cursor, to default to true (formerly
7581 false). Fixes oci8 backward compat problems with OUT params. </p>
7583 <p>Fixed month calculation error in adodb-time.inc.php. 2102-June-01 appeared
7584 as 2102-May-32. </p>
7586 <p>Updated PHP5 RC1 iterator support. API changed, hasMore() renamed to
7589 <p>Changed internal format of serialized cache recordsets. As we store a
7590 version number, this should be backward compatible. </p>
7592 <p>Error handling when driver file not found was flawed in ADOLoadCode().
7595 <p><b>4.20 27 Feb 2004</b> </p>
7597 <p>Updated to AXMLS 1.01. </p>
7599 <p>MetaForeignKeys for postgres7 modified by Edward Jaramilla, works on pg 7.4.
7602 <p>Now numbers accepts function calls or sequences for
7603 GetInsertSQL/GetUpdateSQL numeric fields. </p>
7605 <p>Changed quotes of 'delete from $perf_table' to "". Thx Kehui
7606 (webmaster#kehui.net) </p>
7608 <p>Added ServerInfo() for ifx, and putenv trim fix. Thx Fernando Ortiz. </p>
7610 <p>Added addq(), which is analogous to addslashes(). </p>
7612 <p>Tested with php5b4. Fix some php5 compat problems with exceptions and
7615 <p>Carl-Christian Salvesen added patch to mssql _query to support binds greater
7616 than 4000 chars. </p>
7618 <p>Mike suggested patch to PHP5 exception handler. $errno must be numeric. </p>
7620 <p>Added double quotes (") to ADODB_TABLE_REGEX. </p>
7622 <p>For oci8, Prepare(...,$cursor), $cursor's meaning was accidentally inverted
7623 in 4.11. This causes problems with ExecuteCursor() too, which calls Prepare()
7624 internally. Thx to William Lovaton. </p>
7626 <p>Now dateHasTime property in connection object renamed to datetime for
7627 consistency. This could break bc. </p>
7629 <p>Csongor Halmai reports that db2 SelectLimit with input array is not working.
7632 <p><b>4.11 27 Jan 2004</b> </p>
7634 <p>Csongor Halmai reports db2 binding not working. Reverted back to emulated
7637 <p>Dan Cech modifies datadict code. Adds support for DropIndex. Minor cleanups.
7640 <p>Table misspelt in perf-oci8.inc.php. Changed v$conn_cache_advice to
7641 v$db_cache_advice. Reported by Steve W. </p>
7643 <p>UserTimeStamp and DBTimeStamp did not handle YYYYMMDDHHMMSS format properly.
7644 Reported by Mike Muir. Fixed. </p>
7646 <p>Changed oci8 Prepare(). Does not auto-allocate OCINewCursor automatically,
7647 unless 2nd param is set to true. This will break backward compat, if
7648 Prepare/Execute is used instead of ExecuteCursor. Reported by Chris Jones. </p>
7650 <p>Added InParameter() and OutParameter(). Wrapper functions to Parameter(),
7651 but nicer because they are self-documenting. </p>
7653 <p>Added 'R' handling in ActualType() to datadict-mysql.inc.php </p>
7655 <p>Added ADOConnection::SerializableRS($rs). Returns a recordset that can be
7656 serialized in a session. </p>
7658 <p>Added "Run SQL" to performance UI(). </p>
7660 <p>Misc spelling corrections in adodb-mysqli.inc.php, adodb-oci8.inc.php and
7661 datadict-oci8.inc.php, from Heinz Hombergs. </p>
7663 <p>MetaIndexes() for ibase contributed by Heinz Hombergs. </p>
7665 <p><b>4.10 12 Jan 2004</b> </p>
7667 <p>Dan Cech contributed extensive changes to data dictionary to support name
7668 quoting (with `), and drop table/index. </p>
7670 <p>Informix added cursorType property. Default remains IFX_SCROLL, but you can
7671 change to 0 (non-scrollable cursor) for performance. </p>
7673 <p>Added ADODB_View_PrimaryKeys() for returning view primary keys to
7674 MetaPrimaryKeys(). </p>
7676 <p>Simplified chinese file, adodb-cn.inc.php from cysoft. </p>
7678 <p>Added check for ctype_alnum in adodb-datadict.inc.php. Thx to Jason Judge. </p>
7680 <p>Added connection parameter to ibase Prepare(). Fix by Daniel Hassan. </p>
7682 <p>Added nameQuote for quoting identifiers and names to connection obj.
7683 Requested by Jason Judge. Also the data dictionary parser now detects `field
7684 name` and generates column names with spaces correctly. </p>
7686 <p>BOOL type not recognised correctly as L. Fixed. </p>
7688 <p>Fixed paths in ADODB_DIR for session files, and back-ported it to 4.05 (15
7691 <p>Added Schema to postgresql MetaTables. Thx to col#gear.hu </p>
7693 <p>Empty postgresql recordsets that had blob fields did not set EOF properly.
7696 <p>CacheSelectLimit internal parameters to SelectLimit were wrong. Thx to Nio. </p>
7698 <p>Modified adodb_pr() and adodb_backtrace() to support command-line usage (eg.
7701 <p>Fixed some fr and it lang errors. Thx to Gaetano G. </p>
7703 <p>Added contrib directory, with adodb rs to xmlrpc convertor by Gaetano G. </p>
7705 <p>Fixed array recordset bugs when _skiprow1 is true. Thx to Gaetano G. </p>
7707 <p>Fixed pivot table code when count is false. </p>
7709 <p><b>4.05 13 Dec 2003 </b></p>
7711 <p>Added MetaIndexes to data-dict code - thx to Dan Cech. </p>
7713 <p>Rewritten session code by Ross Smith. Moved code to adodb/session directory.
7716 <p>Added function exists check on connecting to most drivers, so we don't crash
7717 with the unknown function error. </p>
7719 <p>Smart Transactions failed with GenID() when it no seq table has been created
7720 because the sql statement fails. Fix by Mark Newnham. </p>
7722 <p>Added $db->length, which holds name of function that returns strlen. </p>
7724 <p>Fixed error handling for bad driver in ADONewConnection - passed too few
7725 params to error-handler. </p>
7727 <p>Datadict did not handle types like 16.0 properly in _GetSize. Fixed. </p>
7729 <p>Oci8 driver SelectLimit() bug &= instead of =& used. Thx to Swen
7732 <p>Jesse Mullan suggested not flushing outp when output buffering enabled. Due
7733 to Apache 2.0 bug. Added. </p>
7735 <p>MetaTables/MetaColumns return ref bug with PHP5 fixed in
7736 adodb-datadict.inc.php. </p>
7738 <p>New mysqli driver contributed by Arjen de Rijke. Based on adodb 3.40 driver.
7739 Then jlim added BeginTrans, CommitTrans, RollbackTrans, IfNull, SQLDate. Also
7740 fixed return ref bug. </p>
7742 <p>$ADODB_FLUSH added, if true then force flush in debugging outp. Default is
7743 false. In earlier versions, outp defaulted to flush, which is not compat with
7746 <p>Mysql driver's GenID() function did not work when when sql logging is on.
7749 <p>$ADODB_SESSION_TBL not declared as global var. Not available if
7750 adodb-session.inc.php included in function. Fixed. </p>
7752 <p>The input array not passed to Execute() in _adodb_getcount(). Fixed. </p>
7754 <p><b>4.04 13 Nov 2003 </b></p>
7756 <p>Switched back to foreach - faster than list-each. </p>
7758 <p>Fixed bug in ado driver - wiping out $this->fields with date fields. </p>
7760 <p>Performance Monitor, View SQL, Explain Plan did not work if
7761 strlen($SQL)>max($_GET length). Fixed. </p>
7763 <p>Performance monitor, oci8 driver added memory sort ratio. </p>
7765 <p>Added random property, returns SQL to generate a floating point number
7766 between 0 and 1; </p>
7768 <p><b>4.03 6 Nov 2003 </b></p>
7770 <p>The path to adodb-php4.inc.php and adodb-iterators.inc.php was not setup
7773 <p>Patched SQLDate in interbase to support hours/mins/secs. Thx to ari
7776 <p>Force autorollback for pgsql persistent connections - apparently pgsql did
7777 not autorollback properly before 4.3.4. See http://bugs.php.net/bug.php?id=25404
7780 <p><b>4.02 5 Nov 2003 </b></p>
7782 <p>Some errors in adodb_error_pg() fixed. Thx to Styve. </p>
7784 <p>Spurious Insert_ID() error was generated by LogSQL(). Fixed. </p>
7786 <p>Insert_ID was interfering with Affected_Rows() and Replace() when LogSQL()
7787 enabled. Fixed. </p>
7789 <p>More foreach loops optimized with list/each. </p>
7791 <p>Null dates not handled properly in <st1:City w:st="on"><st1:place w:st="on">ADO</st1:place></st1:City>
7792 driver (it becomes 31 Dec 1969!). </p>
7794 <p>Heinz Hombergs contributed patches for mysql MetaColumns - adding scale,
7795 made interbase MetaColumns work with firebird/interbase, and added
7796 lang/adodb-de.inc.php. </p>
7798 <p>Added INFORMIXSERVER environment variable. </p>
7800 <p>Added $ADODB_ANSI_PADDING_OFF for interbase/firebird. </p>
7802 <p>PHP 5 beta 2 compat check. Foreach (Iterator) support. Exceptions support. </p>
7804 <p><b>4.01 23 Oct 2003 </b></p>
7806 <p>Fixed bug in rs2html(), tohtml.inc.php, that generated blank table cells. </p>
7808 <p>Fixed insert_id() incorrectly generated when logsql() enabled. </p>
7810 <p>Modified PostgreSQL _fixblobs to use list/each instead of foreach. </p>
7812 <p>Informix ErrorNo() implemented correctly. </p>
7814 <p>Modified several places to use list/each, including GetRowAssoc(). </p>
7816 <p>Added UserTimeStamp() to connection class. </p>
7818 <p>Added $ADODB_ANSI_PADDING_OFF for oci8po. </p>
7820 <p><b>4.00 20 Oct 2003 </b></p>
7822 <p>Upgraded adodb-xmlschema to 1 Oct 2003 snapshot. </p>
7824 <p>Fix to rs2html warning message. Thx to Filo. </p>
7826 <p>Fix for odbc_mssql/mssql SQLDate(), hours was wrong. </p>
7828 <p>Added MetaColumns and MetaPrimaryKeys for sybase. Thx to Chris Phillipson. </p>
7830 <p>Added autoquoting to datadict for MySQL and PostgreSQL. Suggestion by
7831 Karsten Dambekalns </p>
7833 <p><b>3.94 11 Oct 2003 </b></p>
7835 <p>Create trigger in datadict-oci8.inc.php did not work, because all cr/lf's
7836 must be removed. </p>
7838 <p>ErrorMsg()/ErrorNo() did not work for many databases when logging enabled.
7841 <p>Removed global variable $ADODB_LOGSQL as it does not work properly with
7842 multiple connections. </p>
7844 <p>Added SQLDate support for sybase. Thx to Chris Phillipson </p>
7846 <p>Postgresql checking of pgsql resultset resource was incorrect. Fix by Bharat
7847 Mediratta bharat#menalto.com. Same patch applied to _insertid and _affectedrows
7848 for adodb-postgres64.inc.php. </p>
7850 <p>Added support for NConnect for postgresql. </p>
7852 <p>Added Sybase data dict support. Thx to Chris Phillipson </p>
7854 <p>Extensive improvements in $perf->UI(), eg. Explain now opens in new
7855 window, we show scripts which call sql, etc. </p>
7857 <p>Perf Monitor UI works with magic quotes enabled. </p>
7859 <p>rsPrefix was declared twice. Removed. </p>
7861 <p>Oci8 stored procedure support, eg. "begin func(); end;" was
7862 incorrect in _query. Fixed. </p>
7864 <p>Tiraboschi Massimiliano contributed italian language file. </p>
7866 <p>Fernando Ortiz, fortiz#lacorona.com.mx, contributed informix performance
7869 <p>Added _varchar (varchar arrays) support for postgresql. Reported by PREVOT
7872 <div class=MsoNormal align=center style='text-align:center'>
7874 <hr size=2 width="100%" align=center>
7878 <p><strong>0.10 Sept 9 2000</strong> First release </p>
7880 <h3><strong>Old change log history moved to <a href="old-changelog.htm">old-changelog.htm</a>.