/
Zebra_Database.html
3263 lines (3263 loc) · 223 KB
/
Zebra_Database.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE HTML>
<html>
<head>
<title>Zebra_Database - a compact, lightweight and feature-rich PHP MySQLi database wrapper - Class: Zebra_Database</title>
<meta http-equiv="content-type" content="text/html;charset=UTF-8">
<link rel="stylesheet" type="text/css" href="../media/reset.css">
<link rel="stylesheet" type="text/css" href="../media/style.css">
</head>
<body>
<div id="phpdoc">
<div id="doc_header">
Package: <strong>Zebra_Database</strong>
<ul class="notype float">
<!--
<li><a href="../classtrees_Zebra_Database.html">class tree: Zebra_Database</a></li>
-->
<li><a href="../elementindex_Zebra_Database.html">element index: Zebra_Database</a></li>
<!--
<li class="last"><a href="../elementindex.html">all elements</a></li>
-->
</ul>
<div class="clear"></div>
</div>
<table cellspacing="0" cellpadding="0" class="stretch">
<tr>
<td valign="top" class="sidebar">
<div id="doc_sidebar">
<p><strong>Project's homepage</strong></p>
<ul>
<li>
<a href="https://github.com/stefangabos/Zebra_Database" class="projects-homepage">Zebra_Database</a>
</li>
</ul>
<p><strong>Classes:</strong></p>
<ul>
<li><a href="../Zebra_Database/Zebra_Database.html">Zebra_Database</a></li>
</ul>
</div>
</td>
<td valign="top" width="100%">
<div id="doc_content">
<h2>Class: <strong>Zebra_Database</strong></h2>
<h6><strong>source file:</strong> /Zebra_Database.php</h6>
<pre></pre>
<p>A compact (one-file only), lightweight yet feature-rich PHP MySQLi database wrapper providing methods for interacting with MySQL databases that are more secure, powerful and intuitive than PHP's default ones.<p>Read more <a href="https://github.com/stefangabos/Zebra_Database">here</a></p></p>
<h4>Author(s):</h4>
<ul>
<li>Stefan Gabos <<a href="mailto:contact@stefangabos.ro">contact@stefangabos.ro</a>></li>
</ul>
<h4>Version:</h4>
<ul>
<li>2.9.12 (last revision: January 16, 2019)</li>
</ul>
<h4>Copyright:</h4>
<ul>
<li>(c) 2006 - 2019 Stefan Gabos</li>
</ul>
<a name="top"></a>
<div class="doc_toc">
<div class="left">
<h3>Properties</h3>
<ul>
<li><a href="#var$affected_rows">$affected_rows</a></li>
<li><a href="#var$cache_path">$cache_path</a></li>
<li><a href="#var$caching_method">$caching_method</a></li>
<li><a href="#var$debug">$debug</a></li>
<li><a href="#var$debugger_ip">$debugger_ip</a></li>
<li><a href="#var$debug_show_backtrace">$debug_show_backtrace</a></li>
<li><a href="#var$debug_show_explain">$debug_show_explain</a></li>
<li><a href="#var$debug_show_records">$debug_show_records</a></li>
<li><a href="#var$disable_warnings">$disable_warnings</a></li>
<li><a href="#var$found_rows">$found_rows</a></li>
<li><a href="#var$halt_on_errors">$halt_on_errors</a></li>
<li><a href="#var$log_path">$log_path</a></li>
<li><a href="#var$max_query_time">$max_query_time</a></li>
<li><a href="#var$memcache_compressed">$memcache_compressed</a></li>
<li><a href="#var$memcache_host">$memcache_host</a></li>
<li><a href="#var$memcache_key_prefix">$memcache_key_prefix</a></li>
<li><a href="#var$memcache_port">$memcache_port</a></li>
<li><a href="#var$minimize_console">$minimize_console</a></li>
<li><a href="#var$notification_address">$notification_address</a></li>
<li><a href="#var$notifier_domain">$notifier_domain</a></li>
<li><a href="#var$resource_path">$resource_path</a></li>
<li><a href="#var$returned_rows">$returned_rows</a></li>
</ul>
</div>
<div class="left">
<h3>Methods</h3>
<ul>
</ul>
<ul>
<li><a href="#method__construct">__construct</a></li>
<li><a href="#method__destruct">__destruct</a></li>
<li><a href="#methodclose">close</a></li>
<li><a href="#methodconnect">connect</a></li>
<li><a href="#methoddcount">dcount</a></li>
<li><a href="#methoddelete">delete</a></li>
<li><a href="#methoddlookup">dlookup</a></li>
<li><a href="#methoddmax">dmax</a></li>
<li><a href="#methoddsum">dsum</a></li>
<li><a href="#methoderror">error</a></li>
<li><a href="#methodescape">escape</a></li>
<li><a href="#methodfetch_assoc">fetch_assoc</a></li>
<li><a href="#methodfetch_assoc_all">fetch_assoc_all</a></li>
<li><a href="#methodfetch_obj">fetch_obj</a></li>
<li><a href="#methodfetch_obj_all">fetch_obj_all</a></li>
<li><a href="#methodfree_result">free_result</a></li>
<li><a href="#methodget_columns">get_columns</a></li>
<li><a href="#methodget_link">get_link</a></li>
<li><a href="#methodget_selected_database">get_selected_database</a></li>
<li><a href="#methodget_tables">get_tables</a></li>
<li><a href="#methodget_table_columns">get_table_columns</a></li>
<li><a href="#methodget_table_status">get_table_status</a></li>
<li><a href="#methodimplode">implode</a></li>
<li><a href="#methodinsert">insert</a></li>
<li><a href="#methodinsert_bulk">insert_bulk</a></li>
<li><a href="#methodinsert_id">insert_id</a></li>
<li><a href="#methodinsert_update">insert_update</a></li>
<li><a href="#methodlanguage">language</a></li>
<li><a href="#methodoptimize">optimize</a></li>
<li><a href="#methodoption">option</a></li>
<li><a href="#methodparse_file">parse_file</a></li>
<li><a href="#methodquery">query</a></li>
<li><a href="#methodquery_unbuffered">query_unbuffered</a></li>
<li><a href="#methodseek">seek</a></li>
<li><a href="#methodselect">select</a></li>
<li><a href="#methodselect_database">select_database</a></li>
<li><a href="#methodset_charset">set_charset</a></li>
<li><a href="#methodtable_exists">table_exists</a></li>
<li><a href="#methodtransaction_complete">transaction_complete</a></li>
<li><a href="#methodtransaction_start">transaction_start</a></li>
<li><a href="#methodtruncate">truncate</a></li>
<li><a href="#methodupdate">update</a></li>
</ul>
</div>
<div class="clear"></div>
<div class="clear"></div>
</div>
<a name="class_vars"></a>
<h3>Class properties</h3>
<a name="var$affected_rows"></a>
<h4 class="variable"><span><em>integer</em></span> $affected_rows <span class="value"></span></h4>
<div class="doc_block">
<p>The number of rows affected after running an INSERT, UPDATE, REPLACE or DELETE query.</p>
<p>See the <a href="../Zebra_Database/Zebra_Database.html#var$returned_rows">returned_rows</a> property for getting the number of rows returned by SELECT queries.</p><p><ol class="code"><li><div class="src-line"><span class="src-comm">// update some columns in a table</span></div></li>
<li><div class="src-line"><span class="src-var">$db</span><span class="src-sym">-></span><a href="../Zebra_Database/Zebra_Database.html#methodupdate">update</a><span class="src-sym">(</span><span class="src-str">'table'</span><span class="src-sym">, </span><span class="src-key">array</span><span class="src-sym">(</span></div></li>
<li><div class="src-line"> <span class="src-str">'column_1' </span>=> <span class="src-str">'value 1'</span><span class="src-sym">,</span></div></li>
<li><div class="src-line"> <span class="src-str">'column_2' </span>=> <span class="src-str">'value 2'</span><span class="src-sym">,</span></div></li>
<li><div class="src-line"><span class="src-sym">)</span><span class="src-sym">, </span><span class="src-str">'id = ?'</span><span class="src-sym">, </span><span class="src-key">array</span><span class="src-sym">(</span><span class="src-var">$id</span><span class="src-sym">))</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"> </div></li>
<li><div class="src-line"><span class="src-comm">// print the number of affected rows</span></div></li>
<li><div class="src-line">echo <span class="src-var">$db</span><span class="src-sym">-></span><span class="src-id"><a href="../Zebra_Database/Zebra_Database.html#var$affected_rows">affected_rows</a></span><span class="src-sym">;</span></div></li>
</ol>
<h5>Tags:</h5>
<table cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><strong>access:</strong> </td>
<td valign="top">public</td>
</tr>
</table>
<a href="#top" class="top">top</a>
<div class="clear"></div>
</div>
<a name="var$cache_path"></a>
<h4 class="variable"><span><em>string</em></span> $cache_path <span class="value"></span></h4>
<div class="doc_block">
<p>Path (with trailing slash) where to cache queries results.</p>
<p><em>The path must be relative to your working path and not the class' path!</em></p>
<h5>Tags:</h5>
<table cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><strong>access:</strong> </td>
<td valign="top">public</td>
</tr>
</table>
<a href="#top" class="top">top</a>
<div class="clear"></div>
</div>
<a name="var$caching_method"></a>
<h4 class="variable"><span><em>string</em></span> $caching_method <span class="value"></span></h4>
<div class="doc_block">
<p>The method to be used for caching query results.</p>
<p>Can be either:</p><ul><li><strong>disk</strong> - query results are cached as files on the disk at the path specified by <a href="../Zebra_Database/Zebra_Database.html#var$cache_path">cache_path</a>.</li><li><strong>session</strong> - query results are cached in the session (use this only for small data sets). Note that when
using this method for caching results, the library expects an active session, or will trigger
a fatal error otherwise!</li><li><strong>memcache</strong> - query results are cached using a <a href="http://memcached.org/about">memcache</a> server; when
using this method make sure to also set the appropriate values for <a href="../Zebra_Database/Zebra_Database.html#var$memcache_host">memcache_host</a>,
<a href="../Zebra_Database/Zebra_Database.html#var$memcache_port">memcache_port</a> and optionally <a href="../Zebra_Database/Zebra_Database.html#var$memcache_compressed">memcache_compressed</a>.
<br>
<em>For using memcache as caching method, PHP must be compiled with the
<a href="http://pecl.php.net/package/memcache">memcache</a> extension and, if <a href="../Zebra_Database/Zebra_Database.html#var$memcache_compressed">memcache_compressed</a>
property is set to TRUE, needs to be configured with</em><strong>--with-zlib[=DIR]</strong><em>.</em></li></ul><p> If caching method is set to "memcache", <a href="../Zebra_Database/Zebra_Database.html#var$memcache_host">memcache_host</a>, <a href="../Zebra_Database/Zebra_Database.html#var$memcache_port">memcache_port</a> and optionally <a href="../Zebra_Database/Zebra_Database.html#var$memcache_compressed">memcache_compressed</a> must be set <strong>prior</strong> to calling the <a href="../Zebra_Database/Zebra_Database.html#methodconnect">connect()</a> method! Failing to do so will disable caching.</p><p><ol class="code"><li><div class="src-line"><span class="src-comm">// the host where memcache is listening for connections</span></div></li>
<li><div class="src-line"><span class="src-var">$db</span><span class="src-sym">-></span><span class="src-id"><a href="../Zebra_Database/Zebra_Database.html#var$memcache_host">memcache_host</a> </span>= <span class="src-str">'localhost'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"> </div></li>
<li><div class="src-line"><span class="src-comm">// the port where memcache is listening for connections</span></div></li>
<li><div class="src-line"><span class="src-var">$db</span><span class="src-sym">-></span><span class="src-id"><a href="../Zebra_Database/Zebra_Database.html#var$memcache_port">memcache_port</a> </span>= <span class="src-num">11211</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"> </div></li>
<li><div class="src-line"><span class="src-comm">// for this to work, PHP needs to be configured with --with-zlib[=dir] !</span></div></li>
<li><div class="src-line"><span class="src-comm">// set it to FALSE otherwise</span></div></li>
<li><div class="src-line"><span class="src-var">$db</span><span class="src-sym">-></span><span class="src-id"><a href="../Zebra_Database/Zebra_Database.html#var$memcache_compressed">memcache_compressed</a> </span>= <span class="src-id">true</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"> </div></li>
<li><div class="src-line"><span class="src-comm">// cache queries using the memcache server</span></div></li>
<li><div class="src-line"><span class="src-var">$db</span><span class="src-sym">-></span><span class="src-id"><a href="../Zebra_Database/Zebra_Database.html#var$caching_method">caching_method</a> </span>= <span class="src-str">'memcache'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"> </div></li>
<li><div class="src-line"><span class="src-comm">// only now it is the time to connect</span></div></li>
<li><div class="src-line"><span class="src-var">$db</span><span class="src-sym">-></span><a href="../Zebra_Database/Zebra_Database.html#methodconnect">connect</a><span class="src-sym">(</span>...<span class="src-sym">)</span></div></li>
</ol><p><em>Caching is done on a per-query basis by setting the "cache" argument when calling some of the library's
methods like <a href="../Zebra_Database/Zebra_Database.html#methodquery">query()</a>, <a href="../Zebra_Database/Zebra_Database.html#methodselect">select()</a>, <a href="../Zebra_Database/Zebra_Database.html#methoddcount">dcount()</a>, <a href="../Zebra_Database/Zebra_Database.html#methoddlookup">dlookup()</a>, <a href="../Zebra_Database/Zebra_Database.html#methoddmax">dmax()</a> and <a href="../Zebra_Database/Zebra_Database.html#methoddsum">dsum()</a>!</em></p><p>Default is "disk".</p>
<h5>Tags:</h5>
<table cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><strong>since:</strong> </td>
<td valign="top">2.7</td>
</tr>
<tr>
<td valign="top"><strong>access:</strong> </td>
<td valign="top">public</td>
</tr>
</table>
<a href="#top" class="top">top</a>
<div class="clear"></div>
</div>
<a name="var$debug"></a>
<h4 class="variable"><span><em>boolean</em></span> $debug <span class="value"></span></h4>
<div class="doc_block">
<p>Turns debugging on or off.</p>
<p>The property can take one of the following values:</p><p><ul><li><strong>boolean TRUE</strong><br>
Setting this property to a boolean TRUE will instruct the library to generate debugging information for each
query it executes and show the information on the screen when script's execution ends.</li></ul> <ul><li><strong>an array([bool]daily, [bool]hourly, [bool]backtrace)</strong><br>
Setting this property to an array like above, will instruct the library to generate debugging information for
each query it executes and write the information to a log file when the script's execution ends.</li></ul> <ul><li>the value of the first entry (daily) indicates whether the log files should be grouped by days or not;
if set to TRUE, log files will have their name in the form of "log_ymd.txt", where "y", "m" and "d"
represent two digit values for year, month and day, respectively.</li></ul> <ul><li>the value of the second entry (hourly) indicates whether the log files should be grouped by hours or not;
if set to TRUE, log files will have their name in the form of "log_ymd_h.txt", where "y", "m" and "d"
represent two digit values for year, month and day, respectively, while "h" represents the two digit
value for hour.<br>
<em>Note that if this argument is set to TRUE, the first entry will be automatically considered as TRUE.</em></li></ul> <ul><li>the value of the third entry (backtrace) indicates whether backtrace information (where the query was
called from) should also be written to the log file.<br><br>
<em>the default values for all the entries is FALSE and all are optional, therefore setting the value
of this property to an empty array is equivalent of setting it to array(false, false, false)</em></li></ul> <ul><li><strong>boolean FALSE</strong><br>
Setting this property to FALSE will instruct the library to not generate debugging information for any of the
queries it executes. Even so, if an error occurs the library will try to write information to PHP's error log
file, if your environment is <a href="http://www.php.net/manual/en/errorfunc.configuration.php#ini.log-errors">configured to do so</a> !</li></ul> <div class="highlight">It is highly recommended to set the value of this property to FALSE on the production environment. Generating
the debugging information consumes a lot of resources and is meant to be used *only* in the development process!</div></p><p><ol class="code"><li><div class="src-line"><span class="src-comm">// log debug information instead of showing it on screen</span></div></li>
<li><div class="src-line"><span class="src-comm">// log everything in one single file (not by day/hour) and also show backtrace information</span></div></li>
<li><div class="src-line"><span class="src-var">$db</span><span class="src-sym">-></span><span class="src-id"><a href="../Zebra_Database/Zebra_Database.html#var$debug">debug</a> </span>= <span class="src-key">array</span><span class="src-sym">(</span><span class="src-id">false</span><span class="src-sym">, </span><span class="src-id">false</span><span class="src-sym">, </span><span class="src-id">true</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"> </div></li>
<li><div class="src-line"><span class="src-comm">// disable the generation of debugging information</span></div></li>
<li><div class="src-line"><span class="src-var">$db</span><span class="src-sym">-></span><span class="src-id"><a href="../Zebra_Database/Zebra_Database.html#var$debug">debug</a> </span>= <span class="src-id">false</span><span class="src-sym">;</span></div></li>
</ol><p>Default is TRUE.</p>
<h5>Tags:</h5>
<table cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><strong>access:</strong> </td>
<td valign="top">public</td>
</tr>
</table>
<a href="#top" class="top">top</a>
<div class="clear"></div>
</div>
<a name="var$debugger_ip"></a>
<h4 class="variable"><span><em>array</em></span> $debugger_ip <span class="value"></span></h4>
<div class="doc_block">
<p>An array of IP addresses for which to show the debugging console / write to log file, if the <a href="../Zebra_Database/Zebra_Database.html#var$debug">debug</a> property is <strong>not</strong> set to FALSE.</p>
<p><ol class="code"><li><div class="src-line"><span class="src-comm">// show the debugging console only to specific IPs</span></div></li>
<li><div class="src-line"><span class="src-var">$db</span><span class="src-sym">-></span><span class="src-id"><a href="../Zebra_Database/Zebra_Database.html#var$debugger_ip">debugger_ip</a> </span>= <span class="src-key">array</span><span class="src-sym">(</span><span class="src-str">'xxx.xxx.xxx.xxx'</span><span class="src-sym">, </span><span class="src-str">'yyy.yyy.yyy.yyy'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
</ol><p>Default is an empty array.</p>
<h5>Tags:</h5>
<table cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><strong>since:</strong> </td>
<td valign="top">1.0.6</td>
</tr>
<tr>
<td valign="top"><strong>access:</strong> </td>
<td valign="top">public</td>
</tr>
</table>
<a href="#top" class="top">top</a>
<div class="clear"></div>
</div>
<a name="var$debug_show_backtrace"></a>
<h4 class="variable"><span><em>boolean</em></span> $debug_show_backtrace <span class="value"></span></h4>
<div class="doc_block">
<p>Indicates <a href="http://php.net/manual/en/function.debug-backtrace.php">backtrace</a> information should be shown in the debugging console.</p>
<p>Default is TRUE.</p>
<h5>Tags:</h5>
<table cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><strong>since:</strong> </td>
<td valign="top">2.5.9</td>
</tr>
<tr>
<td valign="top"><strong>access:</strong> </td>
<td valign="top">public</td>
</tr>
</table>
<a href="#top" class="top">top</a>
<div class="clear"></div>
</div>
<a name="var$debug_show_explain"></a>
<h4 class="variable"><span><em>boolean</em></span> $debug_show_explain <span class="value"></span></h4>
<div class="doc_block">
<p>Indicates whether queries should be <a href="http://dev.mysql.com/doc/refman/5.0/en/explain.html">EXPLAIN</a>ed in the debugging console.</p>
<p>Default is TRUE.</p>
<h5>Tags:</h5>
<table cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><strong>since:</strong> </td>
<td valign="top">2.5.9</td>
</tr>
<tr>
<td valign="top"><strong>access:</strong> </td>
<td valign="top">public</td>
</tr>
</table>
<a href="#top" class="top">top</a>
<div class="clear"></div>
</div>
<a name="var$debug_show_records"></a>
<h4 class="variable"><span><em>integer</em></span> $debug_show_records <span class="value"></span></h4>
<div class="doc_block">
<p>Sets the number records returned by SELECT queries to be shown in the debugging console.</p>
<p>Setting this to 0 or FALSE will disable this feature.</p><p><ol class="code"><li><div class="src-line"><span class="src-comm">// show 50 records</span></div></li>
<li><div class="src-line"><span class="src-var">$db</span><span class="src-sym">-></span><span class="src-id"><a href="../Zebra_Database/Zebra_Database.html#var$debug_show_records">debug_show_records</a></span><span class="src-sym">(</span><span class="src-num">50</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
</ol><p><em>Be aware that having this property set to a high number (hundreds), and having queries that return that many
rows, can cause your script to crash due to memory limitations. In this case you should either lower the value
of this property or try and set PHP's memory limit higher using:</em></p><p><ol class="code"><li><div class="src-line"><span class="src-comm">// set PHP's memory limit to 20 MB</span></div></li>
<li><div class="src-line"><a href="http://www.php.net/ini_set">ini_set</a><span class="src-sym">(</span><span class="src-str">'memory_limit'</span><span class="src-sym">,</span><span class="src-str">'20M'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
</ol><p>Default is 20.</p>
<h5>Tags:</h5>
<table cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><strong>since:</strong> </td>
<td valign="top">1.0.9</td>
</tr>
<tr>
<td valign="top"><strong>access:</strong> </td>
<td valign="top">public</td>
</tr>
</table>
<a href="#top" class="top">top</a>
<div class="clear"></div>
</div>
<a name="var$disable_warnings"></a>
<h4 class="variable"><span><em>boolean</em></span> $disable_warnings <span class="value"></span></h4>
<div class="doc_block">
<p>By default, if <a href="../Zebra_Database/Zebra_Database.html#methodset_charset">set_charset()</a> method is not called, a warning message will be displayed in the debugging console.</p>
<p>The ensure that data is both properly saved and retrieved to and from the database, this method should be called first thing after connecting to the database.</p><p>If you don't want to call this method nor do you want to see the warning, set this property to FALSE.</p><p>Default is TRUE.</p>
<h5>Tags:</h5>
<table cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><strong>access:</strong> </td>
<td valign="top">public</td>
</tr>
</table>
<a href="#top" class="top">top</a>
<div class="clear"></div>
</div>
<a name="var$found_rows"></a>
<h4 class="variable"><span><em>integer</em></span> $found_rows <span class="value"></span></h4>
<div class="doc_block">
<p>After running a SELECT query through <a href="../Zebra_Database/Zebra_Database.html#methodselect">select()</a>, <a href="../Zebra_Database/Zebra_Database.html#methodquery">query()</a> or <a href="../Zebra_Database/Zebra_Database.html#methodquery_unbuffered">query_unbuffered()</a> methods and having the <em>calc_rows</em> argument set to TRUE, this property will contain the number of records that <strong>would</strong> have been returned <strong>if</strong> there was no LIMIT applied to the query.</p>
<p>If <em>calc_rows</em> is FALSE or is TRUE but there is no LIMIT applied to the query, this property's value will be the same as the value of the <a href="../Zebra_Database/Zebra_Database.html#var$returned_rows">returned_rows</a> property.</p><p><em>For <a href="../Zebra_Database/Zebra_Database.html#methodquery_unbuffered">unbuffered</a> queries the value of this property will be available only after
iterating over all the records with either <a href="../Zebra_Database/Zebra_Database.html#methodfetch_assoc">fetch_assoc()</a> or <a href="../Zebra_Database/Zebra_Database.html#methodfetch_obj">fetch_obj()</a> methods. Until then, the
value will be 0!</em></p><p><ol class="code"><li><div class="src-line"><span class="src-comm">// let's assume that "table" has 100 rows</span></div></li>
<li><div class="src-line"><span class="src-comm">// but we're only selecting the first 10 of those</span></div></li>
<li><div class="src-line"><span class="src-comm">// the last argument of the method tells the library</span></div></li>
<li><div class="src-line"><span class="src-comm">// to get the total number of records in the table</span></div></li>
<li><div class="src-line"><span class="src-var">$db</span><span class="src-sym">-></span><a href="../Zebra_Database/Zebra_Database.html#methodquery">query</a><span class="src-sym">(</span><span class="src-str">'</span></div></li>
<li><div class="src-line"><span class="src-str"> SELECT</span></div></li>
<li><div class="src-line"><span class="src-str"> *</span></div></li>
<li><div class="src-line"><span class="src-str"> FROM</span></div></li>
<li><div class="src-line"><span class="src-str"> table</span></div></li>
<li><div class="src-line"><span class="src-str"> WHERE</span></div></li>
<li><div class="src-line"><span class="src-str"> something = ?</span></div></li>
<li><div class="src-line"><span class="src-str"> LIMIT</span></div></li>
<li><div class="src-line"><span class="src-str"> 10</span></div></li>
<li><div class="src-line"><span class="src-str">'</span><span class="src-sym">, </span><span class="src-key">array</span><span class="src-sym">(</span><span class="src-var">$somevalue</span><span class="src-sym">)</span><span class="src-sym">, </span><span class="src-id">false</span><span class="src-sym">, </span><span class="src-id">true</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"> </div></li>
<li><div class="src-line"><span class="src-comm">// prints "10"</span></div></li>
<li><div class="src-line"><span class="src-comm">// as this is the number of records</span></div></li>
<li><div class="src-line"><span class="src-comm">// returned by the query</span></div></li>
<li><div class="src-line">echo <span class="src-var">$db</span><span class="src-sym">-></span><span class="src-id"><a href="../Zebra_Database/Zebra_Database.html#var$returned_rows">returned_rows</a></span><span class="src-sym">;</span></div></li>
<li><div class="src-line"> </div></li>
<li><div class="src-line"><span class="src-comm">// prints "100"</span></div></li>
<li><div class="src-line"><span class="src-comm">// because we set the "calc_rows" argument of the</span></div></li>
<li><div class="src-line"><span class="src-comm">// "query" method to TRUE</span></div></li>
<li><div class="src-line">echo <span class="src-var">$db</span><span class="src-sym">-></span><span class="src-id"><a href="../Zebra_Database/Zebra_Database.html#var$found_rows">found_rows</a></span><span class="src-sym">;</span></div></li>
</ol>
<h5>Tags:</h5>
<table cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><strong>access:</strong> </td>
<td valign="top">public</td>
</tr>
</table>
<a href="#top" class="top">top</a>
<div class="clear"></div>
</div>
<a name="var$halt_on_errors"></a>
<h4 class="variable"><span><em>boolean</em></span> $halt_on_errors <span class="value"></span></h4>
<div class="doc_block">
<p>When the value of this property is set to TRUE, the execution of the script will be halted for any unsuccessful query and the debugging console will be shown (or debug information will be written to the log file if configured so), <strong>if</strong> the value of the <a href="../Zebra_Database/Zebra_Database.html#var$debug">debug</a> property is <strong>not</strong> FALSE and the viewer's IP address is in the <a href="../Zebra_Database/Zebra_Database.html#var$debugger_ip">debugger_ip</a> array (or <a href="../Zebra_Database/Zebra_Database.html#var$debugger_ip">debugger_ip</a> is an empty array).</p>
<p><ol class="code"><li><div class="src-line"><span class="src-comm">// don't stop execution for unsuccessful queries (if possible)</span></div></li>
<li><div class="src-line"><span class="src-var">$db</span><span class="src-sym">-></span><span class="src-id"><a href="../Zebra_Database/Zebra_Database.html#var$halt_on_errors">halt_on_errors</a> </span>= <span class="src-id">false</span><span class="src-sym">;</span></div></li>
</ol><p>Default is TRUE.</p>
<h5>Tags:</h5>
<table cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><strong>since:</strong> </td>
<td valign="top">1.0.5</td>
</tr>
<tr>
<td valign="top"><strong>access:</strong> </td>
<td valign="top">public</td>
</tr>
</table>
<a href="#top" class="top">top</a>
<div class="clear"></div>
</div>
<a name="var$log_path"></a>
<h4 class="variable"><span><em>string</em></span> $log_path <span class="value"></span></h4>
<div class="doc_block">
<p>Path where to store the log files when the <a href="../Zebra_Database/Zebra_Database.html#var$debug">debug</a> property is set to an array OR a callback function to pass the log information to, instead of being written to a file.</p>
<p><strong>The path is relative to your working directory.</strong></p><p><strong>Use "." (dot) for the current directory instead of an empty string or the log file will be written to the
server's root.</strong></p><p>If a full path is specified (including an extension) the log file's name will be used from there. Otherwise, the log file's name will be <em>log.txt</em></p><p><em>At the given path the library will attempt to create a file named "log.txt" (or variations as described
<a href="../Zebra_Database/Zebra_Database.html#var$debug">here</a>). Remember to grant the appropriate rights to the script!</em></p><p><strong>IF YOU'RE LOGGING, MAKE SURE YOU HAVE A CRON JOB OR SOMETHING THAT DELETES THE LOG FILE FROM TIME TO TIME!</strong></p><p>Default is "" (an empty string) - log files are created in the root of your server.</p><p>If you are using a callback function, the function receives two arguments:</p><p><ul><li>the debug information, as a string, just like it would go into the log file</li><li>the backtrace information, as a string, just like it would go into the log file - if <a href="../Zebra_Database/Zebra_Database.html#var$debug_show_backtrace">$debug_show_backtrace</a>
is set to FALSE, this will be an empty string</li></ul>
<h5>Tags:</h5>
<table cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><strong>access:</strong> </td>
<td valign="top">public</td>
</tr>
</table>
<a href="#top" class="top">top</a>
<div class="clear"></div>
</div>
<a name="var$max_query_time"></a>
<h4 class="variable"><span><em>integer</em></span> $max_query_time <span class="value"></span></h4>
<div class="doc_block">
<p>Time (in seconds) after which a query will be considered as running for too long.</p>
<p>If a query's execution time exceeds this number, a notification email will be automatically sent to the address defined by <a href="../Zebra_Database/Zebra_Database.html#var$notification_address">notification_address</a>, having <a href="../Zebra_Database/Zebra_Database.html#var$notifier_domain">notifier_domain</a> in subject.</p><p><ol class="code"><li><div class="src-line"><span class="src-comm">// consider queries running for more than 5 seconds as slow and send email</span></div></li>
<li><div class="src-line"><span class="src-var">$db</span><span class="src-sym">-></span><span class="src-id"><a href="../Zebra_Database/Zebra_Database.html#var$max_query_time">max_query_time</a> </span>= <span class="src-num">5</span><span class="src-sym">;</span></div></li>
</ol><p>Default is 10.</p>
<h5>Tags:</h5>
<table cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><strong>access:</strong> </td>
<td valign="top">public</td>
</tr>
</table>
<a href="#top" class="top">top</a>
<div class="clear"></div>
</div>
<a name="var$memcache_compressed"></a>
<h4 class="variable"><span><em>boolean</em></span> $memcache_compressed <span class="value"></span></h4>
<div class="doc_block">
<p>Setting this property to TRUE will instruct to library to compress (using zlib) the cached results.</p>
<p><em>For this to work, PHP needs to be configured with</em> <strong>--with-zlib[=DIR]</strong> <em>!</em></p><p><em>Set this property only if you are using "memcache" as <a href="../Zebra_Database/Zebra_Database.html#var$caching_method">caching_method</a>.</em></p><p>Default is FALSE.</p>
<h5>Tags:</h5>
<table cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><strong>since:</strong> </td>
<td valign="top">2.7</td>
</tr>
<tr>
<td valign="top"><strong>access:</strong> </td>
<td valign="top">public</td>
</tr>
</table>
<a href="#top" class="top">top</a>
<div class="clear"></div>
</div>
<a name="var$memcache_host"></a>
<h4 class="variable"><span><em>mixed</em></span> $memcache_host <span class="value"></span></h4>
<div class="doc_block">
<p>The host where memcache is listening for connections.</p>
<p><em>Set this property only if you are using "memcache" as <a href="../Zebra_Database/Zebra_Database.html#var$caching_method">caching_method</a>.</em></p><p>Default is FALSE.</p>
<h5>Tags:</h5>
<table cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><strong>since:</strong> </td>
<td valign="top">2.7</td>
</tr>
<tr>
<td valign="top"><strong>access:</strong> </td>
<td valign="top">public</td>
</tr>
</table>
<a href="#top" class="top">top</a>
<div class="clear"></div>
</div>
<a name="var$memcache_key_prefix"></a>
<h4 class="variable"><span><em>string</em></span> $memcache_key_prefix <span class="value"></span></h4>
<div class="doc_block">
<p>The prefix for the keys used to identify cached queries in memcache. This allows separate caching of the same queries by multiple instances of the libraries, or the same instance handling multiple domains on the same memcache server.</p>
<p><em>Set this property only if you are using "memcache" as <a href="../Zebra_Database/Zebra_Database.html#var$caching_method">caching_method</a>.</em></p><p>Default is "" (an empty string).</p>
<h5>Tags:</h5>
<table cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><strong>since:</strong> </td>
<td valign="top">2.8.4</td>
</tr>
<tr>
<td valign="top"><strong>access:</strong> </td>
<td valign="top">public</td>
</tr>
</table>
<a href="#top" class="top">top</a>
<div class="clear"></div>
</div>
<a name="var$memcache_port"></a>
<h4 class="variable"><span><em>mixed</em></span> $memcache_port <span class="value"></span></h4>
<div class="doc_block">
<p>The port where memcache is listening for connections.</p>
<p><em>Set this property only if you are using "memcache" as <a href="../Zebra_Database/Zebra_Database.html#var$caching_method">caching_method</a>.</em></p><p>Default is FALSE.</p>
<h5>Tags:</h5>
<table cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><strong>since:</strong> </td>
<td valign="top">2.7</td>
</tr>
<tr>
<td valign="top"><strong>access:</strong> </td>
<td valign="top">public</td>
</tr>
</table>
<a href="#top" class="top">top</a>
<div class="clear"></div>
</div>
<a name="var$minimize_console"></a>
<h4 class="variable"><span><em>boolean</em></span> $minimize_console <span class="value"></span></h4>
<div class="doc_block">
<p>By setting this property to TRUE a minimized version of the debugging console will be shown by default, instead of the full-sized one.</p>
<p>Clicking on it will show the full debugging console.</p><p>For quick and easy debugging, setting the <em>highlight</em> argument of a method that has it will result in the debugging console being shown at full size and with the respective query visible for inspecting.</p><p>Default is TRUE</p>
<h5>Tags:</h5>
<table cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><strong>since:</strong> </td>
<td valign="top">1.0.4</td>
</tr>
<tr>
<td valign="top"><strong>access:</strong> </td>
<td valign="top">public</td>
</tr>
</table>
<a href="#top" class="top">top</a>
<div class="clear"></div>
</div>
<a name="var$notification_address"></a>
<h4 class="variable"><span><em>string</em></span> $notification_address <span class="value"></span></h4>
<div class="doc_block">
<p>Email address to which notification emails to be sent when a query's execution time exceeds the number of seconds set by <a href="../Zebra_Database/Zebra_Database.html#var$max_query_time">max_query_time</a>. The notification email will be automatically sent to the address defined by <a href="../Zebra_Database/Zebra_Database.html#var$notification_address">notification_address</a> and having <a href="../Zebra_Database/Zebra_Database.html#var$notifier_domain">notifier_domain</a> in subject.</p>
<p><ol class="code"><li><div class="src-line"><span class="src-comm">// the email address where to send an email when there are slow queries</span></div></li>
<li><div class="src-line"><span class="src-var">$db</span><span class="src-sym">-></span><span class="src-id"><a href="../Zebra_Database/Zebra_Database.html#var$notification_address">notification_address</a> </span>= <span class="src-str">'youremail@yourdomain.com'</span><span class="src-sym">;</span></div></li>
</ol>
<h5>Tags:</h5>
<table cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><strong>access:</strong> </td>
<td valign="top">public</td>
</tr>
</table>
<a href="#top" class="top">top</a>
<div class="clear"></div>
</div>
<a name="var$notifier_domain"></a>
<h4 class="variable"><span><em>string</em></span> $notifier_domain <span class="value"></span></h4>
<div class="doc_block">
<p>Domain name to be used in the subject of notification emails sent when a query's execution time exceeds the number of seconds set by <a href="../Zebra_Database/Zebra_Database.html#var$max_query_time">max_query_time</a>.</p>
<p>If a query's execution time exceeds the number of seconds set by <a href="../Zebra_Database/Zebra_Database.html#var$max_query_time">max_query_time</a>, a notification email will be automatically sent to the address defined by <a href="../Zebra_Database/Zebra_Database.html#var$notification_address">notification_address</a> and having <a href="../Zebra_Database/Zebra_Database.html#var$notifier_domain">notifier_domain</a> in subject.</p><p><ol class="code"><li><div class="src-line"><span class="src-comm">// set a domain name so that you'll know where the email comes from</span></div></li>
<li><div class="src-line"><span class="src-var">$db</span><span class="src-sym">-></span><span class="src-id"><a href="../Zebra_Database/Zebra_Database.html#var$notifier_domain">notifier_domain</a> </span>= <span class="src-str">'yourdomain.com'</span><span class="src-sym">;</span></div></li>
</ol>
<h5>Tags:</h5>
<table cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><strong>access:</strong> </td>
<td valign="top">public</td>
</tr>
</table>
<a href="#top" class="top">top</a>
<div class="clear"></div>
</div>
<a name="var$resource_path"></a>
<h4 class="variable"><span><em>string</em></span> $resource_path <span class="value"></span></h4>
<div class="doc_block">
<p>Path (without leading slash) to parent of public folder containing the css and javascript folders.</p>
<p><em>The path must be relative to your $_SERVER['DOCUMENT_ROOT'] and not the class' path!</em></p>
<h5>Tags:</h5>
<table cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><strong>access:</strong> </td>
<td valign="top">public</td>
</tr>
</table>
<a href="#top" class="top">top</a>
<div class="clear"></div>
</div>
<a name="var$returned_rows"></a>
<h4 class="variable"><span><em>integer</em></span> $returned_rows <span class="value"></span></h4>
<div class="doc_block">
<p>After running a SELECT query through <a href="../Zebra_Database/Zebra_Database.html#methodselect">select()</a>, <a href="../Zebra_Database/Zebra_Database.html#methodquery">query()</a> or <a href="../Zebra_Database/Zebra_Database.html#methodquery_unbuffered">query_unbuffered()</a> methods, this property will contain the number returned rows.</p>
<p><em>For <a href="../Zebra_Database/Zebra_Database.html#methodquery_unbuffered">unbuffered</a> queries the value of this property will be available only after iterating
over all the records with either <a href="../Zebra_Database/Zebra_Database.html#methodfetch_assoc">fetch_assoc()</a> or <a href="../Zebra_Database/Zebra_Database.html#methodfetch_obj">fetch_obj()</a> methods. Until then, the value will
be 0!</em></p><p>See <a href="../Zebra_Database/Zebra_Database.html#var$found_rows">found_rows</a> also.</p><p><ol class="code"><li><div class="src-line"><span class="src-var">$db</span><span class="src-sym">-></span><a href="../Zebra_Database/Zebra_Database.html#methodquery">query</a><span class="src-sym">(</span><span class="src-str">'</span></div></li>
<li><div class="src-line"><span class="src-str"> SELECT</span></div></li>
<li><div class="src-line"><span class="src-str"> *</span></div></li>
<li><div class="src-line"><span class="src-str"> FROM</span></div></li>
<li><div class="src-line"><span class="src-str"> table</span></div></li>
<li><div class="src-line"><span class="src-str"> WHERE</span></div></li>
<li><div class="src-line"><span class="src-str"> something = ?</span></div></li>
<li><div class="src-line"><span class="src-str"> LIMIT</span></div></li>
<li><div class="src-line"><span class="src-str"> 10</span></div></li>
<li><div class="src-line"><span class="src-str">'</span><span class="src-sym">, </span><span class="src-key">array</span><span class="src-sym">(</span><span class="src-var">$somevalue</span><span class="src-sym">))</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"> </div></li>
<li><div class="src-line"><span class="src-comm">// prints "10"</span></div></li>
<li><div class="src-line"><span class="src-comm">// as this is the number of records</span></div></li>
<li><div class="src-line"><span class="src-comm">// returned by the query</span></div></li>
<li><div class="src-line">echo <span class="src-var">$db</span><span class="src-sym">-></span><span class="src-id"><a href="../Zebra_Database/Zebra_Database.html#var$returned_rows">returned_rows</a></span><span class="src-sym">;</span></div></li>
</ol>
<h5>Tags:</h5>
<table cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><strong>since:</strong> </td>
<td valign="top">1.0.4</td>
</tr>
<tr>
<td valign="top"><strong>access:</strong> </td>
<td valign="top">public</td>
</tr>
</table>
<a href="#top" class="top">top</a>
<div class="clear"></div>
</div>
<a name="class_methods"></a>
<h3>Class methods</h3>
<a name="method__construct"></a>
<h4 class="method"><span><em>constructor</em></span> __construct() <span class="smalllinenumber">[line 654]</span></h4>
<div class="doc_block">
<p class="code">
<em>void</em>
__construct (
)
</p>
<p>Constructor of the class</p>
<h5>Tags:</h5>
<table cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><strong>access:</strong> </td>
<td valign="top">public</td>
</tr>
</table>
<a href="#top" class="top">top</a>
<div class="clear"></div>
</div>
<a name="method__destruct"></a>
<h4 class="method"><span><em>destructor</em></span> __destruct() <span class="smalllinenumber">[line 5110]</span></h4>
<div class="doc_block">
<p class="code">
<em>void</em>
__destruct (
)
</p>
<p>Frees the memory associated with the last result.</p>
<h5>Tags:</h5>
<table cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><strong>since:</strong> </td>
<td valign="top">2.8</td>
</tr>
<tr>
<td valign="top"><strong>access:</strong> </td>
<td valign="top">public</td>
</tr>
</table>
<a href="#top" class="top">top</a>
<div class="clear"></div>
</div>
<a name="methodclose"></a>
<h4 class="method"><span><em>method</em></span> close() <span class="smalllinenumber">[line 714]</span></h4>
<div class="doc_block">
<p class="code">
<em>boolean</em>
close (
[
boolean
$reset_options
= false]
)
</p>
<p>Closes the MySQL connection and optionally unsets the connection options previously set with the <a href="../Zebra_Database/Zebra_Database.html#methodoption">option()</a> method.</p>
<h5>Tags:</h5>
<table cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><strong>return:</strong> </td>
<td valign="top">Returns TRUE on success or FALSE on failure.</td>
</tr>
<tr>
<td valign="top"><strong>since:</strong> </td>
<td valign="top">1.1.0</td>
</tr>
<tr>
<td valign="top"><strong>access:</strong> </td>
<td valign="top">public</td>
</tr>
</table>
<h5>Parameters:</h5>
<table cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><em>boolean</em></td>
<td valign="top"><strong>$reset_options</strong></td>
<td valign="top"><p>If set to TRUE the library will also unsets the connection options previously set with the <a href="../Zebra_Database/Zebra_Database.html#methodoption">option()</a> method.</p><p>Default is FALSE.</p><p><em>This option was added in 2.9.5</em></p></td>
</tr>
</table>
<a href="#top" class="top">top</a>
<div class="clear"></div>
</div>
<a name="methodconnect"></a>
<h4 class="method"><span><em>method</em></span> connect() <span class="smalllinenumber">[line 783]</span></h4>
<div class="doc_block">
<p class="code">
<em>void</em>
connect (
string
$host
,
string
$user
,
string
$password
,
[
string
$database
= '']
,
[
string
$port
= '']
,
[
string
$socket
= '']
,
[
boolean
$connect
= false]
)
</p>
<p>Opens a connection to a MySQL Server and optionally selects a database.</p>
<p>Since the library is using <em>lazy connection</em> (it is not actually connecting to the database until the first query is executed), the object representing the connection to the MySQL server is not available at this time. If you need it, use the <a href="../Zebra_Database/Zebra_Database.html#methodget_link">get_link()</a> method.</p><p>If you need the connection to the database to be made right away, set the <em>connect</em> argument to TRUE.</p><p><ol class="code"><li><div class="src-line"><span class="src-comm">// create the database object</span></div></li>
<li><div class="src-line"><span class="src-var">$db </span>= <span class="src-key">new </span><span class="src-id"><a href="../Zebra_Database/Zebra_Database.html">Zebra_Database</a></span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"> </div></li>
<li><div class="src-line"><span class="src-comm">// notice that we're not doing any error checking. errors will be shown in the debugging console</span></div></li>
<li><div class="src-line"><span class="src-var">$db</span><span class="src-sym">-></span><a href="../Zebra_Database/Zebra_Database.html#methodconnect">connect</a><span class="src-sym">(</span><span class="src-str">'host'</span><span class="src-sym">, </span><span class="src-str">'username'</span><span class="src-sym">, </span><span class="src-str">'password'</span><span class="src-sym">, </span><span class="src-str">'database'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
</ol>
<h5>Tags:</h5>
<table cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><strong>access:</strong> </td>
<td valign="top">public</td>
</tr>
</table>
<h5>Parameters:</h5>
<table cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><em>string</em></td>
<td valign="top"><strong>$host</strong></td>
<td valign="top"><p>The address of the MySQL server to connect to (i.e. localhost).</p><p>Prepending host by <strong>p:</strong> opens a persistent connection.</p></td>
</tr>
<tr>
<td valign="top"><em>string</em></td>
<td valign="top"><strong>$user</strong></td>
<td valign="top">The user name used for authentication when connecting to the MySQL server.</td>
</tr>
<tr>
<td valign="top"><em>string</em></td>
<td valign="top"><strong>$password</strong></td>
<td valign="top">The password used for authentication when connecting to the MySQL server.</td>
</tr>
<tr>
<td valign="top"><em>string</em></td>
<td valign="top"><strong>$database</strong></td>
<td valign="top"><p>(Optional) The database to be selected after the connection is established.</p><p>This can also be set later with the <a href="../Zebra_Database/Zebra_Database.html#methodselect_database">select_database()</a> method.</p></td>
</tr>
<tr>
<td valign="top"><em>string</em></td>
<td valign="top"><strong>$port</strong></td>
<td valign="top"><p>(Optional) The port number to attempt to connect to the MySQL server.</p><p>Leave as empty string to use the default as returned by ini_get("mysqli.default_port").</p></td>
</tr>
<tr>
<td valign="top"><em>string</em></td>
<td valign="top"><strong>$socket</strong></td>
<td valign="top"><p>(Optional) The socket or named pipe that should be used.</p><p>Leave as empty string to use the default as returned by ini_get("mysqli.default_socket").</p><p>Specifying the socket parameter will not explicitly determine the type of connection to be used when connecting to the MySQL server. How the connection is made to the MySQL database is determined by the <em>host</em> argument.</p></td>
</tr>
<tr>
<td valign="top"><em>boolean</em></td>
<td valign="top"><strong>$connect</strong></td>
<td valign="top"><p>(Optional) Setting this argument to TRUE will force the library to connect to the database right away instead of using a "lazy connection" where the actual connection to the database will be made when the first query is run.</p><p>Default is FALSE.</p></td>
</tr>
</table>
<a href="#top" class="top">top</a>
<div class="clear"></div>
</div>
<a name="methoddcount"></a>
<h4 class="method"><span><em>method</em></span> dcount() <span class="smalllinenumber">[line 863]</span></h4>
<div class="doc_block">
<p class="code">
<em>mixed</em>
dcount (
string
$column
,
string
$table
,
[
string
$where
= '']
,
[
array
$replacements
= '']
,
[
mixed
$cache
= false]
,
[
boolean
$highlight
= false]
)
</p>
<p>Counts the values in a column of a table.</p>
<p><ol class="code"><li><div class="src-line"><span class="src-comm">// count male users</span></div></li>
<li><div class="src-line"><span class="src-var">$male </span>= <span class="src-var">$db</span><span class="src-sym">-></span><a href="../Zebra_Database/Zebra_Database.html#methoddcount">dcount</a><span class="src-sym">(</span><span class="src-str">'id'</span><span class="src-sym">, </span><span class="src-str">'users'</span><span class="src-sym">, </span><span class="src-str">'gender = "M"'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"> </div></li>
<li><div class="src-line"><span class="src-comm">// when working with variables you should use the following syntax</span></div></li>
<li><div class="src-line"><span class="src-comm">// this way you will stay clear of SQL injections</span></div></li>
<li><div class="src-line"><span class="src-var">$users </span>= <span class="src-var">$db</span><span class="src-sym">-></span><a href="../Zebra_Database/Zebra_Database.html#methoddcount">dcount</a><span class="src-sym">(</span><span class="src-str">'id'</span><span class="src-sym">, </span><span class="src-str">'users'</span><span class="src-sym">, </span><span class="src-str">'gender = ?'</span><span class="src-sym">, </span><span class="src-key">array</span><span class="src-sym">(</span><span class="src-var">$gender</span><span class="src-sym">))</span><span class="src-sym">;</span></div></li>
</ol>
<h5>Tags:</h5>
<table cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><strong>return:</strong> </td>
<td valign="top"><p>Returns the number of counted records or FALSE if no records matching the given criteria (if any) were found. It also returns FALSE if there are no records in the table or if there was an error.</p><p><em>This method may return boolean FALSE but may also return a non-boolean value
which evaluates to FALSE, such as 0. Use the === operator for testing the return
value of this method.</em></p></td>
</tr>
<tr>
<td valign="top"><strong>access:</strong> </td>
<td valign="top">public</td>
</tr>
</table>
<h5>Parameters:</h5>
<table cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><em>string</em></td>
<td valign="top"><strong>$column</strong></td>
<td valign="top">Name of the column in which to do the counting.</td>
</tr>
<tr>
<td valign="top"><em>string</em></td>
<td valign="top"><strong>$table</strong></td>
<td valign="top"><p>Name of the table containing the column.</p><p><em>May also be given like databasename.tablename if a database was not explicitly
selected with the <a href="../Zebra_Database/Zebra_Database.html#methodconnect">connect()</a> or <a href="../Zebra_Database/Zebra_Database.html#methodselect_database">select_database()</a> methods prior to
calling this method.</em></p></td>
</tr>
<tr>
<td valign="top"><em>string</em></td>
<td valign="top"><strong>$where</strong></td>
<td valign="top"><p>(Optional) A MySQL WHERE clause (without the WHERE keyword).</p><p>Default is "" (an empty string).</p></td>
</tr>
<tr>
<td valign="top"><em>array</em></td>
<td valign="top"><strong>$replacements</strong></td>
<td valign="top"><p>(Optional) An array with as many items as the total parameter markers ("?", question marks) in <em>$where</em>. Each item will be automatically <a href="../Zebra_Database/Zebra_Database.html#methodescape">escape()</a>-ed and will replace the corresponding "?". Can also include an array as an item, case in which each value from the array will automatically <a href="../Zebra_Database/Zebra_Database.html#methodescape">escape()</a>-ed and then concatenated with the other elements from the array - useful when using <em>WHERE
column IN (?)</em> conditions. See second example <a href="../Zebra_Database/Zebra_Database.html#methodquery">here</a>.</p><p>Default is "" (an empty string).</p></td>
</tr>
<tr>
<td valign="top"><em>mixed</em></td>
<td valign="top"><strong>$cache</strong></td>
<td valign="top"><p>(Optional) Instructs the library on whether it should cache the query's results or not. Can be either FALSE - meaning no caching - or an integer representing the number of seconds after which the cache will be considered expired and the query executed again.</p><p>The caching method is specified by the value of the <a href="../Zebra_Database/Zebra_Database.html#var$caching_method">caching_method</a> property.</p><p>Default is FALSE.</p></td>
</tr>
<tr>
<td valign="top"><em>boolean</em></td>
<td valign="top"><strong>$highlight</strong></td>
<td valign="top"><p>(Optional) If set to TRUE the debugging console will be opened automatically and the query will be shown - really useful for quick and easy debugging.</p><p>Default is FALSE.</p></td>
</tr>
</table>
<a href="#top" class="top">top</a>
<div class="clear"></div>
</div>
<a name="methoddelete"></a>
<h4 class="method"><span><em>method</em></span> delete() <span class="smalllinenumber">[line 932]</span></h4>
<div class="doc_block">
<p class="code">
<em>boolean</em>
delete (
string
$table
,
[
string
$where
= '']
,
[
array
$replacements
= '']
,
[
boolean
$highlight
= false]
)
</p>
<p>Deletes rows from a table.</p>
<p><ol class="code"><li><div class="src-line"><span class="src-comm">// delete male users</span></div></li>
<li><div class="src-line"><span class="src-var">$db</span><span class="src-sym">-></span><a href="../Zebra_Database/Zebra_Database.html#methoddelete">delete</a><span class="src-sym">(</span><span class="src-str">'users'</span><span class="src-sym">, </span><span class="src-str">'gender = "M"'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"> </div></li>
<li><div class="src-line"><span class="src-comm">// when working with variables you should use the following syntax</span></div></li>
<li><div class="src-line"><span class="src-comm">// this way you will stay clear of SQL injections</span></div></li>
<li><div class="src-line"><span class="src-var">$db</span><span class="src-sym">-></span><a href="../Zebra_Database/Zebra_Database.html#methoddelete">delete</a><span class="src-sym">(</span><span class="src-str">'users'</span><span class="src-sym">, </span><span class="src-str">'gender = ?'</span><span class="src-sym">, </span><span class="src-key">array</span><span class="src-sym">(</span><span class="src-var">$gender</span><span class="src-sym">))</span><span class="src-sym">;</span></div></li>
</ol>
<h5>Tags:</h5>
<table cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><strong>return:</strong> </td>
<td valign="top">Returns TRUE on success or FALSE on error.</td>
</tr>
<tr>
<td valign="top"><strong>since:</strong> </td>
<td valign="top">1.0.9</td>
</tr>
<tr>
<td valign="top"><strong>access:</strong> </td>
<td valign="top">public</td>
</tr>
</table>
<h5>Parameters:</h5>
<table cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><em>string</em></td>
<td valign="top"><strong>$table</strong></td>
<td valign="top"><p>Table from which to delete.</p><p><em>May also be given like databasename.tablename if a database was not explicitly
selected with the <a href="../Zebra_Database/Zebra_Database.html#methodconnect">connect()</a> or <a href="../Zebra_Database/Zebra_Database.html#methodselect_database">select_database()</a> methods prior to
calling this method.</em></p></td>
</tr>
<tr>
<td valign="top"><em>string</em></td>
<td valign="top"><strong>$where</strong></td>
<td valign="top"><p>(Optional) A MySQL WHERE clause (without the WHERE keyword).</p><p>Default is "" (an empty string).</p></td>
</tr>
<tr>
<td valign="top"><em>array</em></td>
<td valign="top"><strong>$replacements</strong></td>
<td valign="top"><p>(Optional) An array with as many items as the total parameter markers ("?", question marks) in <em>$where</em>. Each item will be automatically <a href="../Zebra_Database/Zebra_Database.html#methodescape">escape()</a>-ed and will replace the corresponding "?". Can also include an array as an item, case in which each value from the array will automatically <a href="../Zebra_Database/Zebra_Database.html#methodescape">escape()</a>-ed and then concatenated with the other elements from the array - useful when using <em>WHERE
column IN (?)</em> conditions. See second example <a href="../Zebra_Database/Zebra_Database.html#methodquery">here</a>.</p><p>Default is "" (an empty string).</p></td>
</tr>
<tr>
<td valign="top"><em>boolean</em></td>
<td valign="top"><strong>$highlight</strong></td>
<td valign="top"><p>(Optional) If set to TRUE the debugging console will be opened automatically and the query will be shown - really useful for quick and easy debugging.</p><p>Default is FALSE.</p></td>
</tr>
</table>
<a href="#top" class="top">top</a>
<div class="clear"></div>
</div>
<a name="methoddlookup"></a>
<h4 class="method"><span><em>method</em></span> dlookup() <span class="smalllinenumber">[line 1006]</span></h4>
<div class="doc_block">
<p class="code">
<em>mixed</em>
dlookup (
string
$column
,
string
$table
,
[
string
$where
= '']
,
[
array
$replacements
= '']