Completed
Push — 14.2 ( 8c75f3...7aeda4 )
by Ralf
108:06 queued 84:21
created
phpgwapi/inc/adodb/adodb-lib.inc.php 1 patch
Doc Comments   +28 added lines patch added patch discarded remove patch
@@ -32,6 +32,11 @@  discard block
 block discarded – undo
32 32
 	return $an_array;
33 33
 }
34 34
 
35
+/**
36
+ * @param ADOConnection $zthis
37
+ * @param boolean $autoQuote
38
+ * @param boolean $has_autoinc
39
+ */
35 40
 function _adodb_replace(&$zthis, $table, $fieldArray, $keyCol, $autoQuote, $has_autoinc)
36 41
 {
37 42
 		if (count($fieldArray) == 0) return 0;
@@ -107,6 +112,9 @@  discard block
 block discarded – undo
107 112
 }
108 113
 
109 114
 // Requires $ADODB_FETCH_MODE = ADODB_FETCH_NUM
115
+/**
116
+ * @param ADORecordSet $zthis
117
+ */
110 118
 function _adodb_getmenu(&$zthis, $name,$defstr='',$blank1stItem=true,$multiple=false,
111 119
 			$size=0, $selectAttr='',$compareFields0=true)
112 120
 {
@@ -193,6 +201,9 @@  discard block
 block discarded – undo
193 201
 }
194 202
 
195 203
 // Requires $ADODB_FETCH_MODE = ADODB_FETCH_NUM
204
+/**
205
+ * @param ADORecordSet $zthis
206
+ */
196 207
 function _adodb_getmenu_gp(&$zthis, $name,$defstr='',$blank1stItem=true,$multiple=false,
197 208
 			$size=0, $selectAttr='',$compareFields0=true)
198 209
 {
@@ -376,6 +387,9 @@  discard block
 block discarded – undo
376 387
 	data will get out of synch. use CachePageExecute() only with tables that
377 388
 	rarely change.
378 389
 */
390
+/**
391
+ * @param ADOConnection $zthis
392
+ */
379 393
 function &_adodb_pageexecute_all_rows(&$zthis, $sql, $nrows, $page, 
380 394
 						$inputarr=false, $secs2cache=0) 
381 395
 {
@@ -430,6 +444,9 @@  discard block
 block discarded – undo
430 444
 }
431 445
 
432 446
 // Iván Oliva version
447
+/**
448
+ * @param ADOConnection $zthis
449
+ */
433 450
 function &_adodb_pageexecute_no_last_page(&$zthis, $sql, $nrows, $page, $inputarr=false, $secs2cache=0) 
434 451
 {
435 452
 
@@ -480,6 +497,9 @@  discard block
 block discarded – undo
480 497
 	return $rsreturn;
481 498
 }
482 499
 
500
+/**
501
+ * @param ADOConnection $zthis
502
+ */
483 503
 function _adodb_getupdatesql(&$zthis,&$rs, $arrFields,$forceUpdate=false,$magicq=false,$force=2)
484 504
 {
485 505
 		if (!$rs) {
@@ -615,6 +635,9 @@  discard block
 block discarded – undo
615 635
 	}
616 636
 }
617 637
 
638
+/**
639
+ * @param string $key
640
+ */
618 641
 function adodb_key_exists($key, &$arr,$force=2)
619 642
 {
620 643
 	if ($force<=0) {
@@ -634,6 +657,7 @@  discard block
 block discarded – undo
634 657
  * a returning clause with bind variables and a descriptor blob.
635 658
  * 
636 659
  * 
660
+ * @param ADOConnection $zthis
637 661
  */
638 662
 function _adodb_getinsertsql(&$zthis,&$rs,$arrFields,$magicq=false,$force=2)
639 663
 {
@@ -898,6 +922,10 @@  discard block
 block discarded – undo
898 922
 
899 923
 
900 924
 
925
+/**
926
+ * @param ADOConnection $zthis
927
+ * @param boolean $inputarr
928
+ */
901 929
 function _adodb_debug_execute(&$zthis, $sql, $inputarr)
902 930
 {
903 931
 	$ss = '';
Please login to merge, or discard this patch.
phpgwapi/inc/adodb/adodb-pager.inc.php 4 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -273,6 +273,12 @@
 block discarded – undo
273 273
 	
274 274
 	//------------------------------------------------------
275 275
 	// override this to control overall layout and formating
276
+
277
+	/**
278
+	 * @param string $header
279
+	 * @param string $grid
280
+	 * @param string $footer
281
+	 */
276 282
 	function RenderLayout($header,$grid,$footer,$attributes='border=1 bgcolor=beige')
277 283
 	{
278 284
 		echo "<table ".$attributes."><tr><td>",
Please login to merge, or discard this patch.
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -28,8 +28,8 @@  discard block
 block discarded – undo
28 28
 	var $rs;	// recordset generated
29 29
 	var $curr_page;	// current page number before Render() called, calculated in constructor
30 30
 	var $rows;		// number of rows per page
31
-    var $linksPerPage=10; // number of links per page in navigation bar
32
-    var $showPageLinks; 
31
+	var $linksPerPage=10; // number of links per page in navigation bar
32
+	var $showPageLinks; 
33 33
 
34 34
 	var $gridAttributes = 'width=100% border=1 bgcolor=white';
35 35
 	
@@ -130,40 +130,40 @@  discard block
 block discarded – undo
130 130
 	
131 131
 	//---------------------------------------------------
132 132
 	// original code by "Pablo Costa" <[email protected]> 
133
-        function render_pagelinks()
134
-        {
135
-        global $PHP_SELF;
136
-            $pages        = $this->rs->LastPageNo();
137
-            $linksperpage = $this->linksPerPage ? $this->linksPerPage : $pages;
138
-            for($i=1; $i <= $pages; $i+=$linksperpage)
139
-            {
140
-                if($this->rs->AbsolutePage() >= $i)
141
-                {
142
-                    $start = $i;
143
-                }
144
-            }
133
+		function render_pagelinks()
134
+		{
135
+		global $PHP_SELF;
136
+			$pages        = $this->rs->LastPageNo();
137
+			$linksperpage = $this->linksPerPage ? $this->linksPerPage : $pages;
138
+			for($i=1; $i <= $pages; $i+=$linksperpage)
139
+			{
140
+				if($this->rs->AbsolutePage() >= $i)
141
+				{
142
+					$start = $i;
143
+				}
144
+			}
145 145
 			$numbers = '';
146
-            $end = $start+$linksperpage-1;
146
+			$end = $start+$linksperpage-1;
147 147
 			$link = $this->id . "_next_page";
148
-            if($end > $pages) $end = $pages;
148
+			if($end > $pages) $end = $pages;
149 149
 			
150 150
 			
151 151
 			if ($this->startLinks && $start > 1) {
152 152
 				$pos = $start - 1;
153 153
 				$numbers .= "<a href=$PHP_SELF?$link=$pos>$this->startLinks</a>  ";
154
-            } 
154
+			} 
155 155
 			
156 156
 			for($i=$start; $i <= $end; $i++) {
157
-                if ($this->rs->AbsolutePage() == $i)
158
-                    $numbers .= "<font color=$this->linkSelectedColor><b>$i</b></font>  ";
159
-                else 
160
-                     $numbers .= "<a href=$PHP_SELF?$link=$i>$i</a>  ";
157
+				if ($this->rs->AbsolutePage() == $i)
158
+					$numbers .= "<font color=$this->linkSelectedColor><b>$i</b></font>  ";
159
+				else 
160
+					 $numbers .= "<a href=$PHP_SELF?$link=$i>$i</a>  ";
161 161
             
162
-            }
162
+			}
163 163
 			if ($this->moreLinks && $end < $pages) 
164 164
 				$numbers .= "<a href=$PHP_SELF?$link=$i>$this->moreLinks</a>  ";
165
-            print $numbers . ' &nbsp; ';
166
-        }
165
+			print $numbers . ' &nbsp; ';
166
+		}
167 167
 	// Link to previous page
168 168
 	function render_prev($anchor=true)
169 169
 	{
@@ -208,9 +208,9 @@  discard block
 block discarded – undo
208 208
 			$this->Render_First(false);
209 209
 			$this->Render_Prev(false);
210 210
 		}
211
-        if ($this->showPageLinks){
212
-            $this->Render_PageLinks();
213
-        }
211
+		if ($this->showPageLinks){
212
+			$this->Render_PageLinks();
213
+		}
214 214
 		if (!$this->rs->AtLastPage()) {
215 215
 			$this->Render_Next();
216 216
 			$this->Render_Last();
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -22,13 +22,13 @@  discard block
 block discarded – undo
22 22
 
23 23
 */
24 24
 class ADODB_Pager {
25
-	var $id; 	// unique id for pager (defaults to 'adodb')
26
-	var $db; 	// ADODB connection object
27
-	var $sql; 	// sql used
28
-	var $rs;	// recordset generated
29
-	var $curr_page;	// current page number before Render() called, calculated in constructor
30
-	var $rows;		// number of rows per page
31
-    var $linksPerPage=10; // number of links per page in navigation bar
25
+	var $id; // unique id for pager (defaults to 'adodb')
26
+	var $db; // ADODB connection object
27
+	var $sql; // sql used
28
+	var $rs; // recordset generated
29
+	var $curr_page; // current page number before Render() called, calculated in constructor
30
+	var $rows; // number of rows per page
31
+    var $linksPerPage = 10; // number of links per page in navigation bar
32 32
     var $showPageLinks; 
33 33
 
34 34
 	var $gridAttributes = 'width=100% border=1 bgcolor=white';
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	var $htmlSpecialChars = true;
45 45
 	var $page = 'Page';
46 46
 	var $linkSelectedColor = 'red';
47
-	var $cache = 0;  #secs to cache with CachePageExecute()
47
+	var $cache = 0; #secs to cache with CachePageExecute()
48 48
 	
49 49
 	//----------------------------------------------
50 50
 	// constructor
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	//		if you have multiple on 1 page. 
56 56
 	//		$id should be only be [a-z0-9]*
57 57
 	//
58
-	function ADODB_Pager(&$db,$sql,$id = 'adodb', $showPageLinks = false)
58
+	function ADODB_Pager(&$db, $sql, $id = 'adodb', $showPageLinks = false)
59 59
 	{
60 60
 	global $PHP_SELF;
61 61
 	
@@ -80,12 +80,12 @@  discard block
 block discarded – undo
80 80
 	
81 81
 	//---------------------------
82 82
 	// Display link to first page
83
-	function Render_First($anchor=true)
83
+	function Render_First($anchor = true)
84 84
 	{
85 85
 	global $PHP_SELF;
86 86
 		if ($anchor) {
87 87
 	?>
88
-		<a href="<?php echo $PHP_SELF,'?',$this->id;?>_next_page=1"><?php echo $this->first;?></a> &nbsp; 
88
+		<a href="<?php echo $PHP_SELF, '?', $this->id; ?>_next_page=1"><?php echo $this->first; ?></a> &nbsp; 
89 89
 	<?php
90 90
 		} else {
91 91
 			print "$this->first &nbsp; ";
@@ -94,13 +94,13 @@  discard block
 block discarded – undo
94 94
 	
95 95
 	//--------------------------
96 96
 	// Display link to next page
97
-	function render_next($anchor=true)
97
+	function render_next($anchor = true)
98 98
 	{
99 99
 	global $PHP_SELF;
100 100
 	
101 101
 		if ($anchor) {
102 102
 		?>
103
-		<a href="<?php echo $PHP_SELF,'?',$this->id,'_next_page=',$this->rs->AbsolutePage() + 1 ?>"><?php echo $this->next;?></a> &nbsp; 
103
+		<a href="<?php echo $PHP_SELF, '?', $this->id, '_next_page=', $this->rs->AbsolutePage() + 1 ?>"><?php echo $this->next; ?></a> &nbsp; 
104 104
 		<?php
105 105
 		} else {
106 106
 			print "$this->next &nbsp; ";
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	// for better performance with large recordsets, you can set
114 114
 	// $this->db->pageExecuteCountRows = false, which disables
115 115
 	// last page counting.
116
-	function render_last($anchor=true)
116
+	function render_last($anchor = true)
117 117
 	{
118 118
 	global $PHP_SELF;
119 119
 	
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 		
122 122
 		if ($anchor) {
123 123
 		?>
124
-			<a href="<?php echo $PHP_SELF,'?',$this->id,'_next_page=',$this->rs->LastPageNo() ?>"><?php echo $this->last;?></a> &nbsp; 
124
+			<a href="<?php echo $PHP_SELF, '?', $this->id, '_next_page=', $this->rs->LastPageNo() ?>"><?php echo $this->last; ?></a> &nbsp; 
125 125
 		<?php
126 126
 		} else {
127 127
 			print "$this->last &nbsp; ";
@@ -135,17 +135,17 @@  discard block
 block discarded – undo
135 135
         global $PHP_SELF;
136 136
             $pages        = $this->rs->LastPageNo();
137 137
             $linksperpage = $this->linksPerPage ? $this->linksPerPage : $pages;
138
-            for($i=1; $i <= $pages; $i+=$linksperpage)
138
+            for ($i = 1; $i <= $pages; $i += $linksperpage)
139 139
             {
140
-                if($this->rs->AbsolutePage() >= $i)
140
+                if ($this->rs->AbsolutePage() >= $i)
141 141
                 {
142 142
                     $start = $i;
143 143
                 }
144 144
             }
145 145
 			$numbers = '';
146
-            $end = $start+$linksperpage-1;
147
-			$link = $this->id . "_next_page";
148
-            if($end > $pages) $end = $pages;
146
+            $end = $start + $linksperpage - 1;
147
+			$link = $this->id."_next_page";
148
+            if ($end > $pages) $end = $pages;
149 149
 			
150 150
 			
151 151
 			if ($this->startLinks && $start > 1) {
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 				$numbers .= "<a href=$PHP_SELF?$link=$pos>$this->startLinks</a>  ";
154 154
             } 
155 155
 			
156
-			for($i=$start; $i <= $end; $i++) {
156
+			for ($i = $start; $i <= $end; $i++) {
157 157
                 if ($this->rs->AbsolutePage() == $i)
158 158
                     $numbers .= "<font color=$this->linkSelectedColor><b>$i</b></font>  ";
159 159
                 else 
@@ -162,15 +162,15 @@  discard block
 block discarded – undo
162 162
             }
163 163
 			if ($this->moreLinks && $end < $pages) 
164 164
 				$numbers .= "<a href=$PHP_SELF?$link=$i>$this->moreLinks</a>  ";
165
-            print $numbers . ' &nbsp; ';
165
+            print $numbers.' &nbsp; ';
166 166
         }
167 167
 	// Link to previous page
168
-	function render_prev($anchor=true)
168
+	function render_prev($anchor = true)
169 169
 	{
170 170
 	global $PHP_SELF;
171 171
 		if ($anchor) {
172 172
 	?>
173
-		<a href="<?php echo $PHP_SELF,'?',$this->id,'_next_page=',$this->rs->AbsolutePage() - 1 ?>"><?php echo $this->prev;?></a> &nbsp; 
173
+		<a href="<?php echo $PHP_SELF, '?', $this->id, '_next_page=', $this->rs->AbsolutePage() - 1 ?>"><?php echo $this->prev; ?></a> &nbsp; 
174 174
 	<?php 
175 175
 		} else {
176 176
 			print "$this->prev &nbsp; ";
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 		include_once(ADODB_DIR.'/tohtml.inc.php');
189 189
 		ob_start();
190 190
 		$gSQLBlockRows = $this->rows;
191
-		rs2html($this->rs,$this->gridAttributes,$this->gridHeader,$this->htmlSpecialChars);
191
+		rs2html($this->rs, $this->gridAttributes, $this->gridHeader, $this->htmlSpecialChars);
192 192
 		$s = ob_get_contents();
193 193
 		ob_end_clean();
194 194
 		return $s;
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 			$this->Render_First(false);
209 209
 			$this->Render_Prev(false);
210 210
 		}
211
-        if ($this->showPageLinks){
211
+        if ($this->showPageLinks) {
212 212
             $this->Render_PageLinks();
213 213
         }
214 214
 		if (!$this->rs->AtLastPage()) {
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 	
237 237
 	//-----------------------------------
238 238
 	// Call this class to draw everything.
239
-	function Render($rows=10)
239
+	function Render($rows = 10)
240 240
 	{
241 241
 	global $ADODB_COUNTRECS;
242 242
 	
@@ -247,9 +247,9 @@  discard block
 block discarded – undo
247 247
 		$savec = $ADODB_COUNTRECS;
248 248
 		if ($this->db->pageExecuteCountRows) $ADODB_COUNTRECS = true;
249 249
 		if ($this->cache)
250
-			$rs = &$this->db->CachePageExecute($this->cache,$this->sql,$rows,$this->curr_page);
250
+			$rs = &$this->db->CachePageExecute($this->cache, $this->sql, $rows, $this->curr_page);
251 251
 		else
252
-			$rs = &$this->db->PageExecute($this->sql,$rows,$this->curr_page);
252
+			$rs = &$this->db->PageExecute($this->sql, $rows, $this->curr_page);
253 253
 		$ADODB_COUNTRECS = $savec;
254 254
 		
255 255
 		$this->rs = &$rs;
@@ -268,12 +268,12 @@  discard block
 block discarded – undo
268 268
 		$rs->Close();
269 269
 		$this->rs = false;
270 270
 		
271
-		$this->RenderLayout($header,$grid,$footer);
271
+		$this->RenderLayout($header, $grid, $footer);
272 272
 	}
273 273
 	
274 274
 	//------------------------------------------------------
275 275
 	// override this to control overall layout and formating
276
-	function RenderLayout($header,$grid,$footer,$attributes='border=1 bgcolor=beige')
276
+	function RenderLayout($header, $grid, $footer, $attributes = 'border=1 bgcolor=beige')
277 277
 	{
278 278
 		echo "<table ".$attributes."><tr><td>",
279 279
 				$header,
Please login to merge, or discard this patch.
Braces   +103 added lines, -39 removed lines patch added patch discarded remove patch
@@ -21,7 +21,8 @@  discard block
 block discarded – undo
21 21
 	will be entertained by the author.
22 22
 
23 23
 */
24
-class ADODB_Pager {
24
+class ADODB_Pager
25
+{
25 26
 	var $id; 	// unique id for pager (defaults to 'adodb')
26 27
 	var $db; 	// ADODB connection object
27 28
 	var $sql; 	// sql used
@@ -60,7 +61,10 @@  discard block
 block discarded – undo
60 61
 	global $PHP_SELF;
61 62
 	
62 63
 		$curr_page = $id.'_curr_page';
63
-		if (empty($PHP_SELF)) $PHP_SELF = $_SERVER['PHP_SELF'];
64
+		if (empty($PHP_SELF))
65
+		{
66
+			$PHP_SELF = $_SERVER['PHP_SELF'];
67
+		}
64 68
 		
65 69
 		$this->sql = $sql;
66 70
 		$this->id = $id;
@@ -69,10 +73,15 @@  discard block
 block discarded – undo
69 73
 		
70 74
 		$next_page = $id.'_next_page';	
71 75
 		
72
-		if (isset($_GET[$next_page])) {
76
+		if (isset($_GET[$next_page]))
77
+		{
73 78
 			$_SESSION[$curr_page] = $_GET[$next_page];
74 79
 		}
75
-		if (empty($_SESSION[$curr_page])) $_SESSION[$curr_page] = 1; ## at first page
80
+		if (empty($_SESSION[$curr_page]))
81
+		{
82
+			$_SESSION[$curr_page] = 1;
83
+		}
84
+		## at first page
76 85
 		
77 86
 		$this->curr_page = $_SESSION[$curr_page];
78 87
 		
@@ -83,11 +92,14 @@  discard block
 block discarded – undo
83 92
 	function Render_First($anchor=true)
84 93
 	{
85 94
 	global $PHP_SELF;
86
-		if ($anchor) {
95
+		if ($anchor)
96
+		{
87 97
 	?>
88 98
 		<a href="<?php echo $PHP_SELF,'?',$this->id;?>_next_page=1"><?php echo $this->first;?></a> &nbsp; 
89 99
 	<?php
90
-		} else {
100
+		}
101
+		else
102
+		{
91 103
 			print "$this->first &nbsp; ";
92 104
 		}
93 105
 	}
@@ -98,11 +110,14 @@  discard block
 block discarded – undo
98 110
 	{
99 111
 	global $PHP_SELF;
100 112
 	
101
-		if ($anchor) {
113
+		if ($anchor)
114
+		{
102 115
 		?>
103 116
 		<a href="<?php echo $PHP_SELF,'?',$this->id,'_next_page=',$this->rs->AbsolutePage() + 1 ?>"><?php echo $this->next;?></a> &nbsp; 
104 117
 		<?php
105
-		} else {
118
+		}
119
+		else
120
+		{
106 121
 			print "$this->next &nbsp; ";
107 122
 		}
108 123
 	}
@@ -117,13 +132,19 @@  discard block
 block discarded – undo
117 132
 	{
118 133
 	global $PHP_SELF;
119 134
 	
120
-		if (!$this->db->pageExecuteCountRows) return;
135
+		if (!$this->db->pageExecuteCountRows)
136
+		{
137
+			return;
138
+		}
121 139
 		
122
-		if ($anchor) {
140
+		if ($anchor)
141
+		{
123 142
 		?>
124 143
 			<a href="<?php echo $PHP_SELF,'?',$this->id,'_next_page=',$this->rs->LastPageNo() ?>"><?php echo $this->last;?></a> &nbsp; 
125 144
 		<?php
126
-		} else {
145
+		}
146
+		else
147
+		{
127 148
 			print "$this->last &nbsp; ";
128 149
 		}
129 150
 	}
@@ -145,34 +166,47 @@  discard block
 block discarded – undo
145 166
 			$numbers = '';
146 167
             $end = $start+$linksperpage-1;
147 168
 			$link = $this->id . "_next_page";
148
-            if($end > $pages) $end = $pages;
169
+            if($end > $pages)
170
+            {
171
+            	$end = $pages;
172
+            }
149 173
 			
150 174
 			
151
-			if ($this->startLinks && $start > 1) {
175
+			if ($this->startLinks && $start > 1)
176
+			{
152 177
 				$pos = $start - 1;
153 178
 				$numbers .= "<a href=$PHP_SELF?$link=$pos>$this->startLinks</a>  ";
154 179
             } 
155 180
 			
156
-			for($i=$start; $i <= $end; $i++) {
181
+			for($i=$start; $i <= $end; $i++)
182
+			{
157 183
                 if ($this->rs->AbsolutePage() == $i)
158
-                    $numbers .= "<font color=$this->linkSelectedColor><b>$i</b></font>  ";
159
-                else 
160
-                     $numbers .= "<a href=$PHP_SELF?$link=$i>$i</a>  ";
184
+                {
185
+                                    $numbers .= "<font color=$this->linkSelectedColor><b>$i</b></font>  ";
186
+                }
187
+                else {
188
+                                     $numbers .= "<a href=$PHP_SELF?$link=$i>$i</a>  ";
189
+                }
161 190
             
162 191
             }
163
-			if ($this->moreLinks && $end < $pages) 
164
-				$numbers .= "<a href=$PHP_SELF?$link=$i>$this->moreLinks</a>  ";
192
+			if ($this->moreLinks && $end < $pages)
193
+			{
194
+							$numbers .= "<a href=$PHP_SELF?$link=$i>$this->moreLinks</a>  ";
195
+			}
165 196
             print $numbers . ' &nbsp; ';
166 197
         }
167 198
 	// Link to previous page
168 199
 	function render_prev($anchor=true)
169 200
 	{
170 201
 	global $PHP_SELF;
171
-		if ($anchor) {
202
+		if ($anchor)
203
+		{
172 204
 	?>
173 205
 		<a href="<?php echo $PHP_SELF,'?',$this->id,'_next_page=',$this->rs->AbsolutePage() - 1 ?>"><?php echo $this->prev;?></a> &nbsp; 
174 206
 	<?php 
175
-		} else {
207
+		}
208
+		else
209
+		{
176 210
 			print "$this->prev &nbsp; ";
177 211
 		}
178 212
 	}
@@ -201,20 +235,27 @@  discard block
 block discarded – undo
201 235
 	function RenderNav()
202 236
 	{
203 237
 		ob_start();
204
-		if (!$this->rs->AtFirstPage()) {
238
+		if (!$this->rs->AtFirstPage())
239
+		{
205 240
 			$this->Render_First();
206 241
 			$this->Render_Prev();
207
-		} else {
242
+		}
243
+		else
244
+		{
208 245
 			$this->Render_First(false);
209 246
 			$this->Render_Prev(false);
210 247
 		}
211
-        if ($this->showPageLinks){
248
+        if ($this->showPageLinks)
249
+        {
212 250
             $this->Render_PageLinks();
213 251
         }
214
-		if (!$this->rs->AtLastPage()) {
252
+		if (!$this->rs->AtLastPage())
253
+		{
215 254
 			$this->Render_Next();
216 255
 			$this->Render_Last();
217
-		} else {
256
+		}
257
+		else
258
+		{
218 259
 			$this->Render_Next(false);
219 260
 			$this->Render_Last(false);
220 261
 		}
@@ -227,10 +268,20 @@  discard block
 block discarded – undo
227 268
 	// This is the footer
228 269
 	function RenderPageCount()
229 270
 	{
230
-		if (!$this->db->pageExecuteCountRows) return '';
271
+		if (!$this->db->pageExecuteCountRows)
272
+		{
273
+			return '';
274
+		}
231 275
 		$lastPage = $this->rs->LastPageNo();
232
-		if ($lastPage == -1) $lastPage = 1; // check for empty rs.
233
-		if ($this->curr_page > $lastPage) $this->curr_page = 1;
276
+		if ($lastPage == -1)
277
+		{
278
+			$lastPage = 1;
279
+		}
280
+		// check for empty rs.
281
+		if ($this->curr_page > $lastPage)
282
+		{
283
+			$this->curr_page = 1;
284
+		}
234 285
 		return "<font size=-1>$this->page ".$this->curr_page."/".$lastPage."</font>";
235 286
 	}
236 287
 	
@@ -242,26 +293,39 @@  discard block
 block discarded – undo
242 293
 	
243 294
 		$this->rows = $rows;
244 295
 		
245
-		if ($this->db->dataProvider == 'informix') $this->db->cursorType = IFX_SCROLL;
296
+		if ($this->db->dataProvider == 'informix')
297
+		{
298
+			$this->db->cursorType = IFX_SCROLL;
299
+		}
246 300
 		
247 301
 		$savec = $ADODB_COUNTRECS;
248
-		if ($this->db->pageExecuteCountRows) $ADODB_COUNTRECS = true;
302
+		if ($this->db->pageExecuteCountRows)
303
+		{
304
+			$ADODB_COUNTRECS = true;
305
+		}
249 306
 		if ($this->cache)
250
-			$rs = &$this->db->CachePageExecute($this->cache,$this->sql,$rows,$this->curr_page);
251
-		else
252
-			$rs = &$this->db->PageExecute($this->sql,$rows,$this->curr_page);
307
+		{
308
+					$rs = &$this->db->CachePageExecute($this->cache,$this->sql,$rows,$this->curr_page);
309
+		}
310
+		else {
311
+					$rs = &$this->db->PageExecute($this->sql,$rows,$this->curr_page);
312
+		}
253 313
 		$ADODB_COUNTRECS = $savec;
254 314
 		
255 315
 		$this->rs = &$rs;
256
-		if (!$rs) {
316
+		if (!$rs)
317
+		{
257 318
 			print "<h3>Query failed: $this->sql</h3>";
258 319
 			return;
259 320
 		}
260 321
 		
261
-		if (!$rs->EOF && (!$rs->AtFirstPage() || !$rs->AtLastPage())) 
262
-			$header = $this->RenderNav();
263
-		else
264
-			$header = "&nbsp;";
322
+		if (!$rs->EOF && (!$rs->AtFirstPage() || !$rs->AtLastPage()))
323
+		{
324
+					$header = $this->RenderNav();
325
+		}
326
+		else {
327
+					$header = "&nbsp;";
328
+		}
265 329
 		
266 330
 		$grid = $this->RenderGrid();
267 331
 		$footer = $this->RenderPageCount();
Please login to merge, or discard this patch.
phpgwapi/inc/adodb/adodb-perf.inc.php 4 patches
Doc Comments   +13 added lines, -3 removed lines patch added patch discarded remove patch
@@ -48,6 +48,9 @@  discard block
 block discarded – undo
48 48
 }
49 49
 
50 50
 // avoids localization problems where , is used instead of .
51
+/**
52
+ * @param integer $prec
53
+ */
51 54
 function adodb_round($n,$prec)
52 55
 {
53 56
 	return number_format($n, $prec, '.', '');
@@ -547,6 +550,10 @@  discard block
 block discarded – undo
547 550
 	/*
548 551
 		Raw function to return parameter value from $settings.
549 552
 	*/
553
+
554
+	/**
555
+	 * @param string $param
556
+	 */
550 557
 	function DBParameter($param)
551 558
 	{
552 559
 		if (empty($this->settings[$param])) return false;
@@ -949,6 +956,9 @@  discard block
 block discarded – undo
949 956
 		return $arr;
950 957
 	}
951 958
 	
959
+	/**
960
+	 * @param string $m
961
+	 */
952 962
 	function undomq(&$m) 
953 963
 	{
954 964
 	if (get_magic_quotes_gpc()) {
@@ -984,7 +994,7 @@  discard block
 block discarded – undo
984 994
      *      <code>ADODB_OPT_LOW</code> for CPU-less optimization
985 995
      *      Default is LOW <code>ADODB_OPT_LOW</code> 
986 996
      * @author Markus Staab
987
-     * @return Returns <code>true</code> on success and <code>false</code> on error
997
+     * @return false|null <code>true</code> on success and <code>false</code> on error
988 998
      */
989 999
     function OptimizeTables()
990 1000
     {
@@ -1015,7 +1025,7 @@  discard block
 block discarded – undo
1015 1025
      *      <code>ADODB_OPT_LOW</code> for CPU-less optimization
1016 1026
      *      Default is LOW <code>ADODB_OPT_LOW</code> 
1017 1027
      * @author Markus Staab
1018
-     * @return Returns <code>true</code> on success and <code>false</code> on error
1028
+     * @return boolean <code>true</code> on success and <code>false</code> on error
1019 1029
      */
1020 1030
     function OptimizeTable( $table, $mode = ADODB_OPT_LOW) 
1021 1031
     {
@@ -1029,7 +1039,7 @@  discard block
 block discarded – undo
1029 1039
      * optimize each using <code>optmizeTable()</code>
1030 1040
      * 
1031 1041
      * @author Markus Staab
1032
-     * @return Returns <code>true</code> on success and <code>false</code> on error
1042
+     * @return boolean <code>true</code> on success and <code>false</code> on error
1033 1043
      */
1034 1044
     function optimizeDatabase() 
1035 1045
     {
Please login to merge, or discard this patch.
Indentation   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 function& adodb_log_sql(&$conn,$sql,$inputarr)
66 66
 {
67 67
 	
68
-    $perf_table = adodb_perf::table();
68
+	$perf_table = adodb_perf::table();
69 69
 	$conn->fnExecute = false;
70 70
 	$t0 = microtime();
71 71
 	$rs =& $conn->Execute($sql,$inputarr);
@@ -213,15 +213,15 @@  discard block
 block discarded – undo
213 213
 	var $createTableSQL = false;
214 214
 	var $maxLength = 2000;
215 215
 	
216
-    // Sets the tablename to be used            
217
-    function table($newtable = false)
218
-    {
219
-        static $_table;
216
+	// Sets the tablename to be used            
217
+	function table($newtable = false)
218
+	{
219
+		static $_table;
220 220
 
221
-        if (!empty($newtable))  $_table = $newtable;
221
+		if (!empty($newtable))  $_table = $newtable;
222 222
 		if (empty($_table)) $_table = 'adodb_logsql';
223
-        return $_table;
224
-    }
223
+		return $_table;
224
+	}
225 225
 
226 226
 	// returns array with info to calculate CPU Load
227 227
 	function _CPULoad()
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 	
349 349
 	function Tracer($sql)
350 350
 	{
351
-        $perf_table = adodb_perf::table();
351
+		$perf_table = adodb_perf::table();
352 352
 		$saveE = $this->conn->fnExecute;
353 353
 		$this->conn->fnExecute = false;
354 354
 		
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
 		$s = '<h3>Invalid SQL</h3>';
395 395
 		$saveE = $this->conn->fnExecute;
396 396
 		$this->conn->fnExecute = false;
397
-        $perf_table = adodb_perf::table();
397
+		$perf_table = adodb_perf::table();
398 398
 		$rs =& $this->conn->SelectLimit("select distinct count(*),sql1,tracer as error_msg from $perf_table where tracer like 'ERROR:%' group by sql1,tracer order by 1 desc",$numsql);//,$numsql);
399 399
 		$this->conn->fnExecute = $saveE;
400 400
 		if ($rs) {
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
 	{
414 414
 		global $ADODB_FETCH_MODE;
415 415
 		
416
-            $perf_table = adodb_perf::table();
416
+			$perf_table = adodb_perf::table();
417 417
 			$saveE = $this->conn->fnExecute;
418 418
 			$this->conn->fnExecute = false;
419 419
 			
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
 	{
493 493
 		global $ADODB_FETCH_MODE;
494 494
 		
495
-            $perf_table = adodb_perf::table();
495
+			$perf_table = adodb_perf::table();
496 496
 			$saveE = $this->conn->fnExecute;
497 497
 			$this->conn->fnExecute = false;
498 498
 			
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
 	function UI($pollsecs=5)
636 636
 	{
637 637
 	
638
-    $perf_table = adodb_perf::table();
638
+	$perf_table = adodb_perf::table();
639 639
 	$conn = $this->conn;
640 640
 	
641 641
 	$app = $conn->host;
@@ -963,91 +963,91 @@  discard block
 block discarded – undo
963 963
     
964 964
    /************************************************************************/
965 965
    
966
-    /** 
967
-     * Reorganise multiple table-indices/statistics/..
968
-     * OptimizeMode could be given by last Parameter
969
-     * 
970
-     * @example
971
-     *      <pre>
972
-     *          optimizeTables( 'tableA');
973
-     *      </pre>
974
-     *      <pre>
975
-     *          optimizeTables( 'tableA', 'tableB', 'tableC');
976
-     *      </pre>
977
-     *      <pre>
978
-     *          optimizeTables( 'tableA', 'tableB', ADODB_OPT_LOW);
979
-     *      </pre>
980
-     * 
981
-     * @param string table name of the table to optimize
982
-     * @param int mode optimization-mode
983
-     *      <code>ADODB_OPT_HIGH</code> for full optimization 
984
-     *      <code>ADODB_OPT_LOW</code> for CPU-less optimization
985
-     *      Default is LOW <code>ADODB_OPT_LOW</code> 
986
-     * @author Markus Staab
987
-     * @return Returns <code>true</code> on success and <code>false</code> on error
988
-     */
989
-    function OptimizeTables()
990
-    {
991
-        $args = func_get_args();
992
-        $numArgs = func_num_args();
966
+	/** 
967
+	 * Reorganise multiple table-indices/statistics/..
968
+	 * OptimizeMode could be given by last Parameter
969
+	 * 
970
+	 * @example
971
+	 *      <pre>
972
+	 *          optimizeTables( 'tableA');
973
+	 *      </pre>
974
+	 *      <pre>
975
+	 *          optimizeTables( 'tableA', 'tableB', 'tableC');
976
+	 *      </pre>
977
+	 *      <pre>
978
+	 *          optimizeTables( 'tableA', 'tableB', ADODB_OPT_LOW);
979
+	 *      </pre>
980
+	 * 
981
+	 * @param string table name of the table to optimize
982
+	 * @param int mode optimization-mode
983
+	 *      <code>ADODB_OPT_HIGH</code> for full optimization 
984
+	 *      <code>ADODB_OPT_LOW</code> for CPU-less optimization
985
+	 *      Default is LOW <code>ADODB_OPT_LOW</code> 
986
+	 * @author Markus Staab
987
+	 * @return Returns <code>true</code> on success and <code>false</code> on error
988
+	 */
989
+	function OptimizeTables()
990
+	{
991
+		$args = func_get_args();
992
+		$numArgs = func_num_args();
993 993
         
994
-        if ( $numArgs == 0) return false;
994
+		if ( $numArgs == 0) return false;
995 995
         
996
-        $mode = ADODB_OPT_LOW; 
997
-        $lastArg = $args[ $numArgs - 1];
998
-        if ( !is_string($lastArg)) {
999
-            $mode = $lastArg;
1000
-            unset( $args[ $numArgs - 1]);
1001
-        }
996
+		$mode = ADODB_OPT_LOW; 
997
+		$lastArg = $args[ $numArgs - 1];
998
+		if ( !is_string($lastArg)) {
999
+			$mode = $lastArg;
1000
+			unset( $args[ $numArgs - 1]);
1001
+		}
1002 1002
         
1003
-        foreach( $args as $table) {
1004
-            $this->optimizeTable( $table, $mode);
1005
-        }
1003
+		foreach( $args as $table) {
1004
+			$this->optimizeTable( $table, $mode);
1005
+		}
1006 1006
 	}
1007 1007
 
1008
-    /** 
1009
-     * Reorganise the table-indices/statistics/.. depending on the given mode.
1010
-     * Default Implementation throws an error.
1011
-     * 
1012
-     * @param string table name of the table to optimize
1013
-     * @param int mode optimization-mode
1014
-     *      <code>ADODB_OPT_HIGH</code> for full optimization 
1015
-     *      <code>ADODB_OPT_LOW</code> for CPU-less optimization
1016
-     *      Default is LOW <code>ADODB_OPT_LOW</code> 
1017
-     * @author Markus Staab
1018
-     * @return Returns <code>true</code> on success and <code>false</code> on error
1019
-     */
1020
-    function OptimizeTable( $table, $mode = ADODB_OPT_LOW) 
1021
-    {
1022
-        ADOConnection::outp( sprintf( "<p>%s: '%s' not implemented for driver '%s'</p>", __CLASS__, __FUNCTION__, $this->conn->databaseType));
1023
-        return false;
1024
-    }
1008
+	/** 
1009
+	 * Reorganise the table-indices/statistics/.. depending on the given mode.
1010
+	 * Default Implementation throws an error.
1011
+	 * 
1012
+	 * @param string table name of the table to optimize
1013
+	 * @param int mode optimization-mode
1014
+	 *      <code>ADODB_OPT_HIGH</code> for full optimization 
1015
+	 *      <code>ADODB_OPT_LOW</code> for CPU-less optimization
1016
+	 *      Default is LOW <code>ADODB_OPT_LOW</code> 
1017
+	 * @author Markus Staab
1018
+	 * @return Returns <code>true</code> on success and <code>false</code> on error
1019
+	 */
1020
+	function OptimizeTable( $table, $mode = ADODB_OPT_LOW) 
1021
+	{
1022
+		ADOConnection::outp( sprintf( "<p>%s: '%s' not implemented for driver '%s'</p>", __CLASS__, __FUNCTION__, $this->conn->databaseType));
1023
+		return false;
1024
+	}
1025 1025
     
1026
-    /** 
1027
-     * Reorganise current database.
1028
-     * Default implementation loops over all <code>MetaTables()</code> and 
1029
-     * optimize each using <code>optmizeTable()</code>
1030
-     * 
1031
-     * @author Markus Staab
1032
-     * @return Returns <code>true</code> on success and <code>false</code> on error
1033
-     */
1034
-    function optimizeDatabase() 
1035
-    {
1036
-        $conn = $this->conn;
1037
-        if ( !$conn) return false;
1026
+	/** 
1027
+	 * Reorganise current database.
1028
+	 * Default implementation loops over all <code>MetaTables()</code> and 
1029
+	 * optimize each using <code>optmizeTable()</code>
1030
+	 * 
1031
+	 * @author Markus Staab
1032
+	 * @return Returns <code>true</code> on success and <code>false</code> on error
1033
+	 */
1034
+	function optimizeDatabase() 
1035
+	{
1036
+		$conn = $this->conn;
1037
+		if ( !$conn) return false;
1038 1038
         
1039
-        $tables = $conn->MetaTables( 'TABLES');
1040
-        if ( !$tables ) return false;
1039
+		$tables = $conn->MetaTables( 'TABLES');
1040
+		if ( !$tables ) return false;
1041 1041
 
1042
-        foreach( $tables as $table) {
1043
-            if ( !$this->optimizeTable( $table)) {
1044
-                return false;
1045
-            }
1046
-        }
1042
+		foreach( $tables as $table) {
1043
+			if ( !$this->optimizeTable( $table)) {
1044
+				return false;
1045
+			}
1046
+		}
1047 1047
       
1048
-        return true;
1049
-    }
1050
-    // end hack 
1048
+		return true;
1049
+	}
1050
+	// end hack 
1051 1051
 }
1052 1052
 
1053 1053
 ?>
1054 1054
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -19,21 +19,21 @@  discard block
 block discarded – undo
19 19
 if (!defined(ADODB_DIR)) include_once(dirname(__FILE__).'/adodb.inc.php');
20 20
 include_once(ADODB_DIR.'/tohtml.inc.php');
21 21
 
22
-define( 'ADODB_OPT_HIGH', 2);
23
-define( 'ADODB_OPT_LOW', 1);
22
+define('ADODB_OPT_HIGH', 2);
23
+define('ADODB_OPT_LOW', 1);
24 24
 
25 25
 // returns in K the memory of current process, or 0 if not known
26 26
 function adodb_getmem()
27 27
 {
28 28
 	if (function_exists('memory_get_usage'))
29
-		return (integer) ((memory_get_usage()+512)/1024);
29
+		return (integer)((memory_get_usage() + 512) / 1024);
30 30
 	
31 31
 	$pid = getmypid();
32 32
 	
33
-	if ( strncmp(strtoupper(PHP_OS),'WIN',3)==0) {
33
+	if (strncmp(strtoupper(PHP_OS), 'WIN', 3) == 0) {
34 34
 		$output = array();
35 35
 	
36
-		exec('tasklist /FI "PID eq ' . $pid. '" /FO LIST', $output); 
36
+		exec('tasklist /FI "PID eq '.$pid.'" /FO LIST', $output); 
37 37
 		return substr($output[5], strpos($output[5], ':') + 1);
38 38
 	} 
39 39
 	
@@ -41,14 +41,14 @@  discard block
 block discarded – undo
41 41
 	exec("ps --pid $pid --no-headers -o%mem,size", $output);
42 42
 	if (sizeof($output) == 0) return 0;
43 43
 	
44
-	$memarr = explode(' ',$output[0]);
45
-	if (sizeof($memarr)>=2) return (integer) $memarr[1];
44
+	$memarr = explode(' ', $output[0]);
45
+	if (sizeof($memarr) >= 2) return (integer)$memarr[1];
46 46
 	
47 47
 	return 0;
48 48
 }
49 49
 
50 50
 // avoids localization problems where , is used instead of .
51
-function adodb_round($n,$prec)
51
+function adodb_round($n, $prec)
52 52
 {
53 53
 	return number_format($n, $prec, '.', '');
54 54
 }
@@ -57,29 +57,29 @@  discard block
 block discarded – undo
57 57
 function adodb_microtime()
58 58
 {
59 59
 	$t = microtime();
60
-	$t = explode(' ',$t);
61
-	return (float)$t[1]+ (float)$t[0];
60
+	$t = explode(' ', $t);
61
+	return (float)$t[1] + (float)$t[0];
62 62
 }
63 63
 
64 64
 /* sql code timing */
65
-function& adodb_log_sql(&$conn,$sql,$inputarr)
65
+function& adodb_log_sql(&$conn, $sql, $inputarr)
66 66
 {
67 67
 	
68 68
     $perf_table = adodb_perf::table();
69 69
 	$conn->fnExecute = false;
70 70
 	$t0 = microtime();
71
-	$rs =& $conn->Execute($sql,$inputarr);
71
+	$rs = & $conn->Execute($sql, $inputarr);
72 72
 	$t1 = microtime();
73 73
 
74 74
 	if (!empty($conn->_logsql)) {
75 75
 		$conn->_logsql = false; // disable logsql error simulation
76 76
 		$dbT = $conn->databaseType;
77 77
 		
78
-		$a0 = explode(' ',$t0);
79
-		$a0 = (float)$a0[1]+(float)$a0[0];
78
+		$a0 = explode(' ', $t0);
79
+		$a0 = (float)$a0[1] + (float)$a0[0];
80 80
 		
81
-		$a1 = explode(' ',$t1);
82
-		$a1 = (float)$a1[1]+(float)$a1[0];
81
+		$a1 = explode(' ', $t1);
82
+		$a1 = (float)$a1[1] + (float)$a1[0];
83 83
 		
84 84
 		$time = $a1 - $a0;
85 85
 	
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 			$errM = $conn->ErrorMsg();
88 88
 			$errN = $conn->ErrorNo();
89 89
 			$conn->lastInsID = 0;
90
-			$tracer = substr('ERROR: '.htmlspecialchars($errM),0,250);
90
+			$tracer = substr('ERROR: '.htmlspecialchars($errM), 0, 250);
91 91
 		} else {
92 92
 			$tracer = '';
93 93
 			$errM = '';
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 			if (isset($_SERVER['PHP_SELF'])) $tracer .= '<br>'.$_SERVER['PHP_SELF'];
107 107
 		//$tracer .= (string) adodb_backtrace(false);
108 108
 		
109
-		$tracer = (string) substr($tracer,0,500);
109
+		$tracer = (string)substr($tracer, 0, 500);
110 110
 		
111 111
 		if (is_array($inputarr)) {
112 112
 			if (is_array(reset($inputarr))) $params = 'Array sizeof='.sizeof($inputarr);
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 				$xar_params = $inputarr;
117 117
 				foreach ($xar_params as $xar_param_key => $xar_param) {
118 118
 					if (gettype($xar_param) == 'string')
119
-					$xar_params[$xar_param_key] = '"' . $xar_param . '"';
119
+					$xar_params[$xar_param_key] = '"'.$xar_param.'"';
120 120
 				}
121 121
 				$params = implode(', ', $xar_params);
122 122
 				if (strlen($params) >= 3000) $params = substr($params, 0, 3000);
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 		
128 128
 		if (is_array($sql)) $sql = $sql[0];
129 129
 		$arr = array('b'=>strlen($sql).'.'.crc32($sql),
130
-					'c'=>substr($sql,0,3900), 'd'=>$params,'e'=>$tracer,'f'=>adodb_round($time,6));
130
+					'c'=>substr($sql, 0, 3900), 'd'=>$params, 'e'=>$tracer, 'f'=>adodb_round($time, 6));
131 131
 		//var_dump($arr);
132 132
 		$saved = $conn->debug;
133 133
 		$conn->debug = 0;
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 			$isql = "insert into $perf_table values($d,:b,:c,:d,:e,:f)";
139 139
 		} else if ($dbT == 'odbc_mssql' || $dbT == 'informix') {
140 140
 			$timer = $arr['f'];
141
-			if ($dbT == 'informix') $sql2 = substr($sql2,0,230);
141
+			if ($dbT == 'informix') $sql2 = substr($sql2, 0, 230);
142 142
 
143 143
 			$sql1 = $conn->qstr($arr['b']);
144 144
 			$sql2 = $conn->qstr($arr['c']);
@@ -146,13 +146,13 @@  discard block
 block discarded – undo
146 146
 			$tracer = $conn->qstr($arr['e']);
147 147
 			
148 148
 			$isql = "insert into $perf_table (created,sql0,sql1,params,tracer,timer) values($d,$sql1,$sql2,$params,$tracer,$timer)";
149
-			if ($dbT == 'informix') $isql = str_replace(chr(10),' ',$isql);
149
+			if ($dbT == 'informix') $isql = str_replace(chr(10), ' ', $isql);
150 150
 			$arr = false;
151 151
 		} else {
152 152
 			$isql = "insert into $perf_table (created,sql0,sql1,params,tracer,timer) values( $d,?,?,?,?,?)";
153 153
 		}
154 154
 
155
-		$ok = $conn->Execute($isql,$arr);
155
+		$ok = $conn->Execute($isql, $arr);
156 156
 		$conn->debug = $saved;
157 157
 		
158 158
 		if ($ok) {
@@ -160,9 +160,9 @@  discard block
 block discarded – undo
160 160
 		} else {
161 161
 			$err2 = $conn->ErrorMsg();
162 162
 			$conn->_logsql = true; // enable logsql error simulation
163
-			$perf =& NewPerfMonitor($conn);
163
+			$perf = & NewPerfMonitor($conn);
164 164
 			if ($perf) {
165
-				if ($perf->CreateLogTable()) $ok = $conn->Execute($isql,$arr);
165
+				if ($perf->CreateLogTable()) $ok = $conn->Execute($isql, $arr);
166 166
 			} else {
167 167
 				$ok = $conn->Execute("create table $perf_table (
168 168
 				created varchar(50),
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 				timer decimal(16,6))");
174 174
 			}
175 175
 			if (!$ok) {
176
-				ADOConnection::outp( "<p><b>LOGSQL Insert Failed</b>: $isql<br>$err2</p>");
176
+				ADOConnection::outp("<p><b>LOGSQL Insert Failed</b>: $isql<br>$err2</p>");
177 177
 				$conn->_logsql = false;
178 178
 			}
179 179
 		}
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 	var $warnRatio = 90;
208 208
 	var $tablesSQL = false;
209 209
 	var $cliFormat = "%32s => %s \r\n";
210
-	var $sql1 = 'sql1';  // used for casting sql1 to text for mssql
210
+	var $sql1 = 'sql1'; // used for casting sql1 to text for mssql
211 211
 	var $explain = true;
212 212
 	var $helpurl = "<a href=http://phplens.com/adodb/reference.functions.fnexecute.and.fncacheexecute.properties.html#logsql>LogSQL help</a>";
213 213
 	var $createTableSQL = false;
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 */
243 243
 		// Algorithm is taken from
244 244
 		// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/example__obtaining_raw_performance_data.asp
245
-		if (strncmp(PHP_OS,'WIN',3)==0) {
245
+		if (strncmp(PHP_OS, 'WIN', 3) == 0) {
246 246
 			if (PHP_VERSION == '5.0.0') return false;
247 247
 			if (PHP_VERSION == '5.0.1') return false;
248 248
 			if (PHP_VERSION == '5.0.2') return false;
@@ -264,16 +264,16 @@  discard block
 block discarded – undo
264 264
 		$statfile = '/proc/stat';
265 265
 		if (!file_exists($statfile)) return false;
266 266
 		
267
-		$fd = fopen($statfile,"r");
267
+		$fd = fopen($statfile, "r");
268 268
 		if (!$fd) return false;
269 269
 		
270
-		$statinfo = explode("\n",fgets($fd, 1024));
270
+		$statinfo = explode("\n", fgets($fd, 1024));
271 271
 		fclose($fd);
272
-		foreach($statinfo as $line) {
273
-			$info = explode(" ",$line);
274
-			if($info[0]=="cpu") {
275
-				array_shift($info);  // pop off "cpu"
276
-				if(!$info[0]) array_shift($info); // pop off blank space (if any)
272
+		foreach ($statinfo as $line) {
273
+			$info = explode(" ", $line);
274
+			if ($info[0] == "cpu") {
275
+				array_shift($info); // pop off "cpu"
276
+				if (!$info[0]) array_shift($info); // pop off blank space (if any)
277 277
 				return $info;
278 278
 			}
279 279
 		}
@@ -336,13 +336,13 @@  discard block
 block discarded – undo
336 336
 		
337 337
 		//printf("Delta - User: %f  Nice: %f  System: %f  Idle: %f<br>",$d_user,$d_nice,$d_system,$d_idle);
338 338
 
339
-		if (strncmp(PHP_OS,'WIN',3)==0) {
339
+		if (strncmp(PHP_OS, 'WIN', 3) == 0) {
340 340
 			if ($d_idle < 1) $d_idle = 1;
341
-			return 100*(1-$d_user/$d_idle);
342
-		}else {
343
-			$total=$d_user+$d_nice+$d_system+$d_idle;
344
-			if ($total<1) $total=1;
345
-			return 100*($d_user+$d_nice+$d_system)/$total; 
341
+			return 100 * (1 - $d_user / $d_idle);
342
+		} else {
343
+			$total = $d_user + $d_nice + $d_system + $d_idle;
344
+			if ($total < 1) $total = 1;
345
+			return 100 * ($d_user + $d_nice + $d_system) / $total; 
346 346
 		}
347 347
 	}
348 348
 	
@@ -366,8 +366,8 @@  discard block
 block discarded – undo
366 366
 		$s = '';
367 367
 		if ($arr) {
368 368
 			$s .= '<h3>Scripts Affected</h3>';
369
-			foreach($arr as $k) {
370
-				$s .= sprintf("%4d",$k[0]).' &nbsp; '.strip_tags($k[1]).'<br>';
369
+			foreach ($arr as $k) {
370
+				$s .= sprintf("%4d", $k[0]).' &nbsp; '.strip_tags($k[1]).'<br>';
371 371
 			}
372 372
 		}
373 373
 		
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 		If only a snippet of the $sql is passed in, then $partial will hold the crc32 of the 
383 383
 			actual sql.
384 384
 	*/
385
-	function Explain($sql,$partial=false)
385
+	function Explain($sql, $partial = false)
386 386
 	{	
387 387
 		return false;
388 388
 	}
@@ -395,10 +395,10 @@  discard block
 block discarded – undo
395 395
 		$saveE = $this->conn->fnExecute;
396 396
 		$this->conn->fnExecute = false;
397 397
         $perf_table = adodb_perf::table();
398
-		$rs =& $this->conn->SelectLimit("select distinct count(*),sql1,tracer as error_msg from $perf_table where tracer like 'ERROR:%' group by sql1,tracer order by 1 desc",$numsql);//,$numsql);
398
+		$rs = & $this->conn->SelectLimit("select distinct count(*),sql1,tracer as error_msg from $perf_table where tracer like 'ERROR:%' group by sql1,tracer order by 1 desc", $numsql); //,$numsql);
399 399
 		$this->conn->fnExecute = $saveE;
400 400
 		if ($rs) {
401
-			$s .= rs2html($rs,false,false,false,false);
401
+			$s .= rs2html($rs, false, false, false, false);
402 402
 		} else
403 403
 			return "<p>$this->helpurl. ".$this->conn->ErrorMsg()."</p>";
404 404
 		
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 			
420 420
 			if (isset($_GET['exps']) && isset($_GET['sql'])) {
421 421
 				$partial = !empty($_GET['part']);
422
-				echo "<a name=explain></a>".$this->Explain($_GET['sql'],$partial)."\n";
422
+				echo "<a name=explain></a>".$this->Explain($_GET['sql'], $partial)."\n";
423 423
 			}
424 424
 			
425 425
 			if (isset($_GET['sql'])) return;
@@ -429,13 +429,13 @@  discard block
 block discarded – undo
429 429
 			$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
430 430
 			if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false);
431 431
 			//$this->conn->debug=1;
432
-			$rs =& $this->conn->SelectLimit(
432
+			$rs = & $this->conn->SelectLimit(
433 433
 			"select avg(timer) as avg_timer,$sql1,count(*),max(timer) as max_timer,min(timer) as min_timer
434 434
 				from $perf_table
435 435
 				where {$this->conn->upperCase}({$this->conn->substr}(sql0,1,5)) not in ('DROP ','INSER','COMMI','CREAT')
436 436
 				and (tracer is null or tracer not like 'ERROR:%')
437 437
 				group by sql1
438
-				order by 1 desc",$numsql);
438
+				order by 1 desc", $numsql);
439 439
 			if (isset($savem)) $this->conn->SetFetchMode($savem);
440 440
 			$ADODB_FETCH_MODE = $save;
441 441
 			$this->conn->fnExecute = $saveE;
@@ -448,17 +448,17 @@  discard block
 block discarded – undo
448 448
 			while (!$rs->EOF) {
449 449
 				$sql = $rs->fields[1];
450 450
 				$raw = urlencode($sql);
451
-				if (strlen($raw)>$max-100) {
452
-					$sql2 = substr($sql,0,$max-500);
451
+				if (strlen($raw) > $max - 100) {
452
+					$sql2 = substr($sql, 0, $max - 500);
453 453
 					$raw = urlencode($sql2).'&part='.crc32($sql);
454 454
 				}
455 455
 				$prefix = "<a target=sql".rand()." href=\"?hidem=1&exps=1&sql=".$raw."&x#explain\">";
456 456
 				$suffix = "</a>";
457
-				if ($this->explain == false || strlen($prefix)>$max) {
457
+				if ($this->explain == false || strlen($prefix) > $max) {
458 458
 					$suffix = ' ... <i>String too long for GET parameter: '.strlen($prefix).'</i>';
459 459
 					$prefix = '';
460 460
 				}
461
-				$s .= "<tr><td>".adodb_round($rs->fields[0],6)."<td align=right>".$rs->fields[2]."<td><font size=-1>".$prefix.htmlspecialchars($sql).$suffix."</font>".
461
+				$s .= "<tr><td>".adodb_round($rs->fields[0], 6)."<td align=right>".$rs->fields[2]."<td><font size=-1>".$prefix.htmlspecialchars($sql).$suffix."</font>".
462 462
 					"<td>".$rs->fields[3]."<td>".$rs->fields[4]."</tr>";
463 463
 				$rs->MoveNext();
464 464
 			}
@@ -472,12 +472,12 @@  discard block
 block discarded – undo
472 472
 	}
473 473
 	
474 474
 	
475
-	function SuspiciousSQL($numsql=10)
475
+	function SuspiciousSQL($numsql = 10)
476 476
 	{
477 477
 		return adodb_perf::_SuspiciousSQL($numsql);
478 478
 	}
479 479
 
480
-	function ExpensiveSQL($numsql=10)
480
+	function ExpensiveSQL($numsql = 10)
481 481
 	{
482 482
 		return adodb_perf::_ExpensiveSQL($numsql);
483 483
 	}
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
 			
499 499
 			if (isset($_GET['expe']) && isset($_GET['sql'])) {
500 500
 				$partial = !empty($_GET['part']);
501
-				echo "<a name=explain></a>".$this->Explain($_GET['sql'],$partial)."\n";
501
+				echo "<a name=explain></a>".$this->Explain($_GET['sql'], $partial)."\n";
502 502
 			}
503 503
 			
504 504
 			if (isset($_GET['sql'])) return;
@@ -508,14 +508,14 @@  discard block
 block discarded – undo
508 508
 			$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
509 509
 			if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false);
510 510
 			
511
-			$rs =& $this->conn->SelectLimit(
511
+			$rs = & $this->conn->SelectLimit(
512 512
 			"select sum(timer) as total,$sql1,count(*),max(timer) as max_timer,min(timer) as min_timer
513 513
 				from $perf_table
514 514
 				where {$this->conn->upperCase}({$this->conn->substr}(sql0,1,5))  not in ('DROP ','INSER','COMMI','CREAT')
515 515
 				and (tracer is null or tracer not like 'ERROR:%')
516 516
 				group by sql1
517 517
 				having count(*)>1
518
-				order by 1 desc",$numsql);
518
+				order by 1 desc", $numsql);
519 519
 			if (isset($savem)) $this->conn->SetFetchMode($savem);
520 520
 			$this->conn->fnExecute = $saveE;
521 521
 			$ADODB_FETCH_MODE = $save;
@@ -527,17 +527,17 @@  discard block
 block discarded – undo
527 527
 			while (!$rs->EOF) {
528 528
 				$sql = $rs->fields[1];
529 529
 				$raw = urlencode($sql);
530
-				if (strlen($raw)>$max-100) {
531
-					$sql2 = substr($sql,0,$max-500);
530
+				if (strlen($raw) > $max - 100) {
531
+					$sql2 = substr($sql, 0, $max - 500);
532 532
 					$raw = urlencode($sql2).'&part='.crc32($sql);
533 533
 				}
534 534
 				$prefix = "<a target=sqle".rand()." href=\"?hidem=1&expe=1&sql=".$raw."&x#explain\">";
535 535
 				$suffix = "</a>";
536
-				if($this->explain == false || strlen($prefix>$max)) {
536
+				if ($this->explain == false || strlen($prefix > $max)) {
537 537
 					$prefix = '';
538 538
 					$suffix = '';
539 539
 				}
540
-				$s .= "<tr><td>".adodb_round($rs->fields[0],6)."<td align=right>".$rs->fields[2]."<td><font size=-1>".$prefix.htmlspecialchars($sql).$suffix."</font>".
540
+				$s .= "<tr><td>".adodb_round($rs->fields[0], 6)."<td align=right>".$rs->fields[2]."<td><font size=-1>".$prefix.htmlspecialchars($sql).$suffix."</font>".
541 541
 					"<td>".$rs->fields[3]."<td>".$rs->fields[4]."</tr>";
542 542
 				$rs->MoveNext();
543 543
 			}
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 		$arr[0] = (float)$this->DBParameter('data cache hit ratio');
563 563
 		$arr[1] = (float)$this->DBParameter('data reads');
564 564
 		$arr[2] = (float)$this->DBParameter('data writes');
565
-		$arr[3] = (integer) $this->DBParameter('current connections');
565
+		$arr[3] = (integer)$this->DBParameter('current connections');
566 566
 		return $arr;
567 567
 	}
568 568
 	
@@ -577,9 +577,9 @@  discard block
 block discarded – undo
577 577
 		
578 578
 			$sql1 = $sql[0];
579 579
 			$key = $sql[1];
580
-			if (sizeof($sql)>2) $pos = $sql[2];
580
+			if (sizeof($sql) > 2) $pos = $sql[2];
581 581
 			else $pos = 1;
582
-			if (sizeof($sql)>3) $coef = $sql[3];
582
+			if (sizeof($sql) > 3) $coef = $sql[3];
583 583
 			else $coef = false;
584 584
 			$ret = false;
585 585
 			$save = $ADODB_FETCH_MODE;
@@ -605,11 +605,11 @@  discard block
 block discarded – undo
605 605
 			$this->conn->LogSQL($savelog);
606 606
 			return $ret;
607 607
 		} else {
608
-			if (strncmp($sql,'=',1) == 0) {
609
-				$fn = substr($sql,1);
608
+			if (strncmp($sql, '=', 1) == 0) {
609
+				$fn = substr($sql, 1);
610 610
 				return $this->$fn();
611 611
 			}
612
-			$sql = str_replace('$DATABASE',$this->conn->database,$sql);
612
+			$sql = str_replace('$DATABASE', $this->conn->database, $sql);
613 613
 			$ret = $this->conn->GetOne($sql);
614 614
 			$this->conn->LogSQL($savelog);
615 615
 			
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
 	/***********************************************************************************************/
633 633
 
634 634
 	
635
-	function UI($pollsecs=5)
635
+	function UI($pollsecs = 5)
636 636
 	{
637 637
 	
638 638
     $perf_table = adodb_perf::table();
@@ -653,7 +653,7 @@  discard block
 block discarded – undo
653 653
 	// magic quotes
654 654
 	
655 655
 	if (isset($_GET['sql']) && get_magic_quotes_gpc()) {
656
-		$_GET['sql'] = $_GET['sql'] = str_replace(array("\\'",'\"'),array("'",'"'),$_GET['sql']);
656
+		$_GET['sql'] = $_GET['sql'] = str_replace(array("\\'", '\"'), array("'", '"'), $_GET['sql']);
657 657
 	}
658 658
 	
659 659
 	if (!isset($_SESSION['ADODB_PERF_SQL'])) $nsql = $_SESSION['ADODB_PERF_SQL'] = 10;
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
 	 else $do = 'stats';
669 669
 	 
670 670
 	if (isset($_GET['nsql'])) {
671
-		if ($_GET['nsql'] > 0) $nsql = $_SESSION['ADODB_PERF_SQL'] = (integer) $_GET['nsql'];
671
+		if ($_GET['nsql'] > 0) $nsql = $_SESSION['ADODB_PERF_SQL'] = (integer)$_GET['nsql'];
672 672
 	}
673 673
 	echo "<title>ADOdb Performance Monitor on $app</title><body bgcolor=white>";
674 674
 	if ($do == 'viewsql') $form = "<td><form># SQL:<input type=hidden value=viewsql name=do> <input type=text size=4 name=nsql value=$nsql><input type=submit value=Go></td></form>";
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
 	
677 677
 	$allowsql = !defined('ADODB_PERF_NO_RUN_SQL');
678 678
 	
679
-	if  (empty($_GET['hidem']))
679
+	if (empty($_GET['hidem']))
680 680
 	echo "<table border=1 width=100% bgcolor=lightyellow><tr><td colspan=2>
681 681
 	<b><a href=http://adodb.sourceforge.net/?perf=1>ADOdb</a> Performance Monitor</b> <font size=1>for $app</font></tr><tr><td>
682 682
 	<a href=?do=stats><b>Performance Stats</b></a> &nbsp; <a href=?do=viewsql><b>View SQL</b></a>
@@ -724,30 +724,30 @@  discard block
 block discarded – undo
724 724
 	/*
725 725
 		Runs in infinite loop, returning real-time statistics
726 726
 	*/
727
-	function Poll($secs=5)
727
+	function Poll($secs = 5)
728 728
 	{
729 729
 		$this->conn->fnExecute = false;
730 730
 		//$this->conn->debug=1;
731 731
 		if ($secs <= 1) $secs = 1;
732
-		echo "Accumulating statistics, every $secs seconds...\n";flush();
733
-		$arro =& $this->PollParameters();
732
+		echo "Accumulating statistics, every $secs seconds...\n"; flush();
733
+		$arro = & $this->PollParameters();
734 734
 		$cnt = 0;
735 735
 		set_time_limit(0);
736 736
 		sleep($secs);
737 737
 		while (1) {
738 738
 
739
-			$arr =& $this->PollParameters();
739
+			$arr = & $this->PollParameters();
740 740
 			
741
-			$hits   = sprintf('%2.2f',$arr[0]);
742
-			$reads  = sprintf('%12.4f',($arr[1]-$arro[1])/$secs);
743
-			$writes = sprintf('%12.4f',($arr[2]-$arro[2])/$secs);
744
-			$sess = sprintf('%5d',$arr[3]);
741
+			$hits   = sprintf('%2.2f', $arr[0]);
742
+			$reads  = sprintf('%12.4f', ($arr[1] - $arro[1]) / $secs);
743
+			$writes = sprintf('%12.4f', ($arr[2] - $arro[2]) / $secs);
744
+			$sess = sprintf('%5d', $arr[3]);
745 745
 			
746 746
 			$load = $this->CPULoad();
747 747
 			if ($load !== false) {
748 748
 				$oslabel = 'WS-CPU%';
749
-				$osval = sprintf(" %2.1f  ",(float) $load);
750
-			}else {
749
+				$osval = sprintf(" %2.1f  ", (float)$load);
750
+			} else {
751 751
 				$oslabel = '';
752 752
 				$osval = '';
753 753
 			}
@@ -775,7 +775,7 @@  discard block
 block discarded – undo
775 775
 	/*
776 776
 		Returns basic health check as HTML
777 777
 	*/
778
-	function HealthCheck($cli=false)
778
+	function HealthCheck($cli = false)
779 779
 	{
780 780
 		$saveE = $this->conn->fnExecute;
781 781
 		$this->conn->fnExecute = false;	
@@ -784,7 +784,7 @@  discard block
 block discarded – undo
784 784
 		
785 785
 		$oldc = false;
786 786
 		$bgc = '';
787
-		foreach($this->settings as $name => $arr) {
787
+		foreach ($this->settings as $name => $arr) {
788 788
 			if ($arr === false) break;
789 789
 			
790 790
 			if (!is_string($name)) {
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
 			if (!is_array($arr)) break;
797 797
 			$category = $arr[0];
798 798
 			$how = $arr[1];
799
-			if (sizeof($arr)>2) $desc = $arr[2];
799
+			if (sizeof($arr) > 2) $desc = $arr[2];
800 800
 			else $desc = ' &nbsp; ';
801 801
 			
802 802
 			
@@ -804,8 +804,8 @@  discard block
 block discarded – undo
804 804
 			
805 805
 			$val = $this->_DBParameter($how);
806 806
 			
807
-			if ($desc && strncmp($desc,"=",1) === 0) {
808
-				$fn = substr($desc,1);
807
+			if ($desc && strncmp($desc, "=", 1) === 0) {
808
+				$fn = substr($desc, 1);
809 809
 				$desc = $this->$fn($val);
810 810
 			}
811 811
 			
@@ -813,9 +813,9 @@  discard block
 block discarded – undo
813 813
 				$m = $this->conn->ErrorMsg();
814 814
 				$val = "Error: $m"; 
815 815
 			} else {
816
-				if (is_numeric($val) && $val >= 256*1024) {
817
-					if ($val % (1024*1024) == 0) {
818
-						$val /= (1024*1024);
816
+				if (is_numeric($val) && $val >= 256 * 1024) {
817
+					if ($val % (1024 * 1024) == 0) {
818
+						$val /= (1024 * 1024);
819 819
 						$val .= 'M';
820 820
 					} else if ($val % 1024 == 0) {
821 821
 						$val /= 1024;
@@ -828,12 +828,12 @@  discard block
 block discarded – undo
828 828
 				$oldc = $category;
829 829
 				//$bgc = ($bgc == ' bgcolor='.$this->color) ? ' bgcolor=white' : ' bgcolor='.$this->color;
830 830
 			}
831
-			if (strlen($desc)==0) $desc = '&nbsp;';
832
-			if (strlen($val)==0) $val = '&nbsp;';
831
+			if (strlen($desc) == 0) $desc = '&nbsp;';
832
+			if (strlen($val) == 0) $val = '&nbsp;';
833 833
 			if ($cli) {
834
-				$html  .= str_replace('&nbsp;','',sprintf($this->cliFormat,strip_tags($name),strip_tags($val),strip_tags($desc)));
834
+				$html .= str_replace('&nbsp;', '', sprintf($this->cliFormat, strip_tags($name), strip_tags($val), strip_tags($desc)));
835 835
 				
836
-			}else {
836
+			} else {
837 837
 				$html .= "<tr$bgc><td>".$name.'</td><td>'.$val.'</td><td>'.$desc."</td></tr>\n";
838 838
 			}
839 839
 		}
@@ -844,14 +844,14 @@  discard block
 block discarded – undo
844 844
 		return $html;	
845 845
 	}
846 846
 	
847
-	function Tables($orderby='1')
847
+	function Tables($orderby = '1')
848 848
 	{
849 849
 		if (!$this->tablesSQL) return false;
850 850
 		
851 851
 		$savelog = $this->conn->LogSQL(false);
852 852
 		$rs = $this->conn->Execute($this->tablesSQL.' order by '.$orderby);
853 853
 		$this->conn->LogSQL($savelog);
854
-		$html = rs2html($rs,false,false,false,false);
854
+		$html = rs2html($rs, false, false, false, false);
855 855
 		return $html;
856 856
 	}
857 857
 	
@@ -906,14 +906,14 @@  discard block
 block discarded – undo
906 906
 		if (!isset($_REQUEST['sql'])) return;
907 907
 		
908 908
 		$sql = $this->undomq(trim($sql));
909
-		if (substr($sql,strlen($sql)-1) === ';') {
909
+		if (substr($sql, strlen($sql) - 1) === ';') {
910 910
 			$print = true;
911 911
 			$sqla = $this->SplitSQL($sql);
912
-		} else  {
912
+		} else {
913 913
 			$print = false;
914 914
 			$sqla = array($sql);
915 915
 		}
916
-		foreach($sqla as $sqls) {
916
+		foreach ($sqla as $sqls) {
917 917
 
918 918
 			if (!$sqls) continue;
919 919
 			
@@ -931,7 +931,7 @@  discard block
 block discarded – undo
931 931
 					rs2html($rs);
932 932
 				}
933 933
 			} else {
934
-				$e1 = (integer) $this->conn->ErrorNo();
934
+				$e1 = (integer)$this->conn->ErrorNo();
935 935
 				$e2 = $this->conn->ErrorMsg();
936 936
 				if (($e1) || ($e2)) {
937 937
 					if (empty($e1)) $e1 = '-1'; // postgresql fix
@@ -945,7 +945,7 @@  discard block
 block discarded – undo
945 945
 	
946 946
 	function SplitSQL($sql)
947 947
 	{
948
-		$arr = explode(';',$sql);
948
+		$arr = explode(';', $sql);
949 949
 		return $arr;
950 950
 	}
951 951
 	
@@ -953,9 +953,9 @@  discard block
 block discarded – undo
953 953
 	{
954 954
 	if (get_magic_quotes_gpc()) {
955 955
 		// undo the damage
956
-		$m = str_replace('\\\\','\\',$m);
957
-		$m = str_replace('\"','"',$m);
958
-		$m = str_replace('\\\'','\'',$m);
956
+		$m = str_replace('\\\\', '\\', $m);
957
+		$m = str_replace('\"', '"', $m);
958
+		$m = str_replace('\\\'', '\'', $m);
959 959
 	}
960 960
 	return $m;
961 961
 }
@@ -991,17 +991,17 @@  discard block
 block discarded – undo
991 991
         $args = func_get_args();
992 992
         $numArgs = func_num_args();
993 993
         
994
-        if ( $numArgs == 0) return false;
994
+        if ($numArgs == 0) return false;
995 995
         
996 996
         $mode = ADODB_OPT_LOW; 
997
-        $lastArg = $args[ $numArgs - 1];
998
-        if ( !is_string($lastArg)) {
997
+        $lastArg = $args[$numArgs - 1];
998
+        if (!is_string($lastArg)) {
999 999
             $mode = $lastArg;
1000
-            unset( $args[ $numArgs - 1]);
1000
+            unset($args[$numArgs - 1]);
1001 1001
         }
1002 1002
         
1003
-        foreach( $args as $table) {
1004
-            $this->optimizeTable( $table, $mode);
1003
+        foreach ($args as $table) {
1004
+            $this->optimizeTable($table, $mode);
1005 1005
         }
1006 1006
 	}
1007 1007
 
@@ -1017,9 +1017,9 @@  discard block
 block discarded – undo
1017 1017
      * @author Markus Staab
1018 1018
      * @return Returns <code>true</code> on success and <code>false</code> on error
1019 1019
      */
1020
-    function OptimizeTable( $table, $mode = ADODB_OPT_LOW) 
1020
+    function OptimizeTable($table, $mode = ADODB_OPT_LOW) 
1021 1021
     {
1022
-        ADOConnection::outp( sprintf( "<p>%s: '%s' not implemented for driver '%s'</p>", __CLASS__, __FUNCTION__, $this->conn->databaseType));
1022
+        ADOConnection::outp(sprintf("<p>%s: '%s' not implemented for driver '%s'</p>", __CLASS__, __FUNCTION__, $this->conn->databaseType));
1023 1023
         return false;
1024 1024
     }
1025 1025
     
@@ -1034,13 +1034,13 @@  discard block
 block discarded – undo
1034 1034
     function optimizeDatabase() 
1035 1035
     {
1036 1036
         $conn = $this->conn;
1037
-        if ( !$conn) return false;
1037
+        if (!$conn) return false;
1038 1038
         
1039
-        $tables = $conn->MetaTables( 'TABLES');
1040
-        if ( !$tables ) return false;
1039
+        $tables = $conn->MetaTables('TABLES');
1040
+        if (!$tables) return false;
1041 1041
 
1042
-        foreach( $tables as $table) {
1043
-            if ( !$this->optimizeTable( $table)) {
1042
+        foreach ($tables as $table) {
1043
+            if (!$this->optimizeTable($table)) {
1044 1044
                 return false;
1045 1045
             }
1046 1046
         }
Please login to merge, or discard this patch.
Braces   +524 added lines, -174 removed lines patch added patch discarded remove patch
@@ -16,7 +16,10 @@  discard block
 block discarded – undo
16 16
   
17 17
 */
18 18
 
19
-if (!defined(ADODB_DIR)) include_once(dirname(__FILE__).'/adodb.inc.php');
19
+if (!defined(ADODB_DIR))
20
+{
21
+	include_once(dirname(__FILE__).'/adodb.inc.php');
22
+}
20 23
 include_once(ADODB_DIR.'/tohtml.inc.php');
21 24
 
22 25
 define( 'ADODB_OPT_HIGH', 2);
@@ -26,11 +29,14 @@  discard block
 block discarded – undo
26 29
 function adodb_getmem()
27 30
 {
28 31
 	if (function_exists('memory_get_usage'))
29
-		return (integer) ((memory_get_usage()+512)/1024);
32
+	{
33
+			return (integer) ((memory_get_usage()+512)/1024);
34
+	}
30 35
 	
31 36
 	$pid = getmypid();
32 37
 	
33
-	if ( strncmp(strtoupper(PHP_OS),'WIN',3)==0) {
38
+	if ( strncmp(strtoupper(PHP_OS),'WIN',3)==0)
39
+	{
34 40
 		$output = array();
35 41
 	
36 42
 		exec('tasklist /FI "PID eq ' . $pid. '" /FO LIST', $output); 
@@ -39,10 +45,16 @@  discard block
 block discarded – undo
39 45
 	
40 46
 	/* Hopefully UNIX */
41 47
 	exec("ps --pid $pid --no-headers -o%mem,size", $output);
42
-	if (sizeof($output) == 0) return 0;
48
+	if (sizeof($output) == 0)
49
+	{
50
+		return 0;
51
+	}
43 52
 	
44 53
 	$memarr = explode(' ',$output[0]);
45
-	if (sizeof($memarr)>=2) return (integer) $memarr[1];
54
+	if (sizeof($memarr)>=2)
55
+	{
56
+		return (integer) $memarr[1];
57
+	}
46 58
 	
47 59
 	return 0;
48 60
 }
@@ -71,7 +83,8 @@  discard block
 block discarded – undo
71 83
 	$rs =& $conn->Execute($sql,$inputarr);
72 84
 	$t1 = microtime();
73 85
 
74
-	if (!empty($conn->_logsql)) {
86
+	if (!empty($conn->_logsql))
87
+	{
75 88
 		$conn->_logsql = false; // disable logsql error simulation
76 89
 		$dbT = $conn->databaseType;
77 90
 		
@@ -83,49 +96,78 @@  discard block
 block discarded – undo
83 96
 		
84 97
 		$time = $a1 - $a0;
85 98
 	
86
-		if (!$rs) {
99
+		if (!$rs)
100
+		{
87 101
 			$errM = $conn->ErrorMsg();
88 102
 			$errN = $conn->ErrorNo();
89 103
 			$conn->lastInsID = 0;
90 104
 			$tracer = substr('ERROR: '.htmlspecialchars($errM),0,250);
91
-		} else {
105
+		}
106
+		else
107
+		{
92 108
 			$tracer = '';
93 109
 			$errM = '';
94 110
 			$errN = 0;
95 111
 			$dbg = $conn->debug;
96 112
 			$conn->debug = false;
97
-			if (!is_object($rs) || $rs->dataProvider == 'empty') 
98
-				$conn->_affected = $conn->affected_rows(true);
113
+			if (!is_object($rs) || $rs->dataProvider == 'empty')
114
+			{
115
+							$conn->_affected = $conn->affected_rows(true);
116
+			}
99 117
 			$conn->lastInsID = @$conn->Insert_ID();
100 118
 			$conn->debug = $dbg;
101 119
 		}
102
-		if (isset($_SERVER['HTTP_HOST'])) {
120
+		if (isset($_SERVER['HTTP_HOST']))
121
+		{
103 122
 			$tracer .= '<br>'.$_SERVER['HTTP_HOST'];
104
-			if (isset($_SERVER['PHP_SELF'])) $tracer .= $_SERVER['PHP_SELF'];
105
-		} else 
106
-			if (isset($_SERVER['PHP_SELF'])) $tracer .= '<br>'.$_SERVER['PHP_SELF'];
123
+			if (isset($_SERVER['PHP_SELF']))
124
+			{
125
+				$tracer .= $_SERVER['PHP_SELF'];
126
+			}
127
+		}
128
+		else 
129
+			if (isset($_SERVER['PHP_SELF']))
130
+			{
131
+				$tracer .= '<br>'.$_SERVER['PHP_SELF'];
132
+			}
107 133
 		//$tracer .= (string) adodb_backtrace(false);
108 134
 		
109 135
 		$tracer = (string) substr($tracer,0,500);
110 136
 		
111
-		if (is_array($inputarr)) {
112
-			if (is_array(reset($inputarr))) $params = 'Array sizeof='.sizeof($inputarr);
113
-			else {
137
+		if (is_array($inputarr))
138
+		{
139
+			if (is_array(reset($inputarr)))
140
+			{
141
+				$params = 'Array sizeof='.sizeof($inputarr);
142
+			}
143
+			else
144
+			{
114 145
 				// Quote string parameters so we can see them in the
115 146
 				// performance stats. This helps spot disabled indexes.
116 147
 				$xar_params = $inputarr;
117
-				foreach ($xar_params as $xar_param_key => $xar_param) {
148
+				foreach ($xar_params as $xar_param_key => $xar_param)
149
+				{
118 150
 					if (gettype($xar_param) == 'string')
119
-					$xar_params[$xar_param_key] = '"' . $xar_param . '"';
151
+					{
152
+										$xar_params[$xar_param_key] = '"' . $xar_param . '"';
153
+					}
120 154
 				}
121 155
 				$params = implode(', ', $xar_params);
122
-				if (strlen($params) >= 3000) $params = substr($params, 0, 3000);
156
+				if (strlen($params) >= 3000)
157
+				{
158
+					$params = substr($params, 0, 3000);
159
+				}
123 160
 			}
124
-		} else {
161
+		}
162
+		else
163
+		{
125 164
 			$params = '';
126 165
 		}
127 166
 		
128
-		if (is_array($sql)) $sql = $sql[0];
167
+		if (is_array($sql))
168
+		{
169
+			$sql = $sql[0];
170
+		}
129 171
 		$arr = array('b'=>strlen($sql).'.'.crc32($sql),
130 172
 					'c'=>substr($sql,0,3900), 'd'=>$params,'e'=>$tracer,'f'=>adodb_round($time,6));
131 173
 		//var_dump($arr);
@@ -133,12 +175,21 @@  discard block
 block discarded – undo
133 175
 		$conn->debug = 0;
134 176
 		
135 177
 		$d = $conn->sysTimeStamp;
136
-		if (empty($d)) $d = date("'Y-m-d H:i:s'");
137
-		if ($conn->dataProvider == 'oci8' && $dbT != 'oci8po') {
178
+		if (empty($d))
179
+		{
180
+			$d = date("'Y-m-d H:i:s'");
181
+		}
182
+		if ($conn->dataProvider == 'oci8' && $dbT != 'oci8po')
183
+		{
138 184
 			$isql = "insert into $perf_table values($d,:b,:c,:d,:e,:f)";
139
-		} else if ($dbT == 'odbc_mssql' || $dbT == 'informix') {
185
+		}
186
+		else if ($dbT == 'odbc_mssql' || $dbT == 'informix')
187
+		{
140 188
 			$timer = $arr['f'];
141
-			if ($dbT == 'informix') $sql2 = substr($sql2,0,230);
189
+			if ($dbT == 'informix')
190
+			{
191
+				$sql2 = substr($sql2,0,230);
192
+			}
142 193
 
143 194
 			$sql1 = $conn->qstr($arr['b']);
144 195
 			$sql2 = $conn->qstr($arr['c']);
@@ -146,24 +197,38 @@  discard block
 block discarded – undo
146 197
 			$tracer = $conn->qstr($arr['e']);
147 198
 			
148 199
 			$isql = "insert into $perf_table (created,sql0,sql1,params,tracer,timer) values($d,$sql1,$sql2,$params,$tracer,$timer)";
149
-			if ($dbT == 'informix') $isql = str_replace(chr(10),' ',$isql);
200
+			if ($dbT == 'informix')
201
+			{
202
+				$isql = str_replace(chr(10),' ',$isql);
203
+			}
150 204
 			$arr = false;
151
-		} else {
205
+		}
206
+		else
207
+		{
152 208
 			$isql = "insert into $perf_table (created,sql0,sql1,params,tracer,timer) values( $d,?,?,?,?,?)";
153 209
 		}
154 210
 
155 211
 		$ok = $conn->Execute($isql,$arr);
156 212
 		$conn->debug = $saved;
157 213
 		
158
-		if ($ok) {
214
+		if ($ok)
215
+		{
159 216
 			$conn->_logsql = true; 
160
-		} else {
217
+		}
218
+		else
219
+		{
161 220
 			$err2 = $conn->ErrorMsg();
162 221
 			$conn->_logsql = true; // enable logsql error simulation
163 222
 			$perf =& NewPerfMonitor($conn);
164
-			if ($perf) {
165
-				if ($perf->CreateLogTable()) $ok = $conn->Execute($isql,$arr);
166
-			} else {
223
+			if ($perf)
224
+			{
225
+				if ($perf->CreateLogTable())
226
+				{
227
+					$ok = $conn->Execute($isql,$arr);
228
+				}
229
+			}
230
+			else
231
+			{
167 232
 				$ok = $conn->Execute("create table $perf_table (
168 233
 				created varchar(50),
169 234
 				sql0 varchar(250), 
@@ -172,7 +237,8 @@  discard block
 block discarded – undo
172 237
 				tracer varchar(500),
173 238
 				timer decimal(16,6))");
174 239
 			}
175
-			if (!$ok) {
240
+			if (!$ok)
241
+			{
176 242
 				ADOConnection::outp( "<p><b>LOGSQL Insert Failed</b>: $isql<br>$err2</p>");
177 243
 				$conn->_logsql = false;
178 244
 			}
@@ -199,7 +265,8 @@  discard block
 block discarded – undo
199 265
 2: description of the database parameter
200 266
 */
201 267
 
202
-class adodb_perf {
268
+class adodb_perf
269
+{
203 270
 	var $conn;
204 271
 	var $color = '#F0F0F0';
205 272
 	var $table = '<table border=1 bgcolor=white>';
@@ -218,8 +285,14 @@  discard block
 block discarded – undo
218 285
     {
219 286
         static $_table;
220 287
 
221
-        if (!empty($newtable))  $_table = $newtable;
222
-		if (empty($_table)) $_table = 'adodb_logsql';
288
+        if (!empty($newtable))
289
+        {
290
+        	$_table = $newtable;
291
+        }
292
+		if (empty($_table))
293
+		{
294
+			$_table = 'adodb_logsql';
295
+		}
223 296
         return $_table;
224 297
     }
225 298
 
@@ -242,15 +315,35 @@  discard block
 block discarded – undo
242 315
 */
243 316
 		// Algorithm is taken from
244 317
 		// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/example__obtaining_raw_performance_data.asp
245
-		if (strncmp(PHP_OS,'WIN',3)==0) {
246
-			if (PHP_VERSION == '5.0.0') return false;
247
-			if (PHP_VERSION == '5.0.1') return false;
248
-			if (PHP_VERSION == '5.0.2') return false;
249
-			if (PHP_VERSION == '5.0.3') return false;
250
-			if (PHP_VERSION == '4.3.10') return false; # see http://bugs.php.net/bug.php?id=31737
318
+		if (strncmp(PHP_OS,'WIN',3)==0)
319
+		{
320
+			if (PHP_VERSION == '5.0.0')
321
+			{
322
+				return false;
323
+			}
324
+			if (PHP_VERSION == '5.0.1')
325
+			{
326
+				return false;
327
+			}
328
+			if (PHP_VERSION == '5.0.2')
329
+			{
330
+				return false;
331
+			}
332
+			if (PHP_VERSION == '5.0.3')
333
+			{
334
+				return false;
335
+			}
336
+			if (PHP_VERSION == '4.3.10')
337
+			{
338
+				return false;
339
+			}
340
+			# see http://bugs.php.net/bug.php?id=31737
251 341
 			
252 342
 			@$c = new COM("WinMgmts:{impersonationLevel=impersonate}!Win32_PerfRawData_PerfOS_Processor.Name='_Total'");
253
-			if (!$c) return false;
343
+			if (!$c)
344
+			{
345
+				return false;
346
+			}
254 347
 			
255 348
 			$info[0] = $c->PercentProcessorTime;
256 349
 			$info[1] = 0;
@@ -262,18 +355,30 @@  discard block
 block discarded – undo
262 355
 		
263 356
 		// Algorithm - Steve Blinch (BlitzAffe Online, http://www.blitzaffe.com)
264 357
 		$statfile = '/proc/stat';
265
-		if (!file_exists($statfile)) return false;
358
+		if (!file_exists($statfile))
359
+		{
360
+			return false;
361
+		}
266 362
 		
267 363
 		$fd = fopen($statfile,"r");
268
-		if (!$fd) return false;
364
+		if (!$fd)
365
+		{
366
+			return false;
367
+		}
269 368
 		
270 369
 		$statinfo = explode("\n",fgets($fd, 1024));
271 370
 		fclose($fd);
272
-		foreach($statinfo as $line) {
371
+		foreach($statinfo as $line)
372
+		{
273 373
 			$info = explode(" ",$line);
274
-			if($info[0]=="cpu") {
374
+			if($info[0]=="cpu")
375
+			{
275 376
 				array_shift($info);  // pop off "cpu"
276
-				if(!$info[0]) array_shift($info); // pop off blank space (if any)
377
+				if(!$info[0])
378
+				{
379
+					array_shift($info);
380
+				}
381
+				// pop off blank space (if any)
277 382
 				return $info;
278 383
 			}
279 384
 		}
@@ -318,9 +423,13 @@  discard block
 block discarded – undo
318 423
 	function CPULoad()
319 424
 	{
320 425
 		$info = $this->_CPULoad();
321
-		if (!$info) return false;
426
+		if (!$info)
427
+		{
428
+			return false;
429
+		}
322 430
 			
323
-		if (empty($this->_lastLoad)) {
431
+		if (empty($this->_lastLoad))
432
+		{
324 433
 			sleep(1);
325 434
 			$this->_lastLoad = $info;
326 435
 			$info = $this->_CPULoad();
@@ -336,12 +445,21 @@  discard block
 block discarded – undo
336 445
 		
337 446
 		//printf("Delta - User: %f  Nice: %f  System: %f  Idle: %f<br>",$d_user,$d_nice,$d_system,$d_idle);
338 447
 
339
-		if (strncmp(PHP_OS,'WIN',3)==0) {
340
-			if ($d_idle < 1) $d_idle = 1;
448
+		if (strncmp(PHP_OS,'WIN',3)==0)
449
+		{
450
+			if ($d_idle < 1)
451
+			{
452
+				$d_idle = 1;
453
+			}
341 454
 			return 100*(1-$d_user/$d_idle);
342
-		}else {
455
+		}
456
+		else
457
+		{
343 458
 			$total=$d_user+$d_nice+$d_system+$d_idle;
344
-			if ($total<1) $total=1;
459
+			if ($total<1)
460
+			{
461
+				$total=1;
462
+			}
345 463
 			return 100*($d_user+$d_nice+$d_system)/$total; 
346 464
 		}
347 465
 	}
@@ -355,7 +473,10 @@  discard block
 block discarded – undo
355 473
 		global $ADODB_FETCH_MODE;
356 474
 		$save = $ADODB_FETCH_MODE;
357 475
 		$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
358
-		if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false);
476
+		if ($this->conn->fetchMode !== false)
477
+		{
478
+			$savem = $this->conn->SetFetchMode(false);
479
+		}
359 480
 				
360 481
 		$sqlq = $this->conn->qstr($sql);
361 482
 		$arr = $this->conn->GetArray(
@@ -364,14 +485,19 @@  discard block
 block discarded – undo
364 485
 	group by tracer
365 486
 	order by 1 desc");
366 487
 		$s = '';
367
-		if ($arr) {
488
+		if ($arr)
489
+		{
368 490
 			$s .= '<h3>Scripts Affected</h3>';
369
-			foreach($arr as $k) {
491
+			foreach($arr as $k)
492
+			{
370 493
 				$s .= sprintf("%4d",$k[0]).' &nbsp; '.strip_tags($k[1]).'<br>';
371 494
 			}
372 495
 		}
373 496
 		
374
-		if (isset($savem)) $this->conn->SetFetchMode($savem);
497
+		if (isset($savem))
498
+		{
499
+			$this->conn->SetFetchMode($savem);
500
+		}
375 501
 		$ADODB_CACHE_MODE = $save;
376 502
 		$this->conn->fnExecute = $saveE;
377 503
 		return $s;
@@ -383,24 +509,30 @@  discard block
 block discarded – undo
383 509
 			actual sql.
384 510
 	*/
385 511
 	function Explain($sql,$partial=false)
386
-	{	
512
+	{
387 513
 		return false;
388 514
 	}
389 515
 	
390 516
 	function InvalidSQL($numsql = 10)
391 517
 	{
392 518
 	
393
-		if (isset($_GET['sql'])) return;
519
+		if (isset($_GET['sql']))
520
+		{
521
+			return;
522
+		}
394 523
 		$s = '<h3>Invalid SQL</h3>';
395 524
 		$saveE = $this->conn->fnExecute;
396 525
 		$this->conn->fnExecute = false;
397 526
         $perf_table = adodb_perf::table();
398 527
 		$rs =& $this->conn->SelectLimit("select distinct count(*),sql1,tracer as error_msg from $perf_table where tracer like 'ERROR:%' group by sql1,tracer order by 1 desc",$numsql);//,$numsql);
399 528
 		$this->conn->fnExecute = $saveE;
400
-		if ($rs) {
529
+		if ($rs)
530
+		{
401 531
 			$s .= rs2html($rs,false,false,false,false);
402
-		} else
403
-			return "<p>$this->helpurl. ".$this->conn->ErrorMsg()."</p>";
532
+		}
533
+		else {
534
+					return "<p>$this->helpurl. ".$this->conn->ErrorMsg()."</p>";
535
+		}
404 536
 		
405 537
 		return $s;
406 538
 	}
@@ -417,17 +549,24 @@  discard block
 block discarded – undo
417 549
 			$saveE = $this->conn->fnExecute;
418 550
 			$this->conn->fnExecute = false;
419 551
 			
420
-			if (isset($_GET['exps']) && isset($_GET['sql'])) {
552
+			if (isset($_GET['exps']) && isset($_GET['sql']))
553
+			{
421 554
 				$partial = !empty($_GET['part']);
422 555
 				echo "<a name=explain></a>".$this->Explain($_GET['sql'],$partial)."\n";
423 556
 			}
424 557
 			
425
-			if (isset($_GET['sql'])) return;
558
+			if (isset($_GET['sql']))
559
+			{
560
+				return;
561
+			}
426 562
 			$sql1 = $this->sql1;
427 563
 			
428 564
 			$save = $ADODB_FETCH_MODE;
429 565
 			$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
430
-			if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false);
566
+			if ($this->conn->fetchMode !== false)
567
+			{
568
+				$savem = $this->conn->SetFetchMode(false);
569
+			}
431 570
 			//$this->conn->debug=1;
432 571
 			$rs =& $this->conn->SelectLimit(
433 572
 			"select avg(timer) as avg_timer,$sql1,count(*),max(timer) as max_timer,min(timer) as min_timer
@@ -436,25 +575,34 @@  discard block
 block discarded – undo
436 575
 				and (tracer is null or tracer not like 'ERROR:%')
437 576
 				group by sql1
438 577
 				order by 1 desc",$numsql);
439
-			if (isset($savem)) $this->conn->SetFetchMode($savem);
578
+			if (isset($savem))
579
+			{
580
+				$this->conn->SetFetchMode($savem);
581
+			}
440 582
 			$ADODB_FETCH_MODE = $save;
441 583
 			$this->conn->fnExecute = $saveE;
442 584
 			
443
-			if (!$rs) return "<p>$this->helpurl. ".$this->conn->ErrorMsg()."</p>";
585
+			if (!$rs)
586
+			{
587
+				return "<p>$this->helpurl. ".$this->conn->ErrorMsg()."</p>";
588
+			}
444 589
 			$s = "<h3>Suspicious SQL</h3>
445 590
 <font size=1>The following SQL have high average execution times</font><br>
446 591
 <table border=1 bgcolor=white><tr><td><b>Avg Time</b><td><b>Count</b><td><b>SQL</b><td><b>Max</b><td><b>Min</b></tr>\n";
447 592
 			$max = $this->maxLength;
448
-			while (!$rs->EOF) {
593
+			while (!$rs->EOF)
594
+			{
449 595
 				$sql = $rs->fields[1];
450 596
 				$raw = urlencode($sql);
451
-				if (strlen($raw)>$max-100) {
597
+				if (strlen($raw)>$max-100)
598
+				{
452 599
 					$sql2 = substr($sql,0,$max-500);
453 600
 					$raw = urlencode($sql2).'&part='.crc32($sql);
454 601
 				}
455 602
 				$prefix = "<a target=sql".rand()." href=\"?hidem=1&exps=1&sql=".$raw."&x#explain\">";
456 603
 				$suffix = "</a>";
457
-				if ($this->explain == false || strlen($prefix)>$max) {
604
+				if ($this->explain == false || strlen($prefix)>$max)
605
+				{
458 606
 					$suffix = ' ... <i>String too long for GET parameter: '.strlen($prefix).'</i>';
459 607
 					$prefix = '';
460 608
 				}
@@ -496,17 +644,24 @@  discard block
 block discarded – undo
496 644
 			$saveE = $this->conn->fnExecute;
497 645
 			$this->conn->fnExecute = false;
498 646
 			
499
-			if (isset($_GET['expe']) && isset($_GET['sql'])) {
647
+			if (isset($_GET['expe']) && isset($_GET['sql']))
648
+			{
500 649
 				$partial = !empty($_GET['part']);
501 650
 				echo "<a name=explain></a>".$this->Explain($_GET['sql'],$partial)."\n";
502 651
 			}
503 652
 			
504
-			if (isset($_GET['sql'])) return;
653
+			if (isset($_GET['sql']))
654
+			{
655
+				return;
656
+			}
505 657
 			
506 658
 			$sql1 = $this->sql1;
507 659
 			$save = $ADODB_FETCH_MODE;
508 660
 			$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
509
-			if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false);
661
+			if ($this->conn->fetchMode !== false)
662
+			{
663
+				$savem = $this->conn->SetFetchMode(false);
664
+			}
510 665
 			
511 666
 			$rs =& $this->conn->SelectLimit(
512 667
 			"select sum(timer) as total,$sql1,count(*),max(timer) as max_timer,min(timer) as min_timer
@@ -516,24 +671,33 @@  discard block
 block discarded – undo
516 671
 				group by sql1
517 672
 				having count(*)>1
518 673
 				order by 1 desc",$numsql);
519
-			if (isset($savem)) $this->conn->SetFetchMode($savem);
674
+			if (isset($savem))
675
+			{
676
+				$this->conn->SetFetchMode($savem);
677
+			}
520 678
 			$this->conn->fnExecute = $saveE;
521 679
 			$ADODB_FETCH_MODE = $save;
522
-			if (!$rs) return "<p>$this->helpurl. ".$this->conn->ErrorMsg()."</p>";
680
+			if (!$rs)
681
+			{
682
+				return "<p>$this->helpurl. ".$this->conn->ErrorMsg()."</p>";
683
+			}
523 684
 			$s = "<h3>Expensive SQL</h3>
524 685
 <font size=1>Tuning the following SQL could reduce the server load substantially</font><br>
525 686
 <table border=1 bgcolor=white><tr><td><b>Load</b><td><b>Count</b><td><b>SQL</b><td><b>Max</b><td><b>Min</b></tr>\n";
526 687
 			$max = $this->maxLength;
527
-			while (!$rs->EOF) {
688
+			while (!$rs->EOF)
689
+			{
528 690
 				$sql = $rs->fields[1];
529 691
 				$raw = urlencode($sql);
530
-				if (strlen($raw)>$max-100) {
692
+				if (strlen($raw)>$max-100)
693
+				{
531 694
 					$sql2 = substr($sql,0,$max-500);
532 695
 					$raw = urlencode($sql2).'&part='.crc32($sql);
533 696
 				}
534 697
 				$prefix = "<a target=sqle".rand()." href=\"?hidem=1&expe=1&sql=".$raw."&x#explain\">";
535 698
 				$suffix = "</a>";
536
-				if($this->explain == false || strlen($prefix>$max)) {
699
+				if($this->explain == false || strlen($prefix>$max))
700
+				{
537 701
 					$prefix = '';
538 702
 					$suffix = '';
539 703
 				}
@@ -549,7 +713,10 @@  discard block
 block discarded – undo
549 713
 	*/
550 714
 	function DBParameter($param)
551 715
 	{
552
-		if (empty($this->settings[$param])) return false;
716
+		if (empty($this->settings[$param]))
717
+		{
718
+			return false;
719
+		}
553 720
 		$sql = $this->settings[$param][1];
554 721
 		return $this->_DBParameter($sql);
555 722
 	}
@@ -572,30 +739,53 @@  discard block
 block discarded – undo
572 739
 	function _DBParameter($sql)
573 740
 	{
574 741
 		$savelog = $this->conn->LogSQL(false);
575
-		if (is_array($sql)) {
742
+		if (is_array($sql))
743
+		{
576 744
 		global $ADODB_FETCH_MODE;
577 745
 		
578 746
 			$sql1 = $sql[0];
579 747
 			$key = $sql[1];
580
-			if (sizeof($sql)>2) $pos = $sql[2];
581
-			else $pos = 1;
582
-			if (sizeof($sql)>3) $coef = $sql[3];
583
-			else $coef = false;
748
+			if (sizeof($sql)>2)
749
+			{
750
+				$pos = $sql[2];
751
+			}
752
+			else {
753
+				$pos = 1;
754
+			}
755
+			if (sizeof($sql)>3)
756
+			{
757
+				$coef = $sql[3];
758
+			}
759
+			else {
760
+				$coef = false;
761
+			}
584 762
 			$ret = false;
585 763
 			$save = $ADODB_FETCH_MODE;
586 764
 			$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
587
-			if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false);
765
+			if ($this->conn->fetchMode !== false)
766
+			{
767
+				$savem = $this->conn->SetFetchMode(false);
768
+			}
588 769
 			
589 770
 			$rs = $this->conn->Execute($sql1);
590 771
 			
591
-			if (isset($savem)) $this->SetFetchMode($savem);
772
+			if (isset($savem))
773
+			{
774
+				$this->SetFetchMode($savem);
775
+			}
592 776
 			$ADODB_FETCH_MODE = $save;
593
-			if ($rs) {
594
-				while (!$rs->EOF) {
777
+			if ($rs)
778
+			{
779
+				while (!$rs->EOF)
780
+				{
595 781
 					$keyf = reset($rs->fields);
596
-					if (trim($keyf) == $key) {
782
+					if (trim($keyf) == $key)
783
+					{
597 784
 						$ret = $rs->fields[$pos];
598
-						if ($coef) $ret *= $coef;
785
+						if ($coef)
786
+						{
787
+							$ret *= $coef;
788
+						}
599 789
 						break;
600 790
 					}
601 791
 					$rs->MoveNext();
@@ -604,8 +794,11 @@  discard block
 block discarded – undo
604 794
 			}
605 795
 			$this->conn->LogSQL($savelog);
606 796
 			return $ret;
607
-		} else {
608
-			if (strncmp($sql,'=',1) == 0) {
797
+		}
798
+		else
799
+		{
800
+			if (strncmp($sql,'=',1) == 0)
801
+			{
609 802
 				$fn = substr($sql,1);
610 803
 				return $this->$fn();
611 804
 			}
@@ -622,9 +815,13 @@  discard block
 block discarded – undo
622 815
 	*/
623 816
 	function WarnCacheRatio($val)
624 817
 	{
625
-		if ($val < $this->warnRatio) 
626
-			 return '<font color=red><b>Cache ratio should be at least '.$this->warnRatio.'%</b></font>';
627
-		else return '';
818
+		if ($val < $this->warnRatio)
819
+		{
820
+					 return '<font color=red><b>Cache ratio should be at least '.$this->warnRatio.'%</b></font>';
821
+		}
822
+		else {
823
+			return '';
824
+		}
628 825
 	}
629 826
 	
630 827
 	/***********************************************************************************************/
@@ -639,54 +836,90 @@  discard block
 block discarded – undo
639 836
 	$conn = $this->conn;
640 837
 	
641 838
 	$app = $conn->host;
642
-	if ($conn->host && $conn->database) $app .= ', db=';
839
+	if ($conn->host && $conn->database)
840
+	{
841
+		$app .= ', db=';
842
+	}
643 843
 	$app .= $conn->database;
644 844
 	
645
-	if ($app) $app .= ', ';
845
+	if ($app)
846
+	{
847
+		$app .= ', ';
848
+	}
646 849
 	$savelog = $this->conn->LogSQL(false);	
647 850
 	$info = $conn->ServerInfo();
648
-	if (isset($_GET['clearsql'])) {
851
+	if (isset($_GET['clearsql']))
852
+	{
649 853
 		$this->conn->Execute("delete from $perf_table");
650 854
 	}
651 855
 	$this->conn->LogSQL($savelog);
652 856
 	
653 857
 	// magic quotes
654 858
 	
655
-	if (isset($_GET['sql']) && get_magic_quotes_gpc()) {
859
+	if (isset($_GET['sql']) && get_magic_quotes_gpc())
860
+	{
656 861
 		$_GET['sql'] = $_GET['sql'] = str_replace(array("\\'",'\"'),array("'",'"'),$_GET['sql']);
657 862
 	}
658 863
 	
659
-	if (!isset($_SESSION['ADODB_PERF_SQL'])) $nsql = $_SESSION['ADODB_PERF_SQL'] = 10;
660
-	else  $nsql = $_SESSION['ADODB_PERF_SQL'];
864
+	if (!isset($_SESSION['ADODB_PERF_SQL']))
865
+	{
866
+		$nsql = $_SESSION['ADODB_PERF_SQL'] = 10;
867
+	}
868
+	else {
869
+		$nsql = $_SESSION['ADODB_PERF_SQL'];
870
+	}
661 871
 	
662 872
 	$app .= $info['description'];
663 873
 	
664 874
 	
665
-	if (isset($_GET['do'])) $do = $_GET['do'];
666
-	else if (isset($_POST['do'])) $do = $_POST['do'];
667
-	 else if (isset($_GET['sql'])) $do = 'viewsql';
668
-	 else $do = 'stats';
875
+	if (isset($_GET['do']))
876
+	{
877
+		$do = $_GET['do'];
878
+	}
879
+	else if (isset($_POST['do']))
880
+	{
881
+		$do = $_POST['do'];
882
+	}
883
+	 else if (isset($_GET['sql']))
884
+	 {
885
+	 	$do = 'viewsql';
886
+	 }
887
+	 else {
888
+	 	$do = 'stats';
889
+	 }
669 890
 	 
670
-	if (isset($_GET['nsql'])) {
671
-		if ($_GET['nsql'] > 0) $nsql = $_SESSION['ADODB_PERF_SQL'] = (integer) $_GET['nsql'];
891
+	if (isset($_GET['nsql']))
892
+	{
893
+		if ($_GET['nsql'] > 0)
894
+		{
895
+			$nsql = $_SESSION['ADODB_PERF_SQL'] = (integer) $_GET['nsql'];
896
+		}
672 897
 	}
673 898
 	echo "<title>ADOdb Performance Monitor on $app</title><body bgcolor=white>";
674
-	if ($do == 'viewsql') $form = "<td><form># SQL:<input type=hidden value=viewsql name=do> <input type=text size=4 name=nsql value=$nsql><input type=submit value=Go></td></form>";
675
-	else $form = "<td>&nbsp;</td>";
899
+	if ($do == 'viewsql')
900
+	{
901
+		$form = "<td><form># SQL:<input type=hidden value=viewsql name=do> <input type=text size=4 name=nsql value=$nsql><input type=submit value=Go></td></form>";
902
+	}
903
+	else {
904
+		$form = "<td>&nbsp;</td>";
905
+	}
676 906
 	
677 907
 	$allowsql = !defined('ADODB_PERF_NO_RUN_SQL');
678 908
 	
679 909
 	if  (empty($_GET['hidem']))
680
-	echo "<table border=1 width=100% bgcolor=lightyellow><tr><td colspan=2>
910
+	{
911
+		echo "<table border=1 width=100% bgcolor=lightyellow><tr><td colspan=2>
681 912
 	<b><a href=http://adodb.sourceforge.net/?perf=1>ADOdb</a> Performance Monitor</b> <font size=1>for $app</font></tr><tr><td>
682 913
 	<a href=?do=stats><b>Performance Stats</b></a> &nbsp; <a href=?do=viewsql><b>View SQL</b></a>
683 914
 	 &nbsp; <a href=?do=tables><b>View Tables</b></a> &nbsp; <a href=?do=poll><b>Poll Stats</b></a>",
684 915
 	 $allowsql ? ' &nbsp; <a href=?do=dosql><b>Run SQL</b></a>' : '',
685 916
 	 "$form",
686 917
 	 "</tr></table>";
918
+	}
687 919
 
688 920
 	 
689
-	 	switch ($do) {
921
+	 	switch ($do)
922
+	 	{
690 923
 		default:
691 924
 		case 'stats':
692 925
 			echo $this->HealthCheck();
@@ -703,13 +936,18 @@  discard block
 block discarded – undo
703 936
 			break;
704 937
 		
705 938
 		case 'dosql':
706
-			if (!$allowsql) break;
939
+			if (!$allowsql)
940
+			{
941
+				break;
942
+			}
707 943
 			
708 944
 			$this->DoSQLForm();
709 945
 			break;
710 946
 		case 'viewsql':
711 947
 			if (empty($_GET['hidem']))
712
-				echo "&nbsp; <a href=\"?do=viewsql&clearsql=1\">Clear SQL Log</a><br>";
948
+			{
949
+							echo "&nbsp; <a href=\"?do=viewsql&clearsql=1\">Clear SQL Log</a><br>";
950
+			}
713 951
 			echo($this->SuspiciousSQL($nsql));
714 952
 			echo($this->ExpensiveSQL($nsql));
715 953
 			echo($this->InvalidSQL($nsql));
@@ -728,13 +966,17 @@  discard block
 block discarded – undo
728 966
 	{
729 967
 		$this->conn->fnExecute = false;
730 968
 		//$this->conn->debug=1;
731
-		if ($secs <= 1) $secs = 1;
969
+		if ($secs <= 1)
970
+		{
971
+			$secs = 1;
972
+		}
732 973
 		echo "Accumulating statistics, every $secs seconds...\n";flush();
733 974
 		$arro =& $this->PollParameters();
734 975
 		$cnt = 0;
735 976
 		set_time_limit(0);
736 977
 		sleep($secs);
737
-		while (1) {
978
+		while (1)
979
+		{
738 980
 
739 981
 			$arr =& $this->PollParameters();
740 982
 			
@@ -744,19 +986,28 @@  discard block
 block discarded – undo
744 986
 			$sess = sprintf('%5d',$arr[3]);
745 987
 			
746 988
 			$load = $this->CPULoad();
747
-			if ($load !== false) {
989
+			if ($load !== false)
990
+			{
748 991
 				$oslabel = 'WS-CPU%';
749 992
 				$osval = sprintf(" %2.1f  ",(float) $load);
750
-			}else {
993
+			}
994
+			else
995
+			{
751 996
 				$oslabel = '';
752 997
 				$osval = '';
753 998
 			}
754
-			if ($cnt % 10 == 0) echo " Time   ".$oslabel."   Hit%   Sess           Reads/s          Writes/s\n"; 
999
+			if ($cnt % 10 == 0)
1000
+			{
1001
+				echo " Time   ".$oslabel."   Hit%   Sess           Reads/s          Writes/s\n";
1002
+			}
755 1003
 			$cnt += 1;
756 1004
 			echo date('H:i:s').'  '.$osval."$hits  $sess $reads $writes\n";
757 1005
 			flush();
758 1006
 			
759
-			if (connection_aborted()) return;
1007
+			if (connection_aborted())
1008
+			{
1009
+				return;
1010
+			}
760 1011
 			
761 1012
 			sleep($secs);
762 1013
 			$arro = $arr;
@@ -779,66 +1030,113 @@  discard block
 block discarded – undo
779 1030
 	{
780 1031
 		$saveE = $this->conn->fnExecute;
781 1032
 		$this->conn->fnExecute = false;	
782
-		if ($cli) $html = '';
783
-		else $html = $this->table.'<tr><td colspan=3><h3>'.$this->conn->databaseType.'</h3></td></tr>'.$this->titles;
1033
+		if ($cli)
1034
+		{
1035
+			$html = '';
1036
+		}
1037
+		else {
1038
+			$html = $this->table.'<tr><td colspan=3><h3>'.$this->conn->databaseType.'</h3></td></tr>'.$this->titles;
1039
+		}
784 1040
 		
785 1041
 		$oldc = false;
786 1042
 		$bgc = '';
787
-		foreach($this->settings as $name => $arr) {
788
-			if ($arr === false) break;
1043
+		foreach($this->settings as $name => $arr)
1044
+		{
1045
+			if ($arr === false)
1046
+			{
1047
+				break;
1048
+			}
789 1049
 			
790
-			if (!is_string($name)) {
791
-				if ($cli) $html .= " -- $arr -- \n";
792
-				else $html .= "<tr bgcolor=$this->color><td colspan=3><i>$arr</i> &nbsp;</td></tr>";
1050
+			if (!is_string($name))
1051
+			{
1052
+				if ($cli)
1053
+				{
1054
+					$html .= " -- $arr -- \n";
1055
+				}
1056
+				else {
1057
+					$html .= "<tr bgcolor=$this->color><td colspan=3><i>$arr</i> &nbsp;</td></tr>";
1058
+				}
793 1059
 				continue;
794 1060
 			}
795 1061
 			
796
-			if (!is_array($arr)) break;
1062
+			if (!is_array($arr))
1063
+			{
1064
+				break;
1065
+			}
797 1066
 			$category = $arr[0];
798 1067
 			$how = $arr[1];
799
-			if (sizeof($arr)>2) $desc = $arr[2];
800
-			else $desc = ' &nbsp; ';
1068
+			if (sizeof($arr)>2)
1069
+			{
1070
+				$desc = $arr[2];
1071
+			}
1072
+			else {
1073
+				$desc = ' &nbsp; ';
1074
+			}
801 1075
 			
802 1076
 			
803
-			if ($category == 'HIDE') continue;
1077
+			if ($category == 'HIDE')
1078
+			{
1079
+				continue;
1080
+			}
804 1081
 			
805 1082
 			$val = $this->_DBParameter($how);
806 1083
 			
807
-			if ($desc && strncmp($desc,"=",1) === 0) {
1084
+			if ($desc && strncmp($desc,"=",1) === 0)
1085
+			{
808 1086
 				$fn = substr($desc,1);
809 1087
 				$desc = $this->$fn($val);
810 1088
 			}
811 1089
 			
812
-			if ($val === false) {
1090
+			if ($val === false)
1091
+			{
813 1092
 				$m = $this->conn->ErrorMsg();
814 1093
 				$val = "Error: $m"; 
815
-			} else {
816
-				if (is_numeric($val) && $val >= 256*1024) {
817
-					if ($val % (1024*1024) == 0) {
1094
+			}
1095
+			else
1096
+			{
1097
+				if (is_numeric($val) && $val >= 256*1024)
1098
+				{
1099
+					if ($val % (1024*1024) == 0)
1100
+					{
818 1101
 						$val /= (1024*1024);
819 1102
 						$val .= 'M';
820
-					} else if ($val % 1024 == 0) {
1103
+					}
1104
+					else if ($val % 1024 == 0)
1105
+					{
821 1106
 						$val /= 1024;
822 1107
 						$val .= 'K';
823 1108
 					}
824 1109
 					//$val = htmlspecialchars($val);
825 1110
 				}
826 1111
 			}
827
-			if ($category != $oldc) {
1112
+			if ($category != $oldc)
1113
+			{
828 1114
 				$oldc = $category;
829 1115
 				//$bgc = ($bgc == ' bgcolor='.$this->color) ? ' bgcolor=white' : ' bgcolor='.$this->color;
830 1116
 			}
831
-			if (strlen($desc)==0) $desc = '&nbsp;';
832
-			if (strlen($val)==0) $val = '&nbsp;';
833
-			if ($cli) {
1117
+			if (strlen($desc)==0)
1118
+			{
1119
+				$desc = '&nbsp;';
1120
+			}
1121
+			if (strlen($val)==0)
1122
+			{
1123
+				$val = '&nbsp;';
1124
+			}
1125
+			if ($cli)
1126
+			{
834 1127
 				$html  .= str_replace('&nbsp;','',sprintf($this->cliFormat,strip_tags($name),strip_tags($val),strip_tags($desc)));
835 1128
 				
836
-			}else {
1129
+			}
1130
+			else
1131
+			{
837 1132
 				$html .= "<tr$bgc><td>".$name.'</td><td>'.$val.'</td><td>'.$desc."</td></tr>\n";
838 1133
 			}
839 1134
 		}
840 1135
 		
841
-		if (!$cli) $html .= "</table>\n";
1136
+		if (!$cli)
1137
+		{
1138
+			$html .= "</table>\n";
1139
+		}
842 1140
 		$this->conn->fnExecute = $saveE;
843 1141
 			
844 1142
 		return $html;	
@@ -846,7 +1144,10 @@  discard block
 block discarded – undo
846 1144
 	
847 1145
 	function Tables($orderby='1')
848 1146
 	{
849
-		if (!$this->tablesSQL) return false;
1147
+		if (!$this->tablesSQL)
1148
+		{
1149
+			return false;
1150
+		}
850 1151
 		
851 1152
 		$savelog = $this->conn->LogSQL(false);
852 1153
 		$rs = $this->conn->Execute($this->tablesSQL.' order by '.$orderby);
@@ -858,7 +1159,10 @@  discard block
 block discarded – undo
858 1159
 
859 1160
 	function CreateLogTable()
860 1161
 	{
861
-		if (!$this->createTableSQL) return false;
1162
+		if (!$this->createTableSQL)
1163
+		{
1164
+			return false;
1165
+		}
862 1166
 		
863 1167
 		$savelog = $this->conn->LogSQL(false);
864 1168
 		$ok = $this->conn->Execute($this->createTableSQL);
@@ -873,15 +1177,25 @@  discard block
 block discarded – undo
873 1177
 		$PHP_SELF = $_SERVER['PHP_SELF'];
874 1178
 		$sql = isset($_REQUEST['sql']) ? $_REQUEST['sql'] : '';
875 1179
 
876
-		if (isset($_SESSION['phplens_sqlrows'])) $rows = $_SESSION['phplens_sqlrows'];
877
-		else $rows = 3;
1180
+		if (isset($_SESSION['phplens_sqlrows']))
1181
+		{
1182
+			$rows = $_SESSION['phplens_sqlrows'];
1183
+		}
1184
+		else {
1185
+			$rows = 3;
1186
+		}
878 1187
 		
879
-		if (isset($_REQUEST['SMALLER'])) {
1188
+		if (isset($_REQUEST['SMALLER']))
1189
+		{
880 1190
 			$rows /= 2;
881
-			if ($rows < 3) $rows = 3;
1191
+			if ($rows < 3)
1192
+			{
1193
+				$rows = 3;
1194
+			}
882 1195
 			$_SESSION['phplens_sqlrows'] = $rows;
883 1196
 		}
884
-		if (isset($_REQUEST['BIGGER'])) {
1197
+		if (isset($_REQUEST['BIGGER']))
1198
+		{
885 1199
 			$rows *= 2;
886 1200
 			$_SESSION['phplens_sqlrows'] = $rows;
887 1201
 		}
@@ -903,40 +1217,62 @@  discard block
 block discarded – undo
903 1217
 </form>
904 1218
 
905 1219
 <?php
906
-		if (!isset($_REQUEST['sql'])) return;
1220
+		if (!isset($_REQUEST['sql']))
1221
+		{
1222
+			return;
1223
+		}
907 1224
 		
908 1225
 		$sql = $this->undomq(trim($sql));
909
-		if (substr($sql,strlen($sql)-1) === ';') {
1226
+		if (substr($sql,strlen($sql)-1) === ';')
1227
+		{
910 1228
 			$print = true;
911 1229
 			$sqla = $this->SplitSQL($sql);
912
-		} else  {
1230
+		}
1231
+		else
1232
+		{
913 1233
 			$print = false;
914 1234
 			$sqla = array($sql);
915 1235
 		}
916
-		foreach($sqla as $sqls) {
1236
+		foreach($sqla as $sqls)
1237
+		{
917 1238
 
918
-			if (!$sqls) continue;
1239
+			if (!$sqls)
1240
+			{
1241
+				continue;
1242
+			}
919 1243
 			
920
-			if ($print) {
1244
+			if ($print)
1245
+			{
921 1246
 				print "<p>".htmlspecialchars($sqls)."</p>";
922 1247
 				flush();
923 1248
 			}
924 1249
 			$savelog = $this->conn->LogSQL(false);
925 1250
 			$rs = $this->conn->Execute($sqls);
926 1251
 			$this->conn->LogSQL($savelog);
927
-			if ($rs && is_object($rs) && !$rs->EOF) {
1252
+			if ($rs && is_object($rs) && !$rs->EOF)
1253
+			{
928 1254
 				rs2html($rs);
929
-				while ($rs->NextRecordSet()) {
1255
+				while ($rs->NextRecordSet())
1256
+				{
930 1257
 					print "<table width=98% bgcolor=#C0C0FF><tr><td>&nbsp;</td></tr></table>";
931 1258
 					rs2html($rs);
932 1259
 				}
933
-			} else {
1260
+			}
1261
+			else
1262
+			{
934 1263
 				$e1 = (integer) $this->conn->ErrorNo();
935 1264
 				$e2 = $this->conn->ErrorMsg();
936
-				if (($e1) || ($e2)) {
937
-					if (empty($e1)) $e1 = '-1'; // postgresql fix
1265
+				if (($e1) || ($e2))
1266
+				{
1267
+					if (empty($e1))
1268
+					{
1269
+						$e1 = '-1';
1270
+					}
1271
+					// postgresql fix
938 1272
 					print ' &nbsp; '.$e1.': '.$e2;
939
-				} else {
1273
+				}
1274
+				else
1275
+				{
940 1276
 					print "<p>No Recordset returned<br></p>";
941 1277
 				}
942 1278
 			}
@@ -949,9 +1285,10 @@  discard block
 block discarded – undo
949 1285
 		return $arr;
950 1286
 	}
951 1287
 	
952
-	function undomq(&$m) 
1288
+	function undomq(&$m)
1289
+	{
1290
+	if (get_magic_quotes_gpc())
953 1291
 	{
954
-	if (get_magic_quotes_gpc()) {
955 1292
 		// undo the damage
956 1293
 		$m = str_replace('\\\\','\\',$m);
957 1294
 		$m = str_replace('\"','"',$m);
@@ -991,16 +1328,21 @@  discard block
 block discarded – undo
991 1328
         $args = func_get_args();
992 1329
         $numArgs = func_num_args();
993 1330
         
994
-        if ( $numArgs == 0) return false;
1331
+        if ( $numArgs == 0)
1332
+        {
1333
+        	return false;
1334
+        }
995 1335
         
996 1336
         $mode = ADODB_OPT_LOW; 
997 1337
         $lastArg = $args[ $numArgs - 1];
998
-        if ( !is_string($lastArg)) {
1338
+        if ( !is_string($lastArg))
1339
+        {
999 1340
             $mode = $lastArg;
1000 1341
             unset( $args[ $numArgs - 1]);
1001 1342
         }
1002 1343
         
1003
-        foreach( $args as $table) {
1344
+        foreach( $args as $table)
1345
+        {
1004 1346
             $this->optimizeTable( $table, $mode);
1005 1347
         }
1006 1348
 	}
@@ -1017,7 +1359,7 @@  discard block
 block discarded – undo
1017 1359
      * @author Markus Staab
1018 1360
      * @return Returns <code>true</code> on success and <code>false</code> on error
1019 1361
      */
1020
-    function OptimizeTable( $table, $mode = ADODB_OPT_LOW) 
1362
+    function OptimizeTable( $table, $mode = ADODB_OPT_LOW)
1021 1363
     {
1022 1364
         ADOConnection::outp( sprintf( "<p>%s: '%s' not implemented for driver '%s'</p>", __CLASS__, __FUNCTION__, $this->conn->databaseType));
1023 1365
         return false;
@@ -1031,16 +1373,24 @@  discard block
 block discarded – undo
1031 1373
      * @author Markus Staab
1032 1374
      * @return Returns <code>true</code> on success and <code>false</code> on error
1033 1375
      */
1034
-    function optimizeDatabase() 
1376
+    function optimizeDatabase()
1035 1377
     {
1036 1378
         $conn = $this->conn;
1037
-        if ( !$conn) return false;
1379
+        if ( !$conn)
1380
+        {
1381
+        	return false;
1382
+        }
1038 1383
         
1039 1384
         $tables = $conn->MetaTables( 'TABLES');
1040
-        if ( !$tables ) return false;
1385
+        if ( !$tables )
1386
+        {
1387
+        	return false;
1388
+        }
1041 1389
 
1042
-        foreach( $tables as $table) {
1043
-            if ( !$this->optimizeTable( $table)) {
1390
+        foreach( $tables as $table)
1391
+        {
1392
+            if ( !$this->optimizeTable( $table))
1393
+            {
1044 1394
                 return false;
1045 1395
             }
1046 1396
         }
Please login to merge, or discard this patch.
phpgwapi/inc/adodb/adodb-time.inc.php 6 patches
Doc Comments   +7 added lines patch added patch discarded remove patch
@@ -376,6 +376,10 @@  discard block
 block discarded – undo
376 376
 
377 377
 if (!defined('ADODB_ALLOW_NEGATIVE_TS')) define('ADODB_NO_NEGATIVE_TS',1);
378 378
 
379
+/**
380
+ * @param integer $y1
381
+ * @param integer $m
382
+ */
379 383
 function adodb_date_test_date($y1,$m,$d=13)
380 384
 {
381 385
 	$t = adodb_mktime(0,0,0,$m,$d,$y1);
@@ -387,6 +391,9 @@  discard block
 block discarded – undo
387 391
 	return true;
388 392
 }
389 393
 
394
+/**
395
+ * @param string $fmt
396
+ */
390 397
 function adodb_date_test_strftime($fmt)
391 398
 {
392 399
 	$s1 = strftime($fmt);
Please login to merge, or discard this patch.
Indentation   +15 added lines, -29 removed lines patch added patch discarded remove patch
@@ -72,16 +72,12 @@  discard block
 block discarded – undo
72 72
 =============================================================================
73 73
 
74 74
 FUNCTION DESCRIPTIONS
75
-
76
-
77
-** FUNCTION adodb_getdate($date=false)
75
+ ** FUNCTION adodb_getdate($date=false)
78 76
 
79 77
 Returns an array containing date information, as getdate(), but supports
80 78
 dates greater than 1901 to 2038. The local date/time format is derived from a 
81 79
 heuristic the first time adodb_getdate is called. 
82
-	 
83
-	 
84
-** FUNCTION adodb_date($fmt, $timestamp = false)
80
+ ** FUNCTION adodb_date($fmt, $timestamp = false)
85 81
 
86 82
 Convert a timestamp to a formatted local date. If $timestamp is not defined, the
87 83
 current timestamp is used. Unlike the function date(), it supports dates
@@ -131,37 +127,27 @@  discard block
 block discarded – undo
131 127
 	W - ISO-8601 week number of year, weeks starting on Monday 
132 128
 
133 129
 </pre>
134
-
135
-
136
-** FUNCTION adodb_date2($fmt, $isoDateString = false)
130
+ ** FUNCTION adodb_date2($fmt, $isoDateString = false)
137 131
 Same as adodb_date, but 2nd parameter accepts iso date, eg.
138 132
 
139 133
   adodb_date2('d-M-Y H:i','2003-12-25 13:01:34');
140
-
141
-  
142
-** FUNCTION adodb_gmdate($fmt, $timestamp = false)
134
+ ** FUNCTION adodb_gmdate($fmt, $timestamp = false)
143 135
 
144 136
 Convert a timestamp to a formatted GMT date. If $timestamp is not defined, the
145 137
 current timestamp is used. Unlike the function date(), it supports dates
146 138
 outside the 1901 to 2038 range.
147
-
148
-
149
-** FUNCTION adodb_mktime($hr, $min, $sec[, $month, $day, $year])
139
+ ** FUNCTION adodb_mktime($hr, $min, $sec[, $month, $day, $year])
150 140
 
151 141
 Converts a local date to a unix timestamp.  Unlike the function mktime(), it supports
152 142
 dates outside the 1901 to 2038 range. All parameters are optional.
153
-
154
-
155
-** FUNCTION adodb_gmmktime($hr, $min, $sec [, $month, $day, $year])
143
+ ** FUNCTION adodb_gmmktime($hr, $min, $sec [, $month, $day, $year])
156 144
 
157 145
 Converts a gmt date to a unix timestamp.  Unlike the function gmmktime(), it supports
158 146
 dates outside the 1901 to 2038 range. Differs from gmmktime() in that all parameters
159 147
 are currently compulsory.
160
-
161
-** FUNCTION adodb_gmstrftime($fmt, $timestamp = false)
148
+ ** FUNCTION adodb_gmstrftime($fmt, $timestamp = false)
162 149
 Convert a timestamp to a formatted GMT date.
163
-
164
-** FUNCTION adodb_strftime($fmt, $timestamp = false)
150
+ ** FUNCTION adodb_strftime($fmt, $timestamp = false)
165 151
 
166 152
 Convert a timestamp to a formatted local date. Internally converts $fmt into 
167 153
 adodb_date format, then echo result.
@@ -578,17 +564,17 @@  discard block
 block discarded – undo
578 564
 		$greg_correction = 0;
579 565
 	
580 566
 	if($month > 2)
581
-	    $month -= 2;
567
+		$month -= 2;
582 568
 	else {
583
-	    $month += 10;
584
-	    $year--;
569
+		$month += 10;
570
+		$year--;
585 571
 	}
586 572
 	
587 573
 	$day =  floor((13 * $month - 1) / 5) +
588
-	        $day + ($year % 100) +
589
-	        floor(($year % 100) / 4) +
590
-	        floor(($year / 100) / 4) - 2 *
591
-	        floor($year / 100) + 77 + $greg_correction;
574
+			$day + ($year % 100) +
575
+			floor(($year % 100) / 4) +
576
+			floor(($year / 100) / 4) - 2 *
577
+			floor($year / 100) + 77 + $greg_correction;
592 578
 	
593 579
 	return $day - 7 * floor($day / 7);
594 580
 }
Please login to merge, or discard this patch.
Switch Indentation   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -958,105 +958,105 @@  discard block
 block discarded – undo
958 958
 	*/
959 959
 	for ($i=0; $i < $max; $i++) {
960 960
 		switch($fmt[$i]) {
961
-		case 'T': $dates .= date('T');break;
962
-		// YEAR
963
-		case 'L': $dates .= $arr['leap'] ? '1' : '0'; break;
964
-		case 'r': // Thu, 21 Dec 2000 16:01:07 +0200
961
+			case 'T': $dates .= date('T');break;
962
+			// YEAR
963
+			case 'L': $dates .= $arr['leap'] ? '1' : '0'; break;
964
+			case 'r': // Thu, 21 Dec 2000 16:01:07 +0200
965 965
 		
966
-			// 4.3.11 uses '04 Jun 2004'
967
-			// 4.3.8 uses  ' 4 Jun 2004'
968
-			$dates .= gmdate('D',$_day_power*(3+adodb_dow($year,$month,$day))).', '		
969
-				. ($day<10?'0'.$day:$day) . ' '.date('M',mktime(0,0,0,$month,2,1971)).' '.$year.' ';
966
+				// 4.3.11 uses '04 Jun 2004'
967
+				// 4.3.8 uses  ' 4 Jun 2004'
968
+				$dates .= gmdate('D',$_day_power*(3+adodb_dow($year,$month,$day))).', '		
969
+					. ($day<10?'0'.$day:$day) . ' '.date('M',mktime(0,0,0,$month,2,1971)).' '.$year.' ';
970 970
 			
971
-			if ($hour < 10) $dates .= '0'.$hour; else $dates .= $hour; 
971
+				if ($hour < 10) $dates .= '0'.$hour; else $dates .= $hour; 
972 972
 			
973
-			if ($min < 10) $dates .= ':0'.$min; else $dates .= ':'.$min;
973
+				if ($min < 10) $dates .= ':0'.$min; else $dates .= ':'.$min;
974 974
 			
975
-			if ($secs < 10) $dates .= ':0'.$secs; else $dates .= ':'.$secs;
975
+				if ($secs < 10) $dates .= ':0'.$secs; else $dates .= ':'.$secs;
976 976
 			
977
-			$gmt = adodb_get_gmt_diff();
978
-			$dates .= sprintf(' %s%04d',($gmt<0)?'+':'-',abs($gmt)/36); break;
977
+				$gmt = adodb_get_gmt_diff();
978
+				$dates .= sprintf(' %s%04d',($gmt<0)?'+':'-',abs($gmt)/36); break;
979 979
 				
980
-		case 'Y': $dates .= $year; break;
981
-		case 'y': $dates .= substr($year,strlen($year)-2,2); break;
982
-		// MONTH
983
-		case 'm': if ($month<10) $dates .= '0'.$month; else $dates .= $month; break;
984
-		case 'Q': $dates .= ($month+3)>>2; break;
985
-		case 'n': $dates .= $month; break;
986
-		case 'M': $dates .= date('M',mktime(0,0,0,$month,2,1971)); break;
987
-		case 'F': $dates .= date('F',mktime(0,0,0,$month,2,1971)); break;
988
-		// DAY
989
-		case 't': $dates .= $arr['ndays']; break;
990
-		case 'z': $dates .= $arr['yday']; break;
991
-		case 'w': $dates .= adodb_dow($year,$month,$day); break;
992
-		case 'l': $dates .= gmdate('l',$_day_power*(3+adodb_dow($year,$month,$day))); break;
993
-		case 'D': $dates .= gmdate('D',$_day_power*(3+adodb_dow($year,$month,$day))); break;
994
-		case 'j': $dates .= $day; break;
995
-		case 'd': if ($day<10) $dates .= '0'.$day; else $dates .= $day; break;
996
-		case 'S': 
997
-			$d10 = $day % 10;
998
-			if ($d10 == 1) $dates .= 'st';
999
-			else if ($d10 == 2 && $day != 12) $dates .= 'nd';
1000
-			else if ($d10 == 3) $dates .= 'rd';
1001
-			else $dates .= 'th';
1002
-			break;
980
+			case 'Y': $dates .= $year; break;
981
+			case 'y': $dates .= substr($year,strlen($year)-2,2); break;
982
+			// MONTH
983
+			case 'm': if ($month<10) $dates .= '0'.$month; else $dates .= $month; break;
984
+			case 'Q': $dates .= ($month+3)>>2; break;
985
+			case 'n': $dates .= $month; break;
986
+			case 'M': $dates .= date('M',mktime(0,0,0,$month,2,1971)); break;
987
+			case 'F': $dates .= date('F',mktime(0,0,0,$month,2,1971)); break;
988
+			// DAY
989
+			case 't': $dates .= $arr['ndays']; break;
990
+			case 'z': $dates .= $arr['yday']; break;
991
+			case 'w': $dates .= adodb_dow($year,$month,$day); break;
992
+			case 'l': $dates .= gmdate('l',$_day_power*(3+adodb_dow($year,$month,$day))); break;
993
+			case 'D': $dates .= gmdate('D',$_day_power*(3+adodb_dow($year,$month,$day))); break;
994
+			case 'j': $dates .= $day; break;
995
+			case 'd': if ($day<10) $dates .= '0'.$day; else $dates .= $day; break;
996
+			case 'S': 
997
+				$d10 = $day % 10;
998
+				if ($d10 == 1) $dates .= 'st';
999
+				else if ($d10 == 2 && $day != 12) $dates .= 'nd';
1000
+				else if ($d10 == 3) $dates .= 'rd';
1001
+				else $dates .= 'th';
1002
+				break;
1003 1003
 			
1004
-		// HOUR
1005
-		case 'Z':
1006
-			$dates .= ($is_gmt) ? 0 : -adodb_get_gmt_diff(); break;
1007
-		case 'O': 
1008
-			$gmt = ($is_gmt) ? 0 : adodb_get_gmt_diff();
1009
-			$dates .= sprintf('%s%04d',($gmt<0)?'+':'-',abs($gmt)/36); break;
1004
+			// HOUR
1005
+			case 'Z':
1006
+				$dates .= ($is_gmt) ? 0 : -adodb_get_gmt_diff(); break;
1007
+			case 'O': 
1008
+				$gmt = ($is_gmt) ? 0 : adodb_get_gmt_diff();
1009
+				$dates .= sprintf('%s%04d',($gmt<0)?'+':'-',abs($gmt)/36); break;
1010 1010
 			
1011
-		case 'H': 
1012
-			if ($hour < 10) $dates .= '0'.$hour; 
1013
-			else $dates .= $hour; 
1014
-			break;
1015
-		case 'h': 
1016
-			if ($hour > 12) $hh = $hour - 12; 
1017
-			else {
1018
-				if ($hour == 0) $hh = '12'; 
1019
-				else $hh = $hour;
1020
-			}
1011
+			case 'H': 
1012
+				if ($hour < 10) $dates .= '0'.$hour; 
1013
+				else $dates .= $hour; 
1014
+				break;
1015
+			case 'h': 
1016
+				if ($hour > 12) $hh = $hour - 12; 
1017
+				else {
1018
+					if ($hour == 0) $hh = '12'; 
1019
+					else $hh = $hour;
1020
+				}
1021 1021
 			
1022
-			if ($hh < 10) $dates .= '0'.$hh;
1023
-			else $dates .= $hh;
1024
-			break;
1022
+				if ($hh < 10) $dates .= '0'.$hh;
1023
+				else $dates .= $hh;
1024
+				break;
1025 1025
 			
1026
-		case 'G': 
1027
-			$dates .= $hour;
1028
-			break;
1026
+			case 'G': 
1027
+				$dates .= $hour;
1028
+				break;
1029 1029
 			
1030
-		case 'g':
1031
-			if ($hour > 12) $hh = $hour - 12; 
1032
-			else {
1033
-				if ($hour == 0) $hh = '12'; 
1034
-				else $hh = $hour; 
1035
-			}
1036
-			$dates .= $hh;
1037
-			break;
1038
-		// MINUTES
1039
-		case 'i': if ($min < 10) $dates .= '0'.$min; else $dates .= $min; break;
1040
-		// SECONDS
1041
-		case 'U': $dates .= $d; break;
1042
-		case 's': if ($secs < 10) $dates .= '0'.$secs; else $dates .= $secs; break;
1043
-		// AM/PM
1044
-		// Note 00:00 to 11:59 is AM, while 12:00 to 23:59 is PM
1045
-		case 'a':
1046
-			if ($hour>=12) $dates .= 'pm';
1047
-			else $dates .= 'am';
1048
-			break;
1049
-		case 'A':
1050
-			if ($hour>=12) $dates .= 'PM';
1051
-			else $dates .= 'AM';
1052
-			break;
1053
-		default:
1054
-			$dates .= $fmt[$i]; break;
1055
-		// ESCAPE
1056
-		case "\\": 
1057
-			$i++;
1058
-			if ($i < $max) $dates .= $fmt[$i];
1059
-			break;
1030
+			case 'g':
1031
+				if ($hour > 12) $hh = $hour - 12; 
1032
+				else {
1033
+					if ($hour == 0) $hh = '12'; 
1034
+					else $hh = $hour; 
1035
+				}
1036
+				$dates .= $hh;
1037
+				break;
1038
+			// MINUTES
1039
+			case 'i': if ($min < 10) $dates .= '0'.$min; else $dates .= $min; break;
1040
+			// SECONDS
1041
+			case 'U': $dates .= $d; break;
1042
+			case 's': if ($secs < 10) $dates .= '0'.$secs; else $dates .= $secs; break;
1043
+			// AM/PM
1044
+			// Note 00:00 to 11:59 is AM, while 12:00 to 23:59 is PM
1045
+			case 'a':
1046
+				if ($hour>=12) $dates .= 'pm';
1047
+				else $dates .= 'am';
1048
+				break;
1049
+			case 'A':
1050
+				if ($hour>=12) $dates .= 'PM';
1051
+				else $dates .= 'AM';
1052
+				break;
1053
+			default:
1054
+				$dates .= $fmt[$i]; break;
1055
+			// ESCAPE
1056
+			case "\\": 
1057
+				$i++;
1058
+				if ($i < $max) $dates .= $fmt[$i];
1059
+				break;
1060 1060
 		}
1061 1061
 	}
1062 1062
 	return $dates;
@@ -1222,55 +1222,55 @@  discard block
 block discarded – undo
1222 1222
 		
1223 1223
 			$inpct = false;
1224 1224
 			switch($ch) {
1225
-			case '0':
1226
-			case '1':
1227
-			case '2':
1228
-			case '3':
1229
-			case '4':
1230
-			case '5':
1231
-			case '6':
1232
-			case '7':
1233
-			case '8':
1234
-			case '9':
1235
-			case 'E':
1236
-			case 'O':
1237
-				/* ignore format modifiers */
1238
-				$inpct = true; 
1239
-				break;
1225
+				case '0':
1226
+				case '1':
1227
+				case '2':
1228
+				case '3':
1229
+				case '4':
1230
+				case '5':
1231
+				case '6':
1232
+				case '7':
1233
+				case '8':
1234
+				case '9':
1235
+				case 'E':
1236
+				case 'O':
1237
+					/* ignore format modifiers */
1238
+					$inpct = true; 
1239
+					break;
1240 1240
 				
1241
-			case 'a': $fmtdate .= 'D'; break;
1242
-			case 'A': $fmtdate .= 'l'; break;
1243
-			case 'h':
1244
-			case 'b': $fmtdate .= 'M'; break;
1245
-			case 'B': $fmtdate .= 'F'; break;
1246
-			case 'c': $fmtdate .= $ADODB_DATE_LOCALE[0].$ADODB_DATE_LOCALE[1]; break;
1247
-			case 'C': $fmtdate .= '\C?'; break; // century
1248
-			case 'd': $fmtdate .= 'd'; break;
1249
-			case 'D': $fmtdate .= 'm/d/y'; break;
1250
-			case 'e': $fmtdate .= 'j'; break;
1251
-			case 'g': $fmtdate .= '\g?'; break; //?
1252
-			case 'G': $fmtdate .= '\G?'; break; //?
1253
-			case 'H': $fmtdate .= 'H'; break;
1254
-			case 'I': $fmtdate .= 'h'; break;
1255
-			case 'j': $fmtdate .= '?z'; $parsej = true; break; // wrong as j=1-based, z=0-basd
1256
-			case 'm': $fmtdate .= 'm'; break;
1257
-			case 'M': $fmtdate .= 'i'; break;
1258
-			case 'n': $fmtdate .= "\n"; break;
1259
-			case 'p': $fmtdate .= 'a'; break;
1260
-			case 'r': $fmtdate .= 'h:i:s a'; break;
1261
-			case 'R': $fmtdate .= 'H:i:s'; break;
1262
-			case 'S': $fmtdate .= 's'; break;
1263
-			case 't': $fmtdate .= "\t"; break;
1264
-			case 'T': $fmtdate .= 'H:i:s'; break;
1265
-			case 'u': $fmtdate .= '?u'; $parseu = true; break; // wrong strftime=1-based, date=0-basde
1266
-			case 'U': $fmtdate .= '?U'; $parseU = true; break;// wrong strftime=1-based, date=0-based
1267
-			case 'x': $fmtdate .= $ADODB_DATE_LOCALE[0]; break;
1268
-			case 'X': $fmtdate .= $ADODB_DATE_LOCALE[1]; break;
1269
-			case 'w': $fmtdate .= '?w'; $parseu = true; break; // wrong strftime=1-based, date=0-basde
1270
-			case 'W': $fmtdate .= '?W'; $parseU = true; break;// wrong strftime=1-based, date=0-based
1271
-			case 'y': $fmtdate .= 'y'; break;
1272
-			case 'Y': $fmtdate .= 'Y'; break;
1273
-			case 'Z': $fmtdate .= 'T'; break;
1241
+				case 'a': $fmtdate .= 'D'; break;
1242
+				case 'A': $fmtdate .= 'l'; break;
1243
+				case 'h':
1244
+				case 'b': $fmtdate .= 'M'; break;
1245
+				case 'B': $fmtdate .= 'F'; break;
1246
+				case 'c': $fmtdate .= $ADODB_DATE_LOCALE[0].$ADODB_DATE_LOCALE[1]; break;
1247
+				case 'C': $fmtdate .= '\C?'; break; // century
1248
+				case 'd': $fmtdate .= 'd'; break;
1249
+				case 'D': $fmtdate .= 'm/d/y'; break;
1250
+				case 'e': $fmtdate .= 'j'; break;
1251
+				case 'g': $fmtdate .= '\g?'; break; //?
1252
+				case 'G': $fmtdate .= '\G?'; break; //?
1253
+				case 'H': $fmtdate .= 'H'; break;
1254
+				case 'I': $fmtdate .= 'h'; break;
1255
+				case 'j': $fmtdate .= '?z'; $parsej = true; break; // wrong as j=1-based, z=0-basd
1256
+				case 'm': $fmtdate .= 'm'; break;
1257
+				case 'M': $fmtdate .= 'i'; break;
1258
+				case 'n': $fmtdate .= "\n"; break;
1259
+				case 'p': $fmtdate .= 'a'; break;
1260
+				case 'r': $fmtdate .= 'h:i:s a'; break;
1261
+				case 'R': $fmtdate .= 'H:i:s'; break;
1262
+				case 'S': $fmtdate .= 's'; break;
1263
+				case 't': $fmtdate .= "\t"; break;
1264
+				case 'T': $fmtdate .= 'H:i:s'; break;
1265
+				case 'u': $fmtdate .= '?u'; $parseu = true; break; // wrong strftime=1-based, date=0-basde
1266
+				case 'U': $fmtdate .= '?U'; $parseU = true; break;// wrong strftime=1-based, date=0-based
1267
+				case 'x': $fmtdate .= $ADODB_DATE_LOCALE[0]; break;
1268
+				case 'X': $fmtdate .= $ADODB_DATE_LOCALE[1]; break;
1269
+				case 'w': $fmtdate .= '?w'; $parseu = true; break; // wrong strftime=1-based, date=0-basde
1270
+				case 'W': $fmtdate .= '?W'; $parseU = true; break;// wrong strftime=1-based, date=0-based
1271
+				case 'y': $fmtdate .= 'y'; break;
1272
+				case 'Y': $fmtdate .= 'Y'; break;
1273
+				case 'Z': $fmtdate .= 'T'; break;
1274 1274
 			}
1275 1275
 		} else if (('A' <= ($ch) && ($ch) <= 'Z' ) || ('a' <= ($ch) && ($ch) <= 'z' ))
1276 1276
 			$fmtdate .= "\\".$ch;
Please login to merge, or discard this patch.
Spacing   +154 added lines, -155 removed lines patch added patch discarded remove patch
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 /*
360 360
 	Version Number
361 361
 */
362
-define('ADODB_DATE_VERSION',0.21);
362
+define('ADODB_DATE_VERSION', 0.21);
363 363
 
364 364
 /*
365 365
 	This code was originally for windows. But apparently this problem happens 
@@ -374,12 +374,12 @@  discard block
 block discarded – undo
374 374
 	 http://lists.debian.org/debian-glibc/2002/debian-glibc-200205/msg00010.html
375 375
 */
376 376
 
377
-if (!defined('ADODB_ALLOW_NEGATIVE_TS')) define('ADODB_NO_NEGATIVE_TS',1);
377
+if (!defined('ADODB_ALLOW_NEGATIVE_TS')) define('ADODB_NO_NEGATIVE_TS', 1);
378 378
 
379
-function adodb_date_test_date($y1,$m,$d=13)
379
+function adodb_date_test_date($y1, $m, $d = 13)
380 380
 {
381
-	$t = adodb_mktime(0,0,0,$m,$d,$y1);
382
-	$rez = adodb_date('Y-n-j H:i:s',$t);
381
+	$t = adodb_mktime(0, 0, 0, $m, $d, $y1);
382
+	$rez = adodb_date('Y-n-j H:i:s', $t);
383 383
 	if ("$y1-$m-$d 00:00:00" != $rez) {
384 384
 		print "<b>$y1 error, expected=$y1-$m-$d 00:00:00, adodb=$rez</b><br>";
385 385
 		return false;
@@ -410,55 +410,55 @@  discard block
 block discarded – undo
410 410
 	$fail = false;
411 411
 	
412 412
 	// This flag disables calling of PHP native functions, so we can properly test the code
413
-	if (!defined('ADODB_TEST_DATES')) define('ADODB_TEST_DATES',1);
413
+	if (!defined('ADODB_TEST_DATES')) define('ADODB_TEST_DATES', 1);
414 414
 	
415 415
 	adodb_date_test_strftime('%Y %m %x %X');
416 416
 	adodb_date_test_strftime("%A %d %B %Y");
417 417
 	adodb_date_test_strftime("%H %M S");
418 418
 	
419
-	$t = adodb_mktime(0,0,0);
420
-	if (!(adodb_date('Y-m-d') == date('Y-m-d'))) print 'Error in '.adodb_mktime(0,0,0).'<br>';
419
+	$t = adodb_mktime(0, 0, 0);
420
+	if (!(adodb_date('Y-m-d') == date('Y-m-d'))) print 'Error in '.adodb_mktime(0, 0, 0).'<br>';
421 421
 	
422
-	$t = adodb_mktime(0,0,0,6,1,2102);
423
-	if (!(adodb_date('Y-m-d',$t) == '2102-06-01')) print 'Error in '.adodb_date('Y-m-d',$t).'<br>';
422
+	$t = adodb_mktime(0, 0, 0, 6, 1, 2102);
423
+	if (!(adodb_date('Y-m-d', $t) == '2102-06-01')) print 'Error in '.adodb_date('Y-m-d', $t).'<br>';
424 424
 	
425
-	$t = adodb_mktime(0,0,0,2,1,2102);
426
-	if (!(adodb_date('Y-m-d',$t) == '2102-02-01')) print 'Error in '.adodb_date('Y-m-d',$t).'<br>';
425
+	$t = adodb_mktime(0, 0, 0, 2, 1, 2102);
426
+	if (!(adodb_date('Y-m-d', $t) == '2102-02-01')) print 'Error in '.adodb_date('Y-m-d', $t).'<br>';
427 427
 	
428 428
 	
429 429
 	print "<p>Testing gregorian <=> julian conversion<p>";
430
-	$t = adodb_mktime(0,0,0,10,11,1492);
430
+	$t = adodb_mktime(0, 0, 0, 10, 11, 1492);
431 431
 	//http://www.holidayorigins.com/html/columbus_day.html - Friday check
432
-	if (!(adodb_date('D Y-m-d',$t) == 'Fri 1492-10-11')) print 'Error in Columbus landing<br>';
432
+	if (!(adodb_date('D Y-m-d', $t) == 'Fri 1492-10-11')) print 'Error in Columbus landing<br>';
433 433
 	
434
-	$t = adodb_mktime(0,0,0,2,29,1500);
435
-	if (!(adodb_date('Y-m-d',$t) == '1500-02-29')) print 'Error in julian leap years<br>';
434
+	$t = adodb_mktime(0, 0, 0, 2, 29, 1500);
435
+	if (!(adodb_date('Y-m-d', $t) == '1500-02-29')) print 'Error in julian leap years<br>';
436 436
 	
437
-	$t = adodb_mktime(0,0,0,2,29,1700);
438
-	if (!(adodb_date('Y-m-d',$t) == '1700-03-01')) print 'Error in gregorian leap years<br>';
437
+	$t = adodb_mktime(0, 0, 0, 2, 29, 1700);
438
+	if (!(adodb_date('Y-m-d', $t) == '1700-03-01')) print 'Error in gregorian leap years<br>';
439 439
 	
440
-	print  adodb_mktime(0,0,0,10,4,1582).' ';
441
-	print adodb_mktime(0,0,0,10,15,1582);
442
-	$diff = (adodb_mktime(0,0,0,10,15,1582) - adodb_mktime(0,0,0,10,4,1582));
443
-	if ($diff != 3600*24) print " <b>Error in gregorian correction = ".($diff/3600/24)." days </b><br>";
440
+	print  adodb_mktime(0, 0, 0, 10, 4, 1582).' ';
441
+	print adodb_mktime(0, 0, 0, 10, 15, 1582);
442
+	$diff = (adodb_mktime(0, 0, 0, 10, 15, 1582) - adodb_mktime(0, 0, 0, 10, 4, 1582));
443
+	if ($diff != 3600 * 24) print " <b>Error in gregorian correction = ".($diff / 3600 / 24)." days </b><br>";
444 444
 		
445
-	print " 15 Oct 1582, Fri=".(adodb_dow(1582,10,15) == 5 ? 'Fri' : '<b>Error</b>')."<br>";
446
-	print " 4 Oct 1582, Thu=".(adodb_dow(1582,10,4) == 4 ? 'Thu' : '<b>Error</b>')."<br>";
445
+	print " 15 Oct 1582, Fri=".(adodb_dow(1582, 10, 15) == 5 ? 'Fri' : '<b>Error</b>')."<br>";
446
+	print " 4 Oct 1582, Thu=".(adodb_dow(1582, 10, 4) == 4 ? 'Thu' : '<b>Error</b>')."<br>";
447 447
 	
448 448
 	print "<p>Testing overflow<p>";
449 449
 	
450
-	$t = adodb_mktime(0,0,0,3,33,1965);
451
-	if (!(adodb_date('Y-m-d',$t) == '1965-04-02')) print 'Error in day overflow 1 <br>';
452
-	$t = adodb_mktime(0,0,0,4,33,1971);
453
-	if (!(adodb_date('Y-m-d',$t) == '1971-05-03')) print 'Error in day overflow 2 <br>';
454
-	$t = adodb_mktime(0,0,0,1,60,1965);
455
-	if (!(adodb_date('Y-m-d',$t) == '1965-03-01')) print 'Error in day overflow 3 '.adodb_date('Y-m-d',$t).' <br>';
456
-	$t = adodb_mktime(0,0,0,12,32,1965);
457
-	if (!(adodb_date('Y-m-d',$t) == '1966-01-01')) print 'Error in day overflow 4 '.adodb_date('Y-m-d',$t).' <br>';
458
-	$t = adodb_mktime(0,0,0,12,63,1965);
459
-	if (!(adodb_date('Y-m-d',$t) == '1966-02-01')) print 'Error in day overflow 5 '.adodb_date('Y-m-d',$t).' <br>';
460
-	$t = adodb_mktime(0,0,0,13,3,1965);
461
-	if (!(adodb_date('Y-m-d',$t) == '1966-01-03')) print 'Error in mth overflow 1 <br>';
450
+	$t = adodb_mktime(0, 0, 0, 3, 33, 1965);
451
+	if (!(adodb_date('Y-m-d', $t) == '1965-04-02')) print 'Error in day overflow 1 <br>';
452
+	$t = adodb_mktime(0, 0, 0, 4, 33, 1971);
453
+	if (!(adodb_date('Y-m-d', $t) == '1971-05-03')) print 'Error in day overflow 2 <br>';
454
+	$t = adodb_mktime(0, 0, 0, 1, 60, 1965);
455
+	if (!(adodb_date('Y-m-d', $t) == '1965-03-01')) print 'Error in day overflow 3 '.adodb_date('Y-m-d', $t).' <br>';
456
+	$t = adodb_mktime(0, 0, 0, 12, 32, 1965);
457
+	if (!(adodb_date('Y-m-d', $t) == '1966-01-01')) print 'Error in day overflow 4 '.adodb_date('Y-m-d', $t).' <br>';
458
+	$t = adodb_mktime(0, 0, 0, 12, 63, 1965);
459
+	if (!(adodb_date('Y-m-d', $t) == '1966-02-01')) print 'Error in day overflow 5 '.adodb_date('Y-m-d', $t).' <br>';
460
+	$t = adodb_mktime(0, 0, 0, 13, 3, 1965);
461
+	if (!(adodb_date('Y-m-d', $t) == '1966-01-03')) print 'Error in mth overflow 1 <br>';
462 462
 	
463 463
 	print "Testing 2-digit => 4-digit year conversion<p>";
464 464
 	if (adodb_year_digit_check(00) != 2000) print "Err 2-digit 2000<br>";
@@ -472,24 +472,24 @@  discard block
 block discarded – undo
472 472
 	// Test string formating
473 473
 	print "<p>Testing date formating</p>";
474 474
 	$fmt = '\d\a\t\e T Y-m-d H:i:s a A d D F g G h H i j l L m M n O \R\F\C822 r s t U w y Y z Z 2003';
475
-	$s1 = date($fmt,0);
476
-	$s2 = adodb_date($fmt,0);
475
+	$s1 = date($fmt, 0);
476
+	$s2 = adodb_date($fmt, 0);
477 477
 	if ($s1 != $s2) {
478 478
 		print " date() 0 failed<br>$s1<br>$s2<br>";
479 479
 	}
480 480
 	flush();
481
-	for ($i=100; --$i > 0; ) {
481
+	for ($i = 100; --$i > 0;) {
482 482
 
483
-		$ts = 3600.0*((rand()%60000)+(rand()%60000))+(rand()%60000);
484
-		$s1 = date($fmt,$ts);
485
-		$s2 = adodb_date($fmt,$ts);
483
+		$ts = 3600.0 * ((rand() % 60000) + (rand() % 60000)) + (rand() % 60000);
484
+		$s1 = date($fmt, $ts);
485
+		$s2 = adodb_date($fmt, $ts);
486 486
 		//print "$s1 <br>$s2 <p>";
487
-		$pos = strcmp($s1,$s2);
487
+		$pos = strcmp($s1, $s2);
488 488
 
489 489
 		if (($s1) != ($s2)) {
490
-			for ($j=0,$k=strlen($s1); $j < $k; $j++) {
490
+			for ($j = 0, $k = strlen($s1); $j < $k; $j++) {
491 491
 				if ($s1[$j] != $s2[$j]) {
492
-					print substr($s1,$j).' ';
492
+					print substr($s1, $j).' ';
493 493
 					break;
494 494
 				}
495 495
 			}
@@ -501,8 +501,8 @@  discard block
 block discarded – undo
501 501
 		
502 502
 		$a1 = getdate($ts);
503 503
 		$a2 = adodb_getdate($ts);
504
-		$rez = array_diff($a1,$a2);
505
-		if (sizeof($rez)>0) {
504
+		$rez = array_diff($a1, $a2);
505
+		if (sizeof($rez) > 0) {
506 506
 			print "<b>Error getdate() $ts</b><br>";
507 507
 				print_r($a1);
508 508
 			print "<br>";
@@ -514,36 +514,36 @@  discard block
 block discarded – undo
514 514
 	
515 515
 	// Test generation of dates outside 1901-2038
516 516
 	print "<p>Testing random dates between 100 and 4000</p>";
517
-	adodb_date_test_date(100,1);
518
-	for ($i=100; --$i >= 0;) {
519
-		$y1 = 100+rand(0,1970-100);
520
-		$m = rand(1,12);
521
-		adodb_date_test_date($y1,$m);
517
+	adodb_date_test_date(100, 1);
518
+	for ($i = 100; --$i >= 0;) {
519
+		$y1 = 100 + rand(0, 1970 - 100);
520
+		$m = rand(1, 12);
521
+		adodb_date_test_date($y1, $m);
522 522
 		
523
-		$y1 = 3000-rand(0,3000-1970);
524
-		adodb_date_test_date($y1,$m);
523
+		$y1 = 3000 - rand(0, 3000 - 1970);
524
+		adodb_date_test_date($y1, $m);
525 525
 	}
526 526
 	print '<p>';
527
-	$start = 1960+rand(0,10);
527
+	$start = 1960 + rand(0, 10);
528 528
 	$yrs = 12;
529
-	$i = 365.25*86400*($start-1970);
530
-	$offset = 36000+rand(10000,60000);
531
-	$max = 365*$yrs*86400;
529
+	$i = 365.25 * 86400 * ($start - 1970);
530
+	$offset = 36000 + rand(10000, 60000);
531
+	$max = 365 * $yrs * 86400;
532 532
 	$lastyear = 0;
533 533
 	
534 534
 	// we generate a timestamp, convert it to a date, and convert it back to a timestamp
535 535
 	// and check if the roundtrip broke the original timestamp value.
536
-	print "Testing $start to ".($start+$yrs).", or $max seconds, offset=$offset: ";
536
+	print "Testing $start to ".($start + $yrs).", or $max seconds, offset=$offset: ";
537 537
 	$cnt = 0;
538 538
 	for ($max += $i; $i < $max; $i += $offset) {
539
-		$ret = adodb_date('m,d,Y,H,i,s',$i);
540
-		$arr = explode(',',$ret);
539
+		$ret = adodb_date('m,d,Y,H,i,s', $i);
540
+		$arr = explode(',', $ret);
541 541
 		if ($lastyear != $arr[2]) {
542 542
 			$lastyear = $arr[2];
543 543
 			print " $lastyear ";
544 544
 			flush();
545 545
 		}
546
-		$newi = adodb_mktime($arr[3],$arr[4],$arr[5],$arr[0],$arr[1],$arr[2]);
546
+		$newi = adodb_mktime($arr[3], $arr[4], $arr[5], $arr[0], $arr[1], $arr[2]);
547 547
 		if ($i != $newi) {
548 548
 			print "Error at $i, adodb_mktime returned $newi ($ret)";
549 549
 			$fail = true;
@@ -577,14 +577,14 @@  discard block
 block discarded – undo
577 577
 	} else
578 578
 		$greg_correction = 0;
579 579
 	
580
-	if($month > 2)
580
+	if ($month > 2)
581 581
 	    $month -= 2;
582 582
 	else {
583 583
 	    $month += 10;
584 584
 	    $year--;
585 585
 	}
586 586
 	
587
-	$day =  floor((13 * $month - 1) / 5) +
587
+	$day = floor((13 * $month - 1) / 5) +
588 588
 	        $day + ($year % 100) +
589 589
 	        floor(($year % 100) / 4) +
590 590
 	        floor(($year / 100) / 4) - 2 *
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
 	if ($year % 400 == 0) {
606 606
 		return true;
607 607
 	// if gregorian calendar (>1582), century not-divisible by 400 is not leap
608
-	} else if ($year > 1582 && $year % 100 == 0 ) {
608
+	} else if ($year > 1582 && $year % 100 == 0) {
609 609
 		return false;
610 610
 	} 
611 611
 	
@@ -629,10 +629,10 @@  discard block
 block discarded – undo
629 629
 {
630 630
 	if ($y < 100) {
631 631
 	
632
-		$yr = (integer) date("Y");
633
-		$century = (integer) ($yr /100);
632
+		$yr = (integer)date("Y");
633
+		$century = (integer)($yr / 100);
634 634
 		
635
-		if ($yr%100 > 50) {
635
+		if ($yr % 100 > 50) {
636 636
 			$c1 = $century + 1;
637 637
 			$c0 = $century;
638 638
 		} else {
@@ -642,8 +642,8 @@  discard block
 block discarded – undo
642 642
 		$c1 *= 100;
643 643
 		// if 2-digit year is less than 30 years in future, set it to this century
644 644
 		// otherwise if more than 30 years in future, then we set 2-digit year to the prev century.
645
-		if (($y + $c1) < $yr+30) $y = $y + $c1;
646
-		else $y = $y + $c0*100;
645
+		if (($y + $c1) < $yr + 30) $y = $y + $c1;
646
+		else $y = $y + $c0 * 100;
647 647
 	}
648 648
 	return $y;
649 649
 }
@@ -656,14 +656,14 @@  discard block
 block discarded – undo
656 656
 static $TZ;
657 657
 	if (isset($TZ)) return $TZ;
658 658
 	
659
-	$TZ = mktime(0,0,0,1,2,1970) - gmmktime(0,0,0,1,2,1970);
659
+	$TZ = mktime(0, 0, 0, 1, 2, 1970) - gmmktime(0, 0, 0, 1, 2, 1970);
660 660
 	return $TZ;
661 661
 }
662 662
 
663 663
 /**
664 664
 	Returns an array with date info.
665 665
 */
666
-function adodb_getdate($d=false,$fast=false)
666
+function adodb_getdate($d = false, $fast = false)
667 667
 {
668 668
 	if ($d === false) return getdate();
669 669
 	if (!defined('ADODB_TEST_DATES')) {
@@ -700,20 +700,20 @@  discard block
 block discarded – undo
700 700
 	$fast flag, which if set to true, will return fewer array values,
701 701
 	and is much faster as it does not calculate dow, etc.
702 702
 */
703
-function _adodb_getdate($origd=false,$fast=false,$is_gmt=false)
703
+function _adodb_getdate($origd = false, $fast = false, $is_gmt = false)
704 704
 {
705 705
 static $YRS;
706 706
 
707
-	$d =  $origd - ($is_gmt ? 0 : adodb_get_gmt_diff());
707
+	$d = $origd - ($is_gmt ? 0 : adodb_get_gmt_diff());
708 708
 	
709 709
 	$_day_power = 86400;
710 710
 	$_hour_power = 3600;
711 711
 	$_min_power = 60;
712 712
 	
713
-	if ($d < -12219321600) $d -= 86400*10; // if 15 Oct 1582 or earlier, gregorian correction 
713
+	if ($d < -12219321600) $d -= 86400 * 10; // if 15 Oct 1582 or earlier, gregorian correction 
714 714
 	
715
-	$_month_table_normal = array("",31,28,31,30,31,30,31,31,30,31,30,31);
716
-	$_month_table_leaf = array("",31,29,31,30,31,30,31,31,30,31,30,31);
715
+	$_month_table_normal = array("", 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
716
+	$_month_table_leaf = array("", 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
717 717
 	
718 718
 	$d366 = $_day_power * 366;
719 719
 	$d365 = $_day_power * 365;
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
 		
786 786
 		$lastsecs = 0;
787 787
 		$lastyear = 1970;
788
-		foreach($YRS as $year => $secs) {
788
+		foreach ($YRS as $year => $secs) {
789 789
 			if ($d >= $secs) {
790 790
 				$a = $lastyear;
791 791
 				break;
@@ -816,7 +816,7 @@  discard block
 block discarded – undo
816 816
 		
817 817
 		$d = $lastd;
818 818
 		$mtab = ($leaf) ? $_month_table_leaf : $_month_table_normal;
819
-		for ($a = 13 ; --$a > 0;) {
819
+		for ($a = 13; --$a > 0;) {
820 820
 			$lastd = $d;
821 821
 			$d += $mtab[$a] * $_day_power;
822 822
 			if ($d >= 0) {
@@ -827,13 +827,13 @@  discard block
 block discarded – undo
827 827
 		}
828 828
 		
829 829
 		$d = $lastd;
830
-		$day = $ndays + ceil(($d+1) / ($_day_power));
830
+		$day = $ndays + ceil(($d + 1) / ($_day_power));
831 831
 
832
-		$d += ($ndays - $day+1)* $_day_power;
833
-		$hour = floor($d/$_hour_power);
832
+		$d += ($ndays - $day + 1) * $_day_power;
833
+		$hour = floor($d / $_hour_power);
834 834
 	
835 835
 	} else {
836
-		for ($a = 1970 ;; $a++) {
836
+		for ($a = 1970; ; $a++) {
837 837
 			$lastd = $d;
838 838
 			
839 839
 			if ($leaf = _adodb_is_leap_year($a)) $d -= $d366;
@@ -846,7 +846,7 @@  discard block
 block discarded – undo
846 846
 		$secsInYear = $lastd;
847 847
 		$d = $lastd;
848 848
 		$mtab = ($leaf) ? $_month_table_leaf : $_month_table_normal;
849
-		for ($a = 1 ; $a <= 12; $a++) {
849
+		for ($a = 1; $a <= 12; $a++) {
850 850
 			$lastd = $d;
851 851
 			$d -= $mtab[$a] * $_day_power;
852 852
 			if ($d < 0) {
@@ -856,13 +856,13 @@  discard block
 block discarded – undo
856 856
 			}
857 857
 		}
858 858
 		$d = $lastd;
859
-		$day = ceil(($d+1) / $_day_power);
860
-		$d = $d - ($day-1) * $_day_power;
861
-		$hour = floor($d /$_hour_power);
859
+		$day = ceil(($d + 1) / $_day_power);
860
+		$d = $d - ($day - 1) * $_day_power;
861
+		$hour = floor($d / $_hour_power);
862 862
 	}
863 863
 	
864 864
 	$d -= $hour * $_hour_power;
865
-	$min = floor($d/$_min_power);
865
+	$min = floor($d / $_min_power);
866 866
 	$secs = $d - $min * $_min_power;
867 867
 	if ($fast) {
868 868
 		return array(
@@ -872,14 +872,14 @@  discard block
 block discarded – undo
872 872
 		'mday' => $day,
873 873
 		'mon' => $month,
874 874
 		'year' => $year,
875
-		'yday' => floor($secsInYear/$_day_power),
875
+		'yday' => floor($secsInYear / $_day_power),
876 876
 		'leap' => $leaf,
877 877
 		'ndays' => $ndays
878 878
 		);
879 879
 	}
880 880
 	
881 881
 	
882
-	$dow = adodb_dow($year,$month,$day);
882
+	$dow = adodb_dow($year, $month, $day);
883 883
 
884 884
 	return array(
885 885
 		'seconds' => $secs,
@@ -889,55 +889,55 @@  discard block
 block discarded – undo
889 889
 		'wday' => $dow,
890 890
 		'mon' => $month,
891 891
 		'year' => $year,
892
-		'yday' => floor($secsInYear/$_day_power),
893
-		'weekday' => gmdate('l',$_day_power*(3+$dow)),
894
-		'month' => gmdate('F',mktime(0,0,0,$month,2,1971)),
892
+		'yday' => floor($secsInYear / $_day_power),
893
+		'weekday' => gmdate('l', $_day_power * (3 + $dow)),
894
+		'month' => gmdate('F', mktime(0, 0, 0, $month, 2, 1971)),
895 895
 		0 => $origd
896 896
 	);
897 897
 }
898 898
 
899
-function adodb_gmdate($fmt,$d=false)
899
+function adodb_gmdate($fmt, $d = false)
900 900
 {
901
-	return adodb_date($fmt,$d,true);
901
+	return adodb_date($fmt, $d, true);
902 902
 }
903 903
 
904 904
 // accepts unix timestamp and iso date format in $d
905
-function adodb_date2($fmt, $d=false, $is_gmt=false)
905
+function adodb_date2($fmt, $d = false, $is_gmt = false)
906 906
 {
907 907
 	if ($d !== false) {
908 908
 		if (!preg_match( 
909 909
 			"|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})[ -]?(([0-9]{1,2}):?([0-9]{1,2}):?([0-9\.]{1,4}))?|", 
910
-			($d), $rr)) return adodb_date($fmt,false,$is_gmt);
910
+			($d), $rr)) return adodb_date($fmt, false, $is_gmt);
911 911
 
912
-		if ($rr[1] <= 100 && $rr[2]<= 1) return adodb_date($fmt,false,$is_gmt);
912
+		if ($rr[1] <= 100 && $rr[2] <= 1) return adodb_date($fmt, false, $is_gmt);
913 913
 	
914 914
 		// h-m-s-MM-DD-YY
915
-		if (!isset($rr[5])) $d = adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]);
916
-		else $d = @adodb_mktime($rr[5],$rr[6],$rr[7],$rr[2],$rr[3],$rr[1]);
915
+		if (!isset($rr[5])) $d = adodb_mktime(0, 0, 0, $rr[2], $rr[3], $rr[1]);
916
+		else $d = @adodb_mktime($rr[5], $rr[6], $rr[7], $rr[2], $rr[3], $rr[1]);
917 917
 	}
918 918
 	
919
-	return adodb_date($fmt,$d,$is_gmt);
919
+	return adodb_date($fmt, $d, $is_gmt);
920 920
 }
921 921
 
922 922
 
923 923
 /**
924 924
 	Return formatted date based on timestamp $d
925 925
 */
926
-function adodb_date($fmt,$d=false,$is_gmt=false)
926
+function adodb_date($fmt, $d = false, $is_gmt = false)
927 927
 {
928 928
 static $daylight;
929 929
 
930
-	if ($d === false) return ($is_gmt)? @gmdate($fmt): @date($fmt);
930
+	if ($d === false) return ($is_gmt) ? @gmdate($fmt) : @date($fmt);
931 931
 	if (!defined('ADODB_TEST_DATES')) {
932 932
 		if ((abs($d) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range
933 933
 			if (!defined('ADODB_NO_NEGATIVE_TS') || $d >= 0) // if windows, must be +ve integer
934
-				return ($is_gmt)? @gmdate($fmt,$d): @date($fmt,$d);
934
+				return ($is_gmt) ? @gmdate($fmt, $d) : @date($fmt, $d);
935 935
 
936 936
 		}
937 937
 	}
938 938
 	$_day_power = 86400;
939 939
 	
940
-	$arr = _adodb_getdate($d,true,$is_gmt);
940
+	$arr = _adodb_getdate($d, true, $is_gmt);
941 941
 	
942 942
 	if (!isset($daylight)) $daylight = function_exists('adodb_daylight_sv');
943 943
 	if ($daylight) adodb_daylight_sv($arr, $is_gmt);
@@ -956,17 +956,17 @@  discard block
 block discarded – undo
956 956
 		at this point, we have the following integer vars to manipulate:
957 957
 		$year, $month, $day, $hour, $min, $secs
958 958
 	*/
959
-	for ($i=0; $i < $max; $i++) {
960
-		switch($fmt[$i]) {
961
-		case 'T': $dates .= date('T');break;
959
+	for ($i = 0; $i < $max; $i++) {
960
+		switch ($fmt[$i]) {
961
+		case 'T': $dates .= date('T'); break;
962 962
 		// YEAR
963 963
 		case 'L': $dates .= $arr['leap'] ? '1' : '0'; break;
964 964
 		case 'r': // Thu, 21 Dec 2000 16:01:07 +0200
965 965
 		
966 966
 			// 4.3.11 uses '04 Jun 2004'
967 967
 			// 4.3.8 uses  ' 4 Jun 2004'
968
-			$dates .= gmdate('D',$_day_power*(3+adodb_dow($year,$month,$day))).', '		
969
-				. ($day<10?'0'.$day:$day) . ' '.date('M',mktime(0,0,0,$month,2,1971)).' '.$year.' ';
968
+			$dates .= gmdate('D', $_day_power * (3 + adodb_dow($year, $month, $day))).', '		
969
+				. ($day < 10 ? '0'.$day : $day).' '.date('M', mktime(0, 0, 0, $month, 2, 1971)).' '.$year.' ';
970 970
 			
971 971
 			if ($hour < 10) $dates .= '0'.$hour; else $dates .= $hour; 
972 972
 			
@@ -975,24 +975,24 @@  discard block
 block discarded – undo
975 975
 			if ($secs < 10) $dates .= ':0'.$secs; else $dates .= ':'.$secs;
976 976
 			
977 977
 			$gmt = adodb_get_gmt_diff();
978
-			$dates .= sprintf(' %s%04d',($gmt<0)?'+':'-',abs($gmt)/36); break;
978
+			$dates .= sprintf(' %s%04d', ($gmt < 0) ? '+' : '-', abs($gmt) / 36); break;
979 979
 				
980 980
 		case 'Y': $dates .= $year; break;
981
-		case 'y': $dates .= substr($year,strlen($year)-2,2); break;
981
+		case 'y': $dates .= substr($year, strlen($year) - 2, 2); break;
982 982
 		// MONTH
983
-		case 'm': if ($month<10) $dates .= '0'.$month; else $dates .= $month; break;
984
-		case 'Q': $dates .= ($month+3)>>2; break;
983
+		case 'm': if ($month < 10) $dates .= '0'.$month; else $dates .= $month; break;
984
+		case 'Q': $dates .= ($month + 3) >> 2; break;
985 985
 		case 'n': $dates .= $month; break;
986
-		case 'M': $dates .= date('M',mktime(0,0,0,$month,2,1971)); break;
987
-		case 'F': $dates .= date('F',mktime(0,0,0,$month,2,1971)); break;
986
+		case 'M': $dates .= date('M', mktime(0, 0, 0, $month, 2, 1971)); break;
987
+		case 'F': $dates .= date('F', mktime(0, 0, 0, $month, 2, 1971)); break;
988 988
 		// DAY
989 989
 		case 't': $dates .= $arr['ndays']; break;
990 990
 		case 'z': $dates .= $arr['yday']; break;
991
-		case 'w': $dates .= adodb_dow($year,$month,$day); break;
992
-		case 'l': $dates .= gmdate('l',$_day_power*(3+adodb_dow($year,$month,$day))); break;
993
-		case 'D': $dates .= gmdate('D',$_day_power*(3+adodb_dow($year,$month,$day))); break;
991
+		case 'w': $dates .= adodb_dow($year, $month, $day); break;
992
+		case 'l': $dates .= gmdate('l', $_day_power * (3 + adodb_dow($year, $month, $day))); break;
993
+		case 'D': $dates .= gmdate('D', $_day_power * (3 + adodb_dow($year, $month, $day))); break;
994 994
 		case 'j': $dates .= $day; break;
995
-		case 'd': if ($day<10) $dates .= '0'.$day; else $dates .= $day; break;
995
+		case 'd': if ($day < 10) $dates .= '0'.$day; else $dates .= $day; break;
996 996
 		case 'S': 
997 997
 			$d10 = $day % 10;
998 998
 			if ($d10 == 1) $dates .= 'st';
@@ -1006,7 +1006,7 @@  discard block
 block discarded – undo
1006 1006
 			$dates .= ($is_gmt) ? 0 : -adodb_get_gmt_diff(); break;
1007 1007
 		case 'O': 
1008 1008
 			$gmt = ($is_gmt) ? 0 : adodb_get_gmt_diff();
1009
-			$dates .= sprintf('%s%04d',($gmt<0)?'+':'-',abs($gmt)/36); break;
1009
+			$dates .= sprintf('%s%04d', ($gmt < 0) ? '+' : '-', abs($gmt) / 36); break;
1010 1010
 			
1011 1011
 		case 'H': 
1012 1012
 			if ($hour < 10) $dates .= '0'.$hour; 
@@ -1043,11 +1043,11 @@  discard block
 block discarded – undo
1043 1043
 		// AM/PM
1044 1044
 		// Note 00:00 to 11:59 is AM, while 12:00 to 23:59 is PM
1045 1045
 		case 'a':
1046
-			if ($hour>=12) $dates .= 'pm';
1046
+			if ($hour >= 12) $dates .= 'pm';
1047 1047
 			else $dates .= 'am';
1048 1048
 			break;
1049 1049
 		case 'A':
1050
-			if ($hour>=12) $dates .= 'PM';
1050
+			if ($hour >= 12) $dates .= 'PM';
1051 1051
 			else $dates .= 'AM';
1052 1052
 			break;
1053 1053
 		default:
@@ -1066,9 +1066,9 @@  discard block
 block discarded – undo
1066 1066
 	Returns a timestamp given a GMT/UTC time. 
1067 1067
 	Note that $is_dst is not implemented and is ignored.
1068 1068
 */
1069
-function adodb_gmmktime($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_dst=false)
1069
+function adodb_gmmktime($hr, $min, $sec, $mon = false, $day = false, $year = false, $is_dst = false)
1070 1070
 {
1071
-	return adodb_mktime($hr,$min,$sec,$mon,$day,$year,$is_dst,true);
1071
+	return adodb_mktime($hr, $min, $sec, $mon, $day, $year, $is_dst, true);
1072 1072
 }
1073 1073
 
1074 1074
 /**
@@ -1077,12 +1077,12 @@  discard block
 block discarded – undo
1077 1077
 	
1078 1078
 	Not a very fast algorithm - O(n) operation. Could be optimized to O(1).
1079 1079
 */
1080
-function adodb_mktime($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_dst=false,$is_gmt=false) 
1080
+function adodb_mktime($hr, $min, $sec, $mon = false, $day = false, $year = false, $is_dst = false, $is_gmt = false) 
1081 1081
 {
1082 1082
 	if (!defined('ADODB_TEST_DATES')) {
1083 1083
 
1084 1084
 		if ($mon === false) {
1085
-			return $is_gmt? @gmmktime($hr,$min,$sec): @mktime($hr,$min,$sec);
1085
+			return $is_gmt ? @gmmktime($hr, $min, $sec) : @mktime($hr, $min, $sec);
1086 1086
 		}
1087 1087
 		
1088 1088
 		// for windows, we don't check 1970 because with timezone differences, 
@@ -1091,8 +1091,7 @@  discard block
 block discarded – undo
1091 1091
 			|| !defined('ADODB_NO_NEGATIVE_TS') && (1901 < $year && $year < 2038)
1092 1092
 			) {
1093 1093
 				return $is_gmt ?
1094
-					@gmmktime($hr,$min,$sec,$mon,$day,$year):
1095
-					@mktime($hr,$min,$sec,$mon,$day,$year);
1094
+					@gmmktime($hr, $min, $sec, $mon, $day, $year) : @mktime($hr, $min, $sec, $mon, $day, $year);
1096 1095
 			}
1097 1096
 	}
1098 1097
 	
@@ -1115,23 +1114,23 @@  discard block
 block discarded – undo
1115 1114
 	if ($mon > 12) {
1116 1115
 		$y = floor($mon / 12);
1117 1116
 		$year += $y;
1118
-		$mon -= $y*12;
1117
+		$mon -= $y * 12;
1119 1118
 	} else if ($mon < 1) {
1120
-		$y = ceil((1-$mon) / 12);
1119
+		$y = ceil((1 - $mon) / 12);
1121 1120
 		$year -= $y;
1122
-		$mon += $y*12;
1121
+		$mon += $y * 12;
1123 1122
 	}
1124 1123
 	
1125 1124
 	$_day_power = 86400;
1126 1125
 	$_hour_power = 3600;
1127 1126
 	$_min_power = 60;
1128 1127
 	
1129
-	$_month_table_normal = array("",31,28,31,30,31,30,31,31,30,31,30,31);
1130
-	$_month_table_leaf = array("",31,29,31,30,31,30,31,31,30,31,30,31);
1128
+	$_month_table_normal = array("", 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
1129
+	$_month_table_leaf = array("", 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
1131 1130
 	
1132 1131
 	$_total_date = 0;
1133 1132
 	if ($year >= 1970) {
1134
-		for ($a = 1970 ; $a <= $year; $a++) {
1133
+		for ($a = 1970; $a <= $year; $a++) {
1135 1134
 			$leaf = _adodb_is_leap_year($a);
1136 1135
 			if ($leaf == true) {
1137 1136
 				$loop_table = $_month_table_leaf;
@@ -1143,16 +1142,16 @@  discard block
 block discarded – undo
1143 1142
 			if ($a < $year) { 
1144 1143
 				$_total_date += $_add_date;
1145 1144
 			} else {
1146
-				for($b=1;$b<$mon;$b++) {
1145
+				for ($b = 1; $b < $mon; $b++) {
1147 1146
 					$_total_date += $loop_table[$b];
1148 1147
 				}
1149 1148
 			}
1150 1149
 		}
1151
-		$_total_date +=$day-1;
1150
+		$_total_date += $day - 1;
1152 1151
 		$ret = $_total_date * $_day_power + $hr * $_hour_power + $min * $_min_power + $sec + $gmt_different;
1153 1152
 	
1154 1153
 	} else {
1155
-		for ($a = 1969 ; $a >= $year; $a--) {
1154
+		for ($a = 1969; $a >= $year; $a--) {
1156 1155
 			$leaf = _adodb_is_leap_year($a);
1157 1156
 			if ($leaf == true) {
1158 1157
 				$loop_table = $_month_table_leaf;
@@ -1163,7 +1162,7 @@  discard block
 block discarded – undo
1163 1162
 			}
1164 1163
 			if ($a > $year) { $_total_date += $_add_date;
1165 1164
 			} else {
1166
-				for($b=12;$b>$mon;$b--) {
1165
+				for ($b = 12; $b > $mon; $b--) {
1167 1166
 					$_total_date += $loop_table[$b];
1168 1167
 				}
1169 1168
 			}
@@ -1172,45 +1171,45 @@  discard block
 block discarded – undo
1172 1171
 		
1173 1172
 		$_day_time = $hr * $_hour_power + $min * $_min_power + $sec;
1174 1173
 		$_day_time = $_day_power - $_day_time;
1175
-		$ret = -( $_total_date * $_day_power + $_day_time - $gmt_different);
1176
-		if ($ret < -12220185600) $ret += 10*86400; // if earlier than 5 Oct 1582 - gregorian correction
1174
+		$ret = -($_total_date * $_day_power + $_day_time - $gmt_different);
1175
+		if ($ret < -12220185600) $ret += 10 * 86400; // if earlier than 5 Oct 1582 - gregorian correction
1177 1176
 		else if ($ret < -12219321600) $ret = -12219321600; // if in limbo, reset to 15 Oct 1582.
1178 1177
 	} 
1179 1178
 	//print " dmy=$day/$mon/$year $hr:$min:$sec => " .$ret;
1180 1179
 	return $ret;
1181 1180
 }
1182 1181
 
1183
-function adodb_gmstrftime($fmt, $ts=false)
1182
+function adodb_gmstrftime($fmt, $ts = false)
1184 1183
 {
1185
-	return adodb_strftime($fmt,$ts,true);
1184
+	return adodb_strftime($fmt, $ts, true);
1186 1185
 }
1187 1186
 
1188 1187
 // hack - convert to adodb_date
1189
-function adodb_strftime($fmt, $ts=false,$is_gmt=false)
1188
+function adodb_strftime($fmt, $ts = false, $is_gmt = false)
1190 1189
 {
1191 1190
 global $ADODB_DATE_LOCALE;
1192 1191
 
1193 1192
 	if (!defined('ADODB_TEST_DATES')) {
1194 1193
 		if ((abs($ts) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range
1195 1194
 			if (!defined('ADODB_NO_NEGATIVE_TS') || $ts >= 0) // if windows, must be +ve integer
1196
-				return ($is_gmt)? @gmstrftime($fmt,$ts): @strftime($fmt,$ts);
1195
+				return ($is_gmt) ? @gmstrftime($fmt, $ts) : @strftime($fmt, $ts);
1197 1196
 
1198 1197
 		}
1199 1198
 	}
1200 1199
 	
1201 1200
 	if (empty($ADODB_DATE_LOCALE)) {
1202
-		$tstr = strtoupper(gmstrftime('%c',31366800)); // 30 Dec 1970, 1 am
1203
-		$sep = substr($tstr,2,1);
1204
-		$hasAM = strrpos($tstr,'M') !== false;
1201
+		$tstr = strtoupper(gmstrftime('%c', 31366800)); // 30 Dec 1970, 1 am
1202
+		$sep = substr($tstr, 2, 1);
1203
+		$hasAM = strrpos($tstr, 'M') !== false;
1205 1204
 		
1206 1205
 		$ADODB_DATE_LOCALE = array();
1207
-		$ADODB_DATE_LOCALE[] =  strncmp($tstr,'30',2) == 0 ? 'd'.$sep.'m'.$sep.'y' : 'm'.$sep.'d'.$sep.'y';	
1208
-		$ADODB_DATE_LOCALE[]  = ($hasAM) ? 'h:i:s a' : 'H:i:s';
1206
+		$ADODB_DATE_LOCALE[] = strncmp($tstr, '30', 2) == 0 ? 'd'.$sep.'m'.$sep.'y' : 'm'.$sep.'d'.$sep.'y';	
1207
+		$ADODB_DATE_LOCALE[] = ($hasAM) ? 'h:i:s a' : 'H:i:s';
1209 1208
 			
1210 1209
 	}
1211 1210
 	$inpct = false;
1212 1211
 	$fmtdate = '';
1213
-	for ($i=0,$max = strlen($fmt); $i < $max; $i++) {
1212
+	for ($i = 0, $max = strlen($fmt); $i < $max; $i++) {
1214 1213
 		$ch = $fmt[$i];
1215 1214
 		if ($ch == '%') {
1216 1215
 			if ($inpct) {
@@ -1221,7 +1220,7 @@  discard block
 block discarded – undo
1221 1220
 		} else if ($inpct) {
1222 1221
 		
1223 1222
 			$inpct = false;
1224
-			switch($ch) {
1223
+			switch ($ch) {
1225 1224
 			case '0':
1226 1225
 			case '1':
1227 1226
 			case '2':
@@ -1263,16 +1262,16 @@  discard block
 block discarded – undo
1263 1262
 			case 't': $fmtdate .= "\t"; break;
1264 1263
 			case 'T': $fmtdate .= 'H:i:s'; break;
1265 1264
 			case 'u': $fmtdate .= '?u'; $parseu = true; break; // wrong strftime=1-based, date=0-basde
1266
-			case 'U': $fmtdate .= '?U'; $parseU = true; break;// wrong strftime=1-based, date=0-based
1265
+			case 'U': $fmtdate .= '?U'; $parseU = true; break; // wrong strftime=1-based, date=0-based
1267 1266
 			case 'x': $fmtdate .= $ADODB_DATE_LOCALE[0]; break;
1268 1267
 			case 'X': $fmtdate .= $ADODB_DATE_LOCALE[1]; break;
1269 1268
 			case 'w': $fmtdate .= '?w'; $parseu = true; break; // wrong strftime=1-based, date=0-basde
1270
-			case 'W': $fmtdate .= '?W'; $parseU = true; break;// wrong strftime=1-based, date=0-based
1269
+			case 'W': $fmtdate .= '?W'; $parseU = true; break; // wrong strftime=1-based, date=0-based
1271 1270
 			case 'y': $fmtdate .= 'y'; break;
1272 1271
 			case 'Y': $fmtdate .= 'Y'; break;
1273 1272
 			case 'Z': $fmtdate .= 'T'; break;
1274 1273
 			}
1275
-		} else if (('A' <= ($ch) && ($ch) <= 'Z' ) || ('a' <= ($ch) && ($ch) <= 'z' ))
1274
+		} else if (('A' <= ($ch) && ($ch) <= 'Z') || ('a' <= ($ch) && ($ch) <= 'z'))
1276 1275
 			$fmtdate .= "\\".$ch;
1277 1276
 		else
1278 1277
 			$fmtdate .= $ch;
Please login to merge, or discard this patch.
Braces   +501 added lines, -160 removed lines patch added patch discarded remove patch
@@ -374,13 +374,17 @@  discard block
 block discarded – undo
374 374
 	 http://lists.debian.org/debian-glibc/2002/debian-glibc-200205/msg00010.html
375 375
 */
376 376
 
377
-if (!defined('ADODB_ALLOW_NEGATIVE_TS')) define('ADODB_NO_NEGATIVE_TS',1);
377
+if (!defined('ADODB_ALLOW_NEGATIVE_TS'))
378
+{
379
+	define('ADODB_NO_NEGATIVE_TS',1);
380
+}
378 381
 
379 382
 function adodb_date_test_date($y1,$m,$d=13)
380 383
 {
381 384
 	$t = adodb_mktime(0,0,0,$m,$d,$y1);
382 385
 	$rez = adodb_date('Y-n-j H:i:s',$t);
383
-	if ("$y1-$m-$d 00:00:00" != $rez) {
386
+	if ("$y1-$m-$d 00:00:00" != $rez)
387
+	{
384 388
 		print "<b>$y1 error, expected=$y1-$m-$d 00:00:00, adodb=$rez</b><br>";
385 389
 		return false;
386 390
 	}
@@ -392,7 +396,10 @@  discard block
 block discarded – undo
392 396
 	$s1 = strftime($fmt);
393 397
 	$s2 = adodb_strftime($fmt);
394 398
 	
395
-	if ($s1 == $s2) return true;
399
+	if ($s1 == $s2)
400
+	{
401
+		return true;
402
+	}
396 403
 	
397 404
 	echo "error for $fmt,  strftime=$s1, $adodb=$s2<br>";
398 405
 	return false;
@@ -410,37 +417,61 @@  discard block
 block discarded – undo
410 417
 	$fail = false;
411 418
 	
412 419
 	// This flag disables calling of PHP native functions, so we can properly test the code
413
-	if (!defined('ADODB_TEST_DATES')) define('ADODB_TEST_DATES',1);
420
+	if (!defined('ADODB_TEST_DATES'))
421
+	{
422
+		define('ADODB_TEST_DATES',1);
423
+	}
414 424
 	
415 425
 	adodb_date_test_strftime('%Y %m %x %X');
416 426
 	adodb_date_test_strftime("%A %d %B %Y");
417 427
 	adodb_date_test_strftime("%H %M S");
418 428
 	
419 429
 	$t = adodb_mktime(0,0,0);
420
-	if (!(adodb_date('Y-m-d') == date('Y-m-d'))) print 'Error in '.adodb_mktime(0,0,0).'<br>';
430
+	if (!(adodb_date('Y-m-d') == date('Y-m-d')))
431
+	{
432
+		print 'Error in '.adodb_mktime(0,0,0).'<br>';
433
+	}
421 434
 	
422 435
 	$t = adodb_mktime(0,0,0,6,1,2102);
423
-	if (!(adodb_date('Y-m-d',$t) == '2102-06-01')) print 'Error in '.adodb_date('Y-m-d',$t).'<br>';
436
+	if (!(adodb_date('Y-m-d',$t) == '2102-06-01'))
437
+	{
438
+		print 'Error in '.adodb_date('Y-m-d',$t).'<br>';
439
+	}
424 440
 	
425 441
 	$t = adodb_mktime(0,0,0,2,1,2102);
426
-	if (!(adodb_date('Y-m-d',$t) == '2102-02-01')) print 'Error in '.adodb_date('Y-m-d',$t).'<br>';
442
+	if (!(adodb_date('Y-m-d',$t) == '2102-02-01'))
443
+	{
444
+		print 'Error in '.adodb_date('Y-m-d',$t).'<br>';
445
+	}
427 446
 	
428 447
 	
429 448
 	print "<p>Testing gregorian <=> julian conversion<p>";
430 449
 	$t = adodb_mktime(0,0,0,10,11,1492);
431 450
 	//http://www.holidayorigins.com/html/columbus_day.html - Friday check
432
-	if (!(adodb_date('D Y-m-d',$t) == 'Fri 1492-10-11')) print 'Error in Columbus landing<br>';
451
+	if (!(adodb_date('D Y-m-d',$t) == 'Fri 1492-10-11'))
452
+	{
453
+		print 'Error in Columbus landing<br>';
454
+	}
433 455
 	
434 456
 	$t = adodb_mktime(0,0,0,2,29,1500);
435
-	if (!(adodb_date('Y-m-d',$t) == '1500-02-29')) print 'Error in julian leap years<br>';
457
+	if (!(adodb_date('Y-m-d',$t) == '1500-02-29'))
458
+	{
459
+		print 'Error in julian leap years<br>';
460
+	}
436 461
 	
437 462
 	$t = adodb_mktime(0,0,0,2,29,1700);
438
-	if (!(adodb_date('Y-m-d',$t) == '1700-03-01')) print 'Error in gregorian leap years<br>';
463
+	if (!(adodb_date('Y-m-d',$t) == '1700-03-01'))
464
+	{
465
+		print 'Error in gregorian leap years<br>';
466
+	}
439 467
 	
440 468
 	print  adodb_mktime(0,0,0,10,4,1582).' ';
441 469
 	print adodb_mktime(0,0,0,10,15,1582);
442 470
 	$diff = (adodb_mktime(0,0,0,10,15,1582) - adodb_mktime(0,0,0,10,4,1582));
443
-	if ($diff != 3600*24) print " <b>Error in gregorian correction = ".($diff/3600/24)." days </b><br>";
471
+	if ($diff != 3600*24)
472
+	{
473
+		print " <b>Error in gregorian correction = ".($diff/3600/24)." days </b><br>";
474
+	}
444 475
 		
445 476
 	print " 15 Oct 1582, Fri=".(adodb_dow(1582,10,15) == 5 ? 'Fri' : '<b>Error</b>')."<br>";
446 477
 	print " 4 Oct 1582, Thu=".(adodb_dow(1582,10,4) == 4 ? 'Thu' : '<b>Error</b>')."<br>";
@@ -448,37 +479,78 @@  discard block
 block discarded – undo
448 479
 	print "<p>Testing overflow<p>";
449 480
 	
450 481
 	$t = adodb_mktime(0,0,0,3,33,1965);
451
-	if (!(adodb_date('Y-m-d',$t) == '1965-04-02')) print 'Error in day overflow 1 <br>';
482
+	if (!(adodb_date('Y-m-d',$t) == '1965-04-02'))
483
+	{
484
+		print 'Error in day overflow 1 <br>';
485
+	}
452 486
 	$t = adodb_mktime(0,0,0,4,33,1971);
453
-	if (!(adodb_date('Y-m-d',$t) == '1971-05-03')) print 'Error in day overflow 2 <br>';
487
+	if (!(adodb_date('Y-m-d',$t) == '1971-05-03'))
488
+	{
489
+		print 'Error in day overflow 2 <br>';
490
+	}
454 491
 	$t = adodb_mktime(0,0,0,1,60,1965);
455
-	if (!(adodb_date('Y-m-d',$t) == '1965-03-01')) print 'Error in day overflow 3 '.adodb_date('Y-m-d',$t).' <br>';
492
+	if (!(adodb_date('Y-m-d',$t) == '1965-03-01'))
493
+	{
494
+		print 'Error in day overflow 3 '.adodb_date('Y-m-d',$t).' <br>';
495
+	}
456 496
 	$t = adodb_mktime(0,0,0,12,32,1965);
457
-	if (!(adodb_date('Y-m-d',$t) == '1966-01-01')) print 'Error in day overflow 4 '.adodb_date('Y-m-d',$t).' <br>';
497
+	if (!(adodb_date('Y-m-d',$t) == '1966-01-01'))
498
+	{
499
+		print 'Error in day overflow 4 '.adodb_date('Y-m-d',$t).' <br>';
500
+	}
458 501
 	$t = adodb_mktime(0,0,0,12,63,1965);
459
-	if (!(adodb_date('Y-m-d',$t) == '1966-02-01')) print 'Error in day overflow 5 '.adodb_date('Y-m-d',$t).' <br>';
502
+	if (!(adodb_date('Y-m-d',$t) == '1966-02-01'))
503
+	{
504
+		print 'Error in day overflow 5 '.adodb_date('Y-m-d',$t).' <br>';
505
+	}
460 506
 	$t = adodb_mktime(0,0,0,13,3,1965);
461
-	if (!(adodb_date('Y-m-d',$t) == '1966-01-03')) print 'Error in mth overflow 1 <br>';
507
+	if (!(adodb_date('Y-m-d',$t) == '1966-01-03'))
508
+	{
509
+		print 'Error in mth overflow 1 <br>';
510
+	}
462 511
 	
463 512
 	print "Testing 2-digit => 4-digit year conversion<p>";
464
-	if (adodb_year_digit_check(00) != 2000) print "Err 2-digit 2000<br>";
465
-	if (adodb_year_digit_check(10) != 2010) print "Err 2-digit 2010<br>";
466
-	if (adodb_year_digit_check(20) != 2020) print "Err 2-digit 2020<br>";
467
-	if (adodb_year_digit_check(30) != 2030) print "Err 2-digit 2030<br>";
468
-	if (adodb_year_digit_check(40) != 1940) print "Err 2-digit 1940<br>";
469
-	if (adodb_year_digit_check(50) != 1950) print "Err 2-digit 1950<br>";
470
-	if (adodb_year_digit_check(90) != 1990) print "Err 2-digit 1990<br>";
513
+	if (adodb_year_digit_check(00) != 2000)
514
+	{
515
+		print "Err 2-digit 2000<br>";
516
+	}
517
+	if (adodb_year_digit_check(10) != 2010)
518
+	{
519
+		print "Err 2-digit 2010<br>";
520
+	}
521
+	if (adodb_year_digit_check(20) != 2020)
522
+	{
523
+		print "Err 2-digit 2020<br>";
524
+	}
525
+	if (adodb_year_digit_check(30) != 2030)
526
+	{
527
+		print "Err 2-digit 2030<br>";
528
+	}
529
+	if (adodb_year_digit_check(40) != 1940)
530
+	{
531
+		print "Err 2-digit 1940<br>";
532
+	}
533
+	if (adodb_year_digit_check(50) != 1950)
534
+	{
535
+		print "Err 2-digit 1950<br>";
536
+	}
537
+	if (adodb_year_digit_check(90) != 1990)
538
+	{
539
+		print "Err 2-digit 1990<br>";
540
+	}
471 541
 	
472 542
 	// Test string formating
473 543
 	print "<p>Testing date formating</p>";
474 544
 	$fmt = '\d\a\t\e T Y-m-d H:i:s a A d D F g G h H i j l L m M n O \R\F\C822 r s t U w y Y z Z 2003';
475 545
 	$s1 = date($fmt,0);
476 546
 	$s2 = adodb_date($fmt,0);
477
-	if ($s1 != $s2) {
547
+	if ($s1 != $s2)
548
+	{
478 549
 		print " date() 0 failed<br>$s1<br>$s2<br>";
479 550
 	}
480 551
 	flush();
481
-	for ($i=100; --$i > 0; ) {
552
+	for ($i=100; --$i > 0; )
553
+	{
482 554
 
483 555
 		$ts = 3600.0*((rand()%60000)+(rand()%60000))+(rand()%60000);
484 556
 		$s1 = date($fmt,$ts);
@@ -486,9 +558,12 @@  discard block
 block discarded – undo
486 558
 		//print "$s1 <br>$s2 <p>";
487 559
 		$pos = strcmp($s1,$s2);
488 560
 
489
-		if (($s1) != ($s2)) {
490
-			for ($j=0,$k=strlen($s1); $j < $k; $j++) {
491
-				if ($s1[$j] != $s2[$j]) {
561
+		if (($s1) != ($s2))
562
+		{
563
+			for ($j=0,$k=strlen($s1); $j < $k; $j++)
564
+			{
565
+				if ($s1[$j] != $s2[$j])
566
+				{
492 567
 					print substr($s1,$j).' ';
493 568
 					break;
494 569
 				}
@@ -502,7 +577,8 @@  discard block
 block discarded – undo
502 577
 		$a1 = getdate($ts);
503 578
 		$a2 = adodb_getdate($ts);
504 579
 		$rez = array_diff($a1,$a2);
505
-		if (sizeof($rez)>0) {
580
+		if (sizeof($rez)>0)
581
+		{
506 582
 			print "<b>Error getdate() $ts</b><br>";
507 583
 				print_r($a1);
508 584
 			print "<br>";
@@ -515,7 +591,8 @@  discard block
 block discarded – undo
515 591
 	// Test generation of dates outside 1901-2038
516 592
 	print "<p>Testing random dates between 100 and 4000</p>";
517 593
 	adodb_date_test_date(100,1);
518
-	for ($i=100; --$i >= 0;) {
594
+	for ($i=100; --$i >= 0;)
595
+	{
519 596
 		$y1 = 100+rand(0,1970-100);
520 597
 		$m = rand(1,12);
521 598
 		adodb_date_test_date($y1,$m);
@@ -535,16 +612,19 @@  discard block
 block discarded – undo
535 612
 	// and check if the roundtrip broke the original timestamp value.
536 613
 	print "Testing $start to ".($start+$yrs).", or $max seconds, offset=$offset: ";
537 614
 	$cnt = 0;
538
-	for ($max += $i; $i < $max; $i += $offset) {
615
+	for ($max += $i; $i < $max; $i += $offset)
616
+	{
539 617
 		$ret = adodb_date('m,d,Y,H,i,s',$i);
540 618
 		$arr = explode(',',$ret);
541
-		if ($lastyear != $arr[2]) {
619
+		if ($lastyear != $arr[2])
620
+		{
542 621
 			$lastyear = $arr[2];
543 622
 			print " $lastyear ";
544 623
 			flush();
545 624
 		}
546 625
 		$newi = adodb_mktime($arr[3],$arr[4],$arr[5],$arr[0],$arr[1],$arr[2]);
547
-		if ($i != $newi) {
626
+		if ($i != $newi)
627
+		{
548 628
 			print "Error at $i, adodb_mktime returned $newi ($ret)";
549 629
 			$fail = true;
550 630
 			break;
@@ -552,9 +632,14 @@  discard block
 block discarded – undo
552 632
 		$cnt += 1;
553 633
 	}
554 634
 	echo "Tested $cnt dates<br>";
555
-	if (!$fail) print "<p>Passed !</p>";
556
-	else print "<p><b>Failed</b> :-(</p>";
557
-}
635
+	if (!$fail)
636
+	{
637
+		print "<p>Passed !</p>";
638
+	}
639
+	else {
640
+		print "<p><b>Failed</b> :-(</p>";
641
+	}
642
+	}
558 643
 
559 644
 /**
560 645
 	Returns day of week, 0 = Sunday,... 6=Saturday. 
@@ -569,17 +654,27 @@  discard block
 block discarded – undo
569 654
 
570 655
 Thursday, October 4, 1582 (Julian) was followed immediately by Friday, October 15, 1582 (Gregorian). 
571 656
 */
572
-	if ($year <= 1582) {
657
+	if ($year <= 1582)
658
+	{
573 659
 		if ($year < 1582 || 
574
-			($year == 1582 && ($month < 10 || ($month == 10 && $day < 15)))) $greg_correction = 3;
575
-		 else
660
+			($year == 1582 && ($month < 10 || ($month == 10 && $day < 15))))
661
+		{
662
+			$greg_correction = 3;
663
+		}
664
+		 else {
665
+		 			$greg_correction = 0;
666
+		 }
667
+	}
668
+	else {
576 669
 			$greg_correction = 0;
577
-	} else
578
-		$greg_correction = 0;
670
+	}
579 671
 	
580 672
 	if($month > 2)
581
-	    $month -= 2;
582
-	else {
673
+	{
674
+		    $month -= 2;
675
+	}
676
+	else
677
+	{
583 678
 	    $month += 10;
584 679
 	    $year--;
585 680
 	}
@@ -598,14 +693,20 @@  discard block
 block discarded – undo
598 693
  Checks for leap year, returns true if it is. No 2-digit year check. Also 
599 694
  handles julian calendar correctly.
600 695
 */
601
-function _adodb_is_leap_year($year) 
696
+function _adodb_is_leap_year($year)
602 697
 {
603
-	if ($year % 4 != 0) return false;
698
+	if ($year % 4 != 0)
699
+	{
700
+		return false;
701
+	}
604 702
 	
605
-	if ($year % 400 == 0) {
703
+	if ($year % 400 == 0)
704
+	{
606 705
 		return true;
607 706
 	// if gregorian calendar (>1582), century not-divisible by 400 is not leap
608
-	} else if ($year > 1582 && $year % 100 == 0 ) {
707
+	}
708
+	else if ($year > 1582 && $year % 100 == 0 )
709
+	{
609 710
 		return false;
610 711
 	} 
611 712
 	
@@ -616,7 +717,7 @@  discard block
 block discarded – undo
616 717
 /**
617 718
  checks for leap year, returns true if it is. Has 2-digit year check
618 719
 */
619
-function adodb_is_leap_year($year) 
720
+function adodb_is_leap_year($year)
620 721
 {
621 722
 	return  _adodb_is_leap_year(adodb_year_digit_check($year));
622 723
 }
@@ -625,25 +726,34 @@  discard block
 block discarded – undo
625 726
 	Fix 2-digit years. Works for any century.
626 727
  	Assumes that if 2-digit is more than 30 years in future, then previous century.
627 728
 */
628
-function adodb_year_digit_check($y) 
729
+function adodb_year_digit_check($y)
629 730
 {
630
-	if ($y < 100) {
731
+	if ($y < 100)
732
+	{
631 733
 	
632 734
 		$yr = (integer) date("Y");
633 735
 		$century = (integer) ($yr /100);
634 736
 		
635
-		if ($yr%100 > 50) {
737
+		if ($yr%100 > 50)
738
+		{
636 739
 			$c1 = $century + 1;
637 740
 			$c0 = $century;
638
-		} else {
741
+		}
742
+		else
743
+		{
639 744
 			$c1 = $century;
640 745
 			$c0 = $century - 1;
641 746
 		}
642 747
 		$c1 *= 100;
643 748
 		// if 2-digit year is less than 30 years in future, set it to this century
644 749
 		// otherwise if more than 30 years in future, then we set 2-digit year to the prev century.
645
-		if (($y + $c1) < $yr+30) $y = $y + $c1;
646
-		else $y = $y + $c0*100;
750
+		if (($y + $c1) < $yr+30)
751
+		{
752
+			$y = $y + $c1;
753
+		}
754
+		else {
755
+			$y = $y + $c0*100;
756
+		}
647 757
 	}
648 758
 	return $y;
649 759
 }
@@ -651,10 +761,13 @@  discard block
 block discarded – undo
651 761
 /**
652 762
  get local time zone offset from GMT
653 763
 */
654
-function adodb_get_gmt_diff() 
764
+function adodb_get_gmt_diff()
655 765
 {
656 766
 static $TZ;
657
-	if (isset($TZ)) return $TZ;
767
+	if (isset($TZ))
768
+	{
769
+		return $TZ;
770
+	}
658 771
 	
659 772
 	$TZ = mktime(0,0,0,1,2,1970) - gmmktime(0,0,0,1,2,1970);
660 773
 	return $TZ;
@@ -665,11 +778,20 @@  discard block
 block discarded – undo
665 778
 */
666 779
 function adodb_getdate($d=false,$fast=false)
667 780
 {
668
-	if ($d === false) return getdate();
669
-	if (!defined('ADODB_TEST_DATES')) {
670
-		if ((abs($d) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range
671
-			if (!defined('ADODB_NO_NEGATIVE_TS') || $d >= 0) // if windows, must be +ve integer
781
+	if ($d === false)
782
+	{
783
+		return getdate();
784
+	}
785
+	if (!defined('ADODB_TEST_DATES'))
786
+	{
787
+		if ((abs($d) <= 0x7FFFFFFF))
788
+		{
789
+// check if number in 32-bit signed range
790
+			if (!defined('ADODB_NO_NEGATIVE_TS') || $d >= 0)
791
+			{
792
+				// if windows, must be +ve integer
672 793
 				return @getdate($d);
794
+			}
673 795
 		}
674 796
 	}
675 797
 	return _adodb_getdate($d);
@@ -710,7 +832,11 @@  discard block
 block discarded – undo
710 832
 	$_hour_power = 3600;
711 833
 	$_min_power = 60;
712 834
 	
713
-	if ($d < -12219321600) $d -= 86400*10; // if 15 Oct 1582 or earlier, gregorian correction 
835
+	if ($d < -12219321600)
836
+	{
837
+		$d -= 86400*10;
838
+	}
839
+	// if 15 Oct 1582 or earlier, gregorian correction 
714 840
 	
715 841
 	$_month_table_normal = array("",31,28,31,30,31,30,31,31,30,31,30,31);
716 842
 	$_month_table_leaf = array("",31,29,31,30,31,30,31,31,30,31,30,31);
@@ -718,9 +844,12 @@  discard block
 block discarded – undo
718 844
 	$d366 = $_day_power * 366;
719 845
 	$d365 = $_day_power * 365;
720 846
 	
721
-	if ($d < 0) {
847
+	if ($d < 0)
848
+	{
722 849
 		
723
-		if (empty($YRS)) $YRS = array(
850
+		if (empty($YRS))
851
+		{
852
+			$YRS = array(
724 853
 			1970 => 0,
725 854
 			1960 => -315619200,
726 855
 			1950 => -631152000,
@@ -759,8 +888,12 @@  discard block
 block discarded – undo
759 888
 			1620 => -11044944000,
760 889
 			1610 => -11360476800,
761 890
 			1600 => -11676096000);
891
+		}
762 892
 
763
-		if ($is_gmt) $origd = $d;
893
+		if ($is_gmt)
894
+		{
895
+			$origd = $d;
896
+		}
764 897
 		// The valid range of a 32bit signed timestamp is typically from 
765 898
 		// Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT
766 899
 		//
@@ -785,8 +918,10 @@  discard block
 block discarded – undo
785 918
 		
786 919
 		$lastsecs = 0;
787 920
 		$lastyear = 1970;
788
-		foreach($YRS as $year => $secs) {
789
-			if ($d >= $secs) {
921
+		foreach($YRS as $year => $secs)
922
+		{
923
+			if ($d >= $secs)
924
+			{
790 925
 				$a = $lastyear;
791 926
 				break;
792 927
 			}
@@ -795,17 +930,27 @@  discard block
 block discarded – undo
795 930
 		}
796 931
 		
797 932
 		$d -= $lastsecs;
798
-		if (!isset($a)) $a = $lastyear;
933
+		if (!isset($a))
934
+		{
935
+			$a = $lastyear;
936
+		}
799 937
 		
800 938
 		//echo ' yr=',$a,' ', $d,'.';
801 939
 		
802
-		for (; --$a >= 0;) {
940
+		for (; --$a >= 0;)
941
+		{
803 942
 			$lastd = $d;
804 943
 			
805
-			if ($leaf = _adodb_is_leap_year($a)) $d += $d366;
806
-			else $d += $d365;
944
+			if ($leaf = _adodb_is_leap_year($a))
945
+			{
946
+				$d += $d366;
947
+			}
948
+			else {
949
+				$d += $d365;
950
+			}
807 951
 			
808
-			if ($d >= 0) {
952
+			if ($d >= 0)
953
+			{
809 954
 				$year = $a;
810 955
 				break;
811 956
 			}
@@ -816,10 +961,12 @@  discard block
 block discarded – undo
816 961
 		
817 962
 		$d = $lastd;
818 963
 		$mtab = ($leaf) ? $_month_table_leaf : $_month_table_normal;
819
-		for ($a = 13 ; --$a > 0;) {
964
+		for ($a = 13 ; --$a > 0;)
965
+		{
820 966
 			$lastd = $d;
821 967
 			$d += $mtab[$a] * $_day_power;
822
-			if ($d >= 0) {
968
+			if ($d >= 0)
969
+			{
823 970
 				$month = $a;
824 971
 				$ndays = $mtab[$a];
825 972
 				break;
@@ -832,13 +979,22 @@  discard block
 block discarded – undo
832 979
 		$d += ($ndays - $day+1)* $_day_power;
833 980
 		$hour = floor($d/$_hour_power);
834 981
 	
835
-	} else {
836
-		for ($a = 1970 ;; $a++) {
982
+	}
983
+	else
984
+	{
985
+		for ($a = 1970 ;; $a++)
986
+		{
837 987
 			$lastd = $d;
838 988
 			
839
-			if ($leaf = _adodb_is_leap_year($a)) $d -= $d366;
840
-			else $d -= $d365;
841
-			if ($d < 0) {
989
+			if ($leaf = _adodb_is_leap_year($a))
990
+			{
991
+				$d -= $d366;
992
+			}
993
+			else {
994
+				$d -= $d365;
995
+			}
996
+			if ($d < 0)
997
+			{
842 998
 				$year = $a;
843 999
 				break;
844 1000
 			}
@@ -846,10 +1002,12 @@  discard block
 block discarded – undo
846 1002
 		$secsInYear = $lastd;
847 1003
 		$d = $lastd;
848 1004
 		$mtab = ($leaf) ? $_month_table_leaf : $_month_table_normal;
849
-		for ($a = 1 ; $a <= 12; $a++) {
1005
+		for ($a = 1 ; $a <= 12; $a++)
1006
+		{
850 1007
 			$lastd = $d;
851 1008
 			$d -= $mtab[$a] * $_day_power;
852
-			if ($d < 0) {
1009
+			if ($d < 0)
1010
+			{
853 1011
 				$month = $a;
854 1012
 				$ndays = $mtab[$a];
855 1013
 				break;
@@ -864,7 +1022,8 @@  discard block
 block discarded – undo
864 1022
 	$d -= $hour * $_hour_power;
865 1023
 	$min = floor($d/$_min_power);
866 1024
 	$secs = $d - $min * $_min_power;
867
-	if ($fast) {
1025
+	if ($fast)
1026
+	{
868 1027
 		return array(
869 1028
 		'seconds' => $secs,
870 1029
 		'minutes' => $min,
@@ -904,16 +1063,28 @@  discard block
 block discarded – undo
904 1063
 // accepts unix timestamp and iso date format in $d
905 1064
 function adodb_date2($fmt, $d=false, $is_gmt=false)
906 1065
 {
907
-	if ($d !== false) {
1066
+	if ($d !== false)
1067
+	{
908 1068
 		if (!preg_match( 
909 1069
 			"|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})[ -]?(([0-9]{1,2}):?([0-9]{1,2}):?([0-9\.]{1,4}))?|", 
910
-			($d), $rr)) return adodb_date($fmt,false,$is_gmt);
1070
+			($d), $rr))
1071
+		{
1072
+			return adodb_date($fmt,false,$is_gmt);
1073
+		}
911 1074
 
912
-		if ($rr[1] <= 100 && $rr[2]<= 1) return adodb_date($fmt,false,$is_gmt);
1075
+		if ($rr[1] <= 100 && $rr[2]<= 1)
1076
+		{
1077
+			return adodb_date($fmt,false,$is_gmt);
1078
+		}
913 1079
 	
914 1080
 		// h-m-s-MM-DD-YY
915
-		if (!isset($rr[5])) $d = adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]);
916
-		else $d = @adodb_mktime($rr[5],$rr[6],$rr[7],$rr[2],$rr[3],$rr[1]);
1081
+		if (!isset($rr[5]))
1082
+		{
1083
+			$d = adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]);
1084
+		}
1085
+		else {
1086
+			$d = @adodb_mktime($rr[5],$rr[6],$rr[7],$rr[2],$rr[3],$rr[1]);
1087
+		}
917 1088
 	}
918 1089
 	
919 1090
 	return adodb_date($fmt,$d,$is_gmt);
@@ -927,11 +1098,20 @@  discard block
 block discarded – undo
927 1098
 {
928 1099
 static $daylight;
929 1100
 
930
-	if ($d === false) return ($is_gmt)? @gmdate($fmt): @date($fmt);
931
-	if (!defined('ADODB_TEST_DATES')) {
932
-		if ((abs($d) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range
933
-			if (!defined('ADODB_NO_NEGATIVE_TS') || $d >= 0) // if windows, must be +ve integer
1101
+	if ($d === false)
1102
+	{
1103
+		return ($is_gmt)? @gmdate($fmt): @date($fmt);
1104
+	}
1105
+	if (!defined('ADODB_TEST_DATES'))
1106
+	{
1107
+		if ((abs($d) <= 0x7FFFFFFF))
1108
+		{
1109
+// check if number in 32-bit signed range
1110
+			if (!defined('ADODB_NO_NEGATIVE_TS') || $d >= 0)
1111
+			{
1112
+				// if windows, must be +ve integer
934 1113
 				return ($is_gmt)? @gmdate($fmt,$d): @date($fmt,$d);
1114
+			}
935 1115
 
936 1116
 		}
937 1117
 	}
@@ -939,8 +1119,14 @@  discard block
 block discarded – undo
939 1119
 	
940 1120
 	$arr = _adodb_getdate($d,true,$is_gmt);
941 1121
 	
942
-	if (!isset($daylight)) $daylight = function_exists('adodb_daylight_sv');
943
-	if ($daylight) adodb_daylight_sv($arr, $is_gmt);
1122
+	if (!isset($daylight))
1123
+	{
1124
+		$daylight = function_exists('adodb_daylight_sv');
1125
+	}
1126
+	if ($daylight)
1127
+	{
1128
+		adodb_daylight_sv($arr, $is_gmt);
1129
+	}
944 1130
 	
945 1131
 	$year = $arr['year'];
946 1132
 	$month = $arr['mon'];
@@ -956,8 +1142,10 @@  discard block
 block discarded – undo
956 1142
 		at this point, we have the following integer vars to manipulate:
957 1143
 		$year, $month, $day, $hour, $min, $secs
958 1144
 	*/
959
-	for ($i=0; $i < $max; $i++) {
960
-		switch($fmt[$i]) {
1145
+	for ($i=0; $i < $max; $i++)
1146
+	{
1147
+		switch($fmt[$i])
1148
+		{
961 1149
 		case 'T': $dates .= date('T');break;
962 1150
 		// YEAR
963 1151
 		case 'L': $dates .= $arr['leap'] ? '1' : '0'; break;
@@ -968,11 +1156,29 @@  discard block
 block discarded – undo
968 1156
 			$dates .= gmdate('D',$_day_power*(3+adodb_dow($year,$month,$day))).', '		
969 1157
 				. ($day<10?'0'.$day:$day) . ' '.date('M',mktime(0,0,0,$month,2,1971)).' '.$year.' ';
970 1158
 			
971
-			if ($hour < 10) $dates .= '0'.$hour; else $dates .= $hour; 
1159
+			if ($hour < 10)
1160
+			{
1161
+				$dates .= '0'.$hour;
1162
+			}
1163
+			else {
1164
+				$dates .= $hour;
1165
+			}
972 1166
 			
973
-			if ($min < 10) $dates .= ':0'.$min; else $dates .= ':'.$min;
1167
+			if ($min < 10)
1168
+			{
1169
+				$dates .= ':0'.$min;
1170
+			}
1171
+			else {
1172
+				$dates .= ':'.$min;
1173
+			}
974 1174
 			
975
-			if ($secs < 10) $dates .= ':0'.$secs; else $dates .= ':'.$secs;
1175
+			if ($secs < 10)
1176
+			{
1177
+				$dates .= ':0'.$secs;
1178
+			}
1179
+			else {
1180
+				$dates .= ':'.$secs;
1181
+			}
976 1182
 			
977 1183
 			$gmt = adodb_get_gmt_diff();
978 1184
 			$dates .= sprintf(' %s%04d',($gmt<0)?'+':'-',abs($gmt)/36); break;
@@ -980,7 +1186,14 @@  discard block
 block discarded – undo
980 1186
 		case 'Y': $dates .= $year; break;
981 1187
 		case 'y': $dates .= substr($year,strlen($year)-2,2); break;
982 1188
 		// MONTH
983
-		case 'm': if ($month<10) $dates .= '0'.$month; else $dates .= $month; break;
1189
+		case 'm': if ($month<10)
1190
+		{
1191
+			$dates .= '0'.$month;
1192
+		}
1193
+		else {
1194
+			$dates .= $month;
1195
+		}
1196
+		break;
984 1197
 		case 'Q': $dates .= ($month+3)>>2; break;
985 1198
 		case 'n': $dates .= $month; break;
986 1199
 		case 'M': $dates .= date('M',mktime(0,0,0,$month,2,1971)); break;
@@ -992,13 +1205,31 @@  discard block
 block discarded – undo
992 1205
 		case 'l': $dates .= gmdate('l',$_day_power*(3+adodb_dow($year,$month,$day))); break;
993 1206
 		case 'D': $dates .= gmdate('D',$_day_power*(3+adodb_dow($year,$month,$day))); break;
994 1207
 		case 'j': $dates .= $day; break;
995
-		case 'd': if ($day<10) $dates .= '0'.$day; else $dates .= $day; break;
1208
+		case 'd': if ($day<10)
1209
+		{
1210
+			$dates .= '0'.$day;
1211
+		}
1212
+		else {
1213
+			$dates .= $day;
1214
+		}
1215
+		break;
996 1216
 		case 'S': 
997 1217
 			$d10 = $day % 10;
998
-			if ($d10 == 1) $dates .= 'st';
999
-			else if ($d10 == 2 && $day != 12) $dates .= 'nd';
1000
-			else if ($d10 == 3) $dates .= 'rd';
1001
-			else $dates .= 'th';
1218
+			if ($d10 == 1)
1219
+			{
1220
+				$dates .= 'st';
1221
+			}
1222
+			else if ($d10 == 2 && $day != 12)
1223
+			{
1224
+				$dates .= 'nd';
1225
+			}
1226
+			else if ($d10 == 3)
1227
+			{
1228
+				$dates .= 'rd';
1229
+			}
1230
+			else {
1231
+				$dates .= 'th';
1232
+			}
1002 1233
 			break;
1003 1234
 			
1004 1235
 		// HOUR
@@ -1009,18 +1240,37 @@  discard block
 block discarded – undo
1009 1240
 			$dates .= sprintf('%s%04d',($gmt<0)?'+':'-',abs($gmt)/36); break;
1010 1241
 			
1011 1242
 		case 'H': 
1012
-			if ($hour < 10) $dates .= '0'.$hour; 
1013
-			else $dates .= $hour; 
1243
+			if ($hour < 10)
1244
+			{
1245
+				$dates .= '0'.$hour;
1246
+			}
1247
+			else {
1248
+				$dates .= $hour;
1249
+			}
1014 1250
 			break;
1015 1251
 		case 'h': 
1016
-			if ($hour > 12) $hh = $hour - 12; 
1017
-			else {
1018
-				if ($hour == 0) $hh = '12'; 
1019
-				else $hh = $hour;
1252
+			if ($hour > 12)
1253
+			{
1254
+				$hh = $hour - 12;
1255
+			}
1256
+			else
1257
+			{
1258
+				if ($hour == 0)
1259
+				{
1260
+					$hh = '12';
1261
+				}
1262
+				else {
1263
+					$hh = $hour;
1264
+				}
1020 1265
 			}
1021 1266
 			
1022
-			if ($hh < 10) $dates .= '0'.$hh;
1023
-			else $dates .= $hh;
1267
+			if ($hh < 10)
1268
+			{
1269
+				$dates .= '0'.$hh;
1270
+			}
1271
+			else {
1272
+				$dates .= $hh;
1273
+			}
1024 1274
 			break;
1025 1275
 			
1026 1276
 		case 'G': 
@@ -1028,34 +1278,70 @@  discard block
 block discarded – undo
1028 1278
 			break;
1029 1279
 			
1030 1280
 		case 'g':
1031
-			if ($hour > 12) $hh = $hour - 12; 
1032
-			else {
1033
-				if ($hour == 0) $hh = '12'; 
1034
-				else $hh = $hour; 
1281
+			if ($hour > 12)
1282
+			{
1283
+				$hh = $hour - 12;
1284
+			}
1285
+			else
1286
+			{
1287
+				if ($hour == 0)
1288
+				{
1289
+					$hh = '12';
1290
+				}
1291
+				else {
1292
+					$hh = $hour;
1293
+				}
1035 1294
 			}
1036 1295
 			$dates .= $hh;
1037 1296
 			break;
1038 1297
 		// MINUTES
1039
-		case 'i': if ($min < 10) $dates .= '0'.$min; else $dates .= $min; break;
1298
+		case 'i': if ($min < 10)
1299
+		{
1300
+			$dates .= '0'.$min;
1301
+		}
1302
+		else {
1303
+			$dates .= $min;
1304
+		}
1305
+		break;
1040 1306
 		// SECONDS
1041 1307
 		case 'U': $dates .= $d; break;
1042
-		case 's': if ($secs < 10) $dates .= '0'.$secs; else $dates .= $secs; break;
1308
+		case 's': if ($secs < 10)
1309
+		{
1310
+			$dates .= '0'.$secs;
1311
+		}
1312
+		else {
1313
+			$dates .= $secs;
1314
+		}
1315
+		break;
1043 1316
 		// AM/PM
1044 1317
 		// Note 00:00 to 11:59 is AM, while 12:00 to 23:59 is PM
1045 1318
 		case 'a':
1046
-			if ($hour>=12) $dates .= 'pm';
1047
-			else $dates .= 'am';
1319
+			if ($hour>=12)
1320
+			{
1321
+				$dates .= 'pm';
1322
+			}
1323
+			else {
1324
+				$dates .= 'am';
1325
+			}
1048 1326
 			break;
1049 1327
 		case 'A':
1050
-			if ($hour>=12) $dates .= 'PM';
1051
-			else $dates .= 'AM';
1328
+			if ($hour>=12)
1329
+			{
1330
+				$dates .= 'PM';
1331
+			}
1332
+			else {
1333
+				$dates .= 'AM';
1334
+			}
1052 1335
 			break;
1053 1336
 		default:
1054 1337
 			$dates .= $fmt[$i]; break;
1055 1338
 		// ESCAPE
1056 1339
 		case "\\": 
1057 1340
 			$i++;
1058
-			if ($i < $max) $dates .= $fmt[$i];
1341
+			if ($i < $max)
1342
+			{
1343
+				$dates .= $fmt[$i];
1344
+			}
1059 1345
 			break;
1060 1346
 		}
1061 1347
 	}
@@ -1077,11 +1363,13 @@  discard block
 block discarded – undo
1077 1363
 	
1078 1364
 	Not a very fast algorithm - O(n) operation. Could be optimized to O(1).
1079 1365
 */
1080
-function adodb_mktime($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_dst=false,$is_gmt=false) 
1366
+function adodb_mktime($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_dst=false,$is_gmt=false)
1081 1367
 {
1082
-	if (!defined('ADODB_TEST_DATES')) {
1368
+	if (!defined('ADODB_TEST_DATES'))
1369
+	{
1083 1370
 
1084
-		if ($mon === false) {
1371
+		if ($mon === false)
1372
+		{
1085 1373
 			return $is_gmt? @gmmktime($hr,$min,$sec): @mktime($hr,$min,$sec);
1086 1374
 		}
1087 1375
 		
@@ -1112,11 +1400,14 @@  discard block
 block discarded – undo
1112 1400
 	
1113 1401
 	$year = adodb_year_digit_check($year);
1114 1402
 
1115
-	if ($mon > 12) {
1403
+	if ($mon > 12)
1404
+	{
1116 1405
 		$y = floor($mon / 12);
1117 1406
 		$year += $y;
1118 1407
 		$mon -= $y*12;
1119
-	} else if ($mon < 1) {
1408
+	}
1409
+	else if ($mon < 1)
1410
+	{
1120 1411
 		$y = ceil((1-$mon) / 12);
1121 1412
 		$year -= $y;
1122 1413
 		$mon += $y*12;
@@ -1130,20 +1421,29 @@  discard block
 block discarded – undo
1130 1421
 	$_month_table_leaf = array("",31,29,31,30,31,30,31,31,30,31,30,31);
1131 1422
 	
1132 1423
 	$_total_date = 0;
1133
-	if ($year >= 1970) {
1134
-		for ($a = 1970 ; $a <= $year; $a++) {
1424
+	if ($year >= 1970)
1425
+	{
1426
+		for ($a = 1970 ; $a <= $year; $a++)
1427
+		{
1135 1428
 			$leaf = _adodb_is_leap_year($a);
1136
-			if ($leaf == true) {
1429
+			if ($leaf == true)
1430
+			{
1137 1431
 				$loop_table = $_month_table_leaf;
1138 1432
 				$_add_date = 366;
1139
-			} else {
1433
+			}
1434
+			else
1435
+			{
1140 1436
 				$loop_table = $_month_table_normal;
1141 1437
 				$_add_date = 365;
1142 1438
 			}
1143
-			if ($a < $year) { 
1439
+			if ($a < $year)
1440
+			{
1144 1441
 				$_total_date += $_add_date;
1145
-			} else {
1146
-				for($b=1;$b<$mon;$b++) {
1442
+			}
1443
+			else
1444
+			{
1445
+				for($b=1;$b<$mon;$b++)
1446
+				{
1147 1447
 					$_total_date += $loop_table[$b];
1148 1448
 				}
1149 1449
 			}
@@ -1151,19 +1451,30 @@  discard block
 block discarded – undo
1151 1451
 		$_total_date +=$day-1;
1152 1452
 		$ret = $_total_date * $_day_power + $hr * $_hour_power + $min * $_min_power + $sec + $gmt_different;
1153 1453
 	
1154
-	} else {
1155
-		for ($a = 1969 ; $a >= $year; $a--) {
1454
+	}
1455
+	else
1456
+	{
1457
+		for ($a = 1969 ; $a >= $year; $a--)
1458
+		{
1156 1459
 			$leaf = _adodb_is_leap_year($a);
1157
-			if ($leaf == true) {
1460
+			if ($leaf == true)
1461
+			{
1158 1462
 				$loop_table = $_month_table_leaf;
1159 1463
 				$_add_date = 366;
1160
-			} else {
1464
+			}
1465
+			else
1466
+			{
1161 1467
 				$loop_table = $_month_table_normal;
1162 1468
 				$_add_date = 365;
1163 1469
 			}
1164
-			if ($a > $year) { $_total_date += $_add_date;
1165
-			} else {
1166
-				for($b=12;$b>$mon;$b--) {
1470
+			if ($a > $year)
1471
+			{
1472
+$_total_date += $_add_date;
1473
+			}
1474
+			else
1475
+			{
1476
+				for($b=12;$b>$mon;$b--)
1477
+				{
1167 1478
 					$_total_date += $loop_table[$b];
1168 1479
 				}
1169 1480
 			}
@@ -1173,8 +1484,16 @@  discard block
 block discarded – undo
1173 1484
 		$_day_time = $hr * $_hour_power + $min * $_min_power + $sec;
1174 1485
 		$_day_time = $_day_power - $_day_time;
1175 1486
 		$ret = -( $_total_date * $_day_power + $_day_time - $gmt_different);
1176
-		if ($ret < -12220185600) $ret += 10*86400; // if earlier than 5 Oct 1582 - gregorian correction
1177
-		else if ($ret < -12219321600) $ret = -12219321600; // if in limbo, reset to 15 Oct 1582.
1487
+		if ($ret < -12220185600)
1488
+		{
1489
+			$ret += 10*86400;
1490
+		}
1491
+		// if earlier than 5 Oct 1582 - gregorian correction
1492
+		else if ($ret < -12219321600)
1493
+		{
1494
+			$ret = -12219321600;
1495
+		}
1496
+		// if in limbo, reset to 15 Oct 1582.
1178 1497
 	} 
1179 1498
 	//print " dmy=$day/$mon/$year $hr:$min:$sec => " .$ret;
1180 1499
 	return $ret;
@@ -1190,15 +1509,22 @@  discard block
 block discarded – undo
1190 1509
 {
1191 1510
 global $ADODB_DATE_LOCALE;
1192 1511
 
1193
-	if (!defined('ADODB_TEST_DATES')) {
1194
-		if ((abs($ts) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range
1195
-			if (!defined('ADODB_NO_NEGATIVE_TS') || $ts >= 0) // if windows, must be +ve integer
1512
+	if (!defined('ADODB_TEST_DATES'))
1513
+	{
1514
+		if ((abs($ts) <= 0x7FFFFFFF))
1515
+		{
1516
+// check if number in 32-bit signed range
1517
+			if (!defined('ADODB_NO_NEGATIVE_TS') || $ts >= 0)
1518
+			{
1519
+				// if windows, must be +ve integer
1196 1520
 				return ($is_gmt)? @gmstrftime($fmt,$ts): @strftime($fmt,$ts);
1521
+			}
1197 1522
 
1198 1523
 		}
1199 1524
 	}
1200 1525
 	
1201
-	if (empty($ADODB_DATE_LOCALE)) {
1526
+	if (empty($ADODB_DATE_LOCALE))
1527
+	{
1202 1528
 		$tstr = strtoupper(gmstrftime('%c',31366800)); // 30 Dec 1970, 1 am
1203 1529
 		$sep = substr($tstr,2,1);
1204 1530
 		$hasAM = strrpos($tstr,'M') !== false;
@@ -1210,18 +1536,26 @@  discard block
 block discarded – undo
1210 1536
 	}
1211 1537
 	$inpct = false;
1212 1538
 	$fmtdate = '';
1213
-	for ($i=0,$max = strlen($fmt); $i < $max; $i++) {
1539
+	for ($i=0,$max = strlen($fmt); $i < $max; $i++)
1540
+	{
1214 1541
 		$ch = $fmt[$i];
1215
-		if ($ch == '%') {
1216
-			if ($inpct) {
1542
+		if ($ch == '%')
1543
+		{
1544
+			if ($inpct)
1545
+			{
1217 1546
 				$fmtdate .= '%';
1218 1547
 				$inpct = false;
1219
-			} else
1220
-				$inpct = true;
1221
-		} else if ($inpct) {
1548
+			}
1549
+			else {
1550
+							$inpct = true;
1551
+			}
1552
+		}
1553
+		else if ($inpct)
1554
+		{
1222 1555
 		
1223 1556
 			$inpct = false;
1224
-			switch($ch) {
1557
+			switch($ch)
1558
+			{
1225 1559
 			case '0':
1226 1560
 			case '1':
1227 1561
 			case '2':
@@ -1272,13 +1606,20 @@  discard block
 block discarded – undo
1272 1606
 			case 'Y': $fmtdate .= 'Y'; break;
1273 1607
 			case 'Z': $fmtdate .= 'T'; break;
1274 1608
 			}
1275
-		} else if (('A' <= ($ch) && ($ch) <= 'Z' ) || ('a' <= ($ch) && ($ch) <= 'z' ))
1276
-			$fmtdate .= "\\".$ch;
1277
-		else
1278
-			$fmtdate .= $ch;
1609
+		}
1610
+		else if (('A' <= ($ch) && ($ch) <= 'Z' ) || ('a' <= ($ch) && ($ch) <= 'z' ))
1611
+		{
1612
+					$fmtdate .= "\\".$ch;
1613
+		}
1614
+		else {
1615
+					$fmtdate .= $ch;
1616
+		}
1279 1617
 	}
1280 1618
 	//echo "fmt=",$fmtdate,"<br>";
1281
-	if ($ts === false) $ts = time();
1619
+	if ($ts === false)
1620
+	{
1621
+		$ts = time();
1622
+	}
1282 1623
 	$ret = adodb_date($fmtdate, $ts, $is_gmt);
1283 1624
 	return $ret;
1284 1625
 }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
 	
534 534
 	// we generate a timestamp, convert it to a date, and convert it back to a timestamp
535 535
 	// and check if the roundtrip broke the original timestamp value.
536
-	print "Testing $start to ".($start+$yrs).", or $max seconds, offset=$offset: ";
536
+	print "testing $start to ".($start+$yrs).", or $max seconds, offset=$offset: ";
537 537
 	$cnt = 0;
538 538
 	for ($max += $i; $i < $max; $i += $offset) {
539 539
 		$ret = adodb_date('m,d,Y,H,i,s',$i);
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
 		}
552 552
 		$cnt += 1;
553 553
 	}
554
-	echo "Tested $cnt dates<br>";
554
+	echo "tested $cnt dates<br>";
555 555
 	if (!$fail) print "<p>Passed !</p>";
556 556
 	else print "<p><b>Failed</b> :-(</p>";
557 557
 }
Please login to merge, or discard this patch.
phpgwapi/inc/adodb/adodb-xmlschema.inc.php 5 patches
Doc Comments   +13 added lines, -28 removed lines patch added patch discarded remove patch
@@ -231,8 +231,7 @@  discard block
 block discarded – undo
231 231
 	/**
232 232
 	* Iniitializes a new table object.
233 233
 	*
234
-	* @param string $prefix DB Object prefix
235
-	* @param array $attributes Array of table attributes.
234
+	* @param adoSchema $parent
236 235
 	*/
237 236
 	function dbTable( &$parent, $attributes = NULL ) {
238 237
 		$this->parent =& $parent;
@@ -346,7 +345,7 @@  discard block
 block discarded – undo
346 345
 	* Adds an index to a table object
347 346
 	*
348 347
 	* @param array $attributes Index attributes
349
-	* @return object dbIndex object
348
+	* @return dbIndex dbIndex object
350 349
 	*/
351 350
 	function &addIndex( $attributes ) {
352 351
 		$name = strtoupper( $attributes['NAME'] );
@@ -446,7 +445,7 @@  discard block
 block discarded – undo
446 445
 	* and appends them to the table object.
447 446
 	*
448 447
 	* @param string $opt Table option
449
-	* @return array Options
448
+	* @return string[] Options
450 449
 	*/
451 450
 	function addTableOpt( $opt ) {
452 451
 		$this->opts[] = $opt;
@@ -621,7 +620,7 @@  discard block
 block discarded – undo
621 620
 	/**
622 621
 	* Initializes the new dbIndex object.
623 622
 	*
624
-	* @param object $parent Parent object
623
+	* @param dbTable $parent Parent object
625 624
 	* @param array $attributes Attributes
626 625
 	*
627 626
 	* @internal
@@ -710,7 +709,7 @@  discard block
 block discarded – undo
710 709
 	* Adds options to the index
711 710
 	*
712 711
 	* @param string $opt Comma-separated list of index options.
713
-	* @return string Option list
712
+	* @return string[] Option list
714 713
 	*/
715 714
 	function addIndexOpt( $opt ) {
716 715
 		$this->opts[] = $opt;
@@ -765,7 +764,7 @@  discard block
 block discarded – undo
765 764
 	/**
766 765
 	* Initializes the new dbIndex object.
767 766
 	*
768
-	* @param object $parent Parent object
767
+	* @param dbTable $parent Parent object
769 768
 	* @param array $attributes Attributes
770 769
 	*
771 770
 	* @internal
@@ -833,8 +832,6 @@  discard block
 block discarded – undo
833 832
 	/**
834 833
 	* Adds a field to the index
835 834
 	*
836
-	* @param string $name Field name
837
-	* @return string Field list
838 835
 	*/
839 836
 	function addField( $attributes ) {
840 837
 		if( isset( $attributes['NAME'] ) ) {
@@ -850,8 +847,6 @@  discard block
 block discarded – undo
850 847
 	/**
851 848
 	* Adds options to the index
852 849
 	*
853
-	* @param string $opt Comma-separated list of index options.
854
-	* @return string Option list
855 850
 	*/
856 851
 	function addData( $cdata ) {
857 852
 		if( !isset( $this->data[$this->row] ) ) {
@@ -966,7 +961,7 @@  discard block
 block discarded – undo
966 961
 	/**
967 962
 	* Initializes the query set.
968 963
 	*
969
-	* @param object $parent Parent object
964
+	* @param adoSchema $parent Parent object
970 965
 	* @param array $attributes Attributes
971 966
 	*/
972 967
 	function dbQuerySet( &$parent, $attributes = NULL ) {
@@ -1080,8 +1075,6 @@  discard block
 block discarded – undo
1080 1075
 	/** 
1081 1076
 	* Appends a line to a query that is being built line by line
1082 1077
 	*
1083
-	* @param string $data Line of SQL data or NULL to initialize a new query
1084
-	* @return string SQL query string.
1085 1078
 	*/
1086 1079
 	function buildQuery( $sql = NULL ) {
1087 1080
 		if( !isset( $this->query ) OR empty( $sql ) ) {
@@ -1394,9 +1387,6 @@  discard block
 block discarded – undo
1394 1387
 	* the filesystem and generate the SQL necessary to create the database described. 
1395 1388
 	* @see ParseSchemaString()
1396 1389
 	*
1397
-	* @param string $file Name of XML schema file.
1398
-	* @param bool $returnSchema Return schema rather than parsing.
1399
-	* @return array Array of SQL queries, ready to execute
1400 1390
 	*/
1401 1391
 	function ParseSchema( $filename, $returnSchema = FALSE ) {
1402 1392
 		return $this->ParseSchemaString( $this->ConvertSchemaFile( $filename ), $returnSchema );
@@ -1408,12 +1398,6 @@  discard block
 block discarded – undo
1408 1398
 	* Call this method to load the specified schema from a file (see the DTD for the proper format) 
1409 1399
 	* and generate the SQL necessary to create the database described by the schema.
1410 1400
 	*
1411
-	* @param string $file Name of XML schema file.
1412
-	* @param bool $returnSchema Return schema rather than parsing.
1413
-	* @return array Array of SQL queries, ready to execute.
1414
-	*
1415
-	* @deprecated Replaced by adoSchema::ParseSchema() and adoSchema::ParseSchemaString()
1416
-	* @see ParseSchema(), ParseSchemaString()
1417 1401
 	*/
1418 1402
 	function ParseSchemaFile( $filename, $returnSchema = FALSE ) {
1419 1403
 		// Open the file
@@ -1502,9 +1486,6 @@  discard block
 block discarded – undo
1502 1486
 	* the filesystem and generate the SQL necessary to remove the database described.
1503 1487
 	* @see RemoveSchemaString()
1504 1488
 	*
1505
-	* @param string $file Name of XML schema file.
1506
-	* @param bool $returnSchema Return schema rather than parsing.
1507
-	* @return array Array of SQL queries, ready to execute
1508 1489
 	*/
1509 1490
 	function RemoveSchema( $filename, $returnSchema = FALSE ) {
1510 1491
 		return $this->RemoveSchemaString( $this->ConvertSchemaFile( $filename ), $returnSchema );
@@ -1582,7 +1563,7 @@  discard block
 block discarded – undo
1582 1563
 	* parsed XML schema) to the filesystem.
1583 1564
 	*
1584 1565
 	* @param string $filename Path and name where the file should be saved.
1585
-	* @return boolean TRUE if save is successful, else FALSE. 
1566
+	* @return false|null TRUE if save is successful, else FALSE. 
1586 1567
 	*/
1587 1568
 	function SaveSQL( $filename = './schema.sql' ) {
1588 1569
 		
@@ -1604,7 +1585,7 @@  discard block
 block discarded – undo
1604 1585
 	/**
1605 1586
 	* Create an xml parser
1606 1587
 	*
1607
-	* @return object PHP XML parser object
1588
+	* @return resource PHP XML parser object
1608 1589
 	*
1609 1590
 	* @access private
1610 1591
 	*/
@@ -1748,6 +1729,10 @@  discard block
 block discarded – undo
1748 1729
 		return $result;
1749 1730
 	}
1750 1731
 	
1732
+	/**
1733
+	 * @param string $schema
1734
+	 * @param string $xsl
1735
+	 */
1751 1736
 	function TransformSchema( $schema, $xsl, $schematype='string' )
1752 1737
 	{
1753 1738
 		// Fail if XSLT extension is not available
Please login to merge, or discard this patch.
Indentation   +567 added lines, -567 removed lines patch added patch discarded remove patch
@@ -92,45 +92,45 @@  discard block
 block discarded – undo
92 92
 class dbObject {
93 93
 	
94 94
 	/**
95
-	* var object Parent
96
-	*/
95
+	 * var object Parent
96
+	 */
97 97
 	var $parent;
98 98
 	
99 99
 	/**
100
-	* var string current element
101
-	*/
100
+	 * var string current element
101
+	 */
102 102
 	var $currentElement;
103 103
 	
104 104
 	/**
105
-	* NOP
106
-	*/
105
+	 * NOP
106
+	 */
107 107
 	function dbObject( &$parent, $attributes = NULL ) {
108 108
 		$this->parent =& $parent;
109 109
 	}
110 110
 	
111 111
 	/**
112
-	* XML Callback to process start elements
113
-	*
114
-	* @access private
115
-	*/
112
+	 * XML Callback to process start elements
113
+	 *
114
+	 * @access private
115
+	 */
116 116
 	function _tag_open( &$parser, $tag, $attributes ) {
117 117
 		
118 118
 	}
119 119
 	
120 120
 	/**
121
-	* XML Callback to process CDATA elements
122
-	*
123
-	* @access private
124
-	*/
121
+	 * XML Callback to process CDATA elements
122
+	 *
123
+	 * @access private
124
+	 */
125 125
 	function _tag_cdata( &$parser, $cdata ) {
126 126
 		
127 127
 	}
128 128
 	
129 129
 	/**
130
-	* XML Callback to process end elements
131
-	*
132
-	* @access private
133
-	*/
130
+	 * XML Callback to process end elements
131
+	 *
132
+	 * @access private
133
+	 */
134 134
 	function _tag_close( &$parser, $tag ) {
135 135
 		
136 136
 	}
@@ -140,39 +140,39 @@  discard block
 block discarded – undo
140 140
 	}
141 141
 	
142 142
 	/**
143
-	* Destroys the object
144
-	*/
143
+	 * Destroys the object
144
+	 */
145 145
 	function destroy() {
146 146
 		unset( $this );
147 147
 	}
148 148
 	
149 149
 	/**
150
-	* Checks whether the specified RDBMS is supported by the current
151
-	* database object or its ranking ancestor.
152
-	*
153
-	* @param string $platform RDBMS platform name (from ADODB platform list).
154
-	* @return boolean TRUE if RDBMS is supported; otherwise returns FALSE.
155
-	*/
150
+	 * Checks whether the specified RDBMS is supported by the current
151
+	 * database object or its ranking ancestor.
152
+	 *
153
+	 * @param string $platform RDBMS platform name (from ADODB platform list).
154
+	 * @return boolean TRUE if RDBMS is supported; otherwise returns FALSE.
155
+	 */
156 156
 	function supportedPlatform( $platform = NULL ) {
157 157
 		return is_object( $this->parent ) ? $this->parent->supportedPlatform( $platform ) : TRUE;
158 158
 	}
159 159
 	
160 160
 	/**
161
-	* Returns the prefix set by the ranking ancestor of the database object.
162
-	*
163
-	* @param string $name Prefix string.
164
-	* @return string Prefix.
165
-	*/
161
+	 * Returns the prefix set by the ranking ancestor of the database object.
162
+	 *
163
+	 * @param string $name Prefix string.
164
+	 * @return string Prefix.
165
+	 */
166 166
 	function prefix( $name = '' ) {
167 167
 		return is_object( $this->parent ) ? $this->parent->prefix( $name ) : $name;
168 168
 	}
169 169
 	
170 170
 	/**
171
-	* Extracts a field ID from the specified field.
172
-	*
173
-	* @param string $field Field.
174
-	* @return string Field ID.
175
-	*/
171
+	 * Extracts a field ID from the specified field.
172
+	 *
173
+	 * @param string $field Field.
174
+	 * @return string Field ID.
175
+	 */
176 176
 	function FieldID( $field ) {
177 177
 		return strtoupper( preg_replace( '/^`(.+)`$/', '$1', $field ) );
178 178
 	}
@@ -192,59 +192,59 @@  discard block
 block discarded – undo
192 192
 class dbTable extends dbObject {
193 193
 	
194 194
 	/**
195
-	* @var string Table name
196
-	*/
195
+	 * @var string Table name
196
+	 */
197 197
 	var $name;
198 198
 	
199 199
 	/**
200
-	* @var array Field specifier: Meta-information about each field
201
-	*/
200
+	 * @var array Field specifier: Meta-information about each field
201
+	 */
202 202
 	var $fields = array();
203 203
 	
204 204
 	/**
205
-	* @var array List of table indexes.
206
-	*/
205
+	 * @var array List of table indexes.
206
+	 */
207 207
 	var $indexes = array();
208 208
 	
209 209
 	/**
210
-	* @var array Table options: Table-level options
211
-	*/
210
+	 * @var array Table options: Table-level options
211
+	 */
212 212
 	var $opts = array();
213 213
 	
214 214
 	/**
215
-	* @var string Field index: Keeps track of which field is currently being processed
216
-	*/
215
+	 * @var string Field index: Keeps track of which field is currently being processed
216
+	 */
217 217
 	var $current_field;
218 218
 	
219 219
 	/**
220
-	* @var boolean Mark table for destruction
221
-	* @access private
222
-	*/
220
+	 * @var boolean Mark table for destruction
221
+	 * @access private
222
+	 */
223 223
 	var $drop_table;
224 224
 	
225 225
 	/**
226
-	* @var boolean Mark field for destruction (not yet implemented)
227
-	* @access private
228
-	*/
226
+	 * @var boolean Mark field for destruction (not yet implemented)
227
+	 * @access private
228
+	 */
229 229
 	var $drop_field = array();
230 230
 	
231 231
 	/**
232
-	* Iniitializes a new table object.
233
-	*
234
-	* @param string $prefix DB Object prefix
235
-	* @param array $attributes Array of table attributes.
236
-	*/
232
+	 * Iniitializes a new table object.
233
+	 *
234
+	 * @param string $prefix DB Object prefix
235
+	 * @param array $attributes Array of table attributes.
236
+	 */
237 237
 	function dbTable( &$parent, $attributes = NULL ) {
238 238
 		$this->parent =& $parent;
239 239
 		$this->name = $this->prefix($attributes['NAME']);
240 240
 	}
241 241
 	
242 242
 	/**
243
-	* XML Callback to process start elements. Elements currently 
244
-	* processed are: INDEX, DROP, FIELD, KEY, NOTNULL, AUTOINCREMENT & DEFAULT. 
245
-	*
246
-	* @access private
247
-	*/
243
+	 * XML Callback to process start elements. Elements currently 
244
+	 * processed are: INDEX, DROP, FIELD, KEY, NOTNULL, AUTOINCREMENT & DEFAULT. 
245
+	 *
246
+	 * @access private
247
+	 */
248 248
 	function _tag_open( &$parser, $tag, $attributes ) {
249 249
 		$this->currentElement = strtoupper( $tag );
250 250
 		
@@ -298,10 +298,10 @@  discard block
 block discarded – undo
298 298
 	}
299 299
 	
300 300
 	/**
301
-	* XML Callback to process CDATA elements
302
-	*
303
-	* @access private
304
-	*/
301
+	 * XML Callback to process CDATA elements
302
+	 *
303
+	 * @access private
304
+	 */
305 305
 	function _tag_cdata( &$parser, $cdata ) {
306 306
 		switch( $this->currentElement ) {
307 307
 			// Table constraint
@@ -322,10 +322,10 @@  discard block
 block discarded – undo
322 322
 	}
323 323
 	
324 324
 	/**
325
-	* XML Callback to process end elements
326
-	*
327
-	* @access private
328
-	*/
325
+	 * XML Callback to process end elements
326
+	 *
327
+	 * @access private
328
+	 */
329 329
 	function _tag_close( &$parser, $tag ) {
330 330
 		$this->currentElement = '';
331 331
 		
@@ -343,11 +343,11 @@  discard block
 block discarded – undo
343 343
 	}
344 344
 	
345 345
 	/**
346
-	* Adds an index to a table object
347
-	*
348
-	* @param array $attributes Index attributes
349
-	* @return object dbIndex object
350
-	*/
346
+	 * Adds an index to a table object
347
+	 *
348
+	 * @param array $attributes Index attributes
349
+	 * @return object dbIndex object
350
+	 */
351 351
 	function &addIndex( $attributes ) {
352 352
 		$name = strtoupper( $attributes['NAME'] );
353 353
 		$this->indexes[$name] = new dbIndex( $this, $attributes );
@@ -355,11 +355,11 @@  discard block
 block discarded – undo
355 355
 	}
356 356
 	
357 357
 	/**
358
-	* Adds data to a table object
359
-	*
360
-	* @param array $attributes Data attributes
361
-	* @return object dbData object
362
-	*/
358
+	 * Adds data to a table object
359
+	 *
360
+	 * @param array $attributes Data attributes
361
+	 * @return object dbData object
362
+	 */
363 363
 	function &addData( $attributes ) {
364 364
 		if( !isset( $this->data ) ) {
365 365
 			$this->data = new dbData( $this, $attributes );
@@ -368,34 +368,34 @@  discard block
 block discarded – undo
368 368
 	}
369 369
 	
370 370
 	/**
371
-	* Adds a field to a table object
372
-	*
373
-	* $name is the name of the table to which the field should be added. 
374
-	* $type is an ADODB datadict field type. The following field types
375
-	* are supported as of ADODB 3.40:
376
-	* 	- C:  varchar
377
-	*	- X:  CLOB (character large object) or largest varchar size
378
-	*	   if CLOB is not supported
379
-	*	- C2: Multibyte varchar
380
-	*	- X2: Multibyte CLOB
381
-	*	- B:  BLOB (binary large object)
382
-	*	- D:  Date (some databases do not support this, and we return a datetime type)
383
-	*	- T:  Datetime or Timestamp
384
-	*	- L:  Integer field suitable for storing booleans (0 or 1)
385
-	*	- I:  Integer (mapped to I4)
386
-	*	- I1: 1-byte integer
387
-	*	- I2: 2-byte integer
388
-	*	- I4: 4-byte integer
389
-	*	- I8: 8-byte integer
390
-	*	- F:  Floating point number
391
-	*	- N:  Numeric or decimal number
392
-	*
393
-	* @param string $name Name of the table to which the field will be added.
394
-	* @param string $type	ADODB datadict field type.
395
-	* @param string $size	Field size
396
-	* @param array $opts	Field options array
397
-	* @return array Field specifier array
398
-	*/
371
+	 * Adds a field to a table object
372
+	 *
373
+	 * $name is the name of the table to which the field should be added. 
374
+	 * $type is an ADODB datadict field type. The following field types
375
+	 * are supported as of ADODB 3.40:
376
+	 * 	- C:  varchar
377
+	 *	- X:  CLOB (character large object) or largest varchar size
378
+	 *	   if CLOB is not supported
379
+	 *	- C2: Multibyte varchar
380
+	 *	- X2: Multibyte CLOB
381
+	 *	- B:  BLOB (binary large object)
382
+	 *	- D:  Date (some databases do not support this, and we return a datetime type)
383
+	 *	- T:  Datetime or Timestamp
384
+	 *	- L:  Integer field suitable for storing booleans (0 or 1)
385
+	 *	- I:  Integer (mapped to I4)
386
+	 *	- I1: 1-byte integer
387
+	 *	- I2: 2-byte integer
388
+	 *	- I4: 4-byte integer
389
+	 *	- I8: 8-byte integer
390
+	 *	- F:  Floating point number
391
+	 *	- N:  Numeric or decimal number
392
+	 *
393
+	 * @param string $name Name of the table to which the field will be added.
394
+	 * @param string $type	ADODB datadict field type.
395
+	 * @param string $size	Field size
396
+	 * @param array $opts	Field options array
397
+	 * @return array Field specifier array
398
+	 */
399 399
 	function addField( $name, $type, $size = NULL, $opts = NULL ) {
400 400
 		$field_id = $this->FieldID( $name );
401 401
 		
@@ -420,16 +420,16 @@  discard block
 block discarded – undo
420 420
 	}
421 421
 	
422 422
 	/**
423
-	* Adds a field option to the current field specifier
424
-	*
425
-	* This method adds a field option allowed by the ADOdb datadict 
426
-	* and appends it to the given field.
427
-	*
428
-	* @param string $field	Field name
429
-	* @param string $opt ADOdb field option
430
-	* @param mixed $value Field option value
431
-	* @return array Field specifier array
432
-	*/
423
+	 * Adds a field option to the current field specifier
424
+	 *
425
+	 * This method adds a field option allowed by the ADOdb datadict 
426
+	 * and appends it to the given field.
427
+	 *
428
+	 * @param string $field	Field name
429
+	 * @param string $opt ADOdb field option
430
+	 * @param mixed $value Field option value
431
+	 * @return array Field specifier array
432
+	 */
433 433
 	function addFieldOpt( $field, $opt, $value = NULL ) {
434 434
 		if( !isset( $value ) ) {
435 435
 			$this->fields[$this->FieldID( $field )]['OPTS'][] = $opt;
@@ -440,14 +440,14 @@  discard block
 block discarded – undo
440 440
 	}
441 441
 	
442 442
 	/**
443
-	* Adds an option to the table
444
-	*
445
-	* This method takes a comma-separated list of table-level options
446
-	* and appends them to the table object.
447
-	*
448
-	* @param string $opt Table option
449
-	* @return array Options
450
-	*/
443
+	 * Adds an option to the table
444
+	 *
445
+	 * This method takes a comma-separated list of table-level options
446
+	 * and appends them to the table object.
447
+	 *
448
+	 * @param string $opt Table option
449
+	 * @return array Options
450
+	 */
451 451
 	function addTableOpt( $opt ) {
452 452
 		$this->opts[] = $opt;
453 453
 		
@@ -455,11 +455,11 @@  discard block
 block discarded – undo
455 455
 	}
456 456
 	
457 457
 	/**
458
-	* Generates the SQL that will create the table in the database
459
-	*
460
-	* @param object $xmls adoSchema object
461
-	* @return array Array containing table creation SQL
462
-	*/
458
+	 * Generates the SQL that will create the table in the database
459
+	 *
460
+	 * @param object $xmls adoSchema object
461
+	 * @return array Array containing table creation SQL
462
+	 */
463 463
 	function create( &$xmls ) {
464 464
 		$sql = array();
465 465
 		
@@ -567,8 +567,8 @@  discard block
 block discarded – undo
567 567
 	}
568 568
 	
569 569
 	/**
570
-	* Marks a field or table for destruction
571
-	*/
570
+	 * Marks a field or table for destruction
571
+	 */
572 572
 	function drop() {
573 573
 		if( isset( $this->current_field ) ) {
574 574
 			// Drop the current field
@@ -598,34 +598,34 @@  discard block
 block discarded – undo
598 598
 class dbIndex extends dbObject {
599 599
 	
600 600
 	/**
601
-	* @var string	Index name
602
-	*/
601
+	 * @var string	Index name
602
+	 */
603 603
 	var $name;
604 604
 	
605 605
 	/**
606
-	* @var array	Index options: Index-level options
607
-	*/
606
+	 * @var array	Index options: Index-level options
607
+	 */
608 608
 	var $opts = array();
609 609
 	
610 610
 	/**
611
-	* @var array	Indexed fields: Table columns included in this index
612
-	*/
611
+	 * @var array	Indexed fields: Table columns included in this index
612
+	 */
613 613
 	var $columns = array();
614 614
 	
615 615
 	/**
616
-	* @var boolean Mark index for destruction
617
-	* @access private
618
-	*/
616
+	 * @var boolean Mark index for destruction
617
+	 * @access private
618
+	 */
619 619
 	var $drop = FALSE;
620 620
 	
621 621
 	/**
622
-	* Initializes the new dbIndex object.
623
-	*
624
-	* @param object $parent Parent object
625
-	* @param array $attributes Attributes
626
-	*
627
-	* @internal
628
-	*/
622
+	 * Initializes the new dbIndex object.
623
+	 *
624
+	 * @param object $parent Parent object
625
+	 * @param array $attributes Attributes
626
+	 *
627
+	 * @internal
628
+	 */
629 629
 	function dbIndex( &$parent, $attributes = NULL ) {
630 630
 		$this->parent =& $parent;
631 631
 		
@@ -633,13 +633,13 @@  discard block
 block discarded – undo
633 633
 	}
634 634
 	
635 635
 	/**
636
-	* XML Callback to process start elements
637
-	*
638
-	* Processes XML opening tags. 
639
-	* Elements currently processed are: DROP, CLUSTERED, BITMAP, UNIQUE, FULLTEXT & HASH. 
640
-	*
641
-	* @access private
642
-	*/
636
+	 * XML Callback to process start elements
637
+	 *
638
+	 * Processes XML opening tags. 
639
+	 * Elements currently processed are: DROP, CLUSTERED, BITMAP, UNIQUE, FULLTEXT & HASH. 
640
+	 *
641
+	 * @access private
642
+	 */
643 643
 	function _tag_open( &$parser, $tag, $attributes ) {
644 644
 		$this->currentElement = strtoupper( $tag );
645 645
 		
@@ -661,12 +661,12 @@  discard block
 block discarded – undo
661 661
 	}
662 662
 	
663 663
 	/**
664
-	* XML Callback to process CDATA elements
665
-	*
666
-	* Processes XML cdata.
667
-	*
668
-	* @access private
669
-	*/
664
+	 * XML Callback to process CDATA elements
665
+	 *
666
+	 * Processes XML cdata.
667
+	 *
668
+	 * @access private
669
+	 */
670 670
 	function _tag_cdata( &$parser, $cdata ) {
671 671
 		switch( $this->currentElement ) {
672 672
 			// Index field name
@@ -679,10 +679,10 @@  discard block
 block discarded – undo
679 679
 	}
680 680
 	
681 681
 	/**
682
-	* XML Callback to process end elements
683
-	*
684
-	* @access private
685
-	*/
682
+	 * XML Callback to process end elements
683
+	 *
684
+	 * @access private
685
+	 */
686 686
 	function _tag_close( &$parser, $tag ) {
687 687
 		$this->currentElement = '';
688 688
 		
@@ -694,11 +694,11 @@  discard block
 block discarded – undo
694 694
 	}
695 695
 	
696 696
 	/**
697
-	* Adds a field to the index
698
-	*
699
-	* @param string $name Field name
700
-	* @return string Field list
701
-	*/
697
+	 * Adds a field to the index
698
+	 *
699
+	 * @param string $name Field name
700
+	 * @return string Field list
701
+	 */
702 702
 	function addField( $name ) {
703 703
 		$this->columns[$this->FieldID( $name )] = $name;
704 704
 		
@@ -707,11 +707,11 @@  discard block
 block discarded – undo
707 707
 	}
708 708
 	
709 709
 	/**
710
-	* Adds options to the index
711
-	*
712
-	* @param string $opt Comma-separated list of index options.
713
-	* @return string Option list
714
-	*/
710
+	 * Adds options to the index
711
+	 *
712
+	 * @param string $opt Comma-separated list of index options.
713
+	 * @return string Option list
714
+	 */
715 715
 	function addIndexOpt( $opt ) {
716 716
 		$this->opts[] = $opt;
717 717
 		
@@ -720,11 +720,11 @@  discard block
 block discarded – undo
720 720
 	}
721 721
 	
722 722
 	/**
723
-	* Generates the SQL that will create the index in the database
724
-	*
725
-	* @param object $xmls adoSchema object
726
-	* @return array Array containing index creation SQL
727
-	*/
723
+	 * Generates the SQL that will create the index in the database
724
+	 *
725
+	 * @param object $xmls adoSchema object
726
+	 * @return array Array containing index creation SQL
727
+	 */
728 728
 	function create( &$xmls ) {
729 729
 		if( $this->drop ) {
730 730
 			return NULL;
@@ -741,8 +741,8 @@  discard block
 block discarded – undo
741 741
 	}
742 742
 	
743 743
 	/**
744
-	* Marks an index for destruction
745
-	*/
744
+	 * Marks an index for destruction
745
+	 */
746 746
 	function drop() {
747 747
 		$this->drop = TRUE;
748 748
 	}
@@ -763,25 +763,25 @@  discard block
 block discarded – undo
763 763
 	var $row;
764 764
 	
765 765
 	/**
766
-	* Initializes the new dbIndex object.
767
-	*
768
-	* @param object $parent Parent object
769
-	* @param array $attributes Attributes
770
-	*
771
-	* @internal
772
-	*/
766
+	 * Initializes the new dbIndex object.
767
+	 *
768
+	 * @param object $parent Parent object
769
+	 * @param array $attributes Attributes
770
+	 *
771
+	 * @internal
772
+	 */
773 773
 	function dbData( &$parent, $attributes = NULL ) {
774 774
 		$this->parent =& $parent;
775 775
 	}
776 776
 	
777 777
 	/**
778
-	* XML Callback to process start elements
779
-	*
780
-	* Processes XML opening tags. 
781
-	* Elements currently processed are: DROP, CLUSTERED, BITMAP, UNIQUE, FULLTEXT & HASH. 
782
-	*
783
-	* @access private
784
-	*/
778
+	 * XML Callback to process start elements
779
+	 *
780
+	 * Processes XML opening tags. 
781
+	 * Elements currently processed are: DROP, CLUSTERED, BITMAP, UNIQUE, FULLTEXT & HASH. 
782
+	 *
783
+	 * @access private
784
+	 */
785 785
 	function _tag_open( &$parser, $tag, $attributes ) {
786 786
 		$this->currentElement = strtoupper( $tag );
787 787
 		
@@ -798,12 +798,12 @@  discard block
 block discarded – undo
798 798
 	}
799 799
 	
800 800
 	/**
801
-	* XML Callback to process CDATA elements
802
-	*
803
-	* Processes XML cdata.
804
-	*
805
-	* @access private
806
-	*/
801
+	 * XML Callback to process CDATA elements
802
+	 *
803
+	 * Processes XML cdata.
804
+	 *
805
+	 * @access private
806
+	 */
807 807
 	function _tag_cdata( &$parser, $cdata ) {
808 808
 		switch( $this->currentElement ) {
809 809
 			// Index field name
@@ -816,10 +816,10 @@  discard block
 block discarded – undo
816 816
 	}
817 817
 	
818 818
 	/**
819
-	* XML Callback to process end elements
820
-	*
821
-	* @access private
822
-	*/
819
+	 * XML Callback to process end elements
820
+	 *
821
+	 * @access private
822
+	 */
823 823
 	function _tag_close( &$parser, $tag ) {
824 824
 		$this->currentElement = '';
825 825
 		
@@ -831,11 +831,11 @@  discard block
 block discarded – undo
831 831
 	}
832 832
 	
833 833
 	/**
834
-	* Adds a field to the index
835
-	*
836
-	* @param string $name Field name
837
-	* @return string Field list
838
-	*/
834
+	 * Adds a field to the index
835
+	 *
836
+	 * @param string $name Field name
837
+	 * @return string Field list
838
+	 */
839 839
 	function addField( $attributes ) {
840 840
 		if( isset( $attributes['NAME'] ) ) {
841 841
 			$name = $attributes['NAME'];
@@ -848,11 +848,11 @@  discard block
 block discarded – undo
848 848
 	}
849 849
 	
850 850
 	/**
851
-	* Adds options to the index
852
-	*
853
-	* @param string $opt Comma-separated list of index options.
854
-	* @return string Option list
855
-	*/
851
+	 * Adds options to the index
852
+	 *
853
+	 * @param string $opt Comma-separated list of index options.
854
+	 * @return string Option list
855
+	 */
856 856
 	function addData( $cdata ) {
857 857
 		if( !isset( $this->data[$this->row] ) ) {
858 858
 			$this->data[$this->row] = array();
@@ -866,11 +866,11 @@  discard block
 block discarded – undo
866 866
 	}
867 867
 	
868 868
 	/**
869
-	* Generates the SQL that will create the index in the database
870
-	*
871
-	* @param object $xmls adoSchema object
872
-	* @return array Array containing index creation SQL
873
-	*/
869
+	 * Generates the SQL that will create the index in the database
870
+	 *
871
+	 * @param object $xmls adoSchema object
872
+	 * @return array Array containing index creation SQL
873
+	 */
874 874
 	function create( &$xmls ) {
875 875
 		$table = $xmls->dict->TableName($this->parent->name);
876 876
 		$table_field_count = count($this->parent->fields);
@@ -944,31 +944,31 @@  discard block
 block discarded – undo
944 944
 class dbQuerySet extends dbObject {
945 945
 	
946 946
 	/**
947
-	* @var array	List of SQL queries
948
-	*/
947
+	 * @var array	List of SQL queries
948
+	 */
949 949
 	var $queries = array();
950 950
 	
951 951
 	/**
952
-	* @var string	String used to build of a query line by line
953
-	*/
952
+	 * @var string	String used to build of a query line by line
953
+	 */
954 954
 	var $query;
955 955
 	
956 956
 	/**
957
-	* @var string	Query prefix key
958
-	*/
957
+	 * @var string	Query prefix key
958
+	 */
959 959
 	var $prefixKey = '';
960 960
 	
961 961
 	/**
962
-	* @var boolean	Auto prefix enable (TRUE)
963
-	*/
962
+	 * @var boolean	Auto prefix enable (TRUE)
963
+	 */
964 964
 	var $prefixMethod = 'AUTO';
965 965
 	
966 966
 	/**
967
-	* Initializes the query set.
968
-	*
969
-	* @param object $parent Parent object
970
-	* @param array $attributes Attributes
971
-	*/
967
+	 * Initializes the query set.
968
+	 *
969
+	 * @param object $parent Parent object
970
+	 * @param array $attributes Attributes
971
+	 */
972 972
 	function dbQuerySet( &$parent, $attributes = NULL ) {
973 973
 		$this->parent =& $parent;
974 974
 			
@@ -994,11 +994,11 @@  discard block
 block discarded – undo
994 994
 	}
995 995
 	
996 996
 	/**
997
-	* XML Callback to process start elements. Elements currently 
998
-	* processed are: QUERY. 
999
-	*
1000
-	* @access private
1001
-	*/
997
+	 * XML Callback to process start elements. Elements currently 
998
+	 * processed are: QUERY. 
999
+	 *
1000
+	 * @access private
1001
+	 */
1002 1002
 	function _tag_open( &$parser, $tag, $attributes ) {
1003 1003
 		$this->currentElement = strtoupper( $tag );
1004 1004
 		
@@ -1019,8 +1019,8 @@  discard block
 block discarded – undo
1019 1019
 	}
1020 1020
 	
1021 1021
 	/**
1022
-	* XML Callback to process CDATA elements
1023
-	*/
1022
+	 * XML Callback to process CDATA elements
1023
+	 */
1024 1024
 	function _tag_cdata( &$parser, $cdata ) {
1025 1025
 		switch( $this->currentElement ) {
1026 1026
 			// Line of queryset SQL data
@@ -1033,10 +1033,10 @@  discard block
 block discarded – undo
1033 1033
 	}
1034 1034
 	
1035 1035
 	/**
1036
-	* XML Callback to process end elements
1037
-	*
1038
-	* @access private
1039
-	*/
1036
+	 * XML Callback to process end elements
1037
+	 *
1038
+	 * @access private
1039
+	 */
1040 1040
 	function _tag_close( &$parser, $tag ) {
1041 1041
 		$this->currentElement = '';
1042 1042
 		
@@ -1056,10 +1056,10 @@  discard block
 block discarded – undo
1056 1056
 	}
1057 1057
 	
1058 1058
 	/**
1059
-	* Re-initializes the query.
1060
-	*
1061
-	* @return boolean TRUE
1062
-	*/
1059
+	 * Re-initializes the query.
1060
+	 *
1061
+	 * @return boolean TRUE
1062
+	 */
1063 1063
 	function newQuery() {
1064 1064
 		$this->query = '';
1065 1065
 		
@@ -1067,10 +1067,10 @@  discard block
 block discarded – undo
1067 1067
 	}
1068 1068
 	
1069 1069
 	/**
1070
-	* Discards the existing query.
1071
-	*
1072
-	* @return boolean TRUE
1073
-	*/
1070
+	 * Discards the existing query.
1071
+	 *
1072
+	 * @return boolean TRUE
1073
+	 */
1074 1074
 	function discardQuery() {
1075 1075
 		unset( $this->query );
1076 1076
 		
@@ -1078,11 +1078,11 @@  discard block
 block discarded – undo
1078 1078
 	}
1079 1079
 	
1080 1080
 	/** 
1081
-	* Appends a line to a query that is being built line by line
1082
-	*
1083
-	* @param string $data Line of SQL data or NULL to initialize a new query
1084
-	* @return string SQL query string.
1085
-	*/
1081
+	 * Appends a line to a query that is being built line by line
1082
+	 *
1083
+	 * @param string $data Line of SQL data or NULL to initialize a new query
1084
+	 * @return string SQL query string.
1085
+	 */
1086 1086
 	function buildQuery( $sql = NULL ) {
1087 1087
 		if( !isset( $this->query ) OR empty( $sql ) ) {
1088 1088
 			return FALSE;
@@ -1094,10 +1094,10 @@  discard block
 block discarded – undo
1094 1094
 	}
1095 1095
 	
1096 1096
 	/**
1097
-	* Adds a completed query to the query list
1098
-	*
1099
-	* @return string	SQL of added query
1100
-	*/
1097
+	 * Adds a completed query to the query list
1098
+	 *
1099
+	 * @return string	SQL of added query
1100
+	 */
1101 1101
 	function addQuery() {
1102 1102
 		if( !isset( $this->query ) ) {
1103 1103
 			return FALSE;
@@ -1111,11 +1111,11 @@  discard block
 block discarded – undo
1111 1111
 	}
1112 1112
 	
1113 1113
 	/**
1114
-	* Creates and returns the current query set
1115
-	*
1116
-	* @param object $xmls adoSchema object
1117
-	* @return array Query set
1118
-	*/
1114
+	 * Creates and returns the current query set
1115
+	 *
1116
+	 * @param object $xmls adoSchema object
1117
+	 * @return array Query set
1118
+	 */
1119 1119
 	function create( &$xmls ) {
1120 1120
 		foreach( $this->queries as $id => $query ) {
1121 1121
 			switch( $this->prefixMethod ) {
@@ -1151,13 +1151,13 @@  discard block
 block discarded – undo
1151 1151
 	}
1152 1152
 	
1153 1153
 	/**
1154
-	* Rebuilds the query with the prefix attached to any objects
1155
-	*
1156
-	* @param string $regex Regex used to add prefix
1157
-	* @param string $query SQL query string
1158
-	* @param string $prefix Prefix to be appended to tables, indices, etc.
1159
-	* @return string Prefixed SQL query string.
1160
-	*/
1154
+	 * Rebuilds the query with the prefix attached to any objects
1155
+	 *
1156
+	 * @param string $regex Regex used to add prefix
1157
+	 * @param string $query SQL query string
1158
+	 * @param string $prefix Prefix to be appended to tables, indices, etc.
1159
+	 * @return string Prefixed SQL query string.
1160
+	 */
1161 1161
 	function prefixQuery( $regex, $query, $prefix = NULL ) {
1162 1162
 		if( !isset( $prefix ) ) {
1163 1163
 			return $query;
@@ -1202,89 +1202,89 @@  discard block
 block discarded – undo
1202 1202
 class adoSchema {
1203 1203
 	
1204 1204
 	/**
1205
-	* @var array	Array containing SQL queries to generate all objects
1206
-	* @access private
1207
-	*/
1205
+	 * @var array	Array containing SQL queries to generate all objects
1206
+	 * @access private
1207
+	 */
1208 1208
 	var $sqlArray;
1209 1209
 	
1210 1210
 	/**
1211
-	* @var object	ADOdb connection object
1212
-	* @access private
1213
-	*/
1211
+	 * @var object	ADOdb connection object
1212
+	 * @access private
1213
+	 */
1214 1214
 	var $db;
1215 1215
 	
1216 1216
 	/**
1217
-	* @var object	ADOdb Data Dictionary
1218
-	* @access private
1219
-	*/
1217
+	 * @var object	ADOdb Data Dictionary
1218
+	 * @access private
1219
+	 */
1220 1220
 	var $dict;
1221 1221
 	
1222 1222
 	/**
1223
-	* @var string Current XML element
1224
-	* @access private
1225
-	*/
1223
+	 * @var string Current XML element
1224
+	 * @access private
1225
+	 */
1226 1226
 	var $currentElement = '';
1227 1227
 	
1228 1228
 	/**
1229
-	* @var string If set (to 'ALTER' or 'REPLACE'), upgrade an existing database
1230
-	* @access private
1231
-	*/
1229
+	 * @var string If set (to 'ALTER' or 'REPLACE'), upgrade an existing database
1230
+	 * @access private
1231
+	 */
1232 1232
 	var $upgrade = '';
1233 1233
 	
1234 1234
 	/**
1235
-	* @var string Optional object prefix
1236
-	* @access private
1237
-	*/
1235
+	 * @var string Optional object prefix
1236
+	 * @access private
1237
+	 */
1238 1238
 	var $objectPrefix = '';
1239 1239
 	
1240 1240
 	/**
1241
-	* @var long	Original Magic Quotes Runtime value
1242
-	* @access private
1243
-	*/
1241
+	 * @var long	Original Magic Quotes Runtime value
1242
+	 * @access private
1243
+	 */
1244 1244
 	var $mgq;
1245 1245
 	
1246 1246
 	/**
1247
-	* @var long	System debug
1248
-	* @access private
1249
-	*/
1247
+	 * @var long	System debug
1248
+	 * @access private
1249
+	 */
1250 1250
 	var $debug;
1251 1251
 	
1252 1252
 	/**
1253
-	* @var string Regular expression to find schema version
1254
-	* @access private
1255
-	*/
1253
+	 * @var string Regular expression to find schema version
1254
+	 * @access private
1255
+	 */
1256 1256
 	var $versionRegex = '/<schema.*?( version="([^"]*)")?.*?>/';
1257 1257
 	
1258 1258
 	/**
1259
-	* @var string Current schema version
1260
-	* @access private
1261
-	*/
1259
+	 * @var string Current schema version
1260
+	 * @access private
1261
+	 */
1262 1262
 	var $schemaVersion;
1263 1263
 	
1264 1264
 	/**
1265
-	* @var int	Success of last Schema execution
1266
-	*/
1265
+	 * @var int	Success of last Schema execution
1266
+	 */
1267 1267
 	var $success;
1268 1268
 	
1269 1269
 	/**
1270
-	* @var bool	Execute SQL inline as it is generated
1271
-	*/
1270
+	 * @var bool	Execute SQL inline as it is generated
1271
+	 */
1272 1272
 	var $executeInline;
1273 1273
 	
1274 1274
 	/**
1275
-	* @var bool	Continue SQL execution if errors occur
1276
-	*/
1275
+	 * @var bool	Continue SQL execution if errors occur
1276
+	 */
1277 1277
 	var $continueOnError;
1278 1278
 	
1279 1279
 	/**
1280
-	* Creates an adoSchema object
1281
-	*
1282
-	* Creating an adoSchema object is the first step in processing an XML schema.
1283
-	* The only parameter is an ADOdb database connection object, which must already
1284
-	* have been created.
1285
-	*
1286
-	* @param object $db ADOdb database connection object.
1287
-	*/
1280
+	 * Creates an adoSchema object
1281
+	 *
1282
+	 * Creating an adoSchema object is the first step in processing an XML schema.
1283
+	 * The only parameter is an ADOdb database connection object, which must already
1284
+	 * have been created.
1285
+	 *
1286
+	 * @param object $db ADOdb database connection object.
1287
+	 */
1288 1288
 	function adoSchema( &$db ) {
1289 1289
 		// Initialize the environment
1290 1290
 		$this->mgq = get_magic_quotes_runtime();
@@ -1301,21 +1301,21 @@  discard block
 block discarded – undo
1301 1301
 	}
1302 1302
 	
1303 1303
 	/**
1304
-	* Sets the method to be used for upgrading an existing database
1305
-	*
1306
-	* Use this method to specify how existing database objects should be upgraded.
1307
-	* The method option can be set to ALTER, REPLACE, BEST, or NONE. ALTER attempts to
1308
-	* alter each database object directly, REPLACE attempts to rebuild each object
1309
-	* from scratch, BEST attempts to determine the best upgrade method for each
1310
-	* object, and NONE disables upgrading.
1311
-	*
1312
-	* This method is not yet used by AXMLS, but exists for backward compatibility.
1313
-	* The ALTER method is automatically assumed when the adoSchema object is
1314
-	* instantiated; other upgrade methods are not currently supported.
1315
-	*
1316
-	* @param string $method Upgrade method (ALTER|REPLACE|BEST|NONE)
1317
-	* @returns string Upgrade method used
1318
-	*/
1304
+	 * Sets the method to be used for upgrading an existing database
1305
+	 *
1306
+	 * Use this method to specify how existing database objects should be upgraded.
1307
+	 * The method option can be set to ALTER, REPLACE, BEST, or NONE. ALTER attempts to
1308
+	 * alter each database object directly, REPLACE attempts to rebuild each object
1309
+	 * from scratch, BEST attempts to determine the best upgrade method for each
1310
+	 * object, and NONE disables upgrading.
1311
+	 *
1312
+	 * This method is not yet used by AXMLS, but exists for backward compatibility.
1313
+	 * The ALTER method is automatically assumed when the adoSchema object is
1314
+	 * instantiated; other upgrade methods are not currently supported.
1315
+	 *
1316
+	 * @param string $method Upgrade method (ALTER|REPLACE|BEST|NONE)
1317
+	 * @returns string Upgrade method used
1318
+	 */
1319 1319
 	function SetUpgradeMethod( $method = '' ) {
1320 1320
 		if( !is_string( $method ) ) {
1321 1321
 			return FALSE;
@@ -1346,18 +1346,18 @@  discard block
 block discarded – undo
1346 1346
 	}
1347 1347
 	
1348 1348
 	/**
1349
-	* Enables/disables inline SQL execution.
1350
-	*
1351
-	* Call this method to enable or disable inline execution of the schema. If the mode is set to TRUE (inline execution),
1352
-	* AXMLS applies the SQL to the database immediately as each schema entity is parsed. If the mode
1353
-	* is set to FALSE (post execution), AXMLS parses the entire schema and you will need to call adoSchema::ExecuteSchema()
1354
-	* to apply the schema to the database.
1355
-	*
1356
-	* @param bool $mode execute
1357
-	* @return bool current execution mode
1358
-	*
1359
-	* @see ParseSchema(), ExecuteSchema()
1360
-	*/
1349
+	 * Enables/disables inline SQL execution.
1350
+	 *
1351
+	 * Call this method to enable or disable inline execution of the schema. If the mode is set to TRUE (inline execution),
1352
+	 * AXMLS applies the SQL to the database immediately as each schema entity is parsed. If the mode
1353
+	 * is set to FALSE (post execution), AXMLS parses the entire schema and you will need to call adoSchema::ExecuteSchema()
1354
+	 * to apply the schema to the database.
1355
+	 *
1356
+	 * @param bool $mode execute
1357
+	 * @return bool current execution mode
1358
+	 *
1359
+	 * @see ParseSchema(), ExecuteSchema()
1360
+	 */
1361 1361
 	function ExecuteInline( $mode = NULL ) {
1362 1362
 		if( is_bool( $mode ) ) {
1363 1363
 			$this->executeInline = $mode;
@@ -1367,18 +1367,18 @@  discard block
 block discarded – undo
1367 1367
 	}
1368 1368
 	
1369 1369
 	/**
1370
-	* Enables/disables SQL continue on error.
1371
-	*
1372
-	* Call this method to enable or disable continuation of SQL execution if an error occurs.
1373
-	* If the mode is set to TRUE (continue), AXMLS will continue to apply SQL to the database, even if an error occurs.
1374
-	* If the mode is set to FALSE (halt), AXMLS will halt execution of generated sql if an error occurs, though parsing
1375
-	* of the schema will continue.
1376
-	*
1377
-	* @param bool $mode execute
1378
-	* @return bool current continueOnError mode
1379
-	*
1380
-	* @see addSQL(), ExecuteSchema()
1381
-	*/
1370
+	 * Enables/disables SQL continue on error.
1371
+	 *
1372
+	 * Call this method to enable or disable continuation of SQL execution if an error occurs.
1373
+	 * If the mode is set to TRUE (continue), AXMLS will continue to apply SQL to the database, even if an error occurs.
1374
+	 * If the mode is set to FALSE (halt), AXMLS will halt execution of generated sql if an error occurs, though parsing
1375
+	 * of the schema will continue.
1376
+	 *
1377
+	 * @param bool $mode execute
1378
+	 * @return bool current continueOnError mode
1379
+	 *
1380
+	 * @see addSQL(), ExecuteSchema()
1381
+	 */
1382 1382
 	function ContinueOnError( $mode = NULL ) {
1383 1383
 		if( is_bool( $mode ) ) {
1384 1384
 			$this->continueOnError = $mode;
@@ -1388,33 +1388,33 @@  discard block
 block discarded – undo
1388 1388
 	}
1389 1389
 	
1390 1390
 	/**
1391
-	* Loads an XML schema from a file and converts it to SQL.
1392
-	*
1393
-	* Call this method to load the specified schema (see the DTD for the proper format) from
1394
-	* the filesystem and generate the SQL necessary to create the database described. 
1395
-	* @see ParseSchemaString()
1396
-	*
1397
-	* @param string $file Name of XML schema file.
1398
-	* @param bool $returnSchema Return schema rather than parsing.
1399
-	* @return array Array of SQL queries, ready to execute
1400
-	*/
1391
+	 * Loads an XML schema from a file and converts it to SQL.
1392
+	 *
1393
+	 * Call this method to load the specified schema (see the DTD for the proper format) from
1394
+	 * the filesystem and generate the SQL necessary to create the database described. 
1395
+	 * @see ParseSchemaString()
1396
+	 *
1397
+	 * @param string $file Name of XML schema file.
1398
+	 * @param bool $returnSchema Return schema rather than parsing.
1399
+	 * @return array Array of SQL queries, ready to execute
1400
+	 */
1401 1401
 	function ParseSchema( $filename, $returnSchema = FALSE ) {
1402 1402
 		return $this->ParseSchemaString( $this->ConvertSchemaFile( $filename ), $returnSchema );
1403 1403
 	}
1404 1404
 	
1405 1405
 	/**
1406
-	* Loads an XML schema from a file and converts it to SQL.
1407
-	*
1408
-	* Call this method to load the specified schema from a file (see the DTD for the proper format) 
1409
-	* and generate the SQL necessary to create the database described by the schema.
1410
-	*
1411
-	* @param string $file Name of XML schema file.
1412
-	* @param bool $returnSchema Return schema rather than parsing.
1413
-	* @return array Array of SQL queries, ready to execute.
1414
-	*
1415
-	* @deprecated Replaced by adoSchema::ParseSchema() and adoSchema::ParseSchemaString()
1416
-	* @see ParseSchema(), ParseSchemaString()
1417
-	*/
1406
+	 * Loads an XML schema from a file and converts it to SQL.
1407
+	 *
1408
+	 * Call this method to load the specified schema from a file (see the DTD for the proper format) 
1409
+	 * and generate the SQL necessary to create the database described by the schema.
1410
+	 *
1411
+	 * @param string $file Name of XML schema file.
1412
+	 * @param bool $returnSchema Return schema rather than parsing.
1413
+	 * @return array Array of SQL queries, ready to execute.
1414
+	 *
1415
+	 * @deprecated Replaced by adoSchema::ParseSchema() and adoSchema::ParseSchemaString()
1416
+	 * @see ParseSchema(), ParseSchemaString()
1417
+	 */
1418 1418
 	function ParseSchemaFile( $filename, $returnSchema = FALSE ) {
1419 1419
 		// Open the file
1420 1420
 		if( !($fp = fopen( $filename, 'r' )) ) {
@@ -1453,16 +1453,16 @@  discard block
 block discarded – undo
1453 1453
 	}
1454 1454
 	
1455 1455
 	/**
1456
-	* Converts an XML schema string to SQL.
1457
-	*
1458
-	* Call this method to parse a string containing an XML schema (see the DTD for the proper format)
1459
-	* and generate the SQL necessary to create the database described by the schema. 
1460
-	* @see ParseSchema()
1461
-	*
1462
-	* @param string $xmlstring XML schema string.
1463
-	* @param bool $returnSchema Return schema rather than parsing.
1464
-	* @return array Array of SQL queries, ready to execute.
1465
-	*/
1456
+	 * Converts an XML schema string to SQL.
1457
+	 *
1458
+	 * Call this method to parse a string containing an XML schema (see the DTD for the proper format)
1459
+	 * and generate the SQL necessary to create the database described by the schema. 
1460
+	 * @see ParseSchema()
1461
+	 *
1462
+	 * @param string $xmlstring XML schema string.
1463
+	 * @param bool $returnSchema Return schema rather than parsing.
1464
+	 * @return array Array of SQL queries, ready to execute.
1465
+	 */
1466 1466
 	function ParseSchemaString( $xmlstring, $returnSchema = FALSE ) {
1467 1467
 		if( !is_string( $xmlstring ) OR empty( $xmlstring ) ) {
1468 1468
 			return FALSE;
@@ -1496,31 +1496,31 @@  discard block
 block discarded – undo
1496 1496
 	}
1497 1497
 	
1498 1498
 	/**
1499
-	* Loads an XML schema from a file and converts it to uninstallation SQL.
1500
-	*
1501
-	* Call this method to load the specified schema (see the DTD for the proper format) from
1502
-	* the filesystem and generate the SQL necessary to remove the database described.
1503
-	* @see RemoveSchemaString()
1504
-	*
1505
-	* @param string $file Name of XML schema file.
1506
-	* @param bool $returnSchema Return schema rather than parsing.
1507
-	* @return array Array of SQL queries, ready to execute
1508
-	*/
1499
+	 * Loads an XML schema from a file and converts it to uninstallation SQL.
1500
+	 *
1501
+	 * Call this method to load the specified schema (see the DTD for the proper format) from
1502
+	 * the filesystem and generate the SQL necessary to remove the database described.
1503
+	 * @see RemoveSchemaString()
1504
+	 *
1505
+	 * @param string $file Name of XML schema file.
1506
+	 * @param bool $returnSchema Return schema rather than parsing.
1507
+	 * @return array Array of SQL queries, ready to execute
1508
+	 */
1509 1509
 	function RemoveSchema( $filename, $returnSchema = FALSE ) {
1510 1510
 		return $this->RemoveSchemaString( $this->ConvertSchemaFile( $filename ), $returnSchema );
1511 1511
 	}
1512 1512
 	
1513 1513
 	/**
1514
-	* Converts an XML schema string to uninstallation SQL.
1515
-	*
1516
-	* Call this method to parse a string containing an XML schema (see the DTD for the proper format)
1517
-	* and generate the SQL necessary to uninstall the database described by the schema. 
1518
-	* @see RemoveSchema()
1519
-	*
1520
-	* @param string $schema XML schema string.
1521
-	* @param bool $returnSchema Return schema rather than parsing.
1522
-	* @return array Array of SQL queries, ready to execute.
1523
-	*/
1514
+	 * Converts an XML schema string to uninstallation SQL.
1515
+	 *
1516
+	 * Call this method to parse a string containing an XML schema (see the DTD for the proper format)
1517
+	 * and generate the SQL necessary to uninstall the database described by the schema. 
1518
+	 * @see RemoveSchema()
1519
+	 *
1520
+	 * @param string $schema XML schema string.
1521
+	 * @param bool $returnSchema Return schema rather than parsing.
1522
+	 * @return array Array of SQL queries, ready to execute.
1523
+	 */
1524 1524
 	function RemoveSchemaString( $schema, $returnSchema = FALSE ) {
1525 1525
 		
1526 1526
 		// grab current version
@@ -1532,18 +1532,18 @@  discard block
 block discarded – undo
1532 1532
 	}
1533 1533
 	
1534 1534
 	/**
1535
-	* Applies the current XML schema to the database (post execution).
1536
-	*
1537
-	* Call this method to apply the current schema (generally created by calling 
1538
-	* ParseSchema() or ParseSchemaString() ) to the database (creating the tables, indexes, 
1539
-	* and executing other SQL specified in the schema) after parsing.
1540
-	* @see ParseSchema(), ParseSchemaString(), ExecuteInline()
1541
-	*
1542
-	* @param array $sqlArray Array of SQL statements that will be applied rather than
1543
-	*		the current schema.
1544
-	* @param boolean $continueOnErr Continue to apply the schema even if an error occurs.
1545
-	* @returns integer 0 if failure, 1 if errors, 2 if successful.
1546
-	*/
1535
+	 * Applies the current XML schema to the database (post execution).
1536
+	 *
1537
+	 * Call this method to apply the current schema (generally created by calling 
1538
+	 * ParseSchema() or ParseSchemaString() ) to the database (creating the tables, indexes, 
1539
+	 * and executing other SQL specified in the schema) after parsing.
1540
+	 * @see ParseSchema(), ParseSchemaString(), ExecuteInline()
1541
+	 *
1542
+	 * @param array $sqlArray Array of SQL statements that will be applied rather than
1543
+	 *		the current schema.
1544
+	 * @param boolean $continueOnErr Continue to apply the schema even if an error occurs.
1545
+	 * @returns integer 0 if failure, 1 if errors, 2 if successful.
1546
+	 */
1547 1547
 	function ExecuteSchema( $sqlArray = NULL, $continueOnErr =  NULL ) {
1548 1548
 		if( !is_bool( $continueOnErr ) ) {
1549 1549
 			$continueOnErr = $this->ContinueOnError();
@@ -1563,27 +1563,27 @@  discard block
 block discarded – undo
1563 1563
 	}
1564 1564
 	
1565 1565
 	/**
1566
-	* Returns the current SQL array. 
1567
-	*
1568
-	* Call this method to fetch the array of SQL queries resulting from 
1569
-	* ParseSchema() or ParseSchemaString(). 
1570
-	*
1571
-	* @param string $format Format: HTML, TEXT, or NONE (PHP array)
1572
-	* @return array Array of SQL statements or FALSE if an error occurs
1573
-	*/
1566
+	 * Returns the current SQL array. 
1567
+	 *
1568
+	 * Call this method to fetch the array of SQL queries resulting from 
1569
+	 * ParseSchema() or ParseSchemaString(). 
1570
+	 *
1571
+	 * @param string $format Format: HTML, TEXT, or NONE (PHP array)
1572
+	 * @return array Array of SQL statements or FALSE if an error occurs
1573
+	 */
1574 1574
 	function PrintSQL( $format = 'NONE' ) {
1575 1575
 		return $this->getSQL( $format, $sqlArray );
1576 1576
 	}
1577 1577
 	
1578 1578
 	/**
1579
-	* Saves the current SQL array to the local filesystem as a list of SQL queries.
1580
-	*
1581
-	* Call this method to save the array of SQL queries (generally resulting from a
1582
-	* parsed XML schema) to the filesystem.
1583
-	*
1584
-	* @param string $filename Path and name where the file should be saved.
1585
-	* @return boolean TRUE if save is successful, else FALSE. 
1586
-	*/
1579
+	 * Saves the current SQL array to the local filesystem as a list of SQL queries.
1580
+	 *
1581
+	 * Call this method to save the array of SQL queries (generally resulting from a
1582
+	 * parsed XML schema) to the filesystem.
1583
+	 *
1584
+	 * @param string $filename Path and name where the file should be saved.
1585
+	 * @return boolean TRUE if save is successful, else FALSE. 
1586
+	 */
1587 1587
 	function SaveSQL( $filename = './schema.sql' ) {
1588 1588
 		
1589 1589
 		if( !isset( $sqlArray ) ) {
@@ -1602,12 +1602,12 @@  discard block
 block discarded – undo
1602 1602
 	}
1603 1603
 	
1604 1604
 	/**
1605
-	* Create an xml parser
1606
-	*
1607
-	* @return object PHP XML parser object
1608
-	*
1609
-	* @access private
1610
-	*/
1605
+	 * Create an xml parser
1606
+	 *
1607
+	 * @return object PHP XML parser object
1608
+	 *
1609
+	 * @access private
1610
+	 */
1611 1611
 	function &create_parser() {
1612 1612
 		// Create the parser
1613 1613
 		$xmlParser = xml_parser_create();
@@ -1621,10 +1621,10 @@  discard block
 block discarded – undo
1621 1621
 	}
1622 1622
 	
1623 1623
 	/**
1624
-	* XML Callback to process start elements
1625
-	*
1626
-	* @access private
1627
-	*/
1624
+	 * XML Callback to process start elements
1625
+	 *
1626
+	 * @access private
1627
+	 */
1628 1628
 	function _tag_open( &$parser, $tag, $attributes ) {
1629 1629
 		switch( strtoupper( $tag ) ) {
1630 1630
 			case 'TABLE':
@@ -1644,39 +1644,39 @@  discard block
 block discarded – undo
1644 1644
 	}
1645 1645
 	
1646 1646
 	/**
1647
-	* XML Callback to process CDATA elements
1648
-	*
1649
-	* @access private
1650
-	*/
1647
+	 * XML Callback to process CDATA elements
1648
+	 *
1649
+	 * @access private
1650
+	 */
1651 1651
 	function _tag_cdata( &$parser, $cdata ) {
1652 1652
 	}
1653 1653
 	
1654 1654
 	/**
1655
-	* XML Callback to process end elements
1656
-	*
1657
-	* @access private
1658
-	* @internal
1659
-	*/
1655
+	 * XML Callback to process end elements
1656
+	 *
1657
+	 * @access private
1658
+	 * @internal
1659
+	 */
1660 1660
 	function _tag_close( &$parser, $tag ) {
1661 1661
 		
1662 1662
 	}
1663 1663
 	
1664 1664
 	/**
1665
-	* Converts an XML schema string to the specified DTD version.
1666
-	*
1667
-	* Call this method to convert a string containing an XML schema to a different AXMLS
1668
-	* DTD version. For instance, to convert a schema created for an pre-1.0 version for 
1669
-	* AXMLS (DTD version 0.1) to a newer version of the DTD (e.g. 0.2). If no DTD version 
1670
-	* parameter is specified, the schema will be converted to the current DTD version. 
1671
-	* If the newFile parameter is provided, the converted schema will be written to the specified
1672
-	* file.
1673
-	* @see ConvertSchemaFile()
1674
-	*
1675
-	* @param string $schema String containing XML schema that will be converted.
1676
-	* @param string $newVersion DTD version to convert to.
1677
-	* @param string $newFile File name of (converted) output file.
1678
-	* @return string Converted XML schema or FALSE if an error occurs.
1679
-	*/
1665
+	 * Converts an XML schema string to the specified DTD version.
1666
+	 *
1667
+	 * Call this method to convert a string containing an XML schema to a different AXMLS
1668
+	 * DTD version. For instance, to convert a schema created for an pre-1.0 version for 
1669
+	 * AXMLS (DTD version 0.1) to a newer version of the DTD (e.g. 0.2). If no DTD version 
1670
+	 * parameter is specified, the schema will be converted to the current DTD version. 
1671
+	 * If the newFile parameter is provided, the converted schema will be written to the specified
1672
+	 * file.
1673
+	 * @see ConvertSchemaFile()
1674
+	 *
1675
+	 * @param string $schema String containing XML schema that will be converted.
1676
+	 * @param string $newVersion DTD version to convert to.
1677
+	 * @param string $newFile File name of (converted) output file.
1678
+	 * @return string Converted XML schema or FALSE if an error occurs.
1679
+	 */
1680 1680
 	function ConvertSchemaString( $schema, $newVersion = NULL, $newFile = NULL ) {
1681 1681
 		
1682 1682
 		// grab current version
@@ -1703,21 +1703,21 @@  discard block
 block discarded – undo
1703 1703
 	}
1704 1704
 	
1705 1705
 	/**
1706
-	* Converts an XML schema file to the specified DTD version.
1707
-	*
1708
-	* Call this method to convert the specified XML schema file to a different AXMLS
1709
-	* DTD version. For instance, to convert a schema created for an pre-1.0 version for 
1710
-	* AXMLS (DTD version 0.1) to a newer version of the DTD (e.g. 0.2). If no DTD version 
1711
-	* parameter is specified, the schema will be converted to the current DTD version. 
1712
-	* If the newFile parameter is provided, the converted schema will be written to the specified
1713
-	* file.
1714
-	* @see ConvertSchemaString()
1715
-	*
1716
-	* @param string $filename Name of XML schema file that will be converted.
1717
-	* @param string $newVersion DTD version to convert to.
1718
-	* @param string $newFile File name of (converted) output file.
1719
-	* @return string Converted XML schema or FALSE if an error occurs.
1720
-	*/
1706
+	 * Converts an XML schema file to the specified DTD version.
1707
+	 *
1708
+	 * Call this method to convert the specified XML schema file to a different AXMLS
1709
+	 * DTD version. For instance, to convert a schema created for an pre-1.0 version for 
1710
+	 * AXMLS (DTD version 0.1) to a newer version of the DTD (e.g. 0.2). If no DTD version 
1711
+	 * parameter is specified, the schema will be converted to the current DTD version. 
1712
+	 * If the newFile parameter is provided, the converted schema will be written to the specified
1713
+	 * file.
1714
+	 * @see ConvertSchemaString()
1715
+	 *
1716
+	 * @param string $filename Name of XML schema file that will be converted.
1717
+	 * @param string $newVersion DTD version to convert to.
1718
+	 * @param string $newFile File name of (converted) output file.
1719
+	 * @return string Converted XML schema or FALSE if an error occurs.
1720
+	 */
1721 1721
 	function ConvertSchemaFile( $filename, $newVersion = NULL, $newFile = NULL ) {
1722 1722
 		
1723 1723
 		// grab current version
@@ -1798,15 +1798,15 @@  discard block
 block discarded – undo
1798 1798
 	}
1799 1799
 	
1800 1800
 	/**
1801
-	* Processes XSLT transformation errors
1802
-	*
1803
-	* @param object $parser XML parser object
1804
-	* @param integer $errno Error number
1805
-	* @param integer $level Error level
1806
-	* @param array $fields Error information fields
1807
-	*
1808
-	* @access private
1809
-	*/
1801
+	 * Processes XSLT transformation errors
1802
+	 *
1803
+	 * @param object $parser XML parser object
1804
+	 * @param integer $errno Error number
1805
+	 * @param integer $level Error level
1806
+	 * @param array $fields Error information fields
1807
+	 *
1808
+	 * @access private
1809
+	 */
1810 1810
 	function xslt_error_handler( $parser, $errno, $level, $fields ) {
1811 1811
 		if( is_array( $fields ) ) {
1812 1812
 			$msg = array(
@@ -1851,14 +1851,14 @@  discard block
 block discarded – undo
1851 1851
 	}
1852 1852
 	
1853 1853
 	/**
1854
-	* Returns the AXMLS Schema Version of the requested XML schema file.
1855
-	*
1856
-	* Call this method to obtain the AXMLS DTD version of the requested XML schema file.
1857
-	* @see SchemaStringVersion()
1858
-	*
1859
-	* @param string $filename AXMLS schema file
1860
-	* @return string Schema version number or FALSE on error
1861
-	*/
1854
+	 * Returns the AXMLS Schema Version of the requested XML schema file.
1855
+	 *
1856
+	 * Call this method to obtain the AXMLS DTD version of the requested XML schema file.
1857
+	 * @see SchemaStringVersion()
1858
+	 *
1859
+	 * @param string $filename AXMLS schema file
1860
+	 * @return string Schema version number or FALSE on error
1861
+	 */
1862 1862
 	function SchemaFileVersion( $filename ) {
1863 1863
 		// Open the file
1864 1864
 		if( !($fp = fopen( $filename, 'r' )) ) {
@@ -1877,14 +1877,14 @@  discard block
 block discarded – undo
1877 1877
 	}
1878 1878
 	
1879 1879
 	/**
1880
-	* Returns the AXMLS Schema Version of the provided XML schema string.
1881
-	*
1882
-	* Call this method to obtain the AXMLS DTD version of the provided XML schema string.
1883
-	* @see SchemaFileVersion()
1884
-	*
1885
-	* @param string $xmlstring XML schema string
1886
-	* @return string Schema version number or FALSE on error
1887
-	*/
1880
+	 * Returns the AXMLS Schema Version of the provided XML schema string.
1881
+	 *
1882
+	 * Call this method to obtain the AXMLS DTD version of the provided XML schema string.
1883
+	 * @see SchemaFileVersion()
1884
+	 *
1885
+	 * @param string $xmlstring XML schema string
1886
+	 * @return string Schema version number or FALSE on error
1887
+	 */
1888 1888
 	function SchemaStringVersion( $xmlstring ) {
1889 1889
 		if( !is_string( $xmlstring ) OR empty( $xmlstring ) ) {
1890 1890
 			return FALSE;
@@ -1898,15 +1898,15 @@  discard block
 block discarded – undo
1898 1898
 	}
1899 1899
 	
1900 1900
 	/**
1901
-	* Extracts an XML schema from an existing database.
1902
-	*
1903
-	* Call this method to create an XML schema string from an existing database.
1904
-	* If the data parameter is set to TRUE, AXMLS will include the data from the database
1905
-	* in the schema. 
1906
-	*
1907
-	* @param boolean $data Include data in schema dump
1908
-	* @return string Generated XML schema
1909
-	*/
1901
+	 * Extracts an XML schema from an existing database.
1902
+	 *
1903
+	 * Call this method to create an XML schema string from an existing database.
1904
+	 * If the data parameter is set to TRUE, AXMLS will include the data from the database
1905
+	 * in the schema. 
1906
+	 *
1907
+	 * @param boolean $data Include data in schema dump
1908
+	 * @return string Generated XML schema
1909
+	 */
1910 1910
 	function ExtractSchema( $data = FALSE ) {
1911 1911
 		$old_mode = $this->db->SetFetchMode( ADODB_FETCH_NUM );
1912 1912
 		
@@ -2005,15 +2005,15 @@  discard block
 block discarded – undo
2005 2005
 	}
2006 2006
 	
2007 2007
 	/**
2008
-	* Sets a prefix for database objects
2009
-	*
2010
-	* Call this method to set a standard prefix that will be prepended to all database tables 
2011
-	* and indices when the schema is parsed. Calling setPrefix with no arguments clears the prefix.
2012
-	*
2013
-	* @param string $prefix Prefix that will be prepended.
2014
-	* @param boolean $underscore If TRUE, automatically append an underscore character to the prefix.
2015
-	* @return boolean TRUE if successful, else FALSE
2016
-	*/
2008
+	 * Sets a prefix for database objects
2009
+	 *
2010
+	 * Call this method to set a standard prefix that will be prepended to all database tables 
2011
+	 * and indices when the schema is parsed. Calling setPrefix with no arguments clears the prefix.
2012
+	 *
2013
+	 * @param string $prefix Prefix that will be prepended.
2014
+	 * @param boolean $underscore If TRUE, automatically append an underscore character to the prefix.
2015
+	 * @return boolean TRUE if successful, else FALSE
2016
+	 */
2017 2017
 	function SetPrefix( $prefix = '', $underscore = TRUE ) {
2018 2018
 		switch( TRUE ) {
2019 2019
 			// clear prefix
@@ -2040,13 +2040,13 @@  discard block
 block discarded – undo
2040 2040
 	}
2041 2041
 	
2042 2042
 	/**
2043
-	* Returns an object name with the current prefix prepended.
2044
-	*
2045
-	* @param string	$name Name
2046
-	* @return string	Prefixed name
2047
-	*
2048
-	* @access private
2049
-	*/
2043
+	 * Returns an object name with the current prefix prepended.
2044
+	 *
2045
+	 * @param string	$name Name
2046
+	 * @return string	Prefixed name
2047
+	 *
2048
+	 * @access private
2049
+	 */
2050 2050
 	function prefix( $name = '' ) {
2051 2051
 		// if prefix is set
2052 2052
 		if( !empty( $this->objectPrefix ) ) {
@@ -2060,13 +2060,13 @@  discard block
 block discarded – undo
2060 2060
 	}
2061 2061
 	
2062 2062
 	/**
2063
-	* Checks if element references a specific platform
2064
-	*
2065
-	* @param string $platform Requested platform
2066
-	* @returns boolean TRUE if platform check succeeds
2067
-	*
2068
-	* @access private
2069
-	*/
2063
+	 * Checks if element references a specific platform
2064
+	 *
2065
+	 * @param string $platform Requested platform
2066
+	 * @returns boolean TRUE if platform check succeeds
2067
+	 *
2068
+	 * @access private
2069
+	 */
2070 2070
 	function supportedPlatform( $platform = NULL ) {
2071 2071
 		$regex = '/^(\w*\|)*' . $this->db->databaseType . '(\|\w*)*$/';
2072 2072
 		
@@ -2080,22 +2080,22 @@  discard block
 block discarded – undo
2080 2080
 	}
2081 2081
 	
2082 2082
 	/**
2083
-	* Clears the array of generated SQL.
2084
-	*
2085
-	* @access private
2086
-	*/
2083
+	 * Clears the array of generated SQL.
2084
+	 *
2085
+	 * @access private
2086
+	 */
2087 2087
 	function clearSQL() {
2088 2088
 		$this->sqlArray = array();
2089 2089
 	}
2090 2090
 	
2091 2091
 	/**
2092
-	* Adds SQL into the SQL array.
2093
-	*
2094
-	* @param mixed $sql SQL to Add
2095
-	* @return boolean TRUE if successful, else FALSE.
2096
-	*
2097
-	* @access private
2098
-	*/	
2092
+	 * Adds SQL into the SQL array.
2093
+	 *
2094
+	 * @param mixed $sql SQL to Add
2095
+	 * @return boolean TRUE if successful, else FALSE.
2096
+	 *
2097
+	 * @access private
2098
+	 */	
2099 2099
 	function addSQL( $sql = NULL ) {
2100 2100
 		if( is_array( $sql ) ) {
2101 2101
 			foreach( $sql as $line ) {
@@ -2131,13 +2131,13 @@  discard block
 block discarded – undo
2131 2131
 	}
2132 2132
 	
2133 2133
 	/**
2134
-	* Gets the SQL array in the specified format.
2135
-	*
2136
-	* @param string $format Format
2137
-	* @return mixed SQL
2138
-	*	
2139
-	* @access private
2140
-	*/
2134
+	 * Gets the SQL array in the specified format.
2135
+	 *
2136
+	 * @param string $format Format
2137
+	 * @return mixed SQL
2138
+	 *	
2139
+	 * @access private
2140
+	 */
2141 2141
 	function getSQL( $format = NULL, $sqlArray = NULL ) {
2142 2142
 		if( !is_array( $sqlArray ) ) {
2143 2143
 			$sqlArray = $this->sqlArray;
@@ -2159,11 +2159,11 @@  discard block
 block discarded – undo
2159 2159
 	}
2160 2160
 	
2161 2161
 	/**
2162
-	* Destroys an adoSchema object.
2163
-	*
2164
-	* Call this method to clean up after an adoSchema object that is no longer in use.
2165
-	* @deprecated adoSchema now cleans up automatically.
2166
-	*/
2162
+	 * Destroys an adoSchema object.
2163
+	 *
2164
+	 * Call this method to clean up after an adoSchema object that is no longer in use.
2165
+	 * @deprecated adoSchema now cleans up automatically.
2166
+	 */
2167 2167
 	function Destroy() {
2168 2168
 		set_magic_quotes_runtime( $this->mgq );
2169 2169
 		unset( $this );
Please login to merge, or discard this patch.
Spacing   +405 added lines, -405 removed lines patch added patch discarded remove patch
@@ -21,65 +21,65 @@  discard block
 block discarded – undo
21 21
 /**
22 22
 * Debug on or off
23 23
 */
24
-if( !defined( 'XMLS_DEBUG' ) ) {
25
-	define( 'XMLS_DEBUG', FALSE );
24
+if (!defined('XMLS_DEBUG')) {
25
+	define('XMLS_DEBUG', FALSE);
26 26
 }
27 27
 
28 28
 /**
29 29
 * Default prefix key
30 30
 */
31
-if( !defined( 'XMLS_PREFIX' ) ) {
32
-	define( 'XMLS_PREFIX', '%%P' );
31
+if (!defined('XMLS_PREFIX')) {
32
+	define('XMLS_PREFIX', '%%P');
33 33
 }
34 34
 
35 35
 /**
36 36
 * Maximum length allowed for object prefix
37 37
 */
38
-if( !defined( 'XMLS_PREFIX_MAXLEN' ) ) {
39
-	define( 'XMLS_PREFIX_MAXLEN', 10 );
38
+if (!defined('XMLS_PREFIX_MAXLEN')) {
39
+	define('XMLS_PREFIX_MAXLEN', 10);
40 40
 }
41 41
 
42 42
 /**
43 43
 * Execute SQL inline as it is generated
44 44
 */
45
-if( !defined( 'XMLS_EXECUTE_INLINE' ) ) {
46
-	define( 'XMLS_EXECUTE_INLINE', FALSE );
45
+if (!defined('XMLS_EXECUTE_INLINE')) {
46
+	define('XMLS_EXECUTE_INLINE', FALSE);
47 47
 }
48 48
 
49 49
 /**
50 50
 * Continue SQL Execution if an error occurs?
51 51
 */
52
-if( !defined( 'XMLS_CONTINUE_ON_ERROR' ) ) {
53
-	define( 'XMLS_CONTINUE_ON_ERROR', FALSE );
52
+if (!defined('XMLS_CONTINUE_ON_ERROR')) {
53
+	define('XMLS_CONTINUE_ON_ERROR', FALSE);
54 54
 }
55 55
 
56 56
 /**
57 57
 * Current Schema Version
58 58
 */
59
-if( !defined( 'XMLS_SCHEMA_VERSION' ) ) {
60
-	define( 'XMLS_SCHEMA_VERSION', '0.2' );
59
+if (!defined('XMLS_SCHEMA_VERSION')) {
60
+	define('XMLS_SCHEMA_VERSION', '0.2');
61 61
 }
62 62
 
63 63
 /**
64 64
 * Default Schema Version.  Used for Schemas without an explicit version set.
65 65
 */
66
-if( !defined( 'XMLS_DEFAULT_SCHEMA_VERSION' ) ) {
67
-	define( 'XMLS_DEFAULT_SCHEMA_VERSION', '0.1' );
66
+if (!defined('XMLS_DEFAULT_SCHEMA_VERSION')) {
67
+	define('XMLS_DEFAULT_SCHEMA_VERSION', '0.1');
68 68
 }
69 69
 
70 70
 /**
71 71
 * Default Schema Version.  Used for Schemas without an explicit version set.
72 72
 */
73
-if( !defined( 'XMLS_DEFAULT_UPGRADE_METHOD' ) ) {
74
-	define( 'XMLS_DEFAULT_UPGRADE_METHOD', 'ALTER' );
73
+if (!defined('XMLS_DEFAULT_UPGRADE_METHOD')) {
74
+	define('XMLS_DEFAULT_UPGRADE_METHOD', 'ALTER');
75 75
 }
76 76
 
77 77
 /**
78 78
 * Include the main ADODB library
79 79
 */
80
-if( !defined( '_ADODB_LAYER' ) ) {
81
-	require( 'adodb.inc.php' );
82
-	require( 'adodb-datadict.inc.php' );
80
+if (!defined('_ADODB_LAYER')) {
81
+	require('adodb.inc.php');
82
+	require('adodb-datadict.inc.php');
83 83
 }
84 84
 
85 85
 /**
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
 	/**
105 105
 	* NOP
106 106
 	*/
107
-	function dbObject( &$parent, $attributes = NULL ) {
108
-		$this->parent =& $parent;
107
+	function dbObject(&$parent, $attributes = NULL) {
108
+		$this->parent = & $parent;
109 109
 	}
110 110
 	
111 111
 	/**
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	*
114 114
 	* @access private
115 115
 	*/
116
-	function _tag_open( &$parser, $tag, $attributes ) {
116
+	function _tag_open(&$parser, $tag, $attributes) {
117 117
 		
118 118
 	}
119 119
 	
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	*
123 123
 	* @access private
124 124
 	*/
125
-	function _tag_cdata( &$parser, $cdata ) {
125
+	function _tag_cdata(&$parser, $cdata) {
126 126
 		
127 127
 	}
128 128
 	
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	*
132 132
 	* @access private
133 133
 	*/
134
-	function _tag_close( &$parser, $tag ) {
134
+	function _tag_close(&$parser, $tag) {
135 135
 		
136 136
 	}
137 137
 	
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	* Destroys the object
144 144
 	*/
145 145
 	function destroy() {
146
-		unset( $this );
146
+		unset($this);
147 147
 	}
148 148
 	
149 149
 	/**
@@ -153,8 +153,8 @@  discard block
 block discarded – undo
153 153
 	* @param string $platform RDBMS platform name (from ADODB platform list).
154 154
 	* @return boolean TRUE if RDBMS is supported; otherwise returns FALSE.
155 155
 	*/
156
-	function supportedPlatform( $platform = NULL ) {
157
-		return is_object( $this->parent ) ? $this->parent->supportedPlatform( $platform ) : TRUE;
156
+	function supportedPlatform($platform = NULL) {
157
+		return is_object($this->parent) ? $this->parent->supportedPlatform($platform) : TRUE;
158 158
 	}
159 159
 	
160 160
 	/**
@@ -163,8 +163,8 @@  discard block
 block discarded – undo
163 163
 	* @param string $name Prefix string.
164 164
 	* @return string Prefix.
165 165
 	*/
166
-	function prefix( $name = '' ) {
167
-		return is_object( $this->parent ) ? $this->parent->prefix( $name ) : $name;
166
+	function prefix($name = '') {
167
+		return is_object($this->parent) ? $this->parent->prefix($name) : $name;
168 168
 	}
169 169
 	
170 170
 	/**
@@ -173,8 +173,8 @@  discard block
 block discarded – undo
173 173
 	* @param string $field Field.
174 174
 	* @return string Field ID.
175 175
 	*/
176
-	function FieldID( $field ) {
177
-		return strtoupper( preg_replace( '/^`(.+)`$/', '$1', $field ) );
176
+	function FieldID($field) {
177
+		return strtoupper(preg_replace('/^`(.+)`$/', '$1', $field));
178 178
 	}
179 179
 }
180 180
 
@@ -234,8 +234,8 @@  discard block
 block discarded – undo
234 234
 	* @param string $prefix DB Object prefix
235 235
 	* @param array $attributes Array of table attributes.
236 236
 	*/
237
-	function dbTable( &$parent, $attributes = NULL ) {
238
-		$this->parent =& $parent;
237
+	function dbTable(&$parent, $attributes = NULL) {
238
+		$this->parent = & $parent;
239 239
 		$this->name = $this->prefix($attributes['NAME']);
240 240
 	}
241 241
 	
@@ -245,18 +245,18 @@  discard block
 block discarded – undo
245 245
 	*
246 246
 	* @access private
247 247
 	*/
248
-	function _tag_open( &$parser, $tag, $attributes ) {
249
-		$this->currentElement = strtoupper( $tag );
248
+	function _tag_open(&$parser, $tag, $attributes) {
249
+		$this->currentElement = strtoupper($tag);
250 250
 		
251
-		switch( $this->currentElement ) {
251
+		switch ($this->currentElement) {
252 252
 			case 'INDEX':
253
-				if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) {
254
-					xml_set_object( $parser, $this->addIndex( $attributes ) );
253
+				if (!isset($attributes['PLATFORM']) OR $this->supportedPlatform($attributes['PLATFORM'])) {
254
+					xml_set_object($parser, $this->addIndex($attributes));
255 255
 				}
256 256
 				break;
257 257
 			case 'DATA':
258
-				if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) {
259
-					xml_set_object( $parser, $this->addData( $attributes ) );
258
+				if (!isset($attributes['PLATFORM']) OR $this->supportedPlatform($attributes['PLATFORM'])) {
259
+					xml_set_object($parser, $this->addData($attributes));
260 260
 				}
261 261
 				break;
262 262
 			case 'DROP':
@@ -266,31 +266,31 @@  discard block
 block discarded – undo
266 266
 				// Add a field
267 267
 				$fieldName = $attributes['NAME'];
268 268
 				$fieldType = $attributes['TYPE'];
269
-				$fieldSize = isset( $attributes['SIZE'] ) ? $attributes['SIZE'] : NULL;
270
-				$fieldOpts = isset( $attributes['OPTS'] ) ? $attributes['OPTS'] : NULL;
269
+				$fieldSize = isset($attributes['SIZE']) ? $attributes['SIZE'] : NULL;
270
+				$fieldOpts = isset($attributes['OPTS']) ? $attributes['OPTS'] : NULL;
271 271
 				
272
-				$this->addField( $fieldName, $fieldType, $fieldSize, $fieldOpts );
272
+				$this->addField($fieldName, $fieldType, $fieldSize, $fieldOpts);
273 273
 				break;
274 274
 			case 'KEY':
275 275
 			case 'NOTNULL':
276 276
 			case 'AUTOINCREMENT':
277 277
 				// Add a field option
278
-				$this->addFieldOpt( $this->current_field, $this->currentElement );
278
+				$this->addFieldOpt($this->current_field, $this->currentElement);
279 279
 				break;
280 280
 			case 'DEFAULT':
281 281
 				// Add a field option to the table object
282 282
 				
283 283
 				// Work around ADOdb datadict issue that misinterprets empty strings.
284
-				if( $attributes['VALUE'] == '' ) {
284
+				if ($attributes['VALUE'] == '') {
285 285
 					$attributes['VALUE'] = " '' ";
286 286
 				}
287 287
 				
288
-				$this->addFieldOpt( $this->current_field, $this->currentElement, $attributes['VALUE'] );
288
+				$this->addFieldOpt($this->current_field, $this->currentElement, $attributes['VALUE']);
289 289
 				break;
290 290
 			case 'DEFDATE':
291 291
 			case 'DEFTIMESTAMP':
292 292
 				// Add a field option to the table object
293
-				$this->addFieldOpt( $this->current_field, $this->currentElement );
293
+				$this->addFieldOpt($this->current_field, $this->currentElement);
294 294
 				break;
295 295
 			default:
296 296
 				// print_r( array( $tag, $attributes ) );
@@ -302,19 +302,19 @@  discard block
 block discarded – undo
302 302
 	*
303 303
 	* @access private
304 304
 	*/
305
-	function _tag_cdata( &$parser, $cdata ) {
306
-		switch( $this->currentElement ) {
305
+	function _tag_cdata(&$parser, $cdata) {
306
+		switch ($this->currentElement) {
307 307
 			// Table constraint
308 308
 			case 'CONSTRAINT':
309
-				if( isset( $this->current_field ) ) {
310
-					$this->addFieldOpt( $this->current_field, $this->currentElement, $cdata );
309
+				if (isset($this->current_field)) {
310
+					$this->addFieldOpt($this->current_field, $this->currentElement, $cdata);
311 311
 				} else {
312
-					$this->addTableOpt( $cdata );
312
+					$this->addTableOpt($cdata);
313 313
 				}
314 314
 				break;
315 315
 			// Table option
316 316
 			case 'OPT':
317
-				$this->addTableOpt( $cdata );
317
+				$this->addTableOpt($cdata);
318 318
 				break;
319 319
 			default:
320 320
 				
@@ -326,13 +326,13 @@  discard block
 block discarded – undo
326 326
 	*
327 327
 	* @access private
328 328
 	*/
329
-	function _tag_close( &$parser, $tag ) {
329
+	function _tag_close(&$parser, $tag) {
330 330
 		$this->currentElement = '';
331 331
 		
332
-		switch( strtoupper( $tag ) ) {
332
+		switch (strtoupper($tag)) {
333 333
 			case 'TABLE':
334
-				$this->parent->addSQL( $this->create( $this->parent ) );
335
-				xml_set_object( $parser, $this->parent );
334
+				$this->parent->addSQL($this->create($this->parent));
335
+				xml_set_object($parser, $this->parent);
336 336
 				$this->destroy();
337 337
 				break;
338 338
 			case 'FIELD':
@@ -348,9 +348,9 @@  discard block
 block discarded – undo
348 348
 	* @param array $attributes Index attributes
349 349
 	* @return object dbIndex object
350 350
 	*/
351
-	function &addIndex( $attributes ) {
352
-		$name = strtoupper( $attributes['NAME'] );
353
-		$this->indexes[$name] = new dbIndex( $this, $attributes );
351
+	function &addIndex($attributes) {
352
+		$name = strtoupper($attributes['NAME']);
353
+		$this->indexes[$name] = new dbIndex($this, $attributes);
354 354
 		return $this->indexes[$name];
355 355
 	}
356 356
 	
@@ -360,9 +360,9 @@  discard block
 block discarded – undo
360 360
 	* @param array $attributes Data attributes
361 361
 	* @return object dbData object
362 362
 	*/
363
-	function &addData( $attributes ) {
364
-		if( !isset( $this->data ) ) {
365
-			$this->data = new dbData( $this, $attributes );
363
+	function &addData($attributes) {
364
+		if (!isset($this->data)) {
365
+			$this->data = new dbData($this, $attributes);
366 366
 		}
367 367
 		return $this->data;
368 368
 	}
@@ -396,8 +396,8 @@  discard block
 block discarded – undo
396 396
 	* @param array $opts	Field options array
397 397
 	* @return array Field specifier array
398 398
 	*/
399
-	function addField( $name, $type, $size = NULL, $opts = NULL ) {
400
-		$field_id = $this->FieldID( $name );
399
+	function addField($name, $type, $size = NULL, $opts = NULL) {
400
+		$field_id = $this->FieldID($name);
401 401
 		
402 402
 		// Set the field index so we know where we are
403 403
 		$this->current_field = $field_id;
@@ -409,12 +409,12 @@  discard block
 block discarded – undo
409 409
 		$this->fields[$field_id]['TYPE'] = $type;
410 410
 		
411 411
 		// Set the field size (optional)
412
-		if( isset( $size ) ) {
412
+		if (isset($size)) {
413 413
 			$this->fields[$field_id]['SIZE'] = $size;
414 414
 		}
415 415
 		
416 416
 		// Set the field options
417
-		if( isset( $opts ) ) {
417
+		if (isset($opts)) {
418 418
 			$this->fields[$field_id]['OPTS'][] = $opts;
419 419
 		}
420 420
 	}
@@ -430,12 +430,12 @@  discard block
 block discarded – undo
430 430
 	* @param mixed $value Field option value
431 431
 	* @return array Field specifier array
432 432
 	*/
433
-	function addFieldOpt( $field, $opt, $value = NULL ) {
434
-		if( !isset( $value ) ) {
435
-			$this->fields[$this->FieldID( $field )]['OPTS'][] = $opt;
433
+	function addFieldOpt($field, $opt, $value = NULL) {
434
+		if (!isset($value)) {
435
+			$this->fields[$this->FieldID($field)]['OPTS'][] = $opt;
436 436
 		// Add the option and value
437 437
 		} else {
438
-			$this->fields[$this->FieldID( $field )]['OPTS'][] = array( $opt => $value );
438
+			$this->fields[$this->FieldID($field)]['OPTS'][] = array($opt => $value);
439 439
 		}
440 440
 	}
441 441
 	
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
 	* @param string $opt Table option
449 449
 	* @return array Options
450 450
 	*/
451
-	function addTableOpt( $opt ) {
451
+	function addTableOpt($opt) {
452 452
 		$this->opts[] = $opt;
453 453
 		
454 454
 		return $this->opts;
@@ -460,39 +460,39 @@  discard block
 block discarded – undo
460 460
 	* @param object $xmls adoSchema object
461 461
 	* @return array Array containing table creation SQL
462 462
 	*/
463
-	function create( &$xmls ) {
463
+	function create(&$xmls) {
464 464
 		$sql = array();
465 465
 		
466 466
 		// drop any existing indexes
467
-		if( is_array( $legacy_indexes = $xmls->dict->MetaIndexes( $this->name ) ) ) {
468
-			foreach( $legacy_indexes as $index => $index_details ) {
469
-				$sql[] = $xmls->dict->DropIndexSQL( $index, $this->name );
467
+		if (is_array($legacy_indexes = $xmls->dict->MetaIndexes($this->name))) {
468
+			foreach ($legacy_indexes as $index => $index_details) {
469
+				$sql[] = $xmls->dict->DropIndexSQL($index, $this->name);
470 470
 			}
471 471
 		}
472 472
 		
473 473
 		// remove fields to be dropped from table object
474
-		foreach( $this->drop_field as $field ) {
475
-			unset( $this->fields[$field] );
474
+		foreach ($this->drop_field as $field) {
475
+			unset($this->fields[$field]);
476 476
 		}
477 477
 		
478 478
 		// if table exists
479
-		if( is_array( $legacy_fields = $xmls->dict->MetaColumns( $this->name ) ) ) {
479
+		if (is_array($legacy_fields = $xmls->dict->MetaColumns($this->name))) {
480 480
 			// drop table
481
-			if( $this->drop_table ) {
482
-				$sql[] = $xmls->dict->DropTableSQL( $this->name );
481
+			if ($this->drop_table) {
482
+				$sql[] = $xmls->dict->DropTableSQL($this->name);
483 483
 				
484 484
 				return $sql;
485 485
 			}
486 486
 			
487 487
 			// drop any existing fields not in schema
488
-			foreach( $legacy_fields as $field_id => $field ) {
489
-				if( !isset( $this->fields[$field_id] ) ) {
490
-					$sql[] = $xmls->dict->DropColumnSQL( $this->name, '`'.$field->name.'`' );
488
+			foreach ($legacy_fields as $field_id => $field) {
489
+				if (!isset($this->fields[$field_id])) {
490
+					$sql[] = $xmls->dict->DropColumnSQL($this->name, '`'.$field->name.'`');
491 491
 				}
492 492
 			}
493 493
 		// if table doesn't exist
494 494
 		} else {
495
-			if( $this->drop_table ) {
495
+			if ($this->drop_table) {
496 496
 				return $sql;
497 497
 			}
498 498
 			
@@ -502,9 +502,9 @@  discard block
 block discarded – undo
502 502
 		// Loop through the field specifier array, building the associative array for the field options
503 503
 		$fldarray = array();
504 504
 		
505
-		foreach( $this->fields as $field_id => $finfo ) {
505
+		foreach ($this->fields as $field_id => $finfo) {
506 506
 			// Set an empty size if it isn't supplied
507
-			if( !isset( $finfo['SIZE'] ) ) {
507
+			if (!isset($finfo['SIZE'])) {
508 508
 				$finfo['SIZE'] = '';
509 509
 			}
510 510
 			
@@ -516,12 +516,12 @@  discard block
 block discarded – undo
516 516
 			);
517 517
 			
518 518
 			// Loop through the options array and add the field options. 
519
-			if( isset( $finfo['OPTS'] ) ) {
520
-				foreach( $finfo['OPTS'] as $opt ) {
519
+			if (isset($finfo['OPTS'])) {
520
+				foreach ($finfo['OPTS'] as $opt) {
521 521
 					// Option has an argument.
522
-					if( is_array( $opt ) ) {
523
-						$key = key( $opt );
524
-						$value = $opt[key( $opt )];
522
+					if (is_array($opt)) {
523
+						$key = key($opt);
524
+						$value = $opt[key($opt)];
525 525
 						@$fldarray[$field_id][$key] .= $value;
526 526
 					// Option doesn't have arguments
527 527
 					} else {
@@ -531,23 +531,23 @@  discard block
 block discarded – undo
531 531
 			}
532 532
 		}
533 533
 		
534
-		if( empty( $legacy_fields ) ) {
534
+		if (empty($legacy_fields)) {
535 535
 			// Create the new table
536
-			$sql[] = $xmls->dict->CreateTableSQL( $this->name, $fldarray, $this->opts );
537
-			logMsg( end( $sql ), 'Generated CreateTableSQL' );
536
+			$sql[] = $xmls->dict->CreateTableSQL($this->name, $fldarray, $this->opts);
537
+			logMsg(end($sql), 'Generated CreateTableSQL');
538 538
 		} else {
539 539
 			// Upgrade an existing table
540
-			logMsg( "Upgrading {$this->name} using '{$xmls->upgrade}'" );
541
-			switch( $xmls->upgrade ) {
540
+			logMsg("Upgrading {$this->name} using '{$xmls->upgrade}'");
541
+			switch ($xmls->upgrade) {
542 542
 				// Use ChangeTableSQL
543 543
 				case 'ALTER':
544
-					logMsg( 'Generated ChangeTableSQL (ALTERing table)' );
545
-					$sql[] = $xmls->dict->ChangeTableSQL( $this->name, $fldarray, $this->opts );
544
+					logMsg('Generated ChangeTableSQL (ALTERing table)');
545
+					$sql[] = $xmls->dict->ChangeTableSQL($this->name, $fldarray, $this->opts);
546 546
 					break;
547 547
 				case 'REPLACE':
548
-					logMsg( 'Doing upgrade REPLACE (testing)' );
549
-					$sql[] = $xmls->dict->DropTableSQL( $this->name );
550
-					$sql[] = $xmls->dict->CreateTableSQL( $this->name, $fldarray, $this->opts );
548
+					logMsg('Doing upgrade REPLACE (testing)');
549
+					$sql[] = $xmls->dict->DropTableSQL($this->name);
550
+					$sql[] = $xmls->dict->CreateTableSQL($this->name, $fldarray, $this->opts);
551 551
 					break;
552 552
 				// ignore table
553 553
 				default:
@@ -555,12 +555,12 @@  discard block
 block discarded – undo
555 555
 			}
556 556
 		}
557 557
 		
558
-		foreach( $this->indexes as $index ) {
559
-			$sql[] = $index->create( $xmls );
558
+		foreach ($this->indexes as $index) {
559
+			$sql[] = $index->create($xmls);
560 560
 		}
561 561
 		
562
-		if( isset( $this->data ) ) {
563
-			$sql[] = $this->data->create( $xmls );
562
+		if (isset($this->data)) {
563
+			$sql[] = $this->data->create($xmls);
564 564
 		}
565 565
 		
566 566
 		return $sql;
@@ -570,14 +570,14 @@  discard block
 block discarded – undo
570 570
 	* Marks a field or table for destruction
571 571
 	*/
572 572
 	function drop() {
573
-		if( isset( $this->current_field ) ) {
573
+		if (isset($this->current_field)) {
574 574
 			// Drop the current field
575
-			logMsg( "Dropping field '{$this->current_field}' from table '{$this->name}'" );
575
+			logMsg("Dropping field '{$this->current_field}' from table '{$this->name}'");
576 576
 			// $this->drop_field[$this->current_field] = $xmls->dict->DropColumnSQL( $this->name, $this->current_field );
577 577
 			$this->drop_field[$this->current_field] = $this->current_field;
578 578
 		} else {
579 579
 			// Drop the current table
580
-			logMsg( "Dropping table '{$this->name}'" );
580
+			logMsg("Dropping table '{$this->name}'");
581 581
 			// $this->drop_table = $xmls->dict->DropTableSQL( $this->name );
582 582
 			$this->drop_table = TRUE;
583 583
 		}
@@ -626,10 +626,10 @@  discard block
 block discarded – undo
626 626
 	*
627 627
 	* @internal
628 628
 	*/
629
-	function dbIndex( &$parent, $attributes = NULL ) {
630
-		$this->parent =& $parent;
629
+	function dbIndex(&$parent, $attributes = NULL) {
630
+		$this->parent = & $parent;
631 631
 		
632
-		$this->name = $this->prefix ($attributes['NAME']);
632
+		$this->name = $this->prefix($attributes['NAME']);
633 633
 	}
634 634
 	
635 635
 	/**
@@ -640,10 +640,10 @@  discard block
 block discarded – undo
640 640
 	*
641 641
 	* @access private
642 642
 	*/
643
-	function _tag_open( &$parser, $tag, $attributes ) {
644
-		$this->currentElement = strtoupper( $tag );
643
+	function _tag_open(&$parser, $tag, $attributes) {
644
+		$this->currentElement = strtoupper($tag);
645 645
 		
646
-		switch( $this->currentElement ) {
646
+		switch ($this->currentElement) {
647 647
 			case 'DROP':
648 648
 				$this->drop();
649 649
 				break;
@@ -653,7 +653,7 @@  discard block
 block discarded – undo
653 653
 			case 'FULLTEXT':
654 654
 			case 'HASH':
655 655
 				// Add index Option
656
-				$this->addIndexOpt( $this->currentElement );
656
+				$this->addIndexOpt($this->currentElement);
657 657
 				break;
658 658
 			default:
659 659
 				// print_r( array( $tag, $attributes ) );
@@ -667,11 +667,11 @@  discard block
 block discarded – undo
667 667
 	*
668 668
 	* @access private
669 669
 	*/
670
-	function _tag_cdata( &$parser, $cdata ) {
671
-		switch( $this->currentElement ) {
670
+	function _tag_cdata(&$parser, $cdata) {
671
+		switch ($this->currentElement) {
672 672
 			// Index field name
673 673
 			case 'COL':
674
-				$this->addField( $cdata );
674
+				$this->addField($cdata);
675 675
 				break;
676 676
 			default:
677 677
 				
@@ -683,12 +683,12 @@  discard block
 block discarded – undo
683 683
 	*
684 684
 	* @access private
685 685
 	*/
686
-	function _tag_close( &$parser, $tag ) {
686
+	function _tag_close(&$parser, $tag) {
687 687
 		$this->currentElement = '';
688 688
 		
689
-		switch( strtoupper( $tag ) ) {
689
+		switch (strtoupper($tag)) {
690 690
 			case 'INDEX':
691
-				xml_set_object( $parser, $this->parent );
691
+				xml_set_object($parser, $this->parent);
692 692
 				break;
693 693
 		}
694 694
 	}
@@ -699,8 +699,8 @@  discard block
 block discarded – undo
699 699
 	* @param string $name Field name
700 700
 	* @return string Field list
701 701
 	*/
702
-	function addField( $name ) {
703
-		$this->columns[$this->FieldID( $name )] = $name;
702
+	function addField($name) {
703
+		$this->columns[$this->FieldID($name)] = $name;
704 704
 		
705 705
 		// Return the field list
706 706
 		return $this->columns;
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
 	* @param string $opt Comma-separated list of index options.
713 713
 	* @return string Option list
714 714
 	*/
715
-	function addIndexOpt( $opt ) {
715
+	function addIndexOpt($opt) {
716 716
 		$this->opts[] = $opt;
717 717
 		
718 718
 		// Return the options list
@@ -725,19 +725,19 @@  discard block
 block discarded – undo
725 725
 	* @param object $xmls adoSchema object
726 726
 	* @return array Array containing index creation SQL
727 727
 	*/
728
-	function create( &$xmls ) {
729
-		if( $this->drop ) {
728
+	function create(&$xmls) {
729
+		if ($this->drop) {
730 730
 			return NULL;
731 731
 		}
732 732
 		
733 733
 		// eliminate any columns that aren't in the table
734
-		foreach( $this->columns as $id => $col ) {
735
-			if( !isset( $this->parent->fields[$id] ) ) {
736
-				unset( $this->columns[$id] );
734
+		foreach ($this->columns as $id => $col) {
735
+			if (!isset($this->parent->fields[$id])) {
736
+				unset($this->columns[$id]);
737 737
 			}
738 738
 		}
739 739
 		
740
-		return $xmls->dict->CreateIndexSQL( $this->name, $this->parent->name, $this->columns, $this->opts );
740
+		return $xmls->dict->CreateIndexSQL($this->name, $this->parent->name, $this->columns, $this->opts);
741 741
 	}
742 742
 	
743 743
 	/**
@@ -770,8 +770,8 @@  discard block
 block discarded – undo
770 770
 	*
771 771
 	* @internal
772 772
 	*/
773
-	function dbData( &$parent, $attributes = NULL ) {
774
-		$this->parent =& $parent;
773
+	function dbData(&$parent, $attributes = NULL) {
774
+		$this->parent = & $parent;
775 775
 	}
776 776
 	
777 777
 	/**
@@ -782,12 +782,12 @@  discard block
 block discarded – undo
782 782
 	*
783 783
 	* @access private
784 784
 	*/
785
-	function _tag_open( &$parser, $tag, $attributes ) {
786
-		$this->currentElement = strtoupper( $tag );
785
+	function _tag_open(&$parser, $tag, $attributes) {
786
+		$this->currentElement = strtoupper($tag);
787 787
 		
788
-		switch( $this->currentElement ) {
788
+		switch ($this->currentElement) {
789 789
 			case 'ROW':
790
-				$this->row = count( $this->data );
790
+				$this->row = count($this->data);
791 791
 				$this->data[$this->row] = array();
792 792
 				break;
793 793
 			case 'F':
@@ -804,11 +804,11 @@  discard block
 block discarded – undo
804 804
 	*
805 805
 	* @access private
806 806
 	*/
807
-	function _tag_cdata( &$parser, $cdata ) {
808
-		switch( $this->currentElement ) {
807
+	function _tag_cdata(&$parser, $cdata) {
808
+		switch ($this->currentElement) {
809 809
 			// Index field name
810 810
 			case 'F':
811
-				$this->addData( $cdata );
811
+				$this->addData($cdata);
812 812
 				break;
813 813
 			default:
814 814
 				
@@ -820,12 +820,12 @@  discard block
 block discarded – undo
820 820
 	*
821 821
 	* @access private
822 822
 	*/
823
-	function _tag_close( &$parser, $tag ) {
823
+	function _tag_close(&$parser, $tag) {
824 824
 		$this->currentElement = '';
825 825
 		
826
-		switch( strtoupper( $tag ) ) {
826
+		switch (strtoupper($tag)) {
827 827
 			case 'DATA':
828
-				xml_set_object( $parser, $this->parent );
828
+				xml_set_object($parser, $this->parent);
829 829
 				break;
830 830
 		}
831 831
 	}
@@ -836,15 +836,15 @@  discard block
 block discarded – undo
836 836
 	* @param string $name Field name
837 837
 	* @return string Field list
838 838
 	*/
839
-	function addField( $attributes ) {
840
-		if( isset( $attributes['NAME'] ) ) {
839
+	function addField($attributes) {
840
+		if (isset($attributes['NAME'])) {
841 841
 			$name = $attributes['NAME'];
842 842
 		} else {
843 843
 			$name = count($this->data[$this->row]);
844 844
 		}
845 845
 		
846 846
 		// Set the field index so we know where we are
847
-		$this->current_field = $this->FieldID( $name );
847
+		$this->current_field = $this->FieldID($name);
848 848
 	}
849 849
 	
850 850
 	/**
@@ -853,12 +853,12 @@  discard block
 block discarded – undo
853 853
 	* @param string $opt Comma-separated list of index options.
854 854
 	* @return string Option list
855 855
 	*/
856
-	function addData( $cdata ) {
857
-		if( !isset( $this->data[$this->row] ) ) {
856
+	function addData($cdata) {
857
+		if (!isset($this->data[$this->row])) {
858 858
 			$this->data[$this->row] = array();
859 859
 		}
860 860
 		
861
-		if( !isset( $this->data[$this->row][$this->current_field] ) ) {
861
+		if (!isset($this->data[$this->row][$this->current_field])) {
862 862
 			$this->data[$this->row][$this->current_field] = '';
863 863
 		}
864 864
 		
@@ -871,20 +871,20 @@  discard block
 block discarded – undo
871 871
 	* @param object $xmls adoSchema object
872 872
 	* @return array Array containing index creation SQL
873 873
 	*/
874
-	function create( &$xmls ) {
874
+	function create(&$xmls) {
875 875
 		$table = $xmls->dict->TableName($this->parent->name);
876 876
 		$table_field_count = count($this->parent->fields);
877 877
 		$sql = array();
878 878
 		
879 879
 		// eliminate any columns that aren't in the table
880
-		foreach( $this->data as $row ) {
880
+		foreach ($this->data as $row) {
881 881
 			$table_fields = $this->parent->fields;
882 882
 			$fields = array();
883 883
 			
884
-			foreach( $row as $field_id => $field_data ) {
885
-				if( !array_key_exists( $field_id, $table_fields ) ) {
886
-					if( is_numeric( $field_id ) ) {
887
-						$field_id = reset( array_keys( $table_fields ) );
884
+			foreach ($row as $field_id => $field_data) {
885
+				if (!array_key_exists($field_id, $table_fields)) {
886
+					if (is_numeric($field_id)) {
887
+						$field_id = reset(array_keys($table_fields));
888 888
 					} else {
889 889
 						continue;
890 890
 					}
@@ -892,12 +892,12 @@  discard block
 block discarded – undo
892 892
 				
893 893
 				$name = $table_fields[$field_id]['NAME'];
894 894
 				
895
-				switch( $table_fields[$field_id]['TYPE'] ) {
895
+				switch ($table_fields[$field_id]['TYPE']) {
896 896
 					case 'C':
897 897
 					case 'C2':
898 898
 					case 'X':
899 899
 					case 'X2':
900
-						$fields[$name] = $xmls->db->qstr( $field_data );
900
+						$fields[$name] = $xmls->db->qstr($field_data);
901 901
 						break;
902 902
 					case 'I':
903 903
 					case 'I1':
@@ -914,21 +914,21 @@  discard block
 block discarded – undo
914 914
 			}
915 915
 			
916 916
 			// check that at least 1 column is specified
917
-			if( empty( $fields ) ) {
917
+			if (empty($fields)) {
918 918
 				continue;
919 919
 			}
920 920
 			
921 921
 			// check that no required columns are missing
922
-			if( count( $fields ) < $table_field_count ) {
923
-				foreach( $table_fields as $field ) {
924
-					if (isset( $field['OPTS'] ))
925
-						if( ( in_array( 'NOTNULL', $field['OPTS'] ) || in_array( 'KEY', $field['OPTS'] ) ) && !in_array( 'AUTOINCREMENT', $field['OPTS'] ) ) {
922
+			if (count($fields) < $table_field_count) {
923
+				foreach ($table_fields as $field) {
924
+					if (isset($field['OPTS']))
925
+						if ((in_array('NOTNULL', $field['OPTS']) || in_array('KEY', $field['OPTS'])) && !in_array('AUTOINCREMENT', $field['OPTS'])) {
926 926
 							continue(2);
927 927
 						}
928 928
 				}
929 929
 			}
930 930
 			
931
-			$sql[] = 'INSERT INTO '. $table .' ('. implode( ',', array_keys( $fields ) ) .') VALUES ('. implode( ',', $fields ) .')';
931
+			$sql[] = 'INSERT INTO '.$table.' ('.implode(',', array_keys($fields)).') VALUES ('.implode(',', $fields).')';
932 932
 		}
933 933
 		
934 934
 		return $sql;
@@ -969,18 +969,18 @@  discard block
 block discarded – undo
969 969
 	* @param object $parent Parent object
970 970
 	* @param array $attributes Attributes
971 971
 	*/
972
-	function dbQuerySet( &$parent, $attributes = NULL ) {
973
-		$this->parent =& $parent;
972
+	function dbQuerySet(&$parent, $attributes = NULL) {
973
+		$this->parent = & $parent;
974 974
 			
975 975
 		// Overrides the manual prefix key
976
-		if( isset( $attributes['KEY'] ) ) {
976
+		if (isset($attributes['KEY'])) {
977 977
 			$this->prefixKey = $attributes['KEY'];
978 978
 		}
979 979
 		
980
-		$prefixMethod = isset( $attributes['PREFIXMETHOD'] ) ? strtoupper( trim( $attributes['PREFIXMETHOD'] ) ) : '';
980
+		$prefixMethod = isset($attributes['PREFIXMETHOD']) ? strtoupper(trim($attributes['PREFIXMETHOD'])) : '';
981 981
 		
982 982
 		// Enables or disables automatic prefix prepending
983
-		switch( $prefixMethod ) {
983
+		switch ($prefixMethod) {
984 984
 			case 'AUTO':
985 985
 				$this->prefixMethod = 'AUTO';
986 986
 				break;
@@ -999,15 +999,15 @@  discard block
 block discarded – undo
999 999
 	*
1000 1000
 	* @access private
1001 1001
 	*/
1002
-	function _tag_open( &$parser, $tag, $attributes ) {
1003
-		$this->currentElement = strtoupper( $tag );
1002
+	function _tag_open(&$parser, $tag, $attributes) {
1003
+		$this->currentElement = strtoupper($tag);
1004 1004
 		
1005
-		switch( $this->currentElement ) {
1005
+		switch ($this->currentElement) {
1006 1006
 			case 'QUERY':
1007 1007
 				// Create a new query in a SQL queryset.
1008 1008
 				// Ignore this query set if a platform is specified and it's different than the 
1009 1009
 				// current connection platform.
1010
-				if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) {
1010
+				if (!isset($attributes['PLATFORM']) OR $this->supportedPlatform($attributes['PLATFORM'])) {
1011 1011
 					$this->newQuery();
1012 1012
 				} else {
1013 1013
 					$this->discardQuery();
@@ -1021,11 +1021,11 @@  discard block
 block discarded – undo
1021 1021
 	/**
1022 1022
 	* XML Callback to process CDATA elements
1023 1023
 	*/
1024
-	function _tag_cdata( &$parser, $cdata ) {
1025
-		switch( $this->currentElement ) {
1024
+	function _tag_cdata(&$parser, $cdata) {
1025
+		switch ($this->currentElement) {
1026 1026
 			// Line of queryset SQL data
1027 1027
 			case 'QUERY':
1028
-				$this->buildQuery( $cdata );
1028
+				$this->buildQuery($cdata);
1029 1029
 				break;
1030 1030
 			default:
1031 1031
 				
@@ -1037,17 +1037,17 @@  discard block
 block discarded – undo
1037 1037
 	*
1038 1038
 	* @access private
1039 1039
 	*/
1040
-	function _tag_close( &$parser, $tag ) {
1040
+	function _tag_close(&$parser, $tag) {
1041 1041
 		$this->currentElement = '';
1042 1042
 		
1043
-		switch( strtoupper( $tag ) ) {
1043
+		switch (strtoupper($tag)) {
1044 1044
 			case 'QUERY':
1045 1045
 				// Add the finished query to the open query set.
1046 1046
 				$this->addQuery();
1047 1047
 				break;
1048 1048
 			case 'SQL':
1049
-				$this->parent->addSQL( $this->create( $this->parent ) );
1050
-				xml_set_object( $parser, $this->parent );
1049
+				$this->parent->addSQL($this->create($this->parent));
1050
+				xml_set_object($parser, $this->parent);
1051 1051
 				$this->destroy();
1052 1052
 				break;
1053 1053
 			default:
@@ -1072,7 +1072,7 @@  discard block
 block discarded – undo
1072 1072
 	* @return boolean TRUE
1073 1073
 	*/
1074 1074
 	function discardQuery() {
1075
-		unset( $this->query );
1075
+		unset($this->query);
1076 1076
 		
1077 1077
 		return TRUE;
1078 1078
 	}
@@ -1083,8 +1083,8 @@  discard block
 block discarded – undo
1083 1083
 	* @param string $data Line of SQL data or NULL to initialize a new query
1084 1084
 	* @return string SQL query string.
1085 1085
 	*/
1086
-	function buildQuery( $sql = NULL ) {
1087
-		if( !isset( $this->query ) OR empty( $sql ) ) {
1086
+	function buildQuery($sql = NULL) {
1087
+		if (!isset($this->query) OR empty($sql)) {
1088 1088
 			return FALSE;
1089 1089
 		}
1090 1090
 		
@@ -1099,13 +1099,13 @@  discard block
 block discarded – undo
1099 1099
 	* @return string	SQL of added query
1100 1100
 	*/
1101 1101
 	function addQuery() {
1102
-		if( !isset( $this->query ) ) {
1102
+		if (!isset($this->query)) {
1103 1103
 			return FALSE;
1104 1104
 		}
1105 1105
 		
1106 1106
 		$this->queries[] = $return = trim($this->query);
1107 1107
 		
1108
-		unset( $this->query );
1108
+		unset($this->query);
1109 1109
 		
1110 1110
 		return $return;
1111 1111
 	}
@@ -1116,17 +1116,17 @@  discard block
 block discarded – undo
1116 1116
 	* @param object $xmls adoSchema object
1117 1117
 	* @return array Query set
1118 1118
 	*/
1119
-	function create( &$xmls ) {
1120
-		foreach( $this->queries as $id => $query ) {
1121
-			switch( $this->prefixMethod ) {
1119
+	function create(&$xmls) {
1120
+		foreach ($this->queries as $id => $query) {
1121
+			switch ($this->prefixMethod) {
1122 1122
 				case 'AUTO':
1123 1123
 					// Enable auto prefix replacement
1124 1124
 					
1125 1125
 					// Process object prefix.
1126 1126
 					// Evaluate SQL statements to prepend prefix to objects
1127
-					$query = $this->prefixQuery( '/^\s*((?is)INSERT\s+(INTO\s+)?)((\w+\s*,?\s*)+)(\s.*$)/', $query, $xmls->objectPrefix );
1128
-					$query = $this->prefixQuery( '/^\s*((?is)UPDATE\s+(FROM\s+)?)((\w+\s*,?\s*)+)(\s.*$)/', $query, $xmls->objectPrefix );
1129
-					$query = $this->prefixQuery( '/^\s*((?is)DELETE\s+(FROM\s+)?)((\w+\s*,?\s*)+)(\s.*$)/', $query, $xmls->objectPrefix );
1127
+					$query = $this->prefixQuery('/^\s*((?is)INSERT\s+(INTO\s+)?)((\w+\s*,?\s*)+)(\s.*$)/', $query, $xmls->objectPrefix);
1128
+					$query = $this->prefixQuery('/^\s*((?is)UPDATE\s+(FROM\s+)?)((\w+\s*,?\s*)+)(\s.*$)/', $query, $xmls->objectPrefix);
1129
+					$query = $this->prefixQuery('/^\s*((?is)DELETE\s+(FROM\s+)?)((\w+\s*,?\s*)+)(\s.*$)/', $query, $xmls->objectPrefix);
1130 1130
 					
1131 1131
 					// SELECT statements aren't working yet
1132 1132
 					#$data = preg_replace( '/(?ias)(^\s*SELECT\s+.*\s+FROM)\s+(\W\s*,?\s*)+((?i)\s+WHERE.*$)/', "\1 $prefix\2 \3", $data );
@@ -1134,16 +1134,16 @@  discard block
 block discarded – undo
1134 1134
 				case 'MANUAL':
1135 1135
 					// If prefixKey is set and has a value then we use it to override the default constant XMLS_PREFIX.
1136 1136
 					// If prefixKey is not set, we use the default constant XMLS_PREFIX
1137
-					if( isset( $this->prefixKey ) AND( $this->prefixKey !== '' ) ) {
1137
+					if (isset($this->prefixKey) AND ($this->prefixKey !== '')) {
1138 1138
 						// Enable prefix override
1139
-						$query = str_replace( $this->prefixKey, $xmls->objectPrefix, $query );
1139
+						$query = str_replace($this->prefixKey, $xmls->objectPrefix, $query);
1140 1140
 					} else {
1141 1141
 						// Use default replacement
1142
-						$query = str_replace( XMLS_PREFIX , $xmls->objectPrefix, $query );
1142
+						$query = str_replace(XMLS_PREFIX, $xmls->objectPrefix, $query);
1143 1143
 					}
1144 1144
 			}
1145 1145
 			
1146
-			$this->queries[$id] = trim( $query );
1146
+			$this->queries[$id] = trim($query);
1147 1147
 		}
1148 1148
 		
1149 1149
 		// Return the query set array
@@ -1158,28 +1158,28 @@  discard block
 block discarded – undo
1158 1158
 	* @param string $prefix Prefix to be appended to tables, indices, etc.
1159 1159
 	* @return string Prefixed SQL query string.
1160 1160
 	*/
1161
-	function prefixQuery( $regex, $query, $prefix = NULL ) {
1162
-		if( !isset( $prefix ) ) {
1161
+	function prefixQuery($regex, $query, $prefix = NULL) {
1162
+		if (!isset($prefix)) {
1163 1163
 			return $query;
1164 1164
 		}
1165 1165
 		
1166
-		if( preg_match( $regex, $query, $match ) ) {
1166
+		if (preg_match($regex, $query, $match)) {
1167 1167
 			$preamble = $match[1];
1168 1168
 			$postamble = $match[5];
1169
-			$objectList = explode( ',', $match[3] );
1169
+			$objectList = explode(',', $match[3]);
1170 1170
 			// $prefix = $prefix . '_';
1171 1171
 			
1172 1172
 			$prefixedList = '';
1173 1173
 			
1174
-			foreach( $objectList as $object ) {
1175
-				if( $prefixedList !== '' ) {
1174
+			foreach ($objectList as $object) {
1175
+				if ($prefixedList !== '') {
1176 1176
 					$prefixedList .= ', ';
1177 1177
 				}
1178 1178
 				
1179
-				$prefixedList .= $prefix . trim( $object );
1179
+				$prefixedList .= $prefix.trim($object);
1180 1180
 			}
1181 1181
 			
1182
-			$query = $preamble . ' ' . $prefixedList . ' ' . $postamble;
1182
+			$query = $preamble.' '.$prefixedList.' '.$postamble;
1183 1183
 		}
1184 1184
 		
1185 1185
 		return $query;
@@ -1285,18 +1285,18 @@  discard block
 block discarded – undo
1285 1285
 	*
1286 1286
 	* @param object $db ADOdb database connection object.
1287 1287
 	*/
1288
-	function adoSchema( &$db ) {
1288
+	function adoSchema(&$db) {
1289 1289
 		// Initialize the environment
1290 1290
 		$this->mgq = get_magic_quotes_runtime();
1291 1291
 		set_magic_quotes_runtime(0);
1292 1292
 		
1293
-		$this->db =& $db;
1293
+		$this->db = & $db;
1294 1294
 		$this->debug = $this->db->debug;
1295
-		$this->dict = NewDataDictionary( $this->db );
1295
+		$this->dict = NewDataDictionary($this->db);
1296 1296
 		$this->sqlArray = array();
1297 1297
 		$this->schemaVersion = XMLS_SCHEMA_VERSION;
1298
-		$this->executeInline( XMLS_EXECUTE_INLINE );
1299
-		$this->continueOnError( XMLS_CONTINUE_ON_ERROR );
1298
+		$this->executeInline(XMLS_EXECUTE_INLINE);
1299
+		$this->continueOnError(XMLS_CONTINUE_ON_ERROR);
1300 1300
 		$this->setUpgradeMethod();
1301 1301
 	}
1302 1302
 	
@@ -1316,15 +1316,15 @@  discard block
 block discarded – undo
1316 1316
 	* @param string $method Upgrade method (ALTER|REPLACE|BEST|NONE)
1317 1317
 	* @returns string Upgrade method used
1318 1318
 	*/
1319
-	function SetUpgradeMethod( $method = '' ) {
1320
-		if( !is_string( $method ) ) {
1319
+	function SetUpgradeMethod($method = '') {
1320
+		if (!is_string($method)) {
1321 1321
 			return FALSE;
1322 1322
 		}
1323 1323
 		
1324
-		$method = strtoupper( $method );
1324
+		$method = strtoupper($method);
1325 1325
 		
1326 1326
 		// Handle the upgrade methods
1327
-		switch( $method ) {
1327
+		switch ($method) {
1328 1328
 			case 'ALTER':
1329 1329
 				$this->upgrade = $method;
1330 1330
 				break;
@@ -1358,8 +1358,8 @@  discard block
 block discarded – undo
1358 1358
 	*
1359 1359
 	* @see ParseSchema(), ExecuteSchema()
1360 1360
 	*/
1361
-	function ExecuteInline( $mode = NULL ) {
1362
-		if( is_bool( $mode ) ) {
1361
+	function ExecuteInline($mode = NULL) {
1362
+		if (is_bool($mode)) {
1363 1363
 			$this->executeInline = $mode;
1364 1364
 		}
1365 1365
 		
@@ -1379,8 +1379,8 @@  discard block
 block discarded – undo
1379 1379
 	*
1380 1380
 	* @see addSQL(), ExecuteSchema()
1381 1381
 	*/
1382
-	function ContinueOnError( $mode = NULL ) {
1383
-		if( is_bool( $mode ) ) {
1382
+	function ContinueOnError($mode = NULL) {
1383
+		if (is_bool($mode)) {
1384 1384
 			$this->continueOnError = $mode;
1385 1385
 		}
1386 1386
 		
@@ -1398,8 +1398,8 @@  discard block
 block discarded – undo
1398 1398
 	* @param bool $returnSchema Return schema rather than parsing.
1399 1399
 	* @return array Array of SQL queries, ready to execute
1400 1400
 	*/
1401
-	function ParseSchema( $filename, $returnSchema = FALSE ) {
1402
-		return $this->ParseSchemaString( $this->ConvertSchemaFile( $filename ), $returnSchema );
1401
+	function ParseSchema($filename, $returnSchema = FALSE) {
1402
+		return $this->ParseSchemaString($this->ConvertSchemaFile($filename), $returnSchema);
1403 1403
 	}
1404 1404
 	
1405 1405
 	/**
@@ -1415,19 +1415,19 @@  discard block
 block discarded – undo
1415 1415
 	* @deprecated Replaced by adoSchema::ParseSchema() and adoSchema::ParseSchemaString()
1416 1416
 	* @see ParseSchema(), ParseSchemaString()
1417 1417
 	*/
1418
-	function ParseSchemaFile( $filename, $returnSchema = FALSE ) {
1418
+	function ParseSchemaFile($filename, $returnSchema = FALSE) {
1419 1419
 		// Open the file
1420
-		if( !($fp = fopen( $filename, 'r' )) ) {
1420
+		if (!($fp = fopen($filename, 'r'))) {
1421 1421
 			// die( 'Unable to open file' );
1422 1422
 			return FALSE;
1423 1423
 		}
1424 1424
 		
1425 1425
 		// do version detection here
1426
-		if( $this->SchemaFileVersion( $filename ) != $this->schemaVersion ) {
1426
+		if ($this->SchemaFileVersion($filename) != $this->schemaVersion) {
1427 1427
 			return FALSE;
1428 1428
 		}
1429 1429
 		
1430
-		if ( $returnSchema )
1430
+		if ($returnSchema)
1431 1431
 		{
1432 1432
 			return $xmlstring;
1433 1433
 		}
@@ -1437,17 +1437,17 @@  discard block
 block discarded – undo
1437 1437
 		$xmlParser = $this->create_parser();
1438 1438
 		
1439 1439
 		// Process the file
1440
-		while( $data = fread( $fp, 4096 ) ) {
1441
-			if( !xml_parse( $xmlParser, $data, feof( $fp ) ) ) {
1442
-				die( sprintf(
1440
+		while ($data = fread($fp, 4096)) {
1441
+			if (!xml_parse($xmlParser, $data, feof($fp))) {
1442
+				die(sprintf(
1443 1443
 					"XML error: %s at line %d",
1444
-					xml_error_string( xml_get_error_code( $xmlParser) ),
1445
-					xml_get_current_line_number( $xmlParser)
1446
-				) );
1444
+					xml_error_string(xml_get_error_code($xmlParser)),
1445
+					xml_get_current_line_number($xmlParser)
1446
+				));
1447 1447
 			}
1448 1448
 		}
1449 1449
 		
1450
-		xml_parser_free( $xmlParser );
1450
+		xml_parser_free($xmlParser);
1451 1451
 		
1452 1452
 		return $this->sqlArray;
1453 1453
 	}
@@ -1463,17 +1463,17 @@  discard block
 block discarded – undo
1463 1463
 	* @param bool $returnSchema Return schema rather than parsing.
1464 1464
 	* @return array Array of SQL queries, ready to execute.
1465 1465
 	*/
1466
-	function ParseSchemaString( $xmlstring, $returnSchema = FALSE ) {
1467
-		if( !is_string( $xmlstring ) OR empty( $xmlstring ) ) {
1466
+	function ParseSchemaString($xmlstring, $returnSchema = FALSE) {
1467
+		if (!is_string($xmlstring) OR empty($xmlstring)) {
1468 1468
 			return FALSE;
1469 1469
 		}
1470 1470
 		
1471 1471
 		// do version detection here
1472
-		if( $this->SchemaStringVersion( $xmlstring ) != $this->schemaVersion ) {
1472
+		if ($this->SchemaStringVersion($xmlstring) != $this->schemaVersion) {
1473 1473
 			return FALSE;
1474 1474
 		}
1475 1475
 		
1476
-		if ( $returnSchema )
1476
+		if ($returnSchema)
1477 1477
 		{
1478 1478
 			return $xmlstring;
1479 1479
 		}
@@ -1482,15 +1482,15 @@  discard block
 block discarded – undo
1482 1482
 		
1483 1483
 		$xmlParser = $this->create_parser();
1484 1484
 		
1485
-		if( !xml_parse( $xmlParser, $xmlstring, TRUE ) ) {
1486
-			die( sprintf(
1485
+		if (!xml_parse($xmlParser, $xmlstring, TRUE)) {
1486
+			die(sprintf(
1487 1487
 				"XML error: %s at line %d",
1488
-				xml_error_string( xml_get_error_code( $xmlParser) ),
1489
-				xml_get_current_line_number( $xmlParser)
1490
-			) );
1488
+				xml_error_string(xml_get_error_code($xmlParser)),
1489
+				xml_get_current_line_number($xmlParser)
1490
+			));
1491 1491
 		}
1492 1492
 		
1493
-		xml_parser_free( $xmlParser );
1493
+		xml_parser_free($xmlParser);
1494 1494
 		
1495 1495
 		return $this->sqlArray;
1496 1496
 	}
@@ -1506,8 +1506,8 @@  discard block
 block discarded – undo
1506 1506
 	* @param bool $returnSchema Return schema rather than parsing.
1507 1507
 	* @return array Array of SQL queries, ready to execute
1508 1508
 	*/
1509
-	function RemoveSchema( $filename, $returnSchema = FALSE ) {
1510
-		return $this->RemoveSchemaString( $this->ConvertSchemaFile( $filename ), $returnSchema );
1509
+	function RemoveSchema($filename, $returnSchema = FALSE) {
1510
+		return $this->RemoveSchemaString($this->ConvertSchemaFile($filename), $returnSchema);
1511 1511
 	}
1512 1512
 	
1513 1513
 	/**
@@ -1521,14 +1521,14 @@  discard block
 block discarded – undo
1521 1521
 	* @param bool $returnSchema Return schema rather than parsing.
1522 1522
 	* @return array Array of SQL queries, ready to execute.
1523 1523
 	*/
1524
-	function RemoveSchemaString( $schema, $returnSchema = FALSE ) {
1524
+	function RemoveSchemaString($schema, $returnSchema = FALSE) {
1525 1525
 		
1526 1526
 		// grab current version
1527
-		if( !( $version = $this->SchemaStringVersion( $schema ) ) ) {
1527
+		if (!($version = $this->SchemaStringVersion($schema))) {
1528 1528
 			return FALSE;
1529 1529
 		}
1530 1530
 		
1531
-		return $this->ParseSchemaString( $this->TransformSchema( $schema, 'remove-' . $version), $returnSchema );
1531
+		return $this->ParseSchemaString($this->TransformSchema($schema, 'remove-'.$version), $returnSchema);
1532 1532
 	}
1533 1533
 	
1534 1534
 	/**
@@ -1544,19 +1544,19 @@  discard block
 block discarded – undo
1544 1544
 	* @param boolean $continueOnErr Continue to apply the schema even if an error occurs.
1545 1545
 	* @returns integer 0 if failure, 1 if errors, 2 if successful.
1546 1546
 	*/
1547
-	function ExecuteSchema( $sqlArray = NULL, $continueOnErr =  NULL ) {
1548
-		if( !is_bool( $continueOnErr ) ) {
1547
+	function ExecuteSchema($sqlArray = NULL, $continueOnErr = NULL) {
1548
+		if (!is_bool($continueOnErr)) {
1549 1549
 			$continueOnErr = $this->ContinueOnError();
1550 1550
 		}
1551 1551
 		
1552
-		if( !isset( $sqlArray ) ) {
1552
+		if (!isset($sqlArray)) {
1553 1553
 			$sqlArray = $this->sqlArray;
1554 1554
 		}
1555 1555
 		
1556
-		if( !is_array( $sqlArray ) ) {
1556
+		if (!is_array($sqlArray)) {
1557 1557
 			$this->success = 0;
1558 1558
 		} else {
1559
-			$this->success = $this->dict->ExecuteSQLArray( $sqlArray, $continueOnErr );
1559
+			$this->success = $this->dict->ExecuteSQLArray($sqlArray, $continueOnErr);
1560 1560
 		}
1561 1561
 		
1562 1562
 		return $this->success;
@@ -1571,8 +1571,8 @@  discard block
 block discarded – undo
1571 1571
 	* @param string $format Format: HTML, TEXT, or NONE (PHP array)
1572 1572
 	* @return array Array of SQL statements or FALSE if an error occurs
1573 1573
 	*/
1574
-	function PrintSQL( $format = 'NONE' ) {
1575
-		return $this->getSQL( $format, $sqlArray );
1574
+	function PrintSQL($format = 'NONE') {
1575
+		return $this->getSQL($format, $sqlArray);
1576 1576
 	}
1577 1577
 	
1578 1578
 	/**
@@ -1584,21 +1584,21 @@  discard block
 block discarded – undo
1584 1584
 	* @param string $filename Path and name where the file should be saved.
1585 1585
 	* @return boolean TRUE if save is successful, else FALSE. 
1586 1586
 	*/
1587
-	function SaveSQL( $filename = './schema.sql' ) {
1587
+	function SaveSQL($filename = './schema.sql') {
1588 1588
 		
1589
-		if( !isset( $sqlArray ) ) {
1589
+		if (!isset($sqlArray)) {
1590 1590
 			$sqlArray = $this->sqlArray;
1591 1591
 		}
1592
-		if( !isset( $sqlArray ) ) {
1592
+		if (!isset($sqlArray)) {
1593 1593
 			return FALSE;
1594 1594
 		}
1595 1595
 		
1596
-		$fp = fopen( $filename, "w" );
1596
+		$fp = fopen($filename, "w");
1597 1597
 		
1598
-		foreach( $sqlArray as $key => $query ) {
1599
-			fwrite( $fp, $query . ";\n" );
1598
+		foreach ($sqlArray as $key => $query) {
1599
+			fwrite($fp, $query.";\n");
1600 1600
 		}
1601
-		fclose( $fp );
1601
+		fclose($fp);
1602 1602
 	}
1603 1603
 	
1604 1604
 	/**
@@ -1611,11 +1611,11 @@  discard block
 block discarded – undo
1611 1611
 	function &create_parser() {
1612 1612
 		// Create the parser
1613 1613
 		$xmlParser = xml_parser_create();
1614
-		xml_set_object( $xmlParser, $this );
1614
+		xml_set_object($xmlParser, $this);
1615 1615
 		
1616 1616
 		// Initialize the XML callback functions
1617
-		xml_set_element_handler( $xmlParser, '_tag_open', '_tag_close' );
1618
-		xml_set_character_data_handler( $xmlParser, '_tag_cdata' );
1617
+		xml_set_element_handler($xmlParser, '_tag_open', '_tag_close');
1618
+		xml_set_character_data_handler($xmlParser, '_tag_cdata');
1619 1619
 		
1620 1620
 		return $xmlParser;
1621 1621
 	}
@@ -1625,16 +1625,16 @@  discard block
 block discarded – undo
1625 1625
 	*
1626 1626
 	* @access private
1627 1627
 	*/
1628
-	function _tag_open( &$parser, $tag, $attributes ) {
1629
-		switch( strtoupper( $tag ) ) {
1628
+	function _tag_open(&$parser, $tag, $attributes) {
1629
+		switch (strtoupper($tag)) {
1630 1630
 			case 'TABLE':
1631
-				$this->obj = new dbTable( $this, $attributes );
1632
-				xml_set_object( $parser, $this->obj );
1631
+				$this->obj = new dbTable($this, $attributes);
1632
+				xml_set_object($parser, $this->obj);
1633 1633
 				break;
1634 1634
 			case 'SQL':
1635
-				if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) {
1636
-					$this->obj = new dbQuerySet( $this, $attributes );
1637
-					xml_set_object( $parser, $this->obj );
1635
+				if (!isset($attributes['PLATFORM']) OR $this->supportedPlatform($attributes['PLATFORM'])) {
1636
+					$this->obj = new dbQuerySet($this, $attributes);
1637
+					xml_set_object($parser, $this->obj);
1638 1638
 				}
1639 1639
 				break;
1640 1640
 			default:
@@ -1648,7 +1648,7 @@  discard block
 block discarded – undo
1648 1648
 	*
1649 1649
 	* @access private
1650 1650
 	*/
1651
-	function _tag_cdata( &$parser, $cdata ) {
1651
+	function _tag_cdata(&$parser, $cdata) {
1652 1652
 	}
1653 1653
 	
1654 1654
 	/**
@@ -1657,7 +1657,7 @@  discard block
 block discarded – undo
1657 1657
 	* @access private
1658 1658
 	* @internal
1659 1659
 	*/
1660
-	function _tag_close( &$parser, $tag ) {
1660
+	function _tag_close(&$parser, $tag) {
1661 1661
 		
1662 1662
 	}
1663 1663
 	
@@ -1677,26 +1677,26 @@  discard block
 block discarded – undo
1677 1677
 	* @param string $newFile File name of (converted) output file.
1678 1678
 	* @return string Converted XML schema or FALSE if an error occurs.
1679 1679
 	*/
1680
-	function ConvertSchemaString( $schema, $newVersion = NULL, $newFile = NULL ) {
1680
+	function ConvertSchemaString($schema, $newVersion = NULL, $newFile = NULL) {
1681 1681
 		
1682 1682
 		// grab current version
1683
-		if( !( $version = $this->SchemaStringVersion( $schema ) ) ) {
1683
+		if (!($version = $this->SchemaStringVersion($schema))) {
1684 1684
 			return FALSE;
1685 1685
 		}
1686 1686
 		
1687
-		if( !isset ($newVersion) ) {
1687
+		if (!isset ($newVersion)) {
1688 1688
 			$newVersion = $this->schemaVersion;
1689 1689
 		}
1690 1690
 		
1691
-		if( $version == $newVersion ) {
1691
+		if ($version == $newVersion) {
1692 1692
 			$result = $schema;
1693 1693
 		} else {
1694
-			$result = $this->TransformSchema( $schema, 'convert-' . $version . '-' . $newVersion);
1694
+			$result = $this->TransformSchema($schema, 'convert-'.$version.'-'.$newVersion);
1695 1695
 		}
1696 1696
 		
1697
-		if( is_string( $result ) AND is_string( $newFile ) AND ( $fp = fopen( $newFile, 'w' ) ) ) {
1698
-			fwrite( $fp, $result );
1699
-			fclose( $fp );
1697
+		if (is_string($result) AND is_string($newFile) AND ($fp = fopen($newFile, 'w'))) {
1698
+			fwrite($fp, $result);
1699
+			fclose($fp);
1700 1700
 		}
1701 1701
 		
1702 1702
 		return $result;
@@ -1718,81 +1718,81 @@  discard block
 block discarded – undo
1718 1718
 	* @param string $newFile File name of (converted) output file.
1719 1719
 	* @return string Converted XML schema or FALSE if an error occurs.
1720 1720
 	*/
1721
-	function ConvertSchemaFile( $filename, $newVersion = NULL, $newFile = NULL ) {
1721
+	function ConvertSchemaFile($filename, $newVersion = NULL, $newFile = NULL) {
1722 1722
 		
1723 1723
 		// grab current version
1724
-		if( !( $version = $this->SchemaFileVersion( $filename ) ) ) {
1724
+		if (!($version = $this->SchemaFileVersion($filename))) {
1725 1725
 			return FALSE;
1726 1726
 		}
1727 1727
 		
1728
-		if( !isset ($newVersion) ) {
1728
+		if (!isset ($newVersion)) {
1729 1729
 			$newVersion = $this->schemaVersion;
1730 1730
 		}
1731 1731
 		
1732
-		if( $version == $newVersion ) {
1733
-			$result = file_get_contents( $filename );
1732
+		if ($version == $newVersion) {
1733
+			$result = file_get_contents($filename);
1734 1734
 			
1735 1735
 			// remove unicode BOM if present
1736
-			if( substr( $result, 0, 3 ) == sprintf( '%c%c%c', 239, 187, 191 ) ) {
1737
-				$result = substr( $result, 3 );
1736
+			if (substr($result, 0, 3) == sprintf('%c%c%c', 239, 187, 191)) {
1737
+				$result = substr($result, 3);
1738 1738
 			}
1739 1739
 		} else {
1740
-			$result = $this->TransformSchema( $filename, 'convert-' . $version . '-' . $newVersion, 'file' );
1740
+			$result = $this->TransformSchema($filename, 'convert-'.$version.'-'.$newVersion, 'file');
1741 1741
 		}
1742 1742
 		
1743
-		if( is_string( $result ) AND is_string( $newFile ) AND ( $fp = fopen( $newFile, 'w' ) ) ) {
1744
-			fwrite( $fp, $result );
1745
-			fclose( $fp );
1743
+		if (is_string($result) AND is_string($newFile) AND ($fp = fopen($newFile, 'w'))) {
1744
+			fwrite($fp, $result);
1745
+			fclose($fp);
1746 1746
 		}
1747 1747
 		
1748 1748
 		return $result;
1749 1749
 	}
1750 1750
 	
1751
-	function TransformSchema( $schema, $xsl, $schematype='string' )
1751
+	function TransformSchema($schema, $xsl, $schematype = 'string')
1752 1752
 	{
1753 1753
 		// Fail if XSLT extension is not available
1754
-		if( ! function_exists( 'xslt_create' ) ) {
1754
+		if (!function_exists('xslt_create')) {
1755 1755
 			return FALSE;
1756 1756
 		}
1757 1757
 		
1758
-		$xsl_file = dirname( __FILE__ ) . '/xsl/' . $xsl . '.xsl';
1758
+		$xsl_file = dirname(__FILE__).'/xsl/'.$xsl.'.xsl';
1759 1759
 		
1760 1760
 		// look for xsl
1761
-		if( !is_readable( $xsl_file ) ) {
1761
+		if (!is_readable($xsl_file)) {
1762 1762
 			return FALSE;
1763 1763
 		}
1764 1764
 		
1765
-		switch( $schematype )
1765
+		switch ($schematype)
1766 1766
 		{
1767 1767
 			case 'file':
1768
-				if( !is_readable( $schema ) ) {
1768
+				if (!is_readable($schema)) {
1769 1769
 					return FALSE;
1770 1770
 				}
1771 1771
 				
1772
-				$schema = file_get_contents( $schema );
1772
+				$schema = file_get_contents($schema);
1773 1773
 				break;
1774 1774
 			case 'string':
1775 1775
 			default:
1776
-				if( !is_string( $schema ) ) {
1776
+				if (!is_string($schema)) {
1777 1777
 					return FALSE;
1778 1778
 				}
1779 1779
 		}
1780 1780
 		
1781
-		$arguments = array (
1781
+		$arguments = array(
1782 1782
 			'/_xml' => $schema,
1783
-			'/_xsl' => file_get_contents( $xsl_file )
1783
+			'/_xsl' => file_get_contents($xsl_file)
1784 1784
 		);
1785 1785
 		
1786 1786
 		// create an XSLT processor
1787
-		$xh = xslt_create ();
1787
+		$xh = xslt_create();
1788 1788
 		
1789 1789
 		// set error handler
1790
-		xslt_set_error_handler ($xh, array (&$this, 'xslt_error_handler'));
1790
+		xslt_set_error_handler($xh, array(&$this, 'xslt_error_handler'));
1791 1791
 		
1792 1792
 		// process the schema
1793
-		$result = xslt_process ($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments); 
1793
+		$result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments); 
1794 1794
 		
1795
-		xslt_free ($xh);
1795
+		xslt_free($xh);
1796 1796
 		
1797 1797
 		return $result;
1798 1798
 	}
@@ -1807,17 +1807,17 @@  discard block
 block discarded – undo
1807 1807
 	*
1808 1808
 	* @access private
1809 1809
 	*/
1810
-	function xslt_error_handler( $parser, $errno, $level, $fields ) {
1811
-		if( is_array( $fields ) ) {
1810
+	function xslt_error_handler($parser, $errno, $level, $fields) {
1811
+		if (is_array($fields)) {
1812 1812
 			$msg = array(
1813
-				'Message Type' => ucfirst( $fields['msgtype'] ),
1813
+				'Message Type' => ucfirst($fields['msgtype']),
1814 1814
 				'Message Code' => $fields['code'],
1815 1815
 				'Message' => $fields['msg'],
1816 1816
 				'Error Number' => $errno,
1817 1817
 				'Level' => $level
1818 1818
 			);
1819 1819
 			
1820
-			switch( $fields['URI'] ) {
1820
+			switch ($fields['URI']) {
1821 1821
 				case 'arg:/_xml':
1822 1822
 					$msg['Input'] = 'XML';
1823 1823
 					break;
@@ -1834,20 +1834,20 @@  discard block
 block discarded – undo
1834 1834
 				'Message Type' => 'Error',
1835 1835
 				'Error Number' => $errno,
1836 1836
 				'Level' => $level,
1837
-				'Fields' => var_export( $fields, TRUE )
1837
+				'Fields' => var_export($fields, TRUE)
1838 1838
 			);
1839 1839
 		}
1840 1840
 		
1841
-		$error_details = $msg['Message Type'] . ' in XSLT Transformation' . "\n"
1842
-					   . '<table>' . "\n";
1841
+		$error_details = $msg['Message Type'].' in XSLT Transformation'."\n"
1842
+					   . '<table>'."\n";
1843 1843
 		
1844
-		foreach( $msg as $label => $details ) {
1845
-			$error_details .= '<tr><td><b>' . $label . ': </b></td><td>' . htmlentities( $details ) . '</td></tr>' . "\n";
1844
+		foreach ($msg as $label => $details) {
1845
+			$error_details .= '<tr><td><b>'.$label.': </b></td><td>'.htmlentities($details).'</td></tr>'."\n";
1846 1846
 		}
1847 1847
 		
1848 1848
 		$error_details .= '</table>';
1849 1849
 		
1850
-		trigger_error( $error_details, E_USER_ERROR );
1850
+		trigger_error($error_details, E_USER_ERROR);
1851 1851
 	}
1852 1852
 	
1853 1853
 	/**
@@ -1859,17 +1859,17 @@  discard block
 block discarded – undo
1859 1859
 	* @param string $filename AXMLS schema file
1860 1860
 	* @return string Schema version number or FALSE on error
1861 1861
 	*/
1862
-	function SchemaFileVersion( $filename ) {
1862
+	function SchemaFileVersion($filename) {
1863 1863
 		// Open the file
1864
-		if( !($fp = fopen( $filename, 'r' )) ) {
1864
+		if (!($fp = fopen($filename, 'r'))) {
1865 1865
 			// die( 'Unable to open file' );
1866 1866
 			return FALSE;
1867 1867
 		}
1868 1868
 		
1869 1869
 		// Process the file
1870
-		while( $data = fread( $fp, 4096 ) ) {
1871
-			if( preg_match( $this->versionRegex, $data, $matches ) ) {
1872
-				return !empty( $matches[2] ) ? $matches[2] : XMLS_DEFAULT_SCHEMA_VERSION;
1870
+		while ($data = fread($fp, 4096)) {
1871
+			if (preg_match($this->versionRegex, $data, $matches)) {
1872
+				return !empty($matches[2]) ? $matches[2] : XMLS_DEFAULT_SCHEMA_VERSION;
1873 1873
 			}
1874 1874
 		}
1875 1875
 		
@@ -1885,13 +1885,13 @@  discard block
 block discarded – undo
1885 1885
 	* @param string $xmlstring XML schema string
1886 1886
 	* @return string Schema version number or FALSE on error
1887 1887
 	*/
1888
-	function SchemaStringVersion( $xmlstring ) {
1889
-		if( !is_string( $xmlstring ) OR empty( $xmlstring ) ) {
1888
+	function SchemaStringVersion($xmlstring) {
1889
+		if (!is_string($xmlstring) OR empty($xmlstring)) {
1890 1890
 			return FALSE;
1891 1891
 		}
1892 1892
 		
1893
-		if( preg_match( $this->versionRegex, $xmlstring, $matches ) ) {
1894
-			return !empty( $matches[2] ) ? $matches[2] : XMLS_DEFAULT_SCHEMA_VERSION;
1893
+		if (preg_match($this->versionRegex, $xmlstring, $matches)) {
1894
+			return !empty($matches[2]) ? $matches[2] : XMLS_DEFAULT_SCHEMA_VERSION;
1895 1895
 		}
1896 1896
 		
1897 1897
 		return FALSE;
@@ -1907,98 +1907,98 @@  discard block
 block discarded – undo
1907 1907
 	* @param boolean $data Include data in schema dump
1908 1908
 	* @return string Generated XML schema
1909 1909
 	*/
1910
-	function ExtractSchema( $data = FALSE ) {
1911
-		$old_mode = $this->db->SetFetchMode( ADODB_FETCH_NUM );
1910
+	function ExtractSchema($data = FALSE) {
1911
+		$old_mode = $this->db->SetFetchMode(ADODB_FETCH_NUM);
1912 1912
 		
1913
-		$schema = '<?xml version="1.0"?>' . "\n"
1914
-				. '<schema version="' . $this->schemaVersion . '">' . "\n";
1913
+		$schema = '<?xml version="1.0"?>'."\n"
1914
+				. '<schema version="'.$this->schemaVersion.'">'."\n";
1915 1915
 		
1916
-		if( is_array( $tables = $this->db->MetaTables( 'TABLES' ) ) ) {
1917
-			foreach( $tables as $table ) {
1918
-				$schema .= '	<table name="' . $table . '">' . "\n";
1916
+		if (is_array($tables = $this->db->MetaTables('TABLES'))) {
1917
+			foreach ($tables as $table) {
1918
+				$schema .= '	<table name="'.$table.'">'."\n";
1919 1919
 				
1920 1920
 				// grab details from database
1921
-				$rs = $this->db->Execute( 'SELECT * FROM ' . $table . ' WHERE 1=1' );
1922
-				$fields = $this->db->MetaColumns( $table );
1923
-				$indexes = $this->db->MetaIndexes( $table );
1921
+				$rs = $this->db->Execute('SELECT * FROM '.$table.' WHERE 1=1');
1922
+				$fields = $this->db->MetaColumns($table);
1923
+				$indexes = $this->db->MetaIndexes($table);
1924 1924
 				
1925
-				if( is_array( $fields ) ) {
1926
-					foreach( $fields as $details ) {
1925
+				if (is_array($fields)) {
1926
+					foreach ($fields as $details) {
1927 1927
 						$extra = '';
1928 1928
 						$content = array();
1929 1929
 						
1930
-						if( $details->max_length > 0 ) {
1931
-							$extra .= ' size="' . $details->max_length . '"';
1930
+						if ($details->max_length > 0) {
1931
+							$extra .= ' size="'.$details->max_length.'"';
1932 1932
 						}
1933 1933
 						
1934
-						if( $details->primary_key ) {
1934
+						if ($details->primary_key) {
1935 1935
 							$content[] = '<KEY/>';
1936
-						} elseif( $details->not_null ) {
1936
+						} elseif ($details->not_null) {
1937 1937
 							$content[] = '<NOTNULL/>';
1938 1938
 						}
1939 1939
 						
1940
-						if( $details->has_default ) {
1941
-							$content[] = '<DEFAULT value="' . $details->default_value . '"/>';
1940
+						if ($details->has_default) {
1941
+							$content[] = '<DEFAULT value="'.$details->default_value.'"/>';
1942 1942
 						}
1943 1943
 						
1944
-						if( $details->auto_increment ) {
1944
+						if ($details->auto_increment) {
1945 1945
 							$content[] = '<AUTOINCREMENT/>';
1946 1946
 						}
1947 1947
 						
1948 1948
 						// this stops the creation of 'R' columns,
1949 1949
 						// AUTOINCREMENT is used to create auto columns
1950 1950
 						$details->primary_key = 0;
1951
-						$type = $rs->MetaType( $details );
1951
+						$type = $rs->MetaType($details);
1952 1952
 						
1953
-						$schema .= '		<field name="' . $details->name . '" type="' . $type . '"' . $extra . '>';
1953
+						$schema .= '		<field name="'.$details->name.'" type="'.$type.'"'.$extra.'>';
1954 1954
 						
1955
-						if( !empty( $content ) ) {
1956
-							$schema .= "\n			" . implode( "\n			", $content ) . "\n		";
1955
+						if (!empty($content)) {
1956
+							$schema .= "\n			".implode("\n			", $content)."\n		";
1957 1957
 						}
1958 1958
 						
1959
-						$schema .= '</field>' . "\n";
1959
+						$schema .= '</field>'."\n";
1960 1960
 					}
1961 1961
 				}
1962 1962
 				
1963
-				if( is_array( $indexes ) ) {
1964
-					foreach( $indexes as $index => $details ) {
1965
-						$schema .= '		<index name="' . $index . '">' . "\n";
1963
+				if (is_array($indexes)) {
1964
+					foreach ($indexes as $index => $details) {
1965
+						$schema .= '		<index name="'.$index.'">'."\n";
1966 1966
 						
1967
-						if( $details['unique'] ) {
1968
-							$schema .= '			<UNIQUE/>' . "\n";
1967
+						if ($details['unique']) {
1968
+							$schema .= '			<UNIQUE/>'."\n";
1969 1969
 						}
1970 1970
 						
1971
-						foreach( $details['columns'] as $column ) {
1972
-							$schema .= '			<col>' . $column . '</col>' . "\n";
1971
+						foreach ($details['columns'] as $column) {
1972
+							$schema .= '			<col>'.$column.'</col>'."\n";
1973 1973
 						}
1974 1974
 						
1975
-						$schema .= '		</index>' . "\n";
1975
+						$schema .= '		</index>'."\n";
1976 1976
 					}
1977 1977
 				}
1978 1978
 				
1979
-				if( $data ) {
1980
-					$rs = $this->db->Execute( 'SELECT * FROM ' . $table );
1979
+				if ($data) {
1980
+					$rs = $this->db->Execute('SELECT * FROM '.$table);
1981 1981
 					
1982
-					if( is_object( $rs ) ) {
1983
-						$schema .= '		<data>' . "\n";
1982
+					if (is_object($rs)) {
1983
+						$schema .= '		<data>'."\n";
1984 1984
 						
1985
-						while( $row = $rs->FetchRow() ) {
1986
-							foreach( $row as $key => $val ) {
1985
+						while ($row = $rs->FetchRow()) {
1986
+							foreach ($row as $key => $val) {
1987 1987
 								$row[$key] = htmlentities($val);
1988 1988
 							}
1989 1989
 							
1990
-							$schema .= '			<row><f>' . implode( '</f><f>', $row ) . '</f></row>' . "\n";
1990
+							$schema .= '			<row><f>'.implode('</f><f>', $row).'</f></row>'."\n";
1991 1991
 						}
1992 1992
 						
1993
-						$schema .= '		</data>' . "\n";
1993
+						$schema .= '		</data>'."\n";
1994 1994
 					}
1995 1995
 				}
1996 1996
 				
1997
-				$schema .= '	</table>' . "\n";
1997
+				$schema .= '	</table>'."\n";
1998 1998
 			}
1999 1999
 		}
2000 2000
 		
2001
-		$this->db->SetFetchMode( $old_mode );
2001
+		$this->db->SetFetchMode($old_mode);
2002 2002
 		
2003 2003
 		$schema .= '</schema>';
2004 2004
 		return $schema;
@@ -2014,27 +2014,27 @@  discard block
 block discarded – undo
2014 2014
 	* @param boolean $underscore If TRUE, automatically append an underscore character to the prefix.
2015 2015
 	* @return boolean TRUE if successful, else FALSE
2016 2016
 	*/
2017
-	function SetPrefix( $prefix = '', $underscore = TRUE ) {
2018
-		switch( TRUE ) {
2017
+	function SetPrefix($prefix = '', $underscore = TRUE) {
2018
+		switch (TRUE) {
2019 2019
 			// clear prefix
2020
-			case empty( $prefix ):
2021
-				logMsg( 'Cleared prefix' );
2020
+			case empty($prefix):
2021
+				logMsg('Cleared prefix');
2022 2022
 				$this->objectPrefix = '';
2023 2023
 				return TRUE;
2024 2024
 			// prefix too long
2025
-			case strlen( $prefix ) > XMLS_PREFIX_MAXLEN:
2025
+			case strlen($prefix) > XMLS_PREFIX_MAXLEN:
2026 2026
 			// prefix contains invalid characters
2027
-			case !preg_match( '/^[a-z][a-z0-9_]+$/i', $prefix ):
2028
-				logMsg( 'Invalid prefix: ' . $prefix );
2027
+			case !preg_match('/^[a-z][a-z0-9_]+$/i', $prefix):
2028
+				logMsg('Invalid prefix: '.$prefix);
2029 2029
 				return FALSE;
2030 2030
 		}
2031 2031
 		
2032
-		if( $underscore AND substr( $prefix, -1 ) != '_' ) {
2032
+		if ($underscore AND substr($prefix, -1) != '_') {
2033 2033
 			$prefix .= '_';
2034 2034
 		}
2035 2035
 		
2036 2036
 		// prefix valid
2037
-		logMsg( 'Set prefix: ' . $prefix );
2037
+		logMsg('Set prefix: '.$prefix);
2038 2038
 		$this->objectPrefix = $prefix;
2039 2039
 		return TRUE;
2040 2040
 	}
@@ -2047,12 +2047,12 @@  discard block
 block discarded – undo
2047 2047
 	*
2048 2048
 	* @access private
2049 2049
 	*/
2050
-	function prefix( $name = '' ) {
2050
+	function prefix($name = '') {
2051 2051
 		// if prefix is set
2052
-		if( !empty( $this->objectPrefix ) ) {
2052
+		if (!empty($this->objectPrefix)) {
2053 2053
 			// Prepend the object prefix to the table name
2054 2054
 			// prepend after quote if used
2055
-			return preg_replace( '/^(`?)(.+)$/', '$1' . $this->objectPrefix . '$2', $name );
2055
+			return preg_replace('/^(`?)(.+)$/', '$1'.$this->objectPrefix.'$2', $name);
2056 2056
 		}
2057 2057
 		
2058 2058
 		// No prefix set. Use name provided.
@@ -2067,14 +2067,14 @@  discard block
 block discarded – undo
2067 2067
 	*
2068 2068
 	* @access private
2069 2069
 	*/
2070
-	function supportedPlatform( $platform = NULL ) {
2071
-		$regex = '/^(\w*\|)*' . $this->db->databaseType . '(\|\w*)*$/';
2070
+	function supportedPlatform($platform = NULL) {
2071
+		$regex = '/^(\w*\|)*'.$this->db->databaseType.'(\|\w*)*$/';
2072 2072
 		
2073
-		if( !isset( $platform ) OR preg_match( $regex, $platform ) ) {
2074
-			logMsg( "Platform $platform is supported" );
2073
+		if (!isset($platform) OR preg_match($regex, $platform)) {
2074
+			logMsg("Platform $platform is supported");
2075 2075
 			return TRUE;
2076 2076
 		} else {
2077
-			logMsg( "Platform $platform is NOT supported" );
2077
+			logMsg("Platform $platform is NOT supported");
2078 2078
 			return FALSE;
2079 2079
 		}
2080 2080
 	}
@@ -2096,28 +2096,28 @@  discard block
 block discarded – undo
2096 2096
 	*
2097 2097
 	* @access private
2098 2098
 	*/	
2099
-	function addSQL( $sql = NULL ) {
2100
-		if( is_array( $sql ) ) {
2101
-			foreach( $sql as $line ) {
2102
-				$this->addSQL( $line );
2099
+	function addSQL($sql = NULL) {
2100
+		if (is_array($sql)) {
2101
+			foreach ($sql as $line) {
2102
+				$this->addSQL($line);
2103 2103
 			}
2104 2104
 			
2105 2105
 			return TRUE;
2106 2106
 		}
2107 2107
 		
2108
-		if( is_string( $sql ) ) {
2108
+		if (is_string($sql)) {
2109 2109
 			$this->sqlArray[] = $sql;
2110 2110
 			
2111 2111
 			// if executeInline is enabled, and either no errors have occurred or continueOnError is enabled, execute SQL.
2112
-			if( $this->ExecuteInline() && ( $this->success == 2 || $this->ContinueOnError() ) ) {
2112
+			if ($this->ExecuteInline() && ($this->success == 2 || $this->ContinueOnError())) {
2113 2113
 				$saved = $this->db->debug;
2114 2114
 				$this->db->debug = $this->debug;
2115
-				$ok = $this->db->Execute( $sql );
2115
+				$ok = $this->db->Execute($sql);
2116 2116
 				$this->db->debug = $saved;
2117 2117
 				
2118
-				if( !$ok ) {
2119
-					if( $this->debug ) {
2120
-						ADOConnection::outp( $this->db->ErrorMsg() );
2118
+				if (!$ok) {
2119
+					if ($this->debug) {
2120
+						ADOConnection::outp($this->db->ErrorMsg());
2121 2121
 					}
2122 2122
 					
2123 2123
 					$this->success = 1;
@@ -2138,21 +2138,21 @@  discard block
 block discarded – undo
2138 2138
 	*	
2139 2139
 	* @access private
2140 2140
 	*/
2141
-	function getSQL( $format = NULL, $sqlArray = NULL ) {
2142
-		if( !is_array( $sqlArray ) ) {
2141
+	function getSQL($format = NULL, $sqlArray = NULL) {
2142
+		if (!is_array($sqlArray)) {
2143 2143
 			$sqlArray = $this->sqlArray;
2144 2144
 		}
2145 2145
 		
2146
-		if( !is_array( $sqlArray ) ) {
2146
+		if (!is_array($sqlArray)) {
2147 2147
 			return FALSE;
2148 2148
 		}
2149 2149
 		
2150
-		switch( strtolower( $format ) ) {
2150
+		switch (strtolower($format)) {
2151 2151
 			case 'string':
2152 2152
 			case 'text':
2153
-				return !empty( $sqlArray ) ? implode( ";\n\n", $sqlArray ) . ';' : '';
2153
+				return !empty($sqlArray) ? implode(";\n\n", $sqlArray).';' : '';
2154 2154
 			case'html':
2155
-				return !empty( $sqlArray ) ? nl2br( htmlentities( implode( ";\n\n", $sqlArray ) . ';' ) ) : '';
2155
+				return !empty($sqlArray) ? nl2br(htmlentities(implode(";\n\n", $sqlArray).';')) : '';
2156 2156
 		}
2157 2157
 		
2158 2158
 		return $this->sqlArray;
@@ -2165,8 +2165,8 @@  discard block
 block discarded – undo
2165 2165
 	* @deprecated adoSchema now cleans up automatically.
2166 2166
 	*/
2167 2167
 	function Destroy() {
2168
-		set_magic_quotes_runtime( $this->mgq );
2169
-		unset( $this );
2168
+		set_magic_quotes_runtime($this->mgq);
2169
+		unset($this);
2170 2170
 	}
2171 2171
 }
2172 2172
 
@@ -2175,19 +2175,19 @@  discard block
 block discarded – undo
2175 2175
 *
2176 2176
 * @access private
2177 2177
 */
2178
-function logMsg( $msg, $title = NULL, $force = FALSE ) {
2179
-	if( XMLS_DEBUG or $force ) {
2178
+function logMsg($msg, $title = NULL, $force = FALSE) {
2179
+	if (XMLS_DEBUG or $force) {
2180 2180
 		echo '<pre>';
2181 2181
 		
2182
-		if( isset( $title ) ) {
2183
-			echo '<h3>' . htmlentities( $title ) . '</h3>';
2182
+		if (isset($title)) {
2183
+			echo '<h3>'.htmlentities($title).'</h3>';
2184 2184
 		}
2185 2185
 		
2186
-		if( is_object( $this ) ) {
2187
-			echo '[' . get_class( $this ) . '] ';
2186
+		if (is_object($this)) {
2187
+			echo '['.get_class($this).'] ';
2188 2188
 		}
2189 2189
 		
2190
-		print_r( $msg );
2190
+		print_r($msg);
2191 2191
 		
2192 2192
 		echo '</pre>';
2193 2193
 	}
Please login to merge, or discard this patch.
Braces   +501 added lines, -242 removed lines patch added patch discarded remove patch
@@ -21,63 +21,72 @@  discard block
 block discarded – undo
21 21
 /**
22 22
 * Debug on or off
23 23
 */
24
-if( !defined( 'XMLS_DEBUG' ) ) {
24
+if( !defined( 'XMLS_DEBUG' ) )
25
+{
25 26
 	define( 'XMLS_DEBUG', FALSE );
26 27
 }
27 28
 
28 29
 /**
29 30
 * Default prefix key
30 31
 */
31
-if( !defined( 'XMLS_PREFIX' ) ) {
32
+if( !defined( 'XMLS_PREFIX' ) )
33
+{
32 34
 	define( 'XMLS_PREFIX', '%%P' );
33 35
 }
34 36
 
35 37
 /**
36 38
 * Maximum length allowed for object prefix
37 39
 */
38
-if( !defined( 'XMLS_PREFIX_MAXLEN' ) ) {
40
+if( !defined( 'XMLS_PREFIX_MAXLEN' ) )
41
+{
39 42
 	define( 'XMLS_PREFIX_MAXLEN', 10 );
40 43
 }
41 44
 
42 45
 /**
43 46
 * Execute SQL inline as it is generated
44 47
 */
45
-if( !defined( 'XMLS_EXECUTE_INLINE' ) ) {
48
+if( !defined( 'XMLS_EXECUTE_INLINE' ) )
49
+{
46 50
 	define( 'XMLS_EXECUTE_INLINE', FALSE );
47 51
 }
48 52
 
49 53
 /**
50 54
 * Continue SQL Execution if an error occurs?
51 55
 */
52
-if( !defined( 'XMLS_CONTINUE_ON_ERROR' ) ) {
56
+if( !defined( 'XMLS_CONTINUE_ON_ERROR' ) )
57
+{
53 58
 	define( 'XMLS_CONTINUE_ON_ERROR', FALSE );
54 59
 }
55 60
 
56 61
 /**
57 62
 * Current Schema Version
58 63
 */
59
-if( !defined( 'XMLS_SCHEMA_VERSION' ) ) {
64
+if( !defined( 'XMLS_SCHEMA_VERSION' ) )
65
+{
60 66
 	define( 'XMLS_SCHEMA_VERSION', '0.2' );
61 67
 }
62 68
 
63 69
 /**
64 70
 * Default Schema Version.  Used for Schemas without an explicit version set.
65 71
 */
66
-if( !defined( 'XMLS_DEFAULT_SCHEMA_VERSION' ) ) {
72
+if( !defined( 'XMLS_DEFAULT_SCHEMA_VERSION' ) )
73
+{
67 74
 	define( 'XMLS_DEFAULT_SCHEMA_VERSION', '0.1' );
68 75
 }
69 76
 
70 77
 /**
71 78
 * Default Schema Version.  Used for Schemas without an explicit version set.
72 79
 */
73
-if( !defined( 'XMLS_DEFAULT_UPGRADE_METHOD' ) ) {
80
+if( !defined( 'XMLS_DEFAULT_UPGRADE_METHOD' ) )
81
+{
74 82
 	define( 'XMLS_DEFAULT_UPGRADE_METHOD', 'ALTER' );
75 83
 }
76 84
 
77 85
 /**
78 86
 * Include the main ADODB library
79 87
 */
80
-if( !defined( '_ADODB_LAYER' ) ) {
88
+if( !defined( '_ADODB_LAYER' ) )
89
+{
81 90
 	require( 'adodb.inc.php' );
82 91
 	require( 'adodb-datadict.inc.php' );
83 92
 }
@@ -89,7 +98,8 @@  discard block
 block discarded – undo
89 98
 * @package axmls
90 99
 * @access private
91 100
 */
92
-class dbObject {
101
+class dbObject
102
+{
93 103
 	
94 104
 	/**
95 105
 	* var object Parent
@@ -104,7 +114,8 @@  discard block
 block discarded – undo
104 114
 	/**
105 115
 	* NOP
106 116
 	*/
107
-	function dbObject( &$parent, $attributes = NULL ) {
117
+	function dbObject( &$parent, $attributes = NULL )
118
+	{
108 119
 		$this->parent =& $parent;
109 120
 	}
110 121
 	
@@ -113,7 +124,8 @@  discard block
 block discarded – undo
113 124
 	*
114 125
 	* @access private
115 126
 	*/
116
-	function _tag_open( &$parser, $tag, $attributes ) {
127
+	function _tag_open( &$parser, $tag, $attributes )
128
+	{
117 129
 		
118 130
 	}
119 131
 	
@@ -122,7 +134,8 @@  discard block
 block discarded – undo
122 134
 	*
123 135
 	* @access private
124 136
 	*/
125
-	function _tag_cdata( &$parser, $cdata ) {
137
+	function _tag_cdata( &$parser, $cdata )
138
+	{
126 139
 		
127 140
 	}
128 141
 	
@@ -131,18 +144,21 @@  discard block
 block discarded – undo
131 144
 	*
132 145
 	* @access private
133 146
 	*/
134
-	function _tag_close( &$parser, $tag ) {
147
+	function _tag_close( &$parser, $tag )
148
+	{
135 149
 		
136 150
 	}
137 151
 	
138
-	function create() {
152
+	function create()
153
+	{
139 154
 		return array();
140 155
 	}
141 156
 	
142 157
 	/**
143 158
 	* Destroys the object
144 159
 	*/
145
-	function destroy() {
160
+	function destroy()
161
+	{
146 162
 		unset( $this );
147 163
 	}
148 164
 	
@@ -153,7 +169,8 @@  discard block
 block discarded – undo
153 169
 	* @param string $platform RDBMS platform name (from ADODB platform list).
154 170
 	* @return boolean TRUE if RDBMS is supported; otherwise returns FALSE.
155 171
 	*/
156
-	function supportedPlatform( $platform = NULL ) {
172
+	function supportedPlatform( $platform = NULL )
173
+	{
157 174
 		return is_object( $this->parent ) ? $this->parent->supportedPlatform( $platform ) : TRUE;
158 175
 	}
159 176
 	
@@ -163,7 +180,8 @@  discard block
 block discarded – undo
163 180
 	* @param string $name Prefix string.
164 181
 	* @return string Prefix.
165 182
 	*/
166
-	function prefix( $name = '' ) {
183
+	function prefix( $name = '' )
184
+	{
167 185
 		return is_object( $this->parent ) ? $this->parent->prefix( $name ) : $name;
168 186
 	}
169 187
 	
@@ -173,7 +191,8 @@  discard block
 block discarded – undo
173 191
 	* @param string $field Field.
174 192
 	* @return string Field ID.
175 193
 	*/
176
-	function FieldID( $field ) {
194
+	function FieldID( $field )
195
+	{
177 196
 		return strtoupper( preg_replace( '/^`(.+)`$/', '$1', $field ) );
178 197
 	}
179 198
 }
@@ -189,7 +208,8 @@  discard block
 block discarded – undo
189 208
 * @package axmls
190 209
 * @access private
191 210
 */
192
-class dbTable extends dbObject {
211
+class dbTable extends dbObject
212
+{
193 213
 	
194 214
 	/**
195 215
 	* @var string Table name
@@ -234,7 +254,8 @@  discard block
 block discarded – undo
234 254
 	* @param string $prefix DB Object prefix
235 255
 	* @param array $attributes Array of table attributes.
236 256
 	*/
237
-	function dbTable( &$parent, $attributes = NULL ) {
257
+	function dbTable( &$parent, $attributes = NULL )
258
+	{
238 259
 		$this->parent =& $parent;
239 260
 		$this->name = $this->prefix($attributes['NAME']);
240 261
 	}
@@ -245,17 +266,21 @@  discard block
 block discarded – undo
245 266
 	*
246 267
 	* @access private
247 268
 	*/
248
-	function _tag_open( &$parser, $tag, $attributes ) {
269
+	function _tag_open( &$parser, $tag, $attributes )
270
+	{
249 271
 		$this->currentElement = strtoupper( $tag );
250 272
 		
251
-		switch( $this->currentElement ) {
273
+		switch( $this->currentElement )
274
+		{
252 275
 			case 'INDEX':
253
-				if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) {
276
+				if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) )
277
+				{
254 278
 					xml_set_object( $parser, $this->addIndex( $attributes ) );
255 279
 				}
256 280
 				break;
257 281
 			case 'DATA':
258
-				if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) {
282
+				if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) )
283
+				{
259 284
 					xml_set_object( $parser, $this->addData( $attributes ) );
260 285
 				}
261 286
 				break;
@@ -281,7 +306,8 @@  discard block
 block discarded – undo
281 306
 				// Add a field option to the table object
282 307
 				
283 308
 				// Work around ADOdb datadict issue that misinterprets empty strings.
284
-				if( $attributes['VALUE'] == '' ) {
309
+				if( $attributes['VALUE'] == '' )
310
+				{
285 311
 					$attributes['VALUE'] = " '' ";
286 312
 				}
287 313
 				
@@ -302,13 +328,18 @@  discard block
 block discarded – undo
302 328
 	*
303 329
 	* @access private
304 330
 	*/
305
-	function _tag_cdata( &$parser, $cdata ) {
306
-		switch( $this->currentElement ) {
331
+	function _tag_cdata( &$parser, $cdata )
332
+	{
333
+		switch( $this->currentElement )
334
+		{
307 335
 			// Table constraint
308 336
 			case 'CONSTRAINT':
309
-				if( isset( $this->current_field ) ) {
337
+				if( isset( $this->current_field ) )
338
+				{
310 339
 					$this->addFieldOpt( $this->current_field, $this->currentElement, $cdata );
311
-				} else {
340
+				}
341
+				else
342
+				{
312 343
 					$this->addTableOpt( $cdata );
313 344
 				}
314 345
 				break;
@@ -326,10 +357,12 @@  discard block
 block discarded – undo
326 357
 	*
327 358
 	* @access private
328 359
 	*/
329
-	function _tag_close( &$parser, $tag ) {
360
+	function _tag_close( &$parser, $tag )
361
+	{
330 362
 		$this->currentElement = '';
331 363
 		
332
-		switch( strtoupper( $tag ) ) {
364
+		switch( strtoupper( $tag ) )
365
+		{
333 366
 			case 'TABLE':
334 367
 				$this->parent->addSQL( $this->create( $this->parent ) );
335 368
 				xml_set_object( $parser, $this->parent );
@@ -361,7 +394,8 @@  discard block
 block discarded – undo
361 394
 	* @return object dbData object
362 395
 	*/
363 396
 	function &addData( $attributes ) {
364
-		if( !isset( $this->data ) ) {
397
+		if( !isset( $this->data ) )
398
+		{
365 399
 			$this->data = new dbData( $this, $attributes );
366 400
 		}
367 401
 		return $this->data;
@@ -396,7 +430,8 @@  discard block
 block discarded – undo
396 430
 	* @param array $opts	Field options array
397 431
 	* @return array Field specifier array
398 432
 	*/
399
-	function addField( $name, $type, $size = NULL, $opts = NULL ) {
433
+	function addField( $name, $type, $size = NULL, $opts = NULL )
434
+	{
400 435
 		$field_id = $this->FieldID( $name );
401 436
 		
402 437
 		// Set the field index so we know where we are
@@ -409,12 +444,14 @@  discard block
 block discarded – undo
409 444
 		$this->fields[$field_id]['TYPE'] = $type;
410 445
 		
411 446
 		// Set the field size (optional)
412
-		if( isset( $size ) ) {
447
+		if( isset( $size ) )
448
+		{
413 449
 			$this->fields[$field_id]['SIZE'] = $size;
414 450
 		}
415 451
 		
416 452
 		// Set the field options
417
-		if( isset( $opts ) ) {
453
+		if( isset( $opts ) )
454
+		{
418 455
 			$this->fields[$field_id]['OPTS'][] = $opts;
419 456
 		}
420 457
 	}
@@ -430,11 +467,15 @@  discard block
 block discarded – undo
430 467
 	* @param mixed $value Field option value
431 468
 	* @return array Field specifier array
432 469
 	*/
433
-	function addFieldOpt( $field, $opt, $value = NULL ) {
434
-		if( !isset( $value ) ) {
470
+	function addFieldOpt( $field, $opt, $value = NULL )
471
+	{
472
+		if( !isset( $value ) )
473
+		{
435 474
 			$this->fields[$this->FieldID( $field )]['OPTS'][] = $opt;
436 475
 		// Add the option and value
437
-		} else {
476
+		}
477
+		else
478
+		{
438 479
 			$this->fields[$this->FieldID( $field )]['OPTS'][] = array( $opt => $value );
439 480
 		}
440 481
 	}
@@ -448,7 +489,8 @@  discard block
 block discarded – undo
448 489
 	* @param string $opt Table option
449 490
 	* @return array Options
450 491
 	*/
451
-	function addTableOpt( $opt ) {
492
+	function addTableOpt( $opt )
493
+	{
452 494
 		$this->opts[] = $opt;
453 495
 		
454 496
 		return $this->opts;
@@ -460,39 +502,50 @@  discard block
 block discarded – undo
460 502
 	* @param object $xmls adoSchema object
461 503
 	* @return array Array containing table creation SQL
462 504
 	*/
463
-	function create( &$xmls ) {
505
+	function create( &$xmls )
506
+	{
464 507
 		$sql = array();
465 508
 		
466 509
 		// drop any existing indexes
467
-		if( is_array( $legacy_indexes = $xmls->dict->MetaIndexes( $this->name ) ) ) {
468
-			foreach( $legacy_indexes as $index => $index_details ) {
510
+		if( is_array( $legacy_indexes = $xmls->dict->MetaIndexes( $this->name ) ) )
511
+		{
512
+			foreach( $legacy_indexes as $index => $index_details )
513
+			{
469 514
 				$sql[] = $xmls->dict->DropIndexSQL( $index, $this->name );
470 515
 			}
471 516
 		}
472 517
 		
473 518
 		// remove fields to be dropped from table object
474
-		foreach( $this->drop_field as $field ) {
519
+		foreach( $this->drop_field as $field )
520
+		{
475 521
 			unset( $this->fields[$field] );
476 522
 		}
477 523
 		
478 524
 		// if table exists
479
-		if( is_array( $legacy_fields = $xmls->dict->MetaColumns( $this->name ) ) ) {
525
+		if( is_array( $legacy_fields = $xmls->dict->MetaColumns( $this->name ) ) )
526
+		{
480 527
 			// drop table
481
-			if( $this->drop_table ) {
528
+			if( $this->drop_table )
529
+			{
482 530
 				$sql[] = $xmls->dict->DropTableSQL( $this->name );
483 531
 				
484 532
 				return $sql;
485 533
 			}
486 534
 			
487 535
 			// drop any existing fields not in schema
488
-			foreach( $legacy_fields as $field_id => $field ) {
489
-				if( !isset( $this->fields[$field_id] ) ) {
536
+			foreach( $legacy_fields as $field_id => $field )
537
+			{
538
+				if( !isset( $this->fields[$field_id] ) )
539
+				{
490 540
 					$sql[] = $xmls->dict->DropColumnSQL( $this->name, '`'.$field->name.'`' );
491 541
 				}
492 542
 			}
493 543
 		// if table doesn't exist
494
-		} else {
495
-			if( $this->drop_table ) {
544
+		}
545
+		else
546
+		{
547
+			if( $this->drop_table )
548
+			{
496 549
 				return $sql;
497 550
 			}
498 551
 			
@@ -502,9 +555,11 @@  discard block
 block discarded – undo
502 555
 		// Loop through the field specifier array, building the associative array for the field options
503 556
 		$fldarray = array();
504 557
 		
505
-		foreach( $this->fields as $field_id => $finfo ) {
558
+		foreach( $this->fields as $field_id => $finfo )
559
+		{
506 560
 			// Set an empty size if it isn't supplied
507
-			if( !isset( $finfo['SIZE'] ) ) {
561
+			if( !isset( $finfo['SIZE'] ) )
562
+			{
508 563
 				$finfo['SIZE'] = '';
509 564
 			}
510 565
 			
@@ -516,29 +571,38 @@  discard block
 block discarded – undo
516 571
 			);
517 572
 			
518 573
 			// Loop through the options array and add the field options. 
519
-			if( isset( $finfo['OPTS'] ) ) {
520
-				foreach( $finfo['OPTS'] as $opt ) {
574
+			if( isset( $finfo['OPTS'] ) )
575
+			{
576
+				foreach( $finfo['OPTS'] as $opt )
577
+				{
521 578
 					// Option has an argument.
522
-					if( is_array( $opt ) ) {
579
+					if( is_array( $opt ) )
580
+					{
523 581
 						$key = key( $opt );
524 582
 						$value = $opt[key( $opt )];
525 583
 						@$fldarray[$field_id][$key] .= $value;
526 584
 					// Option doesn't have arguments
527
-					} else {
585
+					}
586
+					else
587
+					{
528 588
 						$fldarray[$field_id][$opt] = $opt;
529 589
 					}
530 590
 				}
531 591
 			}
532 592
 		}
533 593
 		
534
-		if( empty( $legacy_fields ) ) {
594
+		if( empty( $legacy_fields ) )
595
+		{
535 596
 			// Create the new table
536 597
 			$sql[] = $xmls->dict->CreateTableSQL( $this->name, $fldarray, $this->opts );
537 598
 			logMsg( end( $sql ), 'Generated CreateTableSQL' );
538
-		} else {
599
+		}
600
+		else
601
+		{
539 602
 			// Upgrade an existing table
540 603
 			logMsg( "Upgrading {$this->name} using '{$xmls->upgrade}'" );
541
-			switch( $xmls->upgrade ) {
604
+			switch( $xmls->upgrade )
605
+			{
542 606
 				// Use ChangeTableSQL
543 607
 				case 'ALTER':
544 608
 					logMsg( 'Generated ChangeTableSQL (ALTERing table)' );
@@ -555,11 +619,13 @@  discard block
 block discarded – undo
555 619
 			}
556 620
 		}
557 621
 		
558
-		foreach( $this->indexes as $index ) {
622
+		foreach( $this->indexes as $index )
623
+		{
559 624
 			$sql[] = $index->create( $xmls );
560 625
 		}
561 626
 		
562
-		if( isset( $this->data ) ) {
627
+		if( isset( $this->data ) )
628
+		{
563 629
 			$sql[] = $this->data->create( $xmls );
564 630
 		}
565 631
 		
@@ -569,13 +635,17 @@  discard block
 block discarded – undo
569 635
 	/**
570 636
 	* Marks a field or table for destruction
571 637
 	*/
572
-	function drop() {
573
-		if( isset( $this->current_field ) ) {
638
+	function drop()
639
+	{
640
+		if( isset( $this->current_field ) )
641
+		{
574 642
 			// Drop the current field
575 643
 			logMsg( "Dropping field '{$this->current_field}' from table '{$this->name}'" );
576 644
 			// $this->drop_field[$this->current_field] = $xmls->dict->DropColumnSQL( $this->name, $this->current_field );
577 645
 			$this->drop_field[$this->current_field] = $this->current_field;
578
-		} else {
646
+		}
647
+		else
648
+		{
579 649
 			// Drop the current table
580 650
 			logMsg( "Dropping table '{$this->name}'" );
581 651
 			// $this->drop_table = $xmls->dict->DropTableSQL( $this->name );
@@ -595,7 +665,8 @@  discard block
 block discarded – undo
595 665
 * @package axmls
596 666
 * @access private
597 667
 */
598
-class dbIndex extends dbObject {
668
+class dbIndex extends dbObject
669
+{
599 670
 	
600 671
 	/**
601 672
 	* @var string	Index name
@@ -626,7 +697,8 @@  discard block
 block discarded – undo
626 697
 	*
627 698
 	* @internal
628 699
 	*/
629
-	function dbIndex( &$parent, $attributes = NULL ) {
700
+	function dbIndex( &$parent, $attributes = NULL )
701
+	{
630 702
 		$this->parent =& $parent;
631 703
 		
632 704
 		$this->name = $this->prefix ($attributes['NAME']);
@@ -640,10 +712,12 @@  discard block
 block discarded – undo
640 712
 	*
641 713
 	* @access private
642 714
 	*/
643
-	function _tag_open( &$parser, $tag, $attributes ) {
715
+	function _tag_open( &$parser, $tag, $attributes )
716
+	{
644 717
 		$this->currentElement = strtoupper( $tag );
645 718
 		
646
-		switch( $this->currentElement ) {
719
+		switch( $this->currentElement )
720
+		{
647 721
 			case 'DROP':
648 722
 				$this->drop();
649 723
 				break;
@@ -667,8 +741,10 @@  discard block
 block discarded – undo
667 741
 	*
668 742
 	* @access private
669 743
 	*/
670
-	function _tag_cdata( &$parser, $cdata ) {
671
-		switch( $this->currentElement ) {
744
+	function _tag_cdata( &$parser, $cdata )
745
+	{
746
+		switch( $this->currentElement )
747
+		{
672 748
 			// Index field name
673 749
 			case 'COL':
674 750
 				$this->addField( $cdata );
@@ -683,10 +759,12 @@  discard block
 block discarded – undo
683 759
 	*
684 760
 	* @access private
685 761
 	*/
686
-	function _tag_close( &$parser, $tag ) {
762
+	function _tag_close( &$parser, $tag )
763
+	{
687 764
 		$this->currentElement = '';
688 765
 		
689
-		switch( strtoupper( $tag ) ) {
766
+		switch( strtoupper( $tag ) )
767
+		{
690 768
 			case 'INDEX':
691 769
 				xml_set_object( $parser, $this->parent );
692 770
 				break;
@@ -699,7 +777,8 @@  discard block
 block discarded – undo
699 777
 	* @param string $name Field name
700 778
 	* @return string Field list
701 779
 	*/
702
-	function addField( $name ) {
780
+	function addField( $name )
781
+	{
703 782
 		$this->columns[$this->FieldID( $name )] = $name;
704 783
 		
705 784
 		// Return the field list
@@ -712,7 +791,8 @@  discard block
 block discarded – undo
712 791
 	* @param string $opt Comma-separated list of index options.
713 792
 	* @return string Option list
714 793
 	*/
715
-	function addIndexOpt( $opt ) {
794
+	function addIndexOpt( $opt )
795
+	{
716 796
 		$this->opts[] = $opt;
717 797
 		
718 798
 		// Return the options list
@@ -725,14 +805,18 @@  discard block
 block discarded – undo
725 805
 	* @param object $xmls adoSchema object
726 806
 	* @return array Array containing index creation SQL
727 807
 	*/
728
-	function create( &$xmls ) {
729
-		if( $this->drop ) {
808
+	function create( &$xmls )
809
+	{
810
+		if( $this->drop )
811
+		{
730 812
 			return NULL;
731 813
 		}
732 814
 		
733 815
 		// eliminate any columns that aren't in the table
734
-		foreach( $this->columns as $id => $col ) {
735
-			if( !isset( $this->parent->fields[$id] ) ) {
816
+		foreach( $this->columns as $id => $col )
817
+		{
818
+			if( !isset( $this->parent->fields[$id] ) )
819
+			{
736 820
 				unset( $this->columns[$id] );
737 821
 			}
738 822
 		}
@@ -743,7 +827,8 @@  discard block
 block discarded – undo
743 827
 	/**
744 828
 	* Marks an index for destruction
745 829
 	*/
746
-	function drop() {
830
+	function drop()
831
+	{
747 832
 		$this->drop = TRUE;
748 833
 	}
749 834
 }
@@ -756,7 +841,8 @@  discard block
 block discarded – undo
756 841
 * @package axmls
757 842
 * @access private
758 843
 */
759
-class dbData extends dbObject {
844
+class dbData extends dbObject
845
+{
760 846
 	
761 847
 	var $data = array();
762 848
 	
@@ -770,7 +856,8 @@  discard block
 block discarded – undo
770 856
 	*
771 857
 	* @internal
772 858
 	*/
773
-	function dbData( &$parent, $attributes = NULL ) {
859
+	function dbData( &$parent, $attributes = NULL )
860
+	{
774 861
 		$this->parent =& $parent;
775 862
 	}
776 863
 	
@@ -782,10 +869,12 @@  discard block
 block discarded – undo
782 869
 	*
783 870
 	* @access private
784 871
 	*/
785
-	function _tag_open( &$parser, $tag, $attributes ) {
872
+	function _tag_open( &$parser, $tag, $attributes )
873
+	{
786 874
 		$this->currentElement = strtoupper( $tag );
787 875
 		
788
-		switch( $this->currentElement ) {
876
+		switch( $this->currentElement )
877
+		{
789 878
 			case 'ROW':
790 879
 				$this->row = count( $this->data );
791 880
 				$this->data[$this->row] = array();
@@ -804,8 +893,10 @@  discard block
 block discarded – undo
804 893
 	*
805 894
 	* @access private
806 895
 	*/
807
-	function _tag_cdata( &$parser, $cdata ) {
808
-		switch( $this->currentElement ) {
896
+	function _tag_cdata( &$parser, $cdata )
897
+	{
898
+		switch( $this->currentElement )
899
+		{
809 900
 			// Index field name
810 901
 			case 'F':
811 902
 				$this->addData( $cdata );
@@ -820,10 +911,12 @@  discard block
 block discarded – undo
820 911
 	*
821 912
 	* @access private
822 913
 	*/
823
-	function _tag_close( &$parser, $tag ) {
914
+	function _tag_close( &$parser, $tag )
915
+	{
824 916
 		$this->currentElement = '';
825 917
 		
826
-		switch( strtoupper( $tag ) ) {
918
+		switch( strtoupper( $tag ) )
919
+		{
827 920
 			case 'DATA':
828 921
 				xml_set_object( $parser, $this->parent );
829 922
 				break;
@@ -836,10 +929,14 @@  discard block
 block discarded – undo
836 929
 	* @param string $name Field name
837 930
 	* @return string Field list
838 931
 	*/
839
-	function addField( $attributes ) {
840
-		if( isset( $attributes['NAME'] ) ) {
932
+	function addField( $attributes )
933
+	{
934
+		if( isset( $attributes['NAME'] ) )
935
+		{
841 936
 			$name = $attributes['NAME'];
842
-		} else {
937
+		}
938
+		else
939
+		{
843 940
 			$name = count($this->data[$this->row]);
844 941
 		}
845 942
 		
@@ -853,12 +950,15 @@  discard block
 block discarded – undo
853 950
 	* @param string $opt Comma-separated list of index options.
854 951
 	* @return string Option list
855 952
 	*/
856
-	function addData( $cdata ) {
857
-		if( !isset( $this->data[$this->row] ) ) {
953
+	function addData( $cdata )
954
+	{
955
+		if( !isset( $this->data[$this->row] ) )
956
+		{
858 957
 			$this->data[$this->row] = array();
859 958
 		}
860 959
 		
861
-		if( !isset( $this->data[$this->row][$this->current_field] ) ) {
960
+		if( !isset( $this->data[$this->row][$this->current_field] ) )
961
+		{
862 962
 			$this->data[$this->row][$this->current_field] = '';
863 963
 		}
864 964
 		
@@ -871,28 +971,36 @@  discard block
 block discarded – undo
871 971
 	* @param object $xmls adoSchema object
872 972
 	* @return array Array containing index creation SQL
873 973
 	*/
874
-	function create( &$xmls ) {
974
+	function create( &$xmls )
975
+	{
875 976
 		$table = $xmls->dict->TableName($this->parent->name);
876 977
 		$table_field_count = count($this->parent->fields);
877 978
 		$sql = array();
878 979
 		
879 980
 		// eliminate any columns that aren't in the table
880
-		foreach( $this->data as $row ) {
981
+		foreach( $this->data as $row )
982
+		{
881 983
 			$table_fields = $this->parent->fields;
882 984
 			$fields = array();
883 985
 			
884
-			foreach( $row as $field_id => $field_data ) {
885
-				if( !array_key_exists( $field_id, $table_fields ) ) {
886
-					if( is_numeric( $field_id ) ) {
986
+			foreach( $row as $field_id => $field_data )
987
+			{
988
+				if( !array_key_exists( $field_id, $table_fields ) )
989
+				{
990
+					if( is_numeric( $field_id ) )
991
+					{
887 992
 						$field_id = reset( array_keys( $table_fields ) );
888
-					} else {
993
+					}
994
+					else
995
+					{
889 996
 						continue;
890 997
 					}
891 998
 				}
892 999
 				
893 1000
 				$name = $table_fields[$field_id]['NAME'];
894 1001
 				
895
-				switch( $table_fields[$field_id]['TYPE'] ) {
1002
+				switch( $table_fields[$field_id]['TYPE'] )
1003
+				{
896 1004
 					case 'C':
897 1005
 					case 'C2':
898 1006
 					case 'X':
@@ -914,16 +1022,21 @@  discard block
 block discarded – undo
914 1022
 			}
915 1023
 			
916 1024
 			// check that at least 1 column is specified
917
-			if( empty( $fields ) ) {
1025
+			if( empty( $fields ) )
1026
+			{
918 1027
 				continue;
919 1028
 			}
920 1029
 			
921 1030
 			// check that no required columns are missing
922
-			if( count( $fields ) < $table_field_count ) {
923
-				foreach( $table_fields as $field ) {
1031
+			if( count( $fields ) < $table_field_count )
1032
+			{
1033
+				foreach( $table_fields as $field )
1034
+				{
924 1035
 					if (isset( $field['OPTS'] ))
925
-						if( ( in_array( 'NOTNULL', $field['OPTS'] ) || in_array( 'KEY', $field['OPTS'] ) ) && !in_array( 'AUTOINCREMENT', $field['OPTS'] ) ) {
1036
+					{
1037
+											if( ( in_array( 'NOTNULL', $field['OPTS'] ) || in_array( 'KEY', $field['OPTS'] ) ) && !in_array( 'AUTOINCREMENT', $field['OPTS'] ) ) {
926 1038
 							continue(2);
1039
+					}
927 1040
 						}
928 1041
 				}
929 1042
 			}
@@ -941,7 +1054,8 @@  discard block
 block discarded – undo
941 1054
 * @package axmls
942 1055
 * @access private
943 1056
 */
944
-class dbQuerySet extends dbObject {
1057
+class dbQuerySet extends dbObject
1058
+{
945 1059
 	
946 1060
 	/**
947 1061
 	* @var array	List of SQL queries
@@ -969,18 +1083,21 @@  discard block
 block discarded – undo
969 1083
 	* @param object $parent Parent object
970 1084
 	* @param array $attributes Attributes
971 1085
 	*/
972
-	function dbQuerySet( &$parent, $attributes = NULL ) {
1086
+	function dbQuerySet( &$parent, $attributes = NULL )
1087
+	{
973 1088
 		$this->parent =& $parent;
974 1089
 			
975 1090
 		// Overrides the manual prefix key
976
-		if( isset( $attributes['KEY'] ) ) {
1091
+		if( isset( $attributes['KEY'] ) )
1092
+		{
977 1093
 			$this->prefixKey = $attributes['KEY'];
978 1094
 		}
979 1095
 		
980 1096
 		$prefixMethod = isset( $attributes['PREFIXMETHOD'] ) ? strtoupper( trim( $attributes['PREFIXMETHOD'] ) ) : '';
981 1097
 		
982 1098
 		// Enables or disables automatic prefix prepending
983
-		switch( $prefixMethod ) {
1099
+		switch( $prefixMethod )
1100
+		{
984 1101
 			case 'AUTO':
985 1102
 				$this->prefixMethod = 'AUTO';
986 1103
 				break;
@@ -999,17 +1116,22 @@  discard block
 block discarded – undo
999 1116
 	*
1000 1117
 	* @access private
1001 1118
 	*/
1002
-	function _tag_open( &$parser, $tag, $attributes ) {
1119
+	function _tag_open( &$parser, $tag, $attributes )
1120
+	{
1003 1121
 		$this->currentElement = strtoupper( $tag );
1004 1122
 		
1005
-		switch( $this->currentElement ) {
1123
+		switch( $this->currentElement )
1124
+		{
1006 1125
 			case 'QUERY':
1007 1126
 				// Create a new query in a SQL queryset.
1008 1127
 				// Ignore this query set if a platform is specified and it's different than the 
1009 1128
 				// current connection platform.
1010
-				if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) {
1129
+				if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) )
1130
+				{
1011 1131
 					$this->newQuery();
1012
-				} else {
1132
+				}
1133
+				else
1134
+				{
1013 1135
 					$this->discardQuery();
1014 1136
 				}
1015 1137
 				break;
@@ -1021,8 +1143,10 @@  discard block
 block discarded – undo
1021 1143
 	/**
1022 1144
 	* XML Callback to process CDATA elements
1023 1145
 	*/
1024
-	function _tag_cdata( &$parser, $cdata ) {
1025
-		switch( $this->currentElement ) {
1146
+	function _tag_cdata( &$parser, $cdata )
1147
+	{
1148
+		switch( $this->currentElement )
1149
+		{
1026 1150
 			// Line of queryset SQL data
1027 1151
 			case 'QUERY':
1028 1152
 				$this->buildQuery( $cdata );
@@ -1037,10 +1161,12 @@  discard block
 block discarded – undo
1037 1161
 	*
1038 1162
 	* @access private
1039 1163
 	*/
1040
-	function _tag_close( &$parser, $tag ) {
1164
+	function _tag_close( &$parser, $tag )
1165
+	{
1041 1166
 		$this->currentElement = '';
1042 1167
 		
1043
-		switch( strtoupper( $tag ) ) {
1168
+		switch( strtoupper( $tag ) )
1169
+		{
1044 1170
 			case 'QUERY':
1045 1171
 				// Add the finished query to the open query set.
1046 1172
 				$this->addQuery();
@@ -1060,7 +1186,8 @@  discard block
 block discarded – undo
1060 1186
 	*
1061 1187
 	* @return boolean TRUE
1062 1188
 	*/
1063
-	function newQuery() {
1189
+	function newQuery()
1190
+	{
1064 1191
 		$this->query = '';
1065 1192
 		
1066 1193
 		return TRUE;
@@ -1071,7 +1198,8 @@  discard block
 block discarded – undo
1071 1198
 	*
1072 1199
 	* @return boolean TRUE
1073 1200
 	*/
1074
-	function discardQuery() {
1201
+	function discardQuery()
1202
+	{
1075 1203
 		unset( $this->query );
1076 1204
 		
1077 1205
 		return TRUE;
@@ -1083,8 +1211,10 @@  discard block
 block discarded – undo
1083 1211
 	* @param string $data Line of SQL data or NULL to initialize a new query
1084 1212
 	* @return string SQL query string.
1085 1213
 	*/
1086
-	function buildQuery( $sql = NULL ) {
1087
-		if( !isset( $this->query ) OR empty( $sql ) ) {
1214
+	function buildQuery( $sql = NULL )
1215
+	{
1216
+		if( !isset( $this->query ) OR empty( $sql ) )
1217
+		{
1088 1218
 			return FALSE;
1089 1219
 		}
1090 1220
 		
@@ -1098,8 +1228,10 @@  discard block
 block discarded – undo
1098 1228
 	*
1099 1229
 	* @return string	SQL of added query
1100 1230
 	*/
1101
-	function addQuery() {
1102
-		if( !isset( $this->query ) ) {
1231
+	function addQuery()
1232
+	{
1233
+		if( !isset( $this->query ) )
1234
+		{
1103 1235
 			return FALSE;
1104 1236
 		}
1105 1237
 		
@@ -1116,9 +1248,12 @@  discard block
 block discarded – undo
1116 1248
 	* @param object $xmls adoSchema object
1117 1249
 	* @return array Query set
1118 1250
 	*/
1119
-	function create( &$xmls ) {
1120
-		foreach( $this->queries as $id => $query ) {
1121
-			switch( $this->prefixMethod ) {
1251
+	function create( &$xmls )
1252
+	{
1253
+		foreach( $this->queries as $id => $query )
1254
+		{
1255
+			switch( $this->prefixMethod )
1256
+			{
1122 1257
 				case 'AUTO':
1123 1258
 					// Enable auto prefix replacement
1124 1259
 					
@@ -1134,10 +1269,13 @@  discard block
 block discarded – undo
1134 1269
 				case 'MANUAL':
1135 1270
 					// If prefixKey is set and has a value then we use it to override the default constant XMLS_PREFIX.
1136 1271
 					// If prefixKey is not set, we use the default constant XMLS_PREFIX
1137
-					if( isset( $this->prefixKey ) AND( $this->prefixKey !== '' ) ) {
1272
+					if( isset( $this->prefixKey ) AND( $this->prefixKey !== '' ) )
1273
+					{
1138 1274
 						// Enable prefix override
1139 1275
 						$query = str_replace( $this->prefixKey, $xmls->objectPrefix, $query );
1140
-					} else {
1276
+					}
1277
+					else
1278
+					{
1141 1279
 						// Use default replacement
1142 1280
 						$query = str_replace( XMLS_PREFIX , $xmls->objectPrefix, $query );
1143 1281
 					}
@@ -1158,12 +1296,15 @@  discard block
 block discarded – undo
1158 1296
 	* @param string $prefix Prefix to be appended to tables, indices, etc.
1159 1297
 	* @return string Prefixed SQL query string.
1160 1298
 	*/
1161
-	function prefixQuery( $regex, $query, $prefix = NULL ) {
1162
-		if( !isset( $prefix ) ) {
1299
+	function prefixQuery( $regex, $query, $prefix = NULL )
1300
+	{
1301
+		if( !isset( $prefix ) )
1302
+		{
1163 1303
 			return $query;
1164 1304
 		}
1165 1305
 		
1166
-		if( preg_match( $regex, $query, $match ) ) {
1306
+		if( preg_match( $regex, $query, $match ) )
1307
+		{
1167 1308
 			$preamble = $match[1];
1168 1309
 			$postamble = $match[5];
1169 1310
 			$objectList = explode( ',', $match[3] );
@@ -1171,8 +1312,10 @@  discard block
 block discarded – undo
1171 1312
 			
1172 1313
 			$prefixedList = '';
1173 1314
 			
1174
-			foreach( $objectList as $object ) {
1175
-				if( $prefixedList !== '' ) {
1315
+			foreach( $objectList as $object )
1316
+			{
1317
+				if( $prefixedList !== '' )
1318
+				{
1176 1319
 					$prefixedList .= ', ';
1177 1320
 				}
1178 1321
 				
@@ -1199,7 +1342,8 @@  discard block
 block discarded – undo
1199 1342
 *
1200 1343
 * @package axmls
1201 1344
 */
1202
-class adoSchema {
1345
+class adoSchema
1346
+{
1203 1347
 	
1204 1348
 	/**
1205 1349
 	* @var array	Array containing SQL queries to generate all objects
@@ -1285,7 +1429,8 @@  discard block
 block discarded – undo
1285 1429
 	*
1286 1430
 	* @param object $db ADOdb database connection object.
1287 1431
 	*/
1288
-	function adoSchema( &$db ) {
1432
+	function adoSchema( &$db )
1433
+	{
1289 1434
 		// Initialize the environment
1290 1435
 		$this->mgq = get_magic_quotes_runtime();
1291 1436
 		set_magic_quotes_runtime(0);
@@ -1316,15 +1461,18 @@  discard block
 block discarded – undo
1316 1461
 	* @param string $method Upgrade method (ALTER|REPLACE|BEST|NONE)
1317 1462
 	* @returns string Upgrade method used
1318 1463
 	*/
1319
-	function SetUpgradeMethod( $method = '' ) {
1320
-		if( !is_string( $method ) ) {
1464
+	function SetUpgradeMethod( $method = '' )
1465
+	{
1466
+		if( !is_string( $method ) )
1467
+		{
1321 1468
 			return FALSE;
1322 1469
 		}
1323 1470
 		
1324 1471
 		$method = strtoupper( $method );
1325 1472
 		
1326 1473
 		// Handle the upgrade methods
1327
-		switch( $method ) {
1474
+		switch( $method )
1475
+		{
1328 1476
 			case 'ALTER':
1329 1477
 				$this->upgrade = $method;
1330 1478
 				break;
@@ -1358,8 +1506,10 @@  discard block
 block discarded – undo
1358 1506
 	*
1359 1507
 	* @see ParseSchema(), ExecuteSchema()
1360 1508
 	*/
1361
-	function ExecuteInline( $mode = NULL ) {
1362
-		if( is_bool( $mode ) ) {
1509
+	function ExecuteInline( $mode = NULL )
1510
+	{
1511
+		if( is_bool( $mode ) )
1512
+		{
1363 1513
 			$this->executeInline = $mode;
1364 1514
 		}
1365 1515
 		
@@ -1379,8 +1529,10 @@  discard block
 block discarded – undo
1379 1529
 	*
1380 1530
 	* @see addSQL(), ExecuteSchema()
1381 1531
 	*/
1382
-	function ContinueOnError( $mode = NULL ) {
1383
-		if( is_bool( $mode ) ) {
1532
+	function ContinueOnError( $mode = NULL )
1533
+	{
1534
+		if( is_bool( $mode ) )
1535
+		{
1384 1536
 			$this->continueOnError = $mode;
1385 1537
 		}
1386 1538
 		
@@ -1398,7 +1550,8 @@  discard block
 block discarded – undo
1398 1550
 	* @param bool $returnSchema Return schema rather than parsing.
1399 1551
 	* @return array Array of SQL queries, ready to execute
1400 1552
 	*/
1401
-	function ParseSchema( $filename, $returnSchema = FALSE ) {
1553
+	function ParseSchema( $filename, $returnSchema = FALSE )
1554
+	{
1402 1555
 		return $this->ParseSchemaString( $this->ConvertSchemaFile( $filename ), $returnSchema );
1403 1556
 	}
1404 1557
 	
@@ -1415,15 +1568,18 @@  discard block
 block discarded – undo
1415 1568
 	* @deprecated Replaced by adoSchema::ParseSchema() and adoSchema::ParseSchemaString()
1416 1569
 	* @see ParseSchema(), ParseSchemaString()
1417 1570
 	*/
1418
-	function ParseSchemaFile( $filename, $returnSchema = FALSE ) {
1571
+	function ParseSchemaFile( $filename, $returnSchema = FALSE )
1572
+	{
1419 1573
 		// Open the file
1420
-		if( !($fp = fopen( $filename, 'r' )) ) {
1574
+		if( !($fp = fopen( $filename, 'r' )) )
1575
+		{
1421 1576
 			// die( 'Unable to open file' );
1422 1577
 			return FALSE;
1423 1578
 		}
1424 1579
 		
1425 1580
 		// do version detection here
1426
-		if( $this->SchemaFileVersion( $filename ) != $this->schemaVersion ) {
1581
+		if( $this->SchemaFileVersion( $filename ) != $this->schemaVersion )
1582
+		{
1427 1583
 			return FALSE;
1428 1584
 		}
1429 1585
 		
@@ -1437,8 +1593,10 @@  discard block
 block discarded – undo
1437 1593
 		$xmlParser = $this->create_parser();
1438 1594
 		
1439 1595
 		// Process the file
1440
-		while( $data = fread( $fp, 4096 ) ) {
1441
-			if( !xml_parse( $xmlParser, $data, feof( $fp ) ) ) {
1596
+		while( $data = fread( $fp, 4096 ) )
1597
+		{
1598
+			if( !xml_parse( $xmlParser, $data, feof( $fp ) ) )
1599
+			{
1442 1600
 				die( sprintf(
1443 1601
 					"XML error: %s at line %d",
1444 1602
 					xml_error_string( xml_get_error_code( $xmlParser) ),
@@ -1463,13 +1621,16 @@  discard block
 block discarded – undo
1463 1621
 	* @param bool $returnSchema Return schema rather than parsing.
1464 1622
 	* @return array Array of SQL queries, ready to execute.
1465 1623
 	*/
1466
-	function ParseSchemaString( $xmlstring, $returnSchema = FALSE ) {
1467
-		if( !is_string( $xmlstring ) OR empty( $xmlstring ) ) {
1624
+	function ParseSchemaString( $xmlstring, $returnSchema = FALSE )
1625
+	{
1626
+		if( !is_string( $xmlstring ) OR empty( $xmlstring ) )
1627
+		{
1468 1628
 			return FALSE;
1469 1629
 		}
1470 1630
 		
1471 1631
 		// do version detection here
1472
-		if( $this->SchemaStringVersion( $xmlstring ) != $this->schemaVersion ) {
1632
+		if( $this->SchemaStringVersion( $xmlstring ) != $this->schemaVersion )
1633
+		{
1473 1634
 			return FALSE;
1474 1635
 		}
1475 1636
 		
@@ -1482,7 +1643,8 @@  discard block
 block discarded – undo
1482 1643
 		
1483 1644
 		$xmlParser = $this->create_parser();
1484 1645
 		
1485
-		if( !xml_parse( $xmlParser, $xmlstring, TRUE ) ) {
1646
+		if( !xml_parse( $xmlParser, $xmlstring, TRUE ) )
1647
+		{
1486 1648
 			die( sprintf(
1487 1649
 				"XML error: %s at line %d",
1488 1650
 				xml_error_string( xml_get_error_code( $xmlParser) ),
@@ -1506,7 +1668,8 @@  discard block
 block discarded – undo
1506 1668
 	* @param bool $returnSchema Return schema rather than parsing.
1507 1669
 	* @return array Array of SQL queries, ready to execute
1508 1670
 	*/
1509
-	function RemoveSchema( $filename, $returnSchema = FALSE ) {
1671
+	function RemoveSchema( $filename, $returnSchema = FALSE )
1672
+	{
1510 1673
 		return $this->RemoveSchemaString( $this->ConvertSchemaFile( $filename ), $returnSchema );
1511 1674
 	}
1512 1675
 	
@@ -1521,10 +1684,12 @@  discard block
 block discarded – undo
1521 1684
 	* @param bool $returnSchema Return schema rather than parsing.
1522 1685
 	* @return array Array of SQL queries, ready to execute.
1523 1686
 	*/
1524
-	function RemoveSchemaString( $schema, $returnSchema = FALSE ) {
1687
+	function RemoveSchemaString( $schema, $returnSchema = FALSE )
1688
+	{
1525 1689
 		
1526 1690
 		// grab current version
1527
-		if( !( $version = $this->SchemaStringVersion( $schema ) ) ) {
1691
+		if( !( $version = $this->SchemaStringVersion( $schema ) ) )
1692
+		{
1528 1693
 			return FALSE;
1529 1694
 		}
1530 1695
 		
@@ -1544,18 +1709,24 @@  discard block
 block discarded – undo
1544 1709
 	* @param boolean $continueOnErr Continue to apply the schema even if an error occurs.
1545 1710
 	* @returns integer 0 if failure, 1 if errors, 2 if successful.
1546 1711
 	*/
1547
-	function ExecuteSchema( $sqlArray = NULL, $continueOnErr =  NULL ) {
1548
-		if( !is_bool( $continueOnErr ) ) {
1712
+	function ExecuteSchema( $sqlArray = NULL, $continueOnErr =  NULL )
1713
+	{
1714
+		if( !is_bool( $continueOnErr ) )
1715
+		{
1549 1716
 			$continueOnErr = $this->ContinueOnError();
1550 1717
 		}
1551 1718
 		
1552
-		if( !isset( $sqlArray ) ) {
1719
+		if( !isset( $sqlArray ) )
1720
+		{
1553 1721
 			$sqlArray = $this->sqlArray;
1554 1722
 		}
1555 1723
 		
1556
-		if( !is_array( $sqlArray ) ) {
1724
+		if( !is_array( $sqlArray ) )
1725
+		{
1557 1726
 			$this->success = 0;
1558
-		} else {
1727
+		}
1728
+		else
1729
+		{
1559 1730
 			$this->success = $this->dict->ExecuteSQLArray( $sqlArray, $continueOnErr );
1560 1731
 		}
1561 1732
 		
@@ -1571,7 +1742,8 @@  discard block
 block discarded – undo
1571 1742
 	* @param string $format Format: HTML, TEXT, or NONE (PHP array)
1572 1743
 	* @return array Array of SQL statements or FALSE if an error occurs
1573 1744
 	*/
1574
-	function PrintSQL( $format = 'NONE' ) {
1745
+	function PrintSQL( $format = 'NONE' )
1746
+	{
1575 1747
 		return $this->getSQL( $format, $sqlArray );
1576 1748
 	}
1577 1749
 	
@@ -1584,18 +1756,22 @@  discard block
 block discarded – undo
1584 1756
 	* @param string $filename Path and name where the file should be saved.
1585 1757
 	* @return boolean TRUE if save is successful, else FALSE. 
1586 1758
 	*/
1587
-	function SaveSQL( $filename = './schema.sql' ) {
1759
+	function SaveSQL( $filename = './schema.sql' )
1760
+	{
1588 1761
 		
1589
-		if( !isset( $sqlArray ) ) {
1762
+		if( !isset( $sqlArray ) )
1763
+		{
1590 1764
 			$sqlArray = $this->sqlArray;
1591 1765
 		}
1592
-		if( !isset( $sqlArray ) ) {
1766
+		if( !isset( $sqlArray ) )
1767
+		{
1593 1768
 			return FALSE;
1594 1769
 		}
1595 1770
 		
1596 1771
 		$fp = fopen( $filename, "w" );
1597 1772
 		
1598
-		foreach( $sqlArray as $key => $query ) {
1773
+		foreach( $sqlArray as $key => $query )
1774
+		{
1599 1775
 			fwrite( $fp, $query . ";\n" );
1600 1776
 		}
1601 1777
 		fclose( $fp );
@@ -1625,14 +1801,17 @@  discard block
 block discarded – undo
1625 1801
 	*
1626 1802
 	* @access private
1627 1803
 	*/
1628
-	function _tag_open( &$parser, $tag, $attributes ) {
1629
-		switch( strtoupper( $tag ) ) {
1804
+	function _tag_open( &$parser, $tag, $attributes )
1805
+	{
1806
+		switch( strtoupper( $tag ) )
1807
+		{
1630 1808
 			case 'TABLE':
1631 1809
 				$this->obj = new dbTable( $this, $attributes );
1632 1810
 				xml_set_object( $parser, $this->obj );
1633 1811
 				break;
1634 1812
 			case 'SQL':
1635
-				if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) {
1813
+				if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) )
1814
+				{
1636 1815
 					$this->obj = new dbQuerySet( $this, $attributes );
1637 1816
 					xml_set_object( $parser, $this->obj );
1638 1817
 				}
@@ -1648,7 +1827,8 @@  discard block
 block discarded – undo
1648 1827
 	*
1649 1828
 	* @access private
1650 1829
 	*/
1651
-	function _tag_cdata( &$parser, $cdata ) {
1830
+	function _tag_cdata( &$parser, $cdata )
1831
+	{
1652 1832
 	}
1653 1833
 	
1654 1834
 	/**
@@ -1657,7 +1837,8 @@  discard block
 block discarded – undo
1657 1837
 	* @access private
1658 1838
 	* @internal
1659 1839
 	*/
1660
-	function _tag_close( &$parser, $tag ) {
1840
+	function _tag_close( &$parser, $tag )
1841
+	{
1661 1842
 		
1662 1843
 	}
1663 1844
 	
@@ -1677,24 +1858,31 @@  discard block
 block discarded – undo
1677 1858
 	* @param string $newFile File name of (converted) output file.
1678 1859
 	* @return string Converted XML schema or FALSE if an error occurs.
1679 1860
 	*/
1680
-	function ConvertSchemaString( $schema, $newVersion = NULL, $newFile = NULL ) {
1861
+	function ConvertSchemaString( $schema, $newVersion = NULL, $newFile = NULL )
1862
+	{
1681 1863
 		
1682 1864
 		// grab current version
1683
-		if( !( $version = $this->SchemaStringVersion( $schema ) ) ) {
1865
+		if( !( $version = $this->SchemaStringVersion( $schema ) ) )
1866
+		{
1684 1867
 			return FALSE;
1685 1868
 		}
1686 1869
 		
1687
-		if( !isset ($newVersion) ) {
1870
+		if( !isset ($newVersion) )
1871
+		{
1688 1872
 			$newVersion = $this->schemaVersion;
1689 1873
 		}
1690 1874
 		
1691
-		if( $version == $newVersion ) {
1875
+		if( $version == $newVersion )
1876
+		{
1692 1877
 			$result = $schema;
1693
-		} else {
1878
+		}
1879
+		else
1880
+		{
1694 1881
 			$result = $this->TransformSchema( $schema, 'convert-' . $version . '-' . $newVersion);
1695 1882
 		}
1696 1883
 		
1697
-		if( is_string( $result ) AND is_string( $newFile ) AND ( $fp = fopen( $newFile, 'w' ) ) ) {
1884
+		if( is_string( $result ) AND is_string( $newFile ) AND ( $fp = fopen( $newFile, 'w' ) ) )
1885
+		{
1698 1886
 			fwrite( $fp, $result );
1699 1887
 			fclose( $fp );
1700 1888
 		}
@@ -1718,29 +1906,37 @@  discard block
 block discarded – undo
1718 1906
 	* @param string $newFile File name of (converted) output file.
1719 1907
 	* @return string Converted XML schema or FALSE if an error occurs.
1720 1908
 	*/
1721
-	function ConvertSchemaFile( $filename, $newVersion = NULL, $newFile = NULL ) {
1909
+	function ConvertSchemaFile( $filename, $newVersion = NULL, $newFile = NULL )
1910
+	{
1722 1911
 		
1723 1912
 		// grab current version
1724
-		if( !( $version = $this->SchemaFileVersion( $filename ) ) ) {
1913
+		if( !( $version = $this->SchemaFileVersion( $filename ) ) )
1914
+		{
1725 1915
 			return FALSE;
1726 1916
 		}
1727 1917
 		
1728
-		if( !isset ($newVersion) ) {
1918
+		if( !isset ($newVersion) )
1919
+		{
1729 1920
 			$newVersion = $this->schemaVersion;
1730 1921
 		}
1731 1922
 		
1732
-		if( $version == $newVersion ) {
1923
+		if( $version == $newVersion )
1924
+		{
1733 1925
 			$result = file_get_contents( $filename );
1734 1926
 			
1735 1927
 			// remove unicode BOM if present
1736
-			if( substr( $result, 0, 3 ) == sprintf( '%c%c%c', 239, 187, 191 ) ) {
1928
+			if( substr( $result, 0, 3 ) == sprintf( '%c%c%c', 239, 187, 191 ) )
1929
+			{
1737 1930
 				$result = substr( $result, 3 );
1738 1931
 			}
1739
-		} else {
1932
+		}
1933
+		else
1934
+		{
1740 1935
 			$result = $this->TransformSchema( $filename, 'convert-' . $version . '-' . $newVersion, 'file' );
1741 1936
 		}
1742 1937
 		
1743
-		if( is_string( $result ) AND is_string( $newFile ) AND ( $fp = fopen( $newFile, 'w' ) ) ) {
1938
+		if( is_string( $result ) AND is_string( $newFile ) AND ( $fp = fopen( $newFile, 'w' ) ) )
1939
+		{
1744 1940
 			fwrite( $fp, $result );
1745 1941
 			fclose( $fp );
1746 1942
 		}
@@ -1751,21 +1947,24 @@  discard block
 block discarded – undo
1751 1947
 	function TransformSchema( $schema, $xsl, $schematype='string' )
1752 1948
 	{
1753 1949
 		// Fail if XSLT extension is not available
1754
-		if( ! function_exists( 'xslt_create' ) ) {
1950
+		if( ! function_exists( 'xslt_create' ) )
1951
+		{
1755 1952
 			return FALSE;
1756 1953
 		}
1757 1954
 		
1758 1955
 		$xsl_file = dirname( __FILE__ ) . '/xsl/' . $xsl . '.xsl';
1759 1956
 		
1760 1957
 		// look for xsl
1761
-		if( !is_readable( $xsl_file ) ) {
1958
+		if( !is_readable( $xsl_file ) )
1959
+		{
1762 1960
 			return FALSE;
1763 1961
 		}
1764 1962
 		
1765 1963
 		switch( $schematype )
1766 1964
 		{
1767 1965
 			case 'file':
1768
-				if( !is_readable( $schema ) ) {
1966
+				if( !is_readable( $schema ) )
1967
+				{
1769 1968
 					return FALSE;
1770 1969
 				}
1771 1970
 				
@@ -1773,7 +1972,8 @@  discard block
 block discarded – undo
1773 1972
 				break;
1774 1973
 			case 'string':
1775 1974
 			default:
1776
-				if( !is_string( $schema ) ) {
1975
+				if( !is_string( $schema ) )
1976
+				{
1777 1977
 					return FALSE;
1778 1978
 				}
1779 1979
 		}
@@ -1807,8 +2007,10 @@  discard block
 block discarded – undo
1807 2007
 	*
1808 2008
 	* @access private
1809 2009
 	*/
1810
-	function xslt_error_handler( $parser, $errno, $level, $fields ) {
1811
-		if( is_array( $fields ) ) {
2010
+	function xslt_error_handler( $parser, $errno, $level, $fields )
2011
+	{
2012
+		if( is_array( $fields ) )
2013
+		{
1812 2014
 			$msg = array(
1813 2015
 				'Message Type' => ucfirst( $fields['msgtype'] ),
1814 2016
 				'Message Code' => $fields['code'],
@@ -1817,7 +2019,8 @@  discard block
 block discarded – undo
1817 2019
 				'Level' => $level
1818 2020
 			);
1819 2021
 			
1820
-			switch( $fields['URI'] ) {
2022
+			switch( $fields['URI'] )
2023
+			{
1821 2024
 				case 'arg:/_xml':
1822 2025
 					$msg['Input'] = 'XML';
1823 2026
 					break;
@@ -1829,7 +2032,9 @@  discard block
 block discarded – undo
1829 2032
 			}
1830 2033
 			
1831 2034
 			$msg['Line'] = $fields['line'];
1832
-		} else {
2035
+		}
2036
+		else
2037
+		{
1833 2038
 			$msg = array(
1834 2039
 				'Message Type' => 'Error',
1835 2040
 				'Error Number' => $errno,
@@ -1841,7 +2046,8 @@  discard block
 block discarded – undo
1841 2046
 		$error_details = $msg['Message Type'] . ' in XSLT Transformation' . "\n"
1842 2047
 					   . '<table>' . "\n";
1843 2048
 		
1844
-		foreach( $msg as $label => $details ) {
2049
+		foreach( $msg as $label => $details )
2050
+		{
1845 2051
 			$error_details .= '<tr><td><b>' . $label . ': </b></td><td>' . htmlentities( $details ) . '</td></tr>' . "\n";
1846 2052
 		}
1847 2053
 		
@@ -1859,16 +2065,20 @@  discard block
 block discarded – undo
1859 2065
 	* @param string $filename AXMLS schema file
1860 2066
 	* @return string Schema version number or FALSE on error
1861 2067
 	*/
1862
-	function SchemaFileVersion( $filename ) {
2068
+	function SchemaFileVersion( $filename )
2069
+	{
1863 2070
 		// Open the file
1864
-		if( !($fp = fopen( $filename, 'r' )) ) {
2071
+		if( !($fp = fopen( $filename, 'r' )) )
2072
+		{
1865 2073
 			// die( 'Unable to open file' );
1866 2074
 			return FALSE;
1867 2075
 		}
1868 2076
 		
1869 2077
 		// Process the file
1870
-		while( $data = fread( $fp, 4096 ) ) {
1871
-			if( preg_match( $this->versionRegex, $data, $matches ) ) {
2078
+		while( $data = fread( $fp, 4096 ) )
2079
+		{
2080
+			if( preg_match( $this->versionRegex, $data, $matches ) )
2081
+			{
1872 2082
 				return !empty( $matches[2] ) ? $matches[2] : XMLS_DEFAULT_SCHEMA_VERSION;
1873 2083
 			}
1874 2084
 		}
@@ -1885,12 +2095,15 @@  discard block
 block discarded – undo
1885 2095
 	* @param string $xmlstring XML schema string
1886 2096
 	* @return string Schema version number or FALSE on error
1887 2097
 	*/
1888
-	function SchemaStringVersion( $xmlstring ) {
1889
-		if( !is_string( $xmlstring ) OR empty( $xmlstring ) ) {
2098
+	function SchemaStringVersion( $xmlstring )
2099
+	{
2100
+		if( !is_string( $xmlstring ) OR empty( $xmlstring ) )
2101
+		{
1890 2102
 			return FALSE;
1891 2103
 		}
1892 2104
 		
1893
-		if( preg_match( $this->versionRegex, $xmlstring, $matches ) ) {
2105
+		if( preg_match( $this->versionRegex, $xmlstring, $matches ) )
2106
+		{
1894 2107
 			return !empty( $matches[2] ) ? $matches[2] : XMLS_DEFAULT_SCHEMA_VERSION;
1895 2108
 		}
1896 2109
 		
@@ -1907,14 +2120,17 @@  discard block
 block discarded – undo
1907 2120
 	* @param boolean $data Include data in schema dump
1908 2121
 	* @return string Generated XML schema
1909 2122
 	*/
1910
-	function ExtractSchema( $data = FALSE ) {
2123
+	function ExtractSchema( $data = FALSE )
2124
+	{
1911 2125
 		$old_mode = $this->db->SetFetchMode( ADODB_FETCH_NUM );
1912 2126
 		
1913 2127
 		$schema = '<?xml version="1.0"?>' . "\n"
1914 2128
 				. '<schema version="' . $this->schemaVersion . '">' . "\n";
1915 2129
 		
1916
-		if( is_array( $tables = $this->db->MetaTables( 'TABLES' ) ) ) {
1917
-			foreach( $tables as $table ) {
2130
+		if( is_array( $tables = $this->db->MetaTables( 'TABLES' ) ) )
2131
+		{
2132
+			foreach( $tables as $table )
2133
+			{
1918 2134
 				$schema .= '	<table name="' . $table . '">' . "\n";
1919 2135
 				
1920 2136
 				// grab details from database
@@ -1922,26 +2138,34 @@  discard block
 block discarded – undo
1922 2138
 				$fields = $this->db->MetaColumns( $table );
1923 2139
 				$indexes = $this->db->MetaIndexes( $table );
1924 2140
 				
1925
-				if( is_array( $fields ) ) {
1926
-					foreach( $fields as $details ) {
2141
+				if( is_array( $fields ) )
2142
+				{
2143
+					foreach( $fields as $details )
2144
+					{
1927 2145
 						$extra = '';
1928 2146
 						$content = array();
1929 2147
 						
1930
-						if( $details->max_length > 0 ) {
2148
+						if( $details->max_length > 0 )
2149
+						{
1931 2150
 							$extra .= ' size="' . $details->max_length . '"';
1932 2151
 						}
1933 2152
 						
1934
-						if( $details->primary_key ) {
2153
+						if( $details->primary_key )
2154
+						{
1935 2155
 							$content[] = '<KEY/>';
1936
-						} elseif( $details->not_null ) {
2156
+						}
2157
+						elseif( $details->not_null )
2158
+						{
1937 2159
 							$content[] = '<NOTNULL/>';
1938 2160
 						}
1939 2161
 						
1940
-						if( $details->has_default ) {
2162
+						if( $details->has_default )
2163
+						{
1941 2164
 							$content[] = '<DEFAULT value="' . $details->default_value . '"/>';
1942 2165
 						}
1943 2166
 						
1944
-						if( $details->auto_increment ) {
2167
+						if( $details->auto_increment )
2168
+						{
1945 2169
 							$content[] = '<AUTOINCREMENT/>';
1946 2170
 						}
1947 2171
 						
@@ -1952,7 +2176,8 @@  discard block
 block discarded – undo
1952 2176
 						
1953 2177
 						$schema .= '		<field name="' . $details->name . '" type="' . $type . '"' . $extra . '>';
1954 2178
 						
1955
-						if( !empty( $content ) ) {
2179
+						if( !empty( $content ) )
2180
+						{
1956 2181
 							$schema .= "\n			" . implode( "\n			", $content ) . "\n		";
1957 2182
 						}
1958 2183
 						
@@ -1960,15 +2185,19 @@  discard block
 block discarded – undo
1960 2185
 					}
1961 2186
 				}
1962 2187
 				
1963
-				if( is_array( $indexes ) ) {
1964
-					foreach( $indexes as $index => $details ) {
2188
+				if( is_array( $indexes ) )
2189
+				{
2190
+					foreach( $indexes as $index => $details )
2191
+					{
1965 2192
 						$schema .= '		<index name="' . $index . '">' . "\n";
1966 2193
 						
1967
-						if( $details['unique'] ) {
2194
+						if( $details['unique'] )
2195
+						{
1968 2196
 							$schema .= '			<UNIQUE/>' . "\n";
1969 2197
 						}
1970 2198
 						
1971
-						foreach( $details['columns'] as $column ) {
2199
+						foreach( $details['columns'] as $column )
2200
+						{
1972 2201
 							$schema .= '			<col>' . $column . '</col>' . "\n";
1973 2202
 						}
1974 2203
 						
@@ -1976,14 +2205,18 @@  discard block
 block discarded – undo
1976 2205
 					}
1977 2206
 				}
1978 2207
 				
1979
-				if( $data ) {
2208
+				if( $data )
2209
+				{
1980 2210
 					$rs = $this->db->Execute( 'SELECT * FROM ' . $table );
1981 2211
 					
1982
-					if( is_object( $rs ) ) {
2212
+					if( is_object( $rs ) )
2213
+					{
1983 2214
 						$schema .= '		<data>' . "\n";
1984 2215
 						
1985
-						while( $row = $rs->FetchRow() ) {
1986
-							foreach( $row as $key => $val ) {
2216
+						while( $row = $rs->FetchRow() )
2217
+						{
2218
+							foreach( $row as $key => $val )
2219
+							{
1987 2220
 								$row[$key] = htmlentities($val);
1988 2221
 							}
1989 2222
 							
@@ -2014,8 +2247,10 @@  discard block
 block discarded – undo
2014 2247
 	* @param boolean $underscore If TRUE, automatically append an underscore character to the prefix.
2015 2248
 	* @return boolean TRUE if successful, else FALSE
2016 2249
 	*/
2017
-	function SetPrefix( $prefix = '', $underscore = TRUE ) {
2018
-		switch( TRUE ) {
2250
+	function SetPrefix( $prefix = '', $underscore = TRUE )
2251
+	{
2252
+		switch( TRUE )
2253
+		{
2019 2254
 			// clear prefix
2020 2255
 			case empty( $prefix ):
2021 2256
 				logMsg( 'Cleared prefix' );
@@ -2029,7 +2264,8 @@  discard block
 block discarded – undo
2029 2264
 				return FALSE;
2030 2265
 		}
2031 2266
 		
2032
-		if( $underscore AND substr( $prefix, -1 ) != '_' ) {
2267
+		if( $underscore AND substr( $prefix, -1 ) != '_' )
2268
+		{
2033 2269
 			$prefix .= '_';
2034 2270
 		}
2035 2271
 		
@@ -2047,9 +2283,11 @@  discard block
 block discarded – undo
2047 2283
 	*
2048 2284
 	* @access private
2049 2285
 	*/
2050
-	function prefix( $name = '' ) {
2286
+	function prefix( $name = '' )
2287
+	{
2051 2288
 		// if prefix is set
2052
-		if( !empty( $this->objectPrefix ) ) {
2289
+		if( !empty( $this->objectPrefix ) )
2290
+		{
2053 2291
 			// Prepend the object prefix to the table name
2054 2292
 			// prepend after quote if used
2055 2293
 			return preg_replace( '/^(`?)(.+)$/', '$1' . $this->objectPrefix . '$2', $name );
@@ -2067,13 +2305,17 @@  discard block
 block discarded – undo
2067 2305
 	*
2068 2306
 	* @access private
2069 2307
 	*/
2070
-	function supportedPlatform( $platform = NULL ) {
2308
+	function supportedPlatform( $platform = NULL )
2309
+	{
2071 2310
 		$regex = '/^(\w*\|)*' . $this->db->databaseType . '(\|\w*)*$/';
2072 2311
 		
2073
-		if( !isset( $platform ) OR preg_match( $regex, $platform ) ) {
2312
+		if( !isset( $platform ) OR preg_match( $regex, $platform ) )
2313
+		{
2074 2314
 			logMsg( "Platform $platform is supported" );
2075 2315
 			return TRUE;
2076
-		} else {
2316
+		}
2317
+		else
2318
+		{
2077 2319
 			logMsg( "Platform $platform is NOT supported" );
2078 2320
 			return FALSE;
2079 2321
 		}
@@ -2084,7 +2326,8 @@  discard block
 block discarded – undo
2084 2326
 	*
2085 2327
 	* @access private
2086 2328
 	*/
2087
-	function clearSQL() {
2329
+	function clearSQL()
2330
+	{
2088 2331
 		$this->sqlArray = array();
2089 2332
 	}
2090 2333
 	
@@ -2096,27 +2339,34 @@  discard block
 block discarded – undo
2096 2339
 	*
2097 2340
 	* @access private
2098 2341
 	*/	
2099
-	function addSQL( $sql = NULL ) {
2100
-		if( is_array( $sql ) ) {
2101
-			foreach( $sql as $line ) {
2342
+	function addSQL( $sql = NULL )
2343
+	{
2344
+		if( is_array( $sql ) )
2345
+		{
2346
+			foreach( $sql as $line )
2347
+			{
2102 2348
 				$this->addSQL( $line );
2103 2349
 			}
2104 2350
 			
2105 2351
 			return TRUE;
2106 2352
 		}
2107 2353
 		
2108
-		if( is_string( $sql ) ) {
2354
+		if( is_string( $sql ) )
2355
+		{
2109 2356
 			$this->sqlArray[] = $sql;
2110 2357
 			
2111 2358
 			// if executeInline is enabled, and either no errors have occurred or continueOnError is enabled, execute SQL.
2112
-			if( $this->ExecuteInline() && ( $this->success == 2 || $this->ContinueOnError() ) ) {
2359
+			if( $this->ExecuteInline() && ( $this->success == 2 || $this->ContinueOnError() ) )
2360
+			{
2113 2361
 				$saved = $this->db->debug;
2114 2362
 				$this->db->debug = $this->debug;
2115 2363
 				$ok = $this->db->Execute( $sql );
2116 2364
 				$this->db->debug = $saved;
2117 2365
 				
2118
-				if( !$ok ) {
2119
-					if( $this->debug ) {
2366
+				if( !$ok )
2367
+				{
2368
+					if( $this->debug )
2369
+					{
2120 2370
 						ADOConnection::outp( $this->db->ErrorMsg() );
2121 2371
 					}
2122 2372
 					
@@ -2138,16 +2388,20 @@  discard block
 block discarded – undo
2138 2388
 	*	
2139 2389
 	* @access private
2140 2390
 	*/
2141
-	function getSQL( $format = NULL, $sqlArray = NULL ) {
2142
-		if( !is_array( $sqlArray ) ) {
2391
+	function getSQL( $format = NULL, $sqlArray = NULL )
2392
+	{
2393
+		if( !is_array( $sqlArray ) )
2394
+		{
2143 2395
 			$sqlArray = $this->sqlArray;
2144 2396
 		}
2145 2397
 		
2146
-		if( !is_array( $sqlArray ) ) {
2398
+		if( !is_array( $sqlArray ) )
2399
+		{
2147 2400
 			return FALSE;
2148 2401
 		}
2149 2402
 		
2150
-		switch( strtolower( $format ) ) {
2403
+		switch( strtolower( $format ) )
2404
+		{
2151 2405
 			case 'string':
2152 2406
 			case 'text':
2153 2407
 				return !empty( $sqlArray ) ? implode( ";\n\n", $sqlArray ) . ';' : '';
@@ -2164,7 +2418,8 @@  discard block
 block discarded – undo
2164 2418
 	* Call this method to clean up after an adoSchema object that is no longer in use.
2165 2419
 	* @deprecated adoSchema now cleans up automatically.
2166 2420
 	*/
2167
-	function Destroy() {
2421
+	function Destroy()
2422
+	{
2168 2423
 		set_magic_quotes_runtime( $this->mgq );
2169 2424
 		unset( $this );
2170 2425
 	}
@@ -2175,15 +2430,19 @@  discard block
 block discarded – undo
2175 2430
 *
2176 2431
 * @access private
2177 2432
 */
2178
-function logMsg( $msg, $title = NULL, $force = FALSE ) {
2179
-	if( XMLS_DEBUG or $force ) {
2433
+function logMsg( $msg, $title = NULL, $force = FALSE )
2434
+{
2435
+	if( XMLS_DEBUG or $force )
2436
+	{
2180 2437
 		echo '<pre>';
2181 2438
 		
2182
-		if( isset( $title ) ) {
2439
+		if( isset( $title ) )
2440
+		{
2183 2441
 			echo '<h3>' . htmlentities( $title ) . '</h3>';
2184 2442
 		}
2185 2443
 		
2186
-		if( is_object( $this ) ) {
2444
+		if( is_object( $this ) )
2445
+		{
2187 2446
 			echo '[' . get_class( $this ) . '] ';
2188 2447
 		}
2189 2448
 		
Please login to merge, or discard this patch.
Upper-Lower-Casing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -250,12 +250,12 @@  discard block
 block discarded – undo
250 250
 		
251 251
 		switch( $this->currentElement ) {
252 252
 			case 'INDEX':
253
-				if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) {
253
+				if( !isset( $attributes['PLATFORM'] ) or $this->supportedPlatform( $attributes['PLATFORM'] ) ) {
254 254
 					xml_set_object( $parser, $this->addIndex( $attributes ) );
255 255
 				}
256 256
 				break;
257 257
 			case 'DATA':
258
-				if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) {
258
+				if( !isset( $attributes['PLATFORM'] ) or $this->supportedPlatform( $attributes['PLATFORM'] ) ) {
259 259
 					xml_set_object( $parser, $this->addData( $attributes ) );
260 260
 				}
261 261
 				break;
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
 			logMsg( end( $sql ), 'Generated CreateTableSQL' );
538 538
 		} else {
539 539
 			// Upgrade an existing table
540
-			logMsg( "Upgrading {$this->name} using '{$xmls->upgrade}'" );
540
+			logMsg( "upgrading {$this->name} using '{$xmls->upgrade}'" );
541 541
 			switch( $xmls->upgrade ) {
542 542
 				// Use ChangeTableSQL
543 543
 				case 'ALTER':
@@ -1007,7 +1007,7 @@  discard block
 block discarded – undo
1007 1007
 				// Create a new query in a SQL queryset.
1008 1008
 				// Ignore this query set if a platform is specified and it's different than the 
1009 1009
 				// current connection platform.
1010
-				if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) {
1010
+				if( !isset( $attributes['PLATFORM'] ) or $this->supportedPlatform( $attributes['PLATFORM'] ) ) {
1011 1011
 					$this->newQuery();
1012 1012
 				} else {
1013 1013
 					$this->discardQuery();
@@ -1084,7 +1084,7 @@  discard block
 block discarded – undo
1084 1084
 	* @return string SQL query string.
1085 1085
 	*/
1086 1086
 	function buildQuery( $sql = NULL ) {
1087
-		if( !isset( $this->query ) OR empty( $sql ) ) {
1087
+		if( !isset( $this->query ) or empty( $sql ) ) {
1088 1088
 			return FALSE;
1089 1089
 		}
1090 1090
 		
@@ -1134,7 +1134,7 @@  discard block
 block discarded – undo
1134 1134
 				case 'MANUAL':
1135 1135
 					// If prefixKey is set and has a value then we use it to override the default constant XMLS_PREFIX.
1136 1136
 					// If prefixKey is not set, we use the default constant XMLS_PREFIX
1137
-					if( isset( $this->prefixKey ) AND( $this->prefixKey !== '' ) ) {
1137
+					if( isset( $this->prefixKey ) and( $this->prefixKey !== '' ) ) {
1138 1138
 						// Enable prefix override
1139 1139
 						$query = str_replace( $this->prefixKey, $xmls->objectPrefix, $query );
1140 1140
 					} else {
@@ -1464,7 +1464,7 @@  discard block
 block discarded – undo
1464 1464
 	* @return array Array of SQL queries, ready to execute.
1465 1465
 	*/
1466 1466
 	function ParseSchemaString( $xmlstring, $returnSchema = FALSE ) {
1467
-		if( !is_string( $xmlstring ) OR empty( $xmlstring ) ) {
1467
+		if( !is_string( $xmlstring ) or empty( $xmlstring ) ) {
1468 1468
 			return FALSE;
1469 1469
 		}
1470 1470
 		
@@ -1632,7 +1632,7 @@  discard block
 block discarded – undo
1632 1632
 				xml_set_object( $parser, $this->obj );
1633 1633
 				break;
1634 1634
 			case 'SQL':
1635
-				if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) {
1635
+				if( !isset( $attributes['PLATFORM'] ) or $this->supportedPlatform( $attributes['PLATFORM'] ) ) {
1636 1636
 					$this->obj = new dbQuerySet( $this, $attributes );
1637 1637
 					xml_set_object( $parser, $this->obj );
1638 1638
 				}
@@ -1694,7 +1694,7 @@  discard block
 block discarded – undo
1694 1694
 			$result = $this->TransformSchema( $schema, 'convert-' . $version . '-' . $newVersion);
1695 1695
 		}
1696 1696
 		
1697
-		if( is_string( $result ) AND is_string( $newFile ) AND ( $fp = fopen( $newFile, 'w' ) ) ) {
1697
+		if( is_string( $result ) and is_string( $newFile ) and ( $fp = fopen( $newFile, 'w' ) ) ) {
1698 1698
 			fwrite( $fp, $result );
1699 1699
 			fclose( $fp );
1700 1700
 		}
@@ -1740,7 +1740,7 @@  discard block
 block discarded – undo
1740 1740
 			$result = $this->TransformSchema( $filename, 'convert-' . $version . '-' . $newVersion, 'file' );
1741 1741
 		}
1742 1742
 		
1743
-		if( is_string( $result ) AND is_string( $newFile ) AND ( $fp = fopen( $newFile, 'w' ) ) ) {
1743
+		if( is_string( $result ) and is_string( $newFile ) and ( $fp = fopen( $newFile, 'w' ) ) ) {
1744 1744
 			fwrite( $fp, $result );
1745 1745
 			fclose( $fp );
1746 1746
 		}
@@ -1886,7 +1886,7 @@  discard block
 block discarded – undo
1886 1886
 	* @return string Schema version number or FALSE on error
1887 1887
 	*/
1888 1888
 	function SchemaStringVersion( $xmlstring ) {
1889
-		if( !is_string( $xmlstring ) OR empty( $xmlstring ) ) {
1889
+		if( !is_string( $xmlstring ) or empty( $xmlstring ) ) {
1890 1890
 			return FALSE;
1891 1891
 		}
1892 1892
 		
@@ -2029,7 +2029,7 @@  discard block
 block discarded – undo
2029 2029
 				return FALSE;
2030 2030
 		}
2031 2031
 		
2032
-		if( $underscore AND substr( $prefix, -1 ) != '_' ) {
2032
+		if( $underscore and substr( $prefix, -1 ) != '_' ) {
2033 2033
 			$prefix .= '_';
2034 2034
 		}
2035 2035
 		
@@ -2070,11 +2070,11 @@  discard block
 block discarded – undo
2070 2070
 	function supportedPlatform( $platform = NULL ) {
2071 2071
 		$regex = '/^(\w*\|)*' . $this->db->databaseType . '(\|\w*)*$/';
2072 2072
 		
2073
-		if( !isset( $platform ) OR preg_match( $regex, $platform ) ) {
2074
-			logMsg( "Platform $platform is supported" );
2073
+		if( !isset( $platform ) or preg_match( $regex, $platform ) ) {
2074
+			logMsg( "platform $platform is supported" );
2075 2075
 			return TRUE;
2076 2076
 		} else {
2077
-			logMsg( "Platform $platform is NOT supported" );
2077
+			logMsg( "platform $platform is NOT supported" );
2078 2078
 			return FALSE;
2079 2079
 		}
2080 2080
 	}
Please login to merge, or discard this patch.
phpgwapi/inc/adodb/adodb.inc.php 6 patches
Doc Comments   +41 added lines, -25 removed lines patch added patch discarded remove patch
@@ -129,6 +129,8 @@  discard block
 block discarded – undo
129 129
 
130 130
 	/**
131 131
 	 	Accepts $src and $dest arrays, replacing string $data
132
+	* @param string[] $src
133
+	* @param string[] $dest
132 134
 	*/
133 135
 	function ADODB_str_replace($src, $dest, $data)
134 136
 	{
@@ -432,6 +434,12 @@  discard block
 block discarded – undo
432 434
 		return $ret;
433 435
 	}
434 436
 
437
+	/**
438
+	 * @param string $argHostname
439
+	 * @param string $argUsername
440
+	 * @param string $argPassword
441
+	 * @param string $argDatabaseName
442
+	 */
435 443
 	function _nconnect($argHostname, $argUsername, $argPassword, $argDatabaseName)
436 444
 	{
437 445
 		return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabaseName);
@@ -540,6 +548,7 @@  discard block
 block discarded – undo
540 548
 
541 549
 	/**
542 550
 	* PEAR DB Compat
551
+	* @param string $s
543 552
 	*/
544 553
 	function Quote($s)
545 554
 	{
@@ -926,7 +935,7 @@  discard block
 block discarded – undo
926 935
 	 * GenID is only available if $this->hasGenID = true;
927 936
 	 *
928 937
 	 * @param seqname		name of sequence to use
929
-	 * @param startID		if sequence does not exist, start at this ID
938
+	 * @param startID		integer sequence does not exist, start at this ID
930 939
 	 * @return		0 if not supported, otherwise a sequence id
931 940
 	 */
932 941
 	function GenID($seqname='adodbseq',$startID=1)
@@ -1008,7 +1017,7 @@  discard block
 block discarded – undo
1008 1017
 
1009 1018
 
1010 1019
 	/**
1011
-	 * @return  the last error message
1020
+	 * @return  string last error message
1012 1021
 	 */
1013 1022
 	function ErrorMsg()
1014 1023
 	{
@@ -1018,7 +1027,7 @@  discard block
 block discarded – undo
1018 1027
 
1019 1028
 
1020 1029
 	/**
1021
-	 * @return the last error number. Normally 0 means no error.
1030
+	 * @return integer last error number. Normally 0 means no error.
1022 1031
 	 */
1023 1032
 	function ErrorNo()
1024 1033
 	{
@@ -1069,7 +1078,7 @@  discard block
 block discarded – undo
1069 1078
 	 * Choose a database to connect to. Many databases do not support this.
1070 1079
 	 *
1071 1080
 	 * @param dbName 	is the name of the database to select
1072
-	 * @return 		true or false
1081
+	 * @return 		boolean or false
1073 1082
 	 */
1074 1083
 	function SelectDB($dbName)
1075 1084
 	{return false;}
@@ -1542,6 +1551,8 @@  discard block
 block discarded – undo
1542 1551
 	* When not in safe mode, we create 256 sub-directories in the cache directory ($ADODB_CACHE_DIR).
1543 1552
 	* Assuming that we can have 50,000 files per directory with good performance,
1544 1553
 	* then we can scale to 12.8 million unique cached recordsets. Wow!
1554
+ 	* @param string $sql
1555
+ 	* @param boolean $createdir
1545 1556
  	*/
1546 1557
 	function _gencachename($sql,$createdir)
1547 1558
 	{
@@ -1913,7 +1924,7 @@  discard block
 block discarded – undo
1913 1924
 	/**
1914 1925
 	 * Begin a Transaction. Must be followed by CommitTrans() or RollbackTrans().
1915 1926
 	 *
1916
-	 * @return true if succeeded or false if database does not support transactions
1927
+	 * @return boolean if succeeded or false if database does not support transactions
1917 1928
 	 */
1918 1929
 	function BeginTrans() {return false;}
1919 1930
 
@@ -2082,7 +2093,7 @@  discard block
 block discarded – undo
2082 2093
       * @param table  table name to query
2083 2094
       * @param primary true to only show primary keys. Not actually used for most databases
2084 2095
 	  *
2085
-      * @return array of indexes on current table. Each element represents an index, and is itself an associative array.
2096
+      * @return boolean of indexes on current table. Each element represents an index, and is itself an associative array.
2086 2097
 
2087 2098
 		 Array (
2088 2099
 		    [name_of_index] => Array
@@ -2132,7 +2143,7 @@  discard block
 block discarded – undo
2132 2143
 	 *
2133 2144
 	 * Usage: $db->Concat($str1,$str2);
2134 2145
 	 *
2135
-	 * @return concatenated string
2146
+	 * @return string string
2136 2147
 	 */
2137 2148
 	function Concat()
2138 2149
 	{
@@ -2167,7 +2178,7 @@  discard block
 block discarded – undo
2167 2178
 	 *
2168 2179
 	 * @param ts	a timestamp in Unix date time format.
2169 2180
 	 *
2170
-	 * @return  timestamp string in database timestamp format
2181
+	 * @return  string string in database timestamp format
2171 2182
 	 */
2172 2183
 	function DBTimeStamp($ts)
2173 2184
 	{
@@ -2538,7 +2549,7 @@  discard block
 block discarded – undo
2538 2549
 	 & @param [compareFields0]	when we have 2 cols in recordset, we compare the defstr with
2539 2550
 	 *				column 0 (1st col) if this is true. This is not documented.
2540 2551
 	 *
2541
-	 * @return HTML
2552
+	 * @return string
2542 2553
 	 *
2543 2554
 	 * changes by [email protected] to support multiple hilited items
2544 2555
 	 */
@@ -2618,7 +2629,7 @@  discard block
 block discarded – undo
2618 2629
 	 * return recordset as a 2-dimensional array.
2619 2630
 	 * Helper function for ADOConnection->SelectLimit()
2620 2631
 	 *
2621
-	 * @param offset	is the row to start calculations from (1-based)
2632
+	 * @param offset	integer the row to start calculations from (1-based)
2622 2633
 	 * @param [nrows]	is the number of rows to return
2623 2634
 	 *
2624 2635
 	 * @return an array indexed by the rows (0-based) from the recordset
@@ -2871,7 +2882,7 @@  discard block
 block discarded – undo
2871 2882
 	/**
2872 2883
 	 * Move to the first row in the recordset. Many databases do NOT support this.
2873 2884
 	 *
2874
-	 * @return true or false
2885
+	 * @return boolean or false
2875 2886
 	 */
2876 2887
 	function MoveFirst()
2877 2888
 	{
@@ -2883,7 +2894,7 @@  discard block
 block discarded – undo
2883 2894
 	/**
2884 2895
 	 * Move to the last row in the recordset.
2885 2896
 	 *
2886
-	 * @return true or false
2897
+	 * @return boolean or false
2887 2898
 	 */
2888 2899
 	function MoveLast()
2889 2900
 	{
@@ -2902,7 +2913,7 @@  discard block
 block discarded – undo
2902 2913
 	/**
2903 2914
 	 * Move to next record in the recordset.
2904 2915
 	 *
2905
-	 * @return true if there still rows available, or false if there are no more rows (EOF).
2916
+	 * @return boolean if there still rows available, or false if there are no more rows (EOF).
2906 2917
 	 */
2907 2918
 	function MoveNext()
2908 2919
 	{
@@ -2926,9 +2937,9 @@  discard block
 block discarded – undo
2926 2937
 	 * Random access to a specific row in the recordset. Some databases do not support
2927 2938
 	 * access to previous rows in the databases (no scrolling backwards).
2928 2939
 	 *
2929
-	 * @param rowNumber is the row to move to (0-based)
2940
+	 * @param rowNumber integer the row to move to (0-based)
2930 2941
 	 *
2931
-	 * @return true if there still rows available, or false if there are no more rows (EOF).
2942
+	 * @return boolean if there still rows available, or false if there are no more rows (EOF).
2932 2943
 	 */
2933 2944
 	function Move($rowNumber = 0)
2934 2945
 	{
@@ -3024,7 +3035,7 @@  discard block
 block discarded – undo
3024 3035
 	/**
3025 3036
 	 * Clean up recordset
3026 3037
 	 *
3027
-	 * @return true or false
3038
+	 * @return null|boolean or false
3028 3039
 	 */
3029 3040
 	function Close()
3030 3041
 	{
@@ -3041,7 +3052,7 @@  discard block
 block discarded – undo
3041 3052
 	/**
3042 3053
 	 * synonyms RecordCount and RowCount
3043 3054
 	 *
3044
-	 * @return the number of rows or -1 if this is not supported
3055
+	 * @return integer number of rows or -1 if this is not supported
3045 3056
 	 */
3046 3057
 	function RecordCount() {return $this->_numOfRows;}
3047 3058
 
@@ -3058,7 +3069,7 @@  discard block
 block discarded – undo
3058 3069
 	/**
3059 3070
 	 * synonyms RecordCount and RowCount
3060 3071
 	 *
3061
-	 * @return the number of rows or -1 if this is not supported
3072
+	 * @return integer number of rows or -1 if this is not supported
3062 3073
 	 */
3063 3074
 	function RowCount() {return $this->_numOfRows;}
3064 3075
 
@@ -3086,19 +3097,19 @@  discard block
 block discarded – undo
3086 3097
 	}
3087 3098
 
3088 3099
 	/**
3089
-	 * @return the current row in the recordset. If at EOF, will return the last row. 0-based.
3100
+	 * @return integer current row in the recordset. If at EOF, will return the last row. 0-based.
3090 3101
 	 */
3091 3102
 	function CurrentRow() {return $this->_currentRow;}
3092 3103
 
3093 3104
 	/**
3094 3105
 	 * synonym for CurrentRow -- for ADO compat
3095 3106
 	 *
3096
-	 * @return the current row in the recordset. If at EOF, will return the last row. 0-based.
3107
+	 * @return integer current row in the recordset. If at EOF, will return the last row. 0-based.
3097 3108
 	 */
3098 3109
 	function AbsolutePosition() {return $this->_currentRow;}
3099 3110
 
3100 3111
 	/**
3101
-	 * @return the number of columns in the recordset. Some databases will set this to 0
3112
+	 * @return integer number of columns in the recordset. Some databases will set this to 0
3102 3113
 	 * if no records are returned, others will return the number of columns in the query.
3103 3114
 	 */
3104 3115
 	function FieldCount() {return $this->_numOfFields;}
@@ -3107,7 +3118,7 @@  discard block
 block discarded – undo
3107 3118
 	/**
3108 3119
 	 * Get the ADOFieldObject of a specific column.
3109 3120
 	 *
3110
-	 * @param fieldoffset	is the column position to access(0-based).
3121
+	 * @param fieldoffset	integer the column position to access(0-based).
3111 3122
 	 *
3112 3123
 	 * @return the ADOFieldObject for that column, or false.
3113 3124
 	 */
@@ -3217,7 +3228,7 @@  discard block
 block discarded – undo
3217 3228
 	 * type to our standardised version which uses 1 character codes:
3218 3229
 	 *
3219 3230
 	 * @param t  is the type passed in. Normally is ADOFieldObject->type.
3220
-	 * @param len is the maximum length of that field. This is because we treat character
3231
+	 * @param len integer the maximum length of that field. This is because we treat character
3221 3232
 	 * 	fields bigger than a certain size as a 'B' (blob).
3222 3233
 	 * @param fieldobj is the field object returned by the database driver. Can hold
3223 3234
 	 *	additional info (eg. primary_key for mysql).
@@ -3409,7 +3420,8 @@  discard block
 block discarded – undo
3409 3420
 	 * PDO compatibility function: fetch the next row
3410 3421
 	 *
3411 3422
 	 * @param $fetchmode=null ADODB_FETCH_{DEFAULT|ASSOC|NUM|BOTH}, default is to use currently selected fetch-mode
3412
-	 * @return array|boolean false if there's nothing to fetch
3423
+	 * @param integer $fetchmode
3424
+	 * @return boolean false if there's nothing to fetch
3413 3425
 	 */
3414 3426
 	function &fetch($fetchmode=null)
3415 3427
 	{
@@ -3429,7 +3441,7 @@  discard block
 block discarded – undo
3429 3441
 	/**
3430 3442
 	 * PDO compatibility function: fetch the n-th column of the next row
3431 3443
 	 *
3432
-	 * @param int $column_number=0
3444
+	 * @param int $column_number
3433 3445
 	 * @return string|boolean false if there's nothing to fetch
3434 3446
 	 */
3435 3447
 	function fetchColumn($column_number=0)
@@ -3828,6 +3840,10 @@  discard block
 block discarded – undo
3828 3840
 
3829 3841
 
3830 3842
 	// $perf == true means called by NewPerfMonitor(), otherwise for data dictionary
3843
+
3844
+	/**
3845
+	 * @return string
3846
+	 */
3831 3847
 	function _adodb_getdriver($provider,$drivername,$perf=false)
3832 3848
 	{
3833 3849
 		switch ($provider) {
Please login to merge, or discard this patch.
Indentation   +289 added lines, -290 removed lines patch added patch discarded remove patch
@@ -30,7 +30,6 @@  discard block
 block discarded – undo
30 30
 
31 31
 	Latest Download at http://php.weblogs.com/adodb<br>
32 32
 	Manual is at http://php.weblogs.com/adodb_manual
33
-
34 33
  */
35 34
 
36 35
  if (!defined('_ADODB_LAYER')) {
@@ -75,11 +74,11 @@  discard block
 block discarded – undo
75 74
 		2 = force empty. All empty, php null and string 'null' fields are changed to sql empty '' or 0 values.
76 75
 		3 = force value. Value is left as it is. Php null and string 'null' are set to sql NULL values and empty fields '' are set to empty '' sql values.
77 76
 	*/
78
-        define('ADODB_FORCE_IGNORE',0);
79
-        define('ADODB_FORCE_NULL',1);
80
-        define('ADODB_FORCE_EMPTY',2);
81
-        define('ADODB_FORCE_VALUE',3);
82
-    //********************************************************//
77
+		define('ADODB_FORCE_IGNORE',0);
78
+		define('ADODB_FORCE_NULL',1);
79
+		define('ADODB_FORCE_EMPTY',2);
80
+		define('ADODB_FORCE_VALUE',3);
81
+	//********************************************************//
83 82
 
84 83
 
85 84
 	if (!$ADODB_EXTENSION || ADODB_EXTENSION < 4.0) {
@@ -129,7 +128,7 @@  discard block
 block discarded – undo
129 128
 
130 129
 	/**
131 130
 	 	Accepts $src and $dest arrays, replacing string $data
132
-	*/
131
+	 */
133 132
 	function ADODB_str_replace($src, $dest, $data)
134 133
 	{
135 134
 		if (ADODB_PHPVER >= 0x4050) return str_replace($src,$dest,$data);
@@ -338,7 +337,7 @@  discard block
 block discarded – undo
338 337
 
339 338
 		@returns An array with 2 elements: $arr['string'] is the description string,
340 339
 			and $arr[version] is the version (also a string).
341
-	*/
340
+	 */
342 341
 	function ServerInfo()
343 342
 	{
344 343
 		return array('description' => '', 'version' => '');
@@ -346,7 +345,7 @@  discard block
 block discarded – undo
346 345
 
347 346
 	function IsConnected()
348 347
 	{
349
-    	return !empty($this->_connectionID);
348
+		return !empty($this->_connectionID);
350 349
 	}
351 350
 
352 351
 	function _findvers($str)
@@ -356,9 +355,9 @@  discard block
 block discarded – undo
356 355
 	}
357 356
 
358 357
 	/**
359
-	* All error messages go through this bottleneck function.
360
-	* You can define your own handler by defining the function name in ADODB_OUTP.
361
-	*/
358
+	 * All error messages go through this bottleneck function.
359
+	 * You can define your own handler by defining the function name in ADODB_OUTP.
360
+	 */
362 361
 	function outp($msg,$newline=true)
363 362
 	{
364 363
 	global $ADODB_FLUSH,$ADODB_OUTP;
@@ -539,8 +538,8 @@  discard block
 block discarded – undo
539 538
 	}
540 539
 
541 540
 	/**
542
-	* PEAR DB Compat
543
-	*/
541
+	 * PEAR DB Compat
542
+	 */
544 543
 	function Quote($s)
545 544
 	{
546 545
 		return $this->qstr($s,false);
@@ -548,7 +547,7 @@  discard block
 block discarded – undo
548 547
 
549 548
 	/**
550 549
 	 Requested by "Karsten Dambekalns" <[email protected]>
551
-	*/
550
+	 */
552 551
 	function QMagic($s)
553 552
 	{
554 553
 		return $this->qstr($s,get_magic_quotes_gpc());
@@ -560,8 +559,8 @@  discard block
 block discarded – undo
560 559
 	}
561 560
 
562 561
 	/**
563
-	* PEAR DB Compat - do not use internally.
564
-	*/
562
+	 * PEAR DB Compat - do not use internally.
563
+	 */
565 564
 	function ErrorNative()
566 565
 	{
567 566
 		return $this->ErrorNo();
@@ -569,20 +568,20 @@  discard block
 block discarded – undo
569 568
 
570 569
 
571 570
    /**
572
-	* PEAR DB Compat - do not use internally.
573
-	*/
571
+    * PEAR DB Compat - do not use internally.
572
+    */
574 573
 	function nextId($seq_name)
575 574
 	{
576 575
 		return $this->GenID($seq_name);
577 576
 	}
578 577
 
579 578
 	/**
580
-	*	 Lock a row, will escalate and lock the table if row locking not supported
581
-	*	will normally free the lock at the end of the transaction
582
-	*
583
-	*  @param $table	name of table to lock
584
-	*  @param $where	where clause to use, eg: "WHERE row=12". If left empty, will escalate to table lock
585
-	*/
579
+	 *	 Lock a row, will escalate and lock the table if row locking not supported
580
+	 *	will normally free the lock at the end of the transaction
581
+	 *
582
+	 *  @param $table	name of table to lock
583
+	 *  @param $where	where clause to use, eg: "WHERE row=12". If left empty, will escalate to table lock
584
+	 */
586 585
 	function RowLock($table,$where)
587 586
 	{
588 587
 		return false;
@@ -599,14 +598,14 @@  discard block
 block discarded – undo
599 598
 	}
600 599
 
601 600
 	/**
602
-	* PEAR DB Compat - do not use internally.
603
-	*
604
-	* The fetch modes for NUMERIC and ASSOC for PEAR DB and ADODB are identical
605
-	* 	for easy porting :-)
606
-	*
607
-	* @param mode	The fetchmode ADODB_FETCH_ASSOC or ADODB_FETCH_NUM
608
-	* @returns		The previous fetch mode
609
-	*/
601
+	 * PEAR DB Compat - do not use internally.
602
+	 *
603
+	 * The fetch modes for NUMERIC and ASSOC for PEAR DB and ADODB are identical
604
+	 * 	for easy porting :-)
605
+	 *
606
+	 * @param mode	The fetchmode ADODB_FETCH_ASSOC or ADODB_FETCH_NUM
607
+	 * @returns		The previous fetch mode
608
+	 */
610 609
 	function SetFetchMode($mode)
611 610
 	{
612 611
 		$old = $this->fetchMode;
@@ -621,8 +620,8 @@  discard block
 block discarded – undo
621 620
 
622 621
 
623 622
 	/**
624
-	* PEAR DB Compat - do not use internally.
625
-	*/
623
+	 * PEAR DB Compat - do not use internally.
624
+	 */
626 625
 	function &Query($sql, $inputarr=false)
627 626
 	{
628 627
 		$rs = &$this->Execute($sql, $inputarr);
@@ -632,8 +631,8 @@  discard block
 block discarded – undo
632 631
 
633 632
 
634 633
 	/**
635
-	* PEAR DB Compat - do not use internally
636
-	*/
634
+	 * PEAR DB Compat - do not use internally
635
+	 */
637 636
 	function &LimitQuery($sql, $offset, $count, $params=false)
638 637
 	{
639 638
 		$rs = &$this->SelectLimit($sql, $count, $offset, $params);
@@ -643,8 +642,8 @@  discard block
 block discarded – undo
643 642
 
644 643
 
645 644
 	/**
646
-	* PEAR DB Compat - do not use internally
647
-	*/
645
+	 * PEAR DB Compat - do not use internally
646
+	 */
648 647
 	function Disconnect()
649 648
 	{
650 649
 		return $this->Close();
@@ -709,7 +708,7 @@  discard block
 block discarded – undo
709 708
 		b. CompleteTrans auto-detects SQL errors, and will rollback on errors, commit otherwise.<br>
710 709
 		c. All BeginTrans/CommitTrans/RollbackTrans inside a StartTrans/CompleteTrans block
711 710
 		   are disabled, making it backward compatible.
712
-	*/
711
+	 */
713 712
 	function StartTrans($errfn = 'ADODB_TransMonitor')
714 713
 	{
715 714
 		if ($this->transOff > 0) {
@@ -734,7 +733,7 @@  discard block
 block discarded – undo
734 733
 		@autoComplete if true, monitor sql errors and commit and rollback as appropriate,
735 734
 		and if set to false force rollback even if no SQL error detected.
736 735
 		@returns true on commit, false on rollback.
737
-	*/
736
+	 */
738 737
 	function CompleteTrans($autoComplete = true)
739 738
 	{
740 739
 		if ($this->transOff > 1) {
@@ -776,7 +775,7 @@  discard block
 block discarded – undo
776 775
 
777 776
 	/**
778 777
 		Check if transaction has failed, only for Smart Transactions.
779
-	*/
778
+	 */
780 779
 	function HasFailedTrans()
781 780
 	{
782 781
 		if ($this->transOff > 0) return $this->_transOK == false;
@@ -990,8 +989,8 @@  discard block
 block discarded – undo
990 989
 	}
991 990
 
992 991
 	/**
993
-	* @return # rows affected by UPDATE/DELETE
994
-	*/
992
+	 * @return # rows affected by UPDATE/DELETE
993
+	 */
995 994
 	function Affected_Rows()
996 995
 	{
997 996
 		if ($this->hasAffectedRows) {
@@ -1076,24 +1075,24 @@  discard block
 block discarded – undo
1076 1075
 
1077 1076
 
1078 1077
 	/**
1079
-	* Will select, getting rows from $offset (1-based), for $nrows.
1080
-	* This simulates the MySQL "select * from table limit $offset,$nrows" , and
1081
-	* the PostgreSQL "select * from table limit $nrows offset $offset". Note that
1082
-	* MySQL and PostgreSQL parameter ordering is the opposite of the other.
1083
-	* eg.
1084
-	*  SelectLimit('select * from table',3); will return rows 1 to 3 (1-based)
1085
-	*  SelectLimit('select * from table',3,2); will return rows 3 to 5 (1-based)
1086
-	*
1087
-	* Uses SELECT TOP for Microsoft databases (when $this->hasTop is set)
1088
-	* BUG: Currently SelectLimit fails with $sql with LIMIT or TOP clause already set
1089
-	*
1090
-	* @param sql
1091
-	* @param [offset]	is the row to start calculations from (1-based)
1092
-	* @param [nrows]		is the number of rows to get
1093
-	* @param [inputarr]	array of bind variables
1094
-	* @param [secs2cache]		is a private parameter only used by jlim
1095
-	* @return		the recordset ($rs->databaseType == 'array')
1096
- 	*/
1078
+	 * Will select, getting rows from $offset (1-based), for $nrows.
1079
+	 * This simulates the MySQL "select * from table limit $offset,$nrows" , and
1080
+	 * the PostgreSQL "select * from table limit $nrows offset $offset". Note that
1081
+	 * MySQL and PostgreSQL parameter ordering is the opposite of the other.
1082
+	 * eg.
1083
+	 *  SelectLimit('select * from table',3); will return rows 1 to 3 (1-based)
1084
+	 *  SelectLimit('select * from table',3,2); will return rows 3 to 5 (1-based)
1085
+	 *
1086
+	 * Uses SELECT TOP for Microsoft databases (when $this->hasTop is set)
1087
+	 * BUG: Currently SelectLimit fails with $sql with LIMIT or TOP clause already set
1088
+	 *
1089
+	 * @param sql
1090
+	 * @param [offset]	is the row to start calculations from (1-based)
1091
+	 * @param [nrows]		is the number of rows to get
1092
+	 * @param [inputarr]	array of bind variables
1093
+	 * @param [secs2cache]		is a private parameter only used by jlim
1094
+	 * @return		the recordset ($rs->databaseType == 'array')
1095
+	 */
1097 1096
 	function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0)
1098 1097
 	{
1099 1098
 		if ($this->hasTop && $nrows > 0) {
@@ -1158,10 +1157,10 @@  discard block
 block discarded – undo
1158 1157
 	}
1159 1158
 
1160 1159
 	/**
1161
-	* Create serializable recordset. Breaks rs link to connection.
1162
-	*
1163
-	* @param rs			the recordset to serialize
1164
-	*/
1160
+	 * Create serializable recordset. Breaks rs link to connection.
1161
+	 *
1162
+	 * @param rs			the recordset to serialize
1163
+	 */
1165 1164
 	function &SerializableRS(&$rs)
1166 1165
 	{
1167 1166
 		$rs2 =& $this->_rs2rs($rs);
@@ -1172,15 +1171,15 @@  discard block
 block discarded – undo
1172 1171
 	}
1173 1172
 
1174 1173
 	/**
1175
-	* Convert database recordset to an array recordset
1176
-	* input recordset's cursor should be at beginning, and
1177
-	* old $rs will be closed.
1178
-	*
1179
-	* @param rs			the recordset to copy
1180
-	* @param [nrows]  	number of rows to retrieve (optional)
1181
-	* @param [offset] 	offset by number of rows (optional)
1182
-	* @return 			the new recordset
1183
-	*/
1174
+	 * Convert database recordset to an array recordset
1175
+	 * input recordset's cursor should be at beginning, and
1176
+	 * old $rs will be closed.
1177
+	 *
1178
+	 * @param rs			the recordset to copy
1179
+	 * @param [nrows]  	number of rows to retrieve (optional)
1180
+	 * @param [offset] 	offset by number of rows (optional)
1181
+	 * @return 			the new recordset
1182
+	 */
1184 1183
 	function &_rs2rs(&$rs,$nrows=-1,$offset=-1,$close=true)
1185 1184
 	{
1186 1185
 		if (! $rs) {
@@ -1253,12 +1252,12 @@  discard block
 block discarded – undo
1253 1252
 	}
1254 1253
 
1255 1254
 	/**
1256
-	* Return first element of first row of sql statement. Recordset is disposed
1257
-	* for you.
1258
-	*
1259
-	* @param sql			SQL statement
1260
-	* @param [inputarr]		input bind array
1261
-	*/
1255
+	 * Return first element of first row of sql statement. Recordset is disposed
1256
+	 * for you.
1257
+	 *
1258
+	 * @param sql			SQL statement
1259
+	 * @param [inputarr]		input bind array
1260
+	 */
1262 1261
 	function GetOne($sql,$inputarr=false)
1263 1262
 	{
1264 1263
 	global $ADODB_COUNTRECS;
@@ -1345,10 +1344,10 @@  discard block
 block discarded – undo
1345 1344
 
1346 1345
 
1347 1346
 	/**
1348
-	*
1349
-	* @param sql			SQL statement
1350
-	* @param [inputarr]		input bind array
1351
-	*/
1347
+	 *
1348
+	 * @param sql			SQL statement
1349
+	 * @param [inputarr]		input bind array
1350
+	 */
1352 1351
 	function &GetArray($sql,$inputarr=false)
1353 1352
 	{
1354 1353
 	global $ADODB_COUNTRECS;
@@ -1396,11 +1395,11 @@  discard block
 block discarded – undo
1396 1395
 
1397 1396
 
1398 1397
 	/**
1399
-	* Return one row of sql statement. Recordset is disposed for you.
1400
-	*
1401
-	* @param sql			SQL statement
1402
-	* @param [inputarr]		input bind array
1403
-	*/
1398
+	 * Return one row of sql statement. Recordset is disposed for you.
1399
+	 *
1400
+	 * @param sql			SQL statement
1401
+	 * @param [inputarr]		input bind array
1402
+	 */
1404 1403
 	function &GetRow($sql,$inputarr=false)
1405 1404
 	{
1406 1405
 	global $ADODB_COUNTRECS;
@@ -1435,24 +1434,24 @@  discard block
 block discarded – undo
1435 1434
 	}
1436 1435
 
1437 1436
 	/**
1438
-	* Insert or replace a single record. Note: this is not the same as MySQL's replace.
1439
-	* ADOdb's Replace() uses update-insert semantics, not insert-delete-duplicates of MySQL.
1440
-	* Also note that no table locking is done currently, so it is possible that the
1441
-	* record be inserted twice by two programs...
1442
-	*
1443
-	* $this->Replace('products', array('prodname' =>"'Nails'","price" => 3.99), 'prodname');
1444
-	*
1445
-	* $table		table name
1446
-	* $fieldArray	associative array of data (you must quote strings yourself).
1447
-	* $keyCol		the primary key field name or if compound key, array of field names
1448
-	* autoQuote		set to true to use a hueristic to quote strings. Works with nulls and numbers
1449
-	*					but does not work with dates nor SQL functions.
1450
-	* has_autoinc	the primary key is an auto-inc field, so skip in insert.
1451
-	*
1452
-	* Currently blob replace not supported
1453
-	*
1454
-	* returns 0 = fail, 1 = update, 2 = insert
1455
-	*/
1437
+	 * Insert or replace a single record. Note: this is not the same as MySQL's replace.
1438
+	 * ADOdb's Replace() uses update-insert semantics, not insert-delete-duplicates of MySQL.
1439
+	 * Also note that no table locking is done currently, so it is possible that the
1440
+	 * record be inserted twice by two programs...
1441
+	 *
1442
+	 * $this->Replace('products', array('prodname' =>"'Nails'","price" => 3.99), 'prodname');
1443
+	 *
1444
+	 * $table		table name
1445
+	 * $fieldArray	associative array of data (you must quote strings yourself).
1446
+	 * $keyCol		the primary key field name or if compound key, array of field names
1447
+	 * autoQuote		set to true to use a hueristic to quote strings. Works with nulls and numbers
1448
+	 *					but does not work with dates nor SQL functions.
1449
+	 * has_autoinc	the primary key is an auto-inc field, so skip in insert.
1450
+	 *
1451
+	 * Currently blob replace not supported
1452
+	 *
1453
+	 * returns 0 = fail, 1 = update, 2 = insert
1454
+	 */
1456 1455
 
1457 1456
 	function Replace($table, $fieldArray, $keyCol, $autoQuote=false, $has_autoinc=false)
1458 1457
 	{
@@ -1464,23 +1463,23 @@  discard block
 block discarded – undo
1464 1463
 
1465 1464
 
1466 1465
 	/**
1467
-	* Will select, getting rows from $offset (1-based), for $nrows.
1468
-	* This simulates the MySQL "select * from table limit $offset,$nrows" , and
1469
-	* the PostgreSQL "select * from table limit $nrows offset $offset". Note that
1470
-	* MySQL and PostgreSQL parameter ordering is the opposite of the other.
1471
-	* eg.
1472
-	*  CacheSelectLimit(15,'select * from table',3); will return rows 1 to 3 (1-based)
1473
-	*  CacheSelectLimit(15,'select * from table',3,2); will return rows 3 to 5 (1-based)
1474
-	*
1475
-	* BUG: Currently CacheSelectLimit fails with $sql with LIMIT or TOP clause already set
1476
-	*
1477
-	* @param [secs2cache]	seconds to cache data, set to 0 to force query. This is optional
1478
-	* @param sql
1479
-	* @param [offset]	is the row to start calculations from (1-based)
1480
-	* @param [nrows]	is the number of rows to get
1481
-	* @param [inputarr]	array of bind variables
1482
-	* @return		the recordset ($rs->databaseType == 'array')
1483
- 	*/
1466
+	 * Will select, getting rows from $offset (1-based), for $nrows.
1467
+	 * This simulates the MySQL "select * from table limit $offset,$nrows" , and
1468
+	 * the PostgreSQL "select * from table limit $nrows offset $offset". Note that
1469
+	 * MySQL and PostgreSQL parameter ordering is the opposite of the other.
1470
+	 * eg.
1471
+	 *  CacheSelectLimit(15,'select * from table',3); will return rows 1 to 3 (1-based)
1472
+	 *  CacheSelectLimit(15,'select * from table',3,2); will return rows 3 to 5 (1-based)
1473
+	 *
1474
+	 * BUG: Currently CacheSelectLimit fails with $sql with LIMIT or TOP clause already set
1475
+	 *
1476
+	 * @param [secs2cache]	seconds to cache data, set to 0 to force query. This is optional
1477
+	 * @param sql
1478
+	 * @param [offset]	is the row to start calculations from (1-based)
1479
+	 * @param [nrows]	is the number of rows to get
1480
+	 * @param [inputarr]	array of bind variables
1481
+	 * @return		the recordset ($rs->databaseType == 'array')
1482
+	 */
1484 1483
 	function &CacheSelectLimit($secs2cache,$sql,$nrows=-1,$offset=-1,$inputarr=false)
1485 1484
 	{
1486 1485
 		if (!is_numeric($secs2cache)) {
@@ -1496,9 +1495,9 @@  discard block
 block discarded – undo
1496 1495
 	}
1497 1496
 
1498 1497
 	/**
1499
-	* Flush cached recordsets that match a particular $sql statement.
1500
-	* If $sql == false, then we purge all files in the cache.
1501
- 	*/
1498
+	 * Flush cached recordsets that match a particular $sql statement.
1499
+	 * If $sql == false, then we purge all files in the cache.
1500
+	 */
1502 1501
 	function CacheFlush($sql=false,$inputarr=false)
1503 1502
 	{
1504 1503
 	global $ADODB_CACHE_DIR;
@@ -1530,19 +1529,19 @@  discard block
 block discarded – undo
1530 1529
 	}
1531 1530
 
1532 1531
 	/**
1533
-	* Private function to generate filename for caching.
1534
-	* Filename is generated based on:
1535
-	*
1536
-	*  - sql statement
1537
-	*  - database type (oci8, ibase, ifx, etc)
1538
-	*  - database name
1539
-	*  - userid
1540
-	*  - setFetchMode (adodb 4.23)
1541
-	*
1542
-	* When not in safe mode, we create 256 sub-directories in the cache directory ($ADODB_CACHE_DIR).
1543
-	* Assuming that we can have 50,000 files per directory with good performance,
1544
-	* then we can scale to 12.8 million unique cached recordsets. Wow!
1545
- 	*/
1532
+	 * Private function to generate filename for caching.
1533
+	 * Filename is generated based on:
1534
+	 *
1535
+	 *  - sql statement
1536
+	 *  - database type (oci8, ibase, ifx, etc)
1537
+	 *  - database name
1538
+	 *  - userid
1539
+	 *  - setFetchMode (adodb 4.23)
1540
+	 *
1541
+	 * When not in safe mode, we create 256 sub-directories in the cache directory ($ADODB_CACHE_DIR).
1542
+	 * Assuming that we can have 50,000 files per directory with good performance,
1543
+	 * then we can scale to 12.8 million unique cached recordsets. Wow!
1544
+	 */
1546 1545
 	function _gencachename($sql,$createdir)
1547 1546
 	{
1548 1547
 	global $ADODB_CACHE_DIR;
@@ -1712,17 +1711,17 @@  discard block
 block discarded – undo
1712 1711
 	 *		 be a simple select stmt with no groupby/orderby/limit
1713 1712
 	 *
1714 1713
 	 * "Jonathan Younger" <[email protected]>
1715
-  	 */
1714
+	 */
1716 1715
 	function GetUpdateSQL(&$rs, $arrFields,$forceUpdate=false,$magicq=false,$force=null)
1717 1716
 	{
1718 1717
 		global $ADODB_INCLUDED_LIB;
1719 1718
 
1720
-        //********************************************************//
1721
-        //This is here to maintain compatibility
1722
-        //with older adodb versions. Sets force type to force nulls if $forcenulls is set.
1719
+		//********************************************************//
1720
+		//This is here to maintain compatibility
1721
+		//with older adodb versions. Sets force type to force nulls if $forcenulls is set.
1723 1722
 		if (!isset($force)) {
1724 1723
 				global $ADODB_FORCE_TYPE;
1725
-			    $force = $ADODB_FORCE_TYPE;
1724
+				$force = $ADODB_FORCE_TYPE;
1726 1725
 		}
1727 1726
 		//********************************************************//
1728 1727
 
@@ -1740,7 +1739,7 @@  discard block
 block discarded – undo
1740 1739
 	 *
1741 1740
 	 * Note: This function should only be used on a recordset
1742 1741
 	 *	   that is run against a single table.
1743
-  	 */
1742
+	 */
1744 1743
 	function GetInsertSQL(&$rs, $arrFields,$magicq=false,$force=null)
1745 1744
 	{
1746 1745
 		global $ADODB_INCLUDED_LIB;
@@ -1755,23 +1754,23 @@  discard block
 block discarded – undo
1755 1754
 
1756 1755
 
1757 1756
 	/**
1758
-	* Update a blob column, given a where clause. There are more sophisticated
1759
-	* blob handling functions that we could have implemented, but all require
1760
-	* a very complex API. Instead we have chosen something that is extremely
1761
-	* simple to understand and use.
1762
-	*
1763
-	* Note: $blobtype supports 'BLOB' and 'CLOB', default is BLOB of course.
1764
-	*
1765
-	* Usage to update a $blobvalue which has a primary key blob_id=1 into a
1766
-	* field blobtable.blobcolumn:
1767
-	*
1768
-	*	UpdateBlob('blobtable', 'blobcolumn', $blobvalue, 'blob_id=1');
1769
-	*
1770
-	* Insert example:
1771
-	*
1772
-	*	$conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)');
1773
-	*	$conn->UpdateBlob('blobtable','blobcol',$blob,'id=1');
1774
-	*/
1757
+	 * Update a blob column, given a where clause. There are more sophisticated
1758
+	 * blob handling functions that we could have implemented, but all require
1759
+	 * a very complex API. Instead we have chosen something that is extremely
1760
+	 * simple to understand and use.
1761
+	 *
1762
+	 * Note: $blobtype supports 'BLOB' and 'CLOB', default is BLOB of course.
1763
+	 *
1764
+	 * Usage to update a $blobvalue which has a primary key blob_id=1 into a
1765
+	 * field blobtable.blobcolumn:
1766
+	 *
1767
+	 *	UpdateBlob('blobtable', 'blobcolumn', $blobvalue, 'blob_id=1');
1768
+	 *
1769
+	 * Insert example:
1770
+	 *
1771
+	 *	$conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)');
1772
+	 *	$conn->UpdateBlob('blobtable','blobcol',$blob,'id=1');
1773
+	 */
1775 1774
 
1776 1775
 	function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB')
1777 1776
 	{
@@ -1779,14 +1778,14 @@  discard block
 block discarded – undo
1779 1778
 	}
1780 1779
 
1781 1780
 	/**
1782
-	* Usage:
1783
-	*	UpdateBlob('TABLE', 'COLUMN', '/path/to/file', 'ID=1');
1784
-	*
1785
-	*	$blobtype supports 'BLOB' and 'CLOB'
1786
-	*
1787
-	*	$conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)');
1788
-	*	$conn->UpdateBlob('blobtable','blobcol',$blobpath,'id=1');
1789
-	*/
1781
+	 * Usage:
1782
+	 *	UpdateBlob('TABLE', 'COLUMN', '/path/to/file', 'ID=1');
1783
+	 *
1784
+	 *	$blobtype supports 'BLOB' and 'CLOB'
1785
+	 *
1786
+	 *	$conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)');
1787
+	 *	$conn->UpdateBlob('blobtable','blobcol',$blobpath,'id=1');
1788
+	 */
1790 1789
 	function UpdateBlobFile($table,$column,$path,$where,$blobtype='BLOB')
1791 1790
 	{
1792 1791
 		$fd = fopen($path,'rb');
@@ -1835,12 +1834,12 @@  discard block
 block discarded – undo
1835 1834
 	}
1836 1835
 
1837 1836
 	/**
1838
-	* Usage:
1839
-	*	UpdateClob('TABLE', 'COLUMN', $var, 'ID=1', 'CLOB');
1840
-	*
1841
-	*	$conn->Execute('INSERT INTO clobtable (id, clobcol) VALUES (1, null)');
1842
-	*	$conn->UpdateClob('clobtable','clobcol',$clob,'id=1');
1843
-	*/
1837
+	 * Usage:
1838
+	 *	UpdateClob('TABLE', 'COLUMN', $var, 'ID=1', 'CLOB');
1839
+	 *
1840
+	 *	$conn->Execute('INSERT INTO clobtable (id, clobcol) VALUES (1, null)');
1841
+	 *	$conn->UpdateClob('clobtable','clobcol',$clob,'id=1');
1842
+	 */
1844 1843
 	function UpdateClob($table,$column,$val,$where)
1845 1844
 	{
1846 1845
 		return $this->UpdateBlob($table,$column,$val,$where,'CLOB');
@@ -1861,9 +1860,9 @@  discard block
 block discarded – undo
1861 1860
 
1862 1861
 
1863 1862
 	/**
1864
-	*  Change the SQL connection locale to a specified locale.
1865
-	*  This is used to get the date formats written depending on the client locale.
1866
-	*/
1863
+	 *  Change the SQL connection locale to a specified locale.
1864
+	 *  This is used to get the date formats written depending on the client locale.
1865
+	 */
1867 1866
 	function SetDateLocale($locale = 'En')
1868 1867
 	{
1869 1868
 		$this->locale = $locale;
@@ -2077,12 +2076,12 @@  discard block
 block discarded – undo
2077 2076
 		return $false;
2078 2077
 	}
2079 2078
 
2080
-    /**
2081
-      * List indexes on a table as an array.
2082
-      * @param table  table name to query
2083
-      * @param primary true to only show primary keys. Not actually used for most databases
2084
-	  *
2085
-      * @return array of indexes on current table. Each element represents an index, and is itself an associative array.
2079
+	/**
2080
+	 * List indexes on a table as an array.
2081
+	 * @param table  table name to query
2082
+	 * @param primary true to only show primary keys. Not actually used for most databases
2083
+	 *
2084
+	 * @return array of indexes on current table. Each element represents an index, and is itself an associative array.
2086 2085
 
2087 2086
 		 Array (
2088 2087
 		    [name_of_index] => Array
@@ -2094,12 +2093,12 @@  discard block
 block discarded – undo
2094 2093
 		      	[1] => lastname
2095 2094
 	          )
2096 2095
 		)
2097
-      */
2098
-     function &MetaIndexes($table, $primary = false, $owner = false)
2099
-     {
2096
+	 */
2097
+	 function &MetaIndexes($table, $primary = false, $owner = false)
2098
+	 {
2100 2099
 	 		$false = false;
2101
-            return $false;
2102
-     }
2100
+			return $false;
2101
+	 }
2103 2102
 
2104 2103
 	/**
2105 2104
 	 * List columns names in a table as an array.
@@ -2259,12 +2258,12 @@  discard block
 block discarded – undo
2259 2258
 	}
2260 2259
 
2261 2260
 		/**
2262
-	 *
2263
-	 * @param v  	is the character timestamp in YYYY-MM-DD hh:mm:ss format
2264
-	 * @param fmt 	is the format to apply to it, using date()
2265
-	 *
2266
-	 * @return a timestamp formated as user desires
2267
-	 */
2261
+		 *
2262
+		 * @param v  	is the character timestamp in YYYY-MM-DD hh:mm:ss format
2263
+		 * @param fmt 	is the format to apply to it, using date()
2264
+		 *
2265
+		 * @return a timestamp formated as user desires
2266
+		 */
2268 2267
 	function UserTimeStamp($v,$fmt='Y-m-d H:i:s',$gmt=false)
2269 2268
 	{
2270 2269
 		if (!isset($v)) return $this->emptyTimeStamp;
@@ -2283,8 +2282,8 @@  discard block
 block discarded – undo
2283 2282
 	}
2284 2283
 
2285 2284
 	/**
2286
-	* Quotes a string, without prefixing nor appending quotes.
2287
-	*/
2285
+	 * Quotes a string, without prefixing nor appending quotes.
2286
+	 */
2288 2287
 	function addq($s,$magic_quotes=false)
2289 2288
 	{
2290 2289
 		if (!$magic_quotes) {
@@ -2344,22 +2343,22 @@  discard block
 block discarded – undo
2344 2343
 
2345 2344
 
2346 2345
 	/**
2347
-	* Will select the supplied $page number from a recordset, given that it is paginated in pages of
2348
-	* $nrows rows per page. It also saves two boolean values saying if the given page is the first
2349
-	* and/or last one of the recordset. Added by Iv�n Oliva to provide recordset pagination.
2350
-	*
2351
-	* See readme.htm#ex8 for an example of usage.
2352
-	*
2353
-	* @param sql
2354
-	* @param nrows		is the number of rows per page to get
2355
-	* @param page		is the page number to get (1-based)
2356
-	* @param [inputarr]	array of bind variables
2357
-	* @param [secs2cache]		is a private parameter only used by jlim
2358
-	* @return		the recordset ($rs->databaseType == 'array')
2359
-	*
2360
-	* NOTE: phpLens uses a different algorithm and does not use PageExecute().
2361
-	*
2362
-	*/
2346
+	 * Will select the supplied $page number from a recordset, given that it is paginated in pages of
2347
+	 * $nrows rows per page. It also saves two boolean values saying if the given page is the first
2348
+	 * and/or last one of the recordset. Added by Iv�n Oliva to provide recordset pagination.
2349
+	 *
2350
+	 * See readme.htm#ex8 for an example of usage.
2351
+	 *
2352
+	 * @param sql
2353
+	 * @param nrows		is the number of rows per page to get
2354
+	 * @param page		is the page number to get (1-based)
2355
+	 * @param [inputarr]	array of bind variables
2356
+	 * @param [secs2cache]		is a private parameter only used by jlim
2357
+	 * @return		the recordset ($rs->databaseType == 'array')
2358
+	 *
2359
+	 * NOTE: phpLens uses a different algorithm and does not use PageExecute().
2360
+	 *
2361
+	 */
2363 2362
 	function &PageExecute($sql, $nrows, $page, $inputarr=false, $secs2cache=0)
2364 2363
 	{
2365 2364
 		global $ADODB_INCLUDED_LIB;
@@ -2371,17 +2370,17 @@  discard block
 block discarded – undo
2371 2370
 
2372 2371
 
2373 2372
 	/**
2374
-	* Will select the supplied $page number from a recordset, given that it is paginated in pages of
2375
-	* $nrows rows per page. It also saves two boolean values saying if the given page is the first
2376
-	* and/or last one of the recordset. Added by Iv�n Oliva to provide recordset pagination.
2377
-	*
2378
-	* @param secs2cache	seconds to cache data, set to 0 to force query
2379
-	* @param sql
2380
-	* @param nrows		is the number of rows per page to get
2381
-	* @param page		is the page number to get (1-based)
2382
-	* @param [inputarr]	array of bind variables
2383
-	* @return		the recordset ($rs->databaseType == 'array')
2384
-	*/
2373
+	 * Will select the supplied $page number from a recordset, given that it is paginated in pages of
2374
+	 * $nrows rows per page. It also saves two boolean values saying if the given page is the first
2375
+	 * and/or last one of the recordset. Added by Iv�n Oliva to provide recordset pagination.
2376
+	 *
2377
+	 * @param secs2cache	seconds to cache data, set to 0 to force query
2378
+	 * @param sql
2379
+	 * @param nrows		is the number of rows per page to get
2380
+	 * @param page		is the page number to get (1-based)
2381
+	 * @param [inputarr]	array of bind variables
2382
+	 * @return		the recordset ($rs->databaseType == 'array')
2383
+	 */
2385 2384
 	function &CachePageExecute($secs2cache, $sql, $nrows, $page,$inputarr=false)
2386 2385
 	{
2387 2386
 		/*switch($this->dataProvider) {
@@ -2403,8 +2402,8 @@  discard block
 block discarded – undo
2403 2402
 	//==============================================================================================
2404 2403
 
2405 2404
 	/**
2406
-	* Internal placeholder for record objects. Used by ADORecordSet->FetchObj().
2407
-	*/
2405
+	 * Internal placeholder for record objects. Used by ADORecordSet->FetchObj().
2406
+	 */
2408 2407
 	class ADOFetchObj {
2409 2408
 	};
2410 2409
 
@@ -2413,8 +2412,8 @@  discard block
 block discarded – undo
2413 2412
 	//==============================================================================================
2414 2413
 
2415 2414
 	/**
2416
-	* Lightweight recordset when there are no records to be returned
2417
-	*/
2415
+	 * Lightweight recordset when there are no records to be returned
2416
+	 */
2418 2417
 	class ADORecordSet_empty
2419 2418
 	{
2420 2419
 		var $dataProvider = 'empty';
@@ -2444,11 +2443,11 @@  discard block
 block discarded – undo
2444 2443
 	if (PHP_VERSION < 5) include_once(ADODB_DIR.'/adodb-php4.inc.php');
2445 2444
 	else include_once(ADODB_DIR.'/adodb-iterator.inc.php');
2446 2445
    /**
2447
-	 * RecordSet class that represents the dataset returned by the database.
2448
-	 * To keep memory overhead low, this class holds only the current row in memory.
2449
-	 * No prefetching of data is done, so the RecordCount() can return -1 ( which
2450
-	 * means recordcount not known).
2451
-	 */
2446
+    * RecordSet class that represents the dataset returned by the database.
2447
+    * To keep memory overhead low, this class holds only the current row in memory.
2448
+    * No prefetching of data is done, so the RecordCount() can return -1 ( which
2449
+    * means recordcount not known).
2450
+    */
2452 2451
 	class ADORecordSet extends ADODB_BASE_RS {
2453 2452
 	/*
2454 2453
 	 * public variables
@@ -2809,8 +2808,8 @@  discard block
 block discarded – undo
2809 2808
 
2810 2809
 
2811 2810
 	/**
2812
-	* PEAR DB Compat - do not use internally
2813
-	*/
2811
+	 * PEAR DB Compat - do not use internally
2812
+	 */
2814 2813
 	function Free()
2815 2814
 	{
2816 2815
 		return $this->Close();
@@ -2818,8 +2817,8 @@  discard block
 block discarded – undo
2818 2817
 
2819 2818
 
2820 2819
 	/**
2821
-	* PEAR DB compat, number of rows
2822
-	*/
2820
+	 * PEAR DB compat, number of rows
2821
+	 */
2823 2822
 	function NumRows()
2824 2823
 	{
2825 2824
 		return $this->_numOfRows;
@@ -2827,19 +2826,19 @@  discard block
 block discarded – undo
2827 2826
 
2828 2827
 
2829 2828
 	/**
2830
-	* PEAR DB compat, number of cols
2831
-	*/
2829
+	 * PEAR DB compat, number of cols
2830
+	 */
2832 2831
 	function NumCols()
2833 2832
 	{
2834 2833
 		return $this->_numOfFields;
2835 2834
 	}
2836 2835
 
2837 2836
 	/**
2838
-	* Fetch a row, returning false if no more rows.
2839
-	* This is PEAR DB compat mode.
2840
-	*
2841
-	* @return false or array containing the current record
2842
-	*/
2837
+	 * Fetch a row, returning false if no more rows.
2838
+	 * This is PEAR DB compat mode.
2839
+	 *
2840
+	 * @return false or array containing the current record
2841
+	 */
2843 2842
 	function &FetchRow()
2844 2843
 	{
2845 2844
 		if ($this->EOF) {
@@ -2854,11 +2853,11 @@  discard block
 block discarded – undo
2854 2853
 
2855 2854
 
2856 2855
 	/**
2857
-	* Fetch a row, returning PEAR_Error if no more rows.
2858
-	* This is PEAR DB compat mode.
2859
-	*
2860
-	* @return DB_OK or error object
2861
-	*/
2856
+	 * Fetch a row, returning PEAR_Error if no more rows.
2857
+	 * This is PEAR DB compat mode.
2858
+	 *
2859
+	 * @return DB_OK or error object
2860
+	 */
2862 2861
 	function FetchInto(&$arr)
2863 2862
 	{
2864 2863
 		if ($this->EOF) return (defined('PEAR_ERROR_RETURN')) ? new PEAR_Error('EOF',-1): false;
@@ -3064,13 +3063,13 @@  discard block
 block discarded – undo
3064 3063
 
3065 3064
 
3066 3065
 	 /**
3067
-	 * Portable RecordCount. Pablo Roca <[email protected]>
3068
-	 *
3069
-	 * @return  the number of records from a previous SELECT. All databases support this.
3070
-	 *
3071
-	 * But aware possible problems in multiuser environments. For better speed the table
3072
-	 * must be indexed by the condition. Heavy test this before deploying.
3073
-	 */
3066
+	  * Portable RecordCount. Pablo Roca <[email protected]>
3067
+	  *
3068
+	  * @return  the number of records from a previous SELECT. All databases support this.
3069
+	  *
3070
+	  * But aware possible problems in multiuser environments. For better speed the table
3071
+	  * must be indexed by the condition. Heavy test this before deploying.
3072
+	  */
3074 3073
 	function PO_RecordCount($table="", $condition="") {
3075 3074
 
3076 3075
 		$lnumrows = $this->_numOfRows;
@@ -3129,11 +3128,11 @@  discard block
 block discarded – undo
3129 3128
 	}
3130 3129
 
3131 3130
 	/**
3132
-	* Return the fields array of the current row as an object for convenience.
3133
-	* The default case is lowercase field names.
3134
-	*
3135
-	* @return the object with the properties set to the fields of the current row
3136
-	*/
3131
+	 * Return the fields array of the current row as an object for convenience.
3132
+	 * The default case is lowercase field names.
3133
+	 *
3134
+	 * @return the object with the properties set to the fields of the current row
3135
+	 */
3137 3136
 	function &FetchObj()
3138 3137
 	{
3139 3138
 		$o =& $this->FetchObject(false);
@@ -3141,13 +3140,13 @@  discard block
 block discarded – undo
3141 3140
 	}
3142 3141
 
3143 3142
 	/**
3144
-	* Return the fields array of the current row as an object for convenience.
3145
-	* The default case is uppercase.
3146
-	*
3147
-	* @param $isupper to set the object property names to uppercase
3148
-	*
3149
-	* @return the object with the properties set to the fields of the current row
3150
-	*/
3143
+	 * Return the fields array of the current row as an object for convenience.
3144
+	 * The default case is uppercase.
3145
+	 *
3146
+	 * @param $isupper to set the object property names to uppercase
3147
+	 *
3148
+	 * @return the object with the properties set to the fields of the current row
3149
+	 */
3151 3150
 	function &FetchObject($isupper=true)
3152 3151
 	{
3153 3152
 		if (empty($this->_obj)) {
@@ -3173,14 +3172,14 @@  discard block
 block discarded – undo
3173 3172
 	}
3174 3173
 
3175 3174
 	/**
3176
-	* Return the fields array of the current row as an object for convenience.
3177
-	* The default is lower-case field names.
3178
-	*
3179
-	* @return the object with the properties set to the fields of the current row,
3180
-	* 	or false if EOF
3181
-	*
3182
-	* Fixed bug reported by [email protected]
3183
-	*/
3175
+	 * Return the fields array of the current row as an object for convenience.
3176
+	 * The default is lower-case field names.
3177
+	 *
3178
+	 * @return the object with the properties set to the fields of the current row,
3179
+	 * 	or false if EOF
3180
+	 *
3181
+	 * Fixed bug reported by [email protected]
3182
+	 */
3184 3183
 	function &FetchNextObj()
3185 3184
 	{
3186 3185
 		$o =& $this->FetchNextObject(false);
@@ -3189,16 +3188,16 @@  discard block
 block discarded – undo
3189 3188
 
3190 3189
 
3191 3190
 	/**
3192
-	* Return the fields array of the current row as an object for convenience.
3193
-	* The default is upper case field names.
3194
-	*
3195
-	* @param $isupper to set the object property names to uppercase
3196
-	*
3197
-	* @return the object with the properties set to the fields of the current row,
3198
-	* 	or false if EOF
3199
-	*
3200
-	* Fixed bug reported by [email protected]
3201
-	*/
3191
+	 * Return the fields array of the current row as an object for convenience.
3192
+	 * The default is upper case field names.
3193
+	 *
3194
+	 * @param $isupper to set the object property names to uppercase
3195
+	 *
3196
+	 * @return the object with the properties set to the fields of the current row,
3197
+	 * 	or false if EOF
3198
+	 *
3199
+	 * Fixed bug reported by [email protected]
3200
+	 */
3202 3201
 	function &FetchNextObject($isupper=true)
3203 3202
 	{
3204 3203
 		$o = false;
@@ -3234,7 +3233,7 @@  discard block
 block discarded – undo
3234 3233
 	 *	R for autoincrement counter/integer
3235 3234
 	 *
3236 3235
 	 *
3237
-	*/
3236
+	 */
3238 3237
 	function MetaType($t,$len=-1,$fieldobj=false)
3239 3238
 	{
3240 3239
 		if (is_object($t)) {
Please login to merge, or discard this patch.
Switch Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -1683,17 +1683,17 @@  discard block
 block discarded – undo
1683 1683
 		$rs->tableName = $table;
1684 1684
 
1685 1685
 		switch((string) $mode) {
1686
-		case 'UPDATE':
1687
-		case '2':
1688
-			$sql = $this->GetUpdateSQL($rs, $fields_values, $forceUpdate, $magicq);
1689
-			break;
1690
-		case 'INSERT':
1691
-		case '1':
1692
-			$sql = $this->GetInsertSQL($rs, $fields_values, $magicq);
1693
-			break;
1694
-		default:
1695
-			ADOConnection::outp("AutoExecute: Unknown mode=$mode");
1696
-			return false;
1686
+			case 'UPDATE':
1687
+			case '2':
1688
+				$sql = $this->GetUpdateSQL($rs, $fields_values, $forceUpdate, $magicq);
1689
+				break;
1690
+			case 'INSERT':
1691
+			case '1':
1692
+				$sql = $this->GetInsertSQL($rs, $fields_values, $magicq);
1693
+				break;
1694
+			default:
1695
+				ADOConnection::outp("AutoExecute: Unknown mode=$mode");
1696
+				return false;
1697 1697
 		}
1698 1698
 		$ret = false;
1699 1699
 		if ($sql) $ret = $this->Execute($sql);
@@ -3338,35 +3338,35 @@  discard block
 block discarded – undo
3338 3338
 		$t = strtoupper($t);
3339 3339
 		$tmap = (isset($typeMap[$t])) ? $typeMap[$t] : 'N';
3340 3340
 		switch ($tmap) {
3341
-		case 'C':
3341
+			case 'C':
3342 3342
 
3343
-			// is the char field is too long, return as text field...
3344
-			if ($this->blobSize >= 0) {
3345
-				if ($len > $this->blobSize) return 'X';
3346
-			} else if ($len > 250) {
3347
-				return 'X';
3348
-			}
3349
-			return 'C';
3343
+				// is the char field is too long, return as text field...
3344
+				if ($this->blobSize >= 0) {
3345
+					if ($len > $this->blobSize) return 'X';
3346
+				} else if ($len > 250) {
3347
+					return 'X';
3348
+				}
3349
+				return 'C';
3350 3350
 
3351
-		case 'I':
3352
-			if (!empty($fieldobj->primary_key)) return 'R';
3353
-			return 'I';
3351
+			case 'I':
3352
+				if (!empty($fieldobj->primary_key)) return 'R';
3353
+				return 'I';
3354 3354
 
3355
-		case false:
3356
-			return 'N';
3355
+			case false:
3356
+				return 'N';
3357 3357
 
3358
-		case 'B':
3359
-			 if (isset($fieldobj->binary))
3360
-				 return ($fieldobj->binary) ? 'B' : 'X';
3361
-			return 'B';
3358
+			case 'B':
3359
+			 	if (isset($fieldobj->binary))
3360
+				 	return ($fieldobj->binary) ? 'B' : 'X';
3361
+				return 'B';
3362 3362
 
3363
-		case 'D':
3364
-			if (!empty($this->datetime)) return 'T';
3365
-			return 'D';
3363
+			case 'D':
3364
+				if (!empty($this->datetime)) return 'T';
3365
+				return 'D';
3366 3366
 
3367
-		default:
3368
-			if ($t == 'LONG' && $this->dataProvider == 'oci8') return 'B';
3369
-			return $tmap;
3367
+			default:
3368
+				if ($t == 'LONG' && $this->dataProvider == 'oci8') return 'B';
3369
+				return $tmap;
3370 3370
 		}
3371 3371
 	}
3372 3372
 
@@ -3793,25 +3793,25 @@  discard block
 block discarded – undo
3793 3793
 				if (isset($dsna['port'])) $obj->port = $dsna['port'];
3794 3794
 				foreach($opt as $k => $v) {
3795 3795
 					switch(strtolower($k)) {
3796
-					case 'persist':
3797
-					case 'persistent': 	$persist = $v; break;
3798
-					case 'debug':		$obj->debug = (integer) $v; break;
3799
-					#ibase
3800
-					case 'role':		$obj->role = $v; break;
3801
-					case 'dialect': 	$obj->dialect = (integer) $v; break;
3802
-					case 'charset':		$obj->charset = $v; $obj->charSet=$v; break;
3803
-					case 'buffers':		$obj->buffers = $v; break;
3804
-					case 'fetchmode':   $obj->SetFetchMode($v); break;
3805
-					#ado
3806
-					case 'charpage':	$obj->charPage = $v; break;
3807
-					#mysql, mysqli
3808
-					case 'clientflags': $obj->clientFlags = $v; break;
3809
-					#mysql, mysqli, postgres
3810
-					case 'port': $obj->port = $v; break;
3811
-					#mysqli
3812
-					case 'socket': $obj->socket = $v; break;
3813
-					#oci8
3814
-					case 'nls_date_format': $obj->NLS_DATE_FORMAT = $v; break;
3796
+						case 'persist':
3797
+						case 'persistent': 	$persist = $v; break;
3798
+						case 'debug':		$obj->debug = (integer) $v; break;
3799
+						#ibase
3800
+						case 'role':		$obj->role = $v; break;
3801
+						case 'dialect': 	$obj->dialect = (integer) $v; break;
3802
+						case 'charset':		$obj->charset = $v; $obj->charSet=$v; break;
3803
+						case 'buffers':		$obj->buffers = $v; break;
3804
+						case 'fetchmode':   $obj->SetFetchMode($v); break;
3805
+						#ado
3806
+						case 'charpage':	$obj->charPage = $v; break;
3807
+						#mysql, mysqli
3808
+						case 'clientflags': $obj->clientFlags = $v; break;
3809
+						#mysql, mysqli, postgres
3810
+						case 'port': $obj->port = $v; break;
3811
+						#mysqli
3812
+						case 'socket': $obj->socket = $v; break;
3813
+						#oci8
3814
+						case 'nls_date_format': $obj->NLS_DATE_FORMAT = $v; break;
3815 3815
 					}
3816 3816
 				}
3817 3817
 				if (empty($persist))
@@ -3831,24 +3831,24 @@  discard block
 block discarded – undo
3831 3831
 	function _adodb_getdriver($provider,$drivername,$perf=false)
3832 3832
 	{
3833 3833
 		switch ($provider) {
3834
-		case 'odbtp':   if (strncmp('odbtp_',$drivername,6)==0) return substr($drivername,6);
3835
-		case 'odbc' :   if (strncmp('odbc_',$drivername,5)==0) return substr($drivername,5);
3836
-		case 'ado'  :   if (strncmp('ado_',$drivername,4)==0) return substr($drivername,4);
3837
-		case 'native':  break;
3838
-		default:
3839
-			return $provider;
3834
+			case 'odbtp':   if (strncmp('odbtp_',$drivername,6)==0) return substr($drivername,6);
3835
+			case 'odbc' :   if (strncmp('odbc_',$drivername,5)==0) return substr($drivername,5);
3836
+			case 'ado'  :   if (strncmp('ado_',$drivername,4)==0) return substr($drivername,4);
3837
+			case 'native':  break;
3838
+			default:
3839
+				return $provider;
3840 3840
 		}
3841 3841
 
3842 3842
 		switch($drivername) {
3843
-		case 'firebird15': $drivername = 'firebird'; break;
3844
-		case 'oracle': $drivername = 'oci8'; break;
3845
-		case 'access': if ($perf) $drivername = ''; break;
3846
-		case 'db2'   : break;
3847
-		case 'sapdb' : break;
3848
-		case 'mysqli': $drivername = 'mysql'; break;
3849
-		default:
3850
-			$drivername = 'generic';
3851
-			break;
3843
+			case 'firebird15': $drivername = 'firebird'; break;
3844
+			case 'oracle': $drivername = 'oci8'; break;
3845
+			case 'access': if ($perf) $drivername = ''; break;
3846
+			case 'db2'   : break;
3847
+			case 'sapdb' : break;
3848
+			case 'mysqli': $drivername = 'mysql'; break;
3849
+			default:
3850
+				$drivername = 'generic';
3851
+				break;
3852 3852
 		}
3853 3853
 		return $drivername;
3854 3854
 	}
Please login to merge, or discard this patch.
Spacing   +438 added lines, -438 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
  */
35 35
 
36 36
  if (!defined('_ADODB_LAYER')) {
37
- 	define('_ADODB_LAYER',1);
37
+ 	define('_ADODB_LAYER', 1);
38 38
 
39 39
 	//==============================================================================================
40 40
 	// CONSTANT DEFINITIONS
@@ -45,19 +45,19 @@  discard block
 block discarded – undo
45 45
 	 * Set ADODB_DIR to the directory where this file resides...
46 46
 	 * This constant was formerly called $ADODB_RootPath
47 47
 	 */
48
-	if (!defined('ADODB_DIR')) define('ADODB_DIR',dirname(__FILE__));
48
+	if (!defined('ADODB_DIR')) define('ADODB_DIR', dirname(__FILE__));
49 49
 
50 50
 	//==============================================================================================
51 51
 	// GLOBAL VARIABLES
52 52
 	//==============================================================================================
53 53
 
54 54
 	GLOBAL
55
-		$ADODB_vers, 		// database version
56
-		$ADODB_COUNTRECS,	// count number of records returned - slows down query
57
-		$ADODB_CACHE_DIR,	// directory to cache recordsets
58
-		$ADODB_EXTENSION,   // ADODB extension installed
55
+		$ADODB_vers, // database version
56
+		$ADODB_COUNTRECS, // count number of records returned - slows down query
57
+		$ADODB_CACHE_DIR, // directory to cache recordsets
58
+		$ADODB_EXTENSION, // ADODB extension installed
59 59
 		$ADODB_COMPAT_FETCH, // If $ADODB_COUNTRECS and this is true, $rs->fields is available on EOF
60
-	 	$ADODB_FETCH_MODE;	// DEFAULT, NUM, ASSOC or BOTH. Default follows native driver default...
60
+	 	$ADODB_FETCH_MODE; // DEFAULT, NUM, ASSOC or BOTH. Default follows native driver default...
61 61
 
62 62
 	//==============================================================================================
63 63
 	// GLOBAL SETUP
@@ -75,22 +75,22 @@  discard block
 block discarded – undo
75 75
 		2 = force empty. All empty, php null and string 'null' fields are changed to sql empty '' or 0 values.
76 76
 		3 = force value. Value is left as it is. Php null and string 'null' are set to sql NULL values and empty fields '' are set to empty '' sql values.
77 77
 	*/
78
-        define('ADODB_FORCE_IGNORE',0);
79
-        define('ADODB_FORCE_NULL',1);
80
-        define('ADODB_FORCE_EMPTY',2);
81
-        define('ADODB_FORCE_VALUE',3);
78
+        define('ADODB_FORCE_IGNORE', 0);
79
+        define('ADODB_FORCE_NULL', 1);
80
+        define('ADODB_FORCE_EMPTY', 2);
81
+        define('ADODB_FORCE_VALUE', 3);
82 82
     //********************************************************//
83 83
 
84 84
 
85 85
 	if (!$ADODB_EXTENSION || ADODB_EXTENSION < 4.0) {
86 86
 
87
-		define('ADODB_BAD_RS','<p>Bad $rs in %s. Connection or SQL invalid. Try using $connection->debug=true;</p>');
87
+		define('ADODB_BAD_RS', '<p>Bad $rs in %s. Connection or SQL invalid. Try using $connection->debug=true;</p>');
88 88
 
89 89
 	// allow [ ] @ ` " and . in table names
90
-		define('ADODB_TABLE_REGEX','([]0-9a-z_\:\"\`\.\@\[-]*)');
90
+		define('ADODB_TABLE_REGEX', '([]0-9a-z_\:\"\`\.\@\[-]*)');
91 91
 
92 92
 	// prefetching used by oracle
93
-		if (!defined('ADODB_PREFETCH_ROWS')) define('ADODB_PREFETCH_ROWS',10);
93
+		if (!defined('ADODB_PREFETCH_ROWS')) define('ADODB_PREFETCH_ROWS', 10);
94 94
 
95 95
 
96 96
 	/*
@@ -102,25 +102,25 @@  discard block
 block discarded – undo
102 102
 		2 = use native-case field names. $rs->fields['OrderID']
103 103
 	*/
104 104
 
105
-		define('ADODB_FETCH_DEFAULT',0);
106
-		define('ADODB_FETCH_NUM',1);
107
-		define('ADODB_FETCH_ASSOC',2);
108
-		define('ADODB_FETCH_BOTH',3);
105
+		define('ADODB_FETCH_DEFAULT', 0);
106
+		define('ADODB_FETCH_NUM', 1);
107
+		define('ADODB_FETCH_ASSOC', 2);
108
+		define('ADODB_FETCH_BOTH', 3);
109 109
 
110
-		if (!defined('TIMESTAMP_FIRST_YEAR')) define('TIMESTAMP_FIRST_YEAR',100);
110
+		if (!defined('TIMESTAMP_FIRST_YEAR')) define('TIMESTAMP_FIRST_YEAR', 100);
111 111
 
112 112
 		// PHP's version scheme makes converting to numbers difficult - workaround
113
-		$_adodb_ver = (float) PHP_VERSION;
113
+		$_adodb_ver = (float)PHP_VERSION;
114 114
 		if ($_adodb_ver >= 5.0) {
115
-			define('ADODB_PHPVER',0x5000);
115
+			define('ADODB_PHPVER', 0x5000);
116 116
 		} else if ($_adodb_ver > 4.299999) { # 4.3
117
-			define('ADODB_PHPVER',0x4300);
117
+			define('ADODB_PHPVER', 0x4300);
118 118
 		} else if ($_adodb_ver > 4.199999) { # 4.2
119
-			define('ADODB_PHPVER',0x4200);
120
-		} else if (strnatcmp(PHP_VERSION,'4.0.5')>=0) {
121
-			define('ADODB_PHPVER',0x4050);
119
+			define('ADODB_PHPVER', 0x4200);
120
+		} else if (strnatcmp(PHP_VERSION, '4.0.5') >= 0) {
121
+			define('ADODB_PHPVER', 0x4050);
122 122
 		} else {
123
-			define('ADODB_PHPVER',0x4000);
123
+			define('ADODB_PHPVER', 0x4000);
124 124
 		}
125 125
 	}
126 126
 
@@ -132,12 +132,12 @@  discard block
 block discarded – undo
132 132
 	*/
133 133
 	function ADODB_str_replace($src, $dest, $data)
134 134
 	{
135
-		if (ADODB_PHPVER >= 0x4050) return str_replace($src,$dest,$data);
135
+		if (ADODB_PHPVER >= 0x4050) return str_replace($src, $dest, $data);
136 136
 
137 137
 		$s = reset($src);
138 138
 		$d = reset($dest);
139 139
 		while ($s !== false) {
140
-			$data = str_replace($s,$d,$data);
140
+			$data = str_replace($s, $d, $data);
141 141
 			$s = next($src);
142 142
 			$d = next($dest);
143 143
 		}
@@ -147,9 +147,9 @@  discard block
 block discarded – undo
147 147
 	function ADODB_Setup()
148 148
 	{
149 149
 	GLOBAL
150
-		$ADODB_vers, 		// database version
151
-		$ADODB_COUNTRECS,	// count number of records returned - slows down query
152
-		$ADODB_CACHE_DIR,	// directory to cache recordsets
150
+		$ADODB_vers, // database version
151
+		$ADODB_COUNTRECS, // count number of records returned - slows down query
152
+		$ADODB_CACHE_DIR, // directory to cache recordsets
153 153
 	 	$ADODB_FETCH_MODE,
154 154
 		$ADODB_FORCE_TYPE;
155 155
 
@@ -161,13 +161,13 @@  discard block
 block discarded – undo
161 161
 			$ADODB_CACHE_DIR = '/tmp'; //(isset($_ENV['TMP'])) ? $_ENV['TMP'] : '/tmp';
162 162
 		} else {
163 163
 			// do not accept url based paths, eg. http:/ or ftp:/
164
-			if (strpos($ADODB_CACHE_DIR,'://') !== false)
164
+			if (strpos($ADODB_CACHE_DIR, '://') !== false)
165 165
 				die("Illegal path http:// or ftp://");
166 166
 		}
167 167
 
168 168
 
169 169
 		// Initialize random number generator for randomizing cache flushes
170
-		srand(((double)microtime())*1000000);
170
+		srand(((double)microtime()) * 1000000);
171 171
 
172 172
 		/**
173 173
 		 * ADODB version as a string.
@@ -197,8 +197,8 @@  discard block
 block discarded – undo
197 197
 	 */
198 198
 	class ADOFieldObject {
199 199
 		var $name = '';
200
-		var $max_length=0;
201
-		var $type="";
200
+		var $max_length = 0;
201
+		var $type = "";
202 202
 /*
203 203
 		// additional fields by dannym... ([email protected])
204 204
 		var $not_null = false;
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 		$thisConnection->_transOK = false;
220 220
 		if ($thisConnection->_oldRaiseFn) {
221 221
 			$fn = $thisConnection->_oldRaiseFn;
222
-			$fn($dbms, $fn, $errno, $errmsg, $p1, $p2,$thisConnection);
222
+			$fn($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection);
223 223
 		}
224 224
 	}
225 225
 
@@ -235,25 +235,25 @@  discard block
 block discarded – undo
235 235
 	// PUBLIC VARS
236 236
 	//
237 237
 	var $dataProvider = 'native';
238
-	var $databaseType = '';		/// RDBMS currently in use, eg. odbc, mysql, mssql
239
-	var $database = '';			/// Name of database to be used.
240
-	var $host = ''; 			/// The hostname of the database server
241
-	var $user = ''; 			/// The username which is used to connect to the database server.
242
-	var $password = ''; 		/// Password for the username. For security, we no longer store it.
243
-	var $debug = false; 		/// if set to true will output sql statements
244
-	var $maxblobsize = 262144; 	/// maximum size of blobs or large text fields (262144 = 256K)-- some db's die otherwise like foxpro
238
+	var $databaseType = ''; /// RDBMS currently in use, eg. odbc, mysql, mssql
239
+	var $database = ''; /// Name of database to be used.
240
+	var $host = ''; /// The hostname of the database server
241
+	var $user = ''; /// The username which is used to connect to the database server.
242
+	var $password = ''; /// Password for the username. For security, we no longer store it.
243
+	var $debug = false; /// if set to true will output sql statements
244
+	var $maxblobsize = 262144; /// maximum size of blobs or large text fields (262144 = 256K)-- some db's die otherwise like foxpro
245 245
 	var $concat_operator = '+'; /// default concat operator -- change to || for Oracle/Interbase
246
-	var $substr = 'substr';		/// substring operator
247
-	var $length = 'length';		/// string length ofperator
248
-	var $random = 'rand()';		/// random function
249
-	var $upperCase = 'upper';		/// uppercase function
250
-	var $fmtDate = "'Y-m-d'";	/// used by DBDate() as the default date format used by the database
246
+	var $substr = 'substr'; /// substring operator
247
+	var $length = 'length'; /// string length ofperator
248
+	var $random = 'rand()'; /// random function
249
+	var $upperCase = 'upper'; /// uppercase function
250
+	var $fmtDate = "'Y-m-d'"; /// used by DBDate() as the default date format used by the database
251 251
 	var $fmtTimeStamp = "'Y-m-d, h:i:s A'"; /// used by DBTimeStamp as the default timestamp fmt.
252
-	var $true = '1'; 			/// string that represents TRUE for a database
253
-	var $false = '0'; 			/// string that represents FALSE for a database
254
-	var $replaceQuote = "\\'"; 	/// string to use to replace quotes
255
-	var $nameQuote = '"';		/// string to use to quote identifiers and names
256
-	var $charSet=false; 		/// character set to use - only for interbase, postgres and oci8
252
+	var $true = '1'; /// string that represents TRUE for a database
253
+	var $false = '0'; /// string that represents FALSE for a database
254
+	var $replaceQuote = "\\'"; /// string to use to replace quotes
255
+	var $nameQuote = '"'; /// string to use to quote identifiers and names
256
+	var $charSet = false; /// character set to use - only for interbase, postgres and oci8
257 257
 	var $metaDatabasesSQL = '';
258 258
 	var $metaTablesSQL = '';
259 259
 	var $uniqueOrderBy = false; /// All order by columns have to be unique
@@ -261,17 +261,17 @@  discard block
 block discarded – undo
261 261
 	var $emptyTimeStamp = '&nbsp;';
262 262
 	var $lastInsID = false;
263 263
 	//--
264
-	var $hasInsertID = false; 		/// supports autoincrement ID?
265
-	var $hasAffectedRows = false; 	/// supports affected rows for update/delete?
266
-	var $hasTop = false;			/// support mssql/access SELECT TOP 10 * FROM TABLE
267
-	var $hasLimit = false;			/// support pgsql/mysql SELECT * FROM TABLE LIMIT 10
268
-	var $readOnly = false; 			/// this is a readonly database - used by phpLens
269
-	var $hasMoveFirst = false;  /// has ability to run MoveFirst(), scrolling backwards
270
-	var $hasGenID = false; 		/// can generate sequences using GenID();
264
+	var $hasInsertID = false; /// supports autoincrement ID?
265
+	var $hasAffectedRows = false; /// supports affected rows for update/delete?
266
+	var $hasTop = false; /// support mssql/access SELECT TOP 10 * FROM TABLE
267
+	var $hasLimit = false; /// support pgsql/mysql SELECT * FROM TABLE LIMIT 10
268
+	var $readOnly = false; /// this is a readonly database - used by phpLens
269
+	var $hasMoveFirst = false; /// has ability to run MoveFirst(), scrolling backwards
270
+	var $hasGenID = false; /// can generate sequences using GenID();
271 271
 	var $hasTransactions = true; /// has transactions
272 272
 	//--
273
-	var $genID = 0; 			/// sequence id used by GenID();
274
-	var $raiseErrorFn = false; 	/// error function to call
273
+	var $genID = 0; /// sequence id used by GenID();
274
+	var $raiseErrorFn = false; /// error function to call
275 275
 	var $isoDates = false; /// accepts dates in ISO format
276 276
 	var $cacheSecs = 3600; /// cache for 1 hour
277 277
 	var $sysDate = false; /// name of function that returns the current date
@@ -294,23 +294,23 @@  discard block
 block discarded – undo
294 294
 	var $blobEncodeType = false; // false=not required, 'I'=encode to integer, 'C'=encode to char
295 295
 	var $rsPrefix = "ADORecordSet_";
296 296
 
297
-	var $autoCommit = true; 	/// do not modify this yourself - actually private
298
-	var $transOff = 0; 			/// temporarily disable transactions
299
-	var $transCnt = 0; 			/// count of nested transactions
297
+	var $autoCommit = true; /// do not modify this yourself - actually private
298
+	var $transOff = 0; /// temporarily disable transactions
299
+	var $transCnt = 0; /// count of nested transactions
300 300
 
301
-	var $fetchMode=false;
301
+	var $fetchMode = false;
302 302
 	 //
303 303
 	 // PRIVATE VARS
304 304
 	 //
305
-	var $_oldRaiseFn =  false;
305
+	var $_oldRaiseFn = false;
306 306
 	var $_transOK = null;
307
-	var $_connectionID	= false;	/// The returned link identifier whenever a successful database connection is made.
308
-	var $_errorMsg = false;		/// A variable which was used to keep the returned last error message.  The value will
307
+	var $_connectionID = false; /// The returned link identifier whenever a successful database connection is made.
308
+	var $_errorMsg = false; /// A variable which was used to keep the returned last error message.  The value will
309 309
 								/// then returned by the errorMsg() function
310
-	var $_errorCode = false;	/// Last error code, not guaranteed to be used - only by oci8
311
-	var $_queryID = false;		/// This variable keeps the last created result link identifier
310
+	var $_errorCode = false; /// Last error code, not guaranteed to be used - only by oci8
311
+	var $_queryID = false; /// This variable keeps the last created result link identifier
312 312
 
313
-	var $_isPersistentConnection = false;	/// A boolean variable to state whether its a persistent connection or normal connection.	*/
313
+	var $_isPersistentConnection = false; /// A boolean variable to state whether its a persistent connection or normal connection.	*/
314 314
 	var $_bindInputArray = false; /// set to true if ADOConnection.Execute() permits binding of array parameters.
315 315
 	var $_evalAll = false;
316 316
 	var $_affected = false;
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 	{
331 331
 	global $ADODB_vers;
332 332
 
333
-		return (float) substr($ADODB_vers,1);
333
+		return (float)substr($ADODB_vers, 1);
334 334
 	}
335 335
 
336 336
 	/**
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 
352 352
 	function _findvers($str)
353 353
 	{
354
-		if (preg_match('/([0-9]+\.([0-9\.])+)/',$str, $arr)) return $arr[1];
354
+		if (preg_match('/([0-9]+\.([0-9\.])+)/', $str, $arr)) return $arr[1];
355 355
 		else return '';
356 356
 	}
357 357
 
@@ -359,17 +359,17 @@  discard block
 block discarded – undo
359 359
 	* All error messages go through this bottleneck function.
360 360
 	* You can define your own handler by defining the function name in ADODB_OUTP.
361 361
 	*/
362
-	function outp($msg,$newline=true)
362
+	function outp($msg, $newline = true)
363 363
 	{
364
-	global $ADODB_FLUSH,$ADODB_OUTP;
364
+	global $ADODB_FLUSH, $ADODB_OUTP;
365 365
 
366 366
 		if (defined('ADODB_OUTP')) {
367 367
 			$fn = ADODB_OUTP;
368
-			$fn($msg,$newline);
368
+			$fn($msg, $newline);
369 369
 			return;
370 370
 		} else if (isset($ADODB_OUTP)) {
371 371
 			$fn = $ADODB_OUTP;
372
-			$fn($msg,$newline);
372
+			$fn($msg, $newline);
373 373
 			return;
374 374
 		}
375 375
 
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 
386 386
 	function Time()
387 387
 	{
388
-		$rs =& $this->_Execute("select $this->sysTimeStamp");
388
+		$rs = & $this->_Execute("select $this->sysTimeStamp");
389 389
 		if ($rs && !$rs->EOF) return $this->UnixTimeStamp(reset($rs->fields));
390 390
 
391 391
 		return false;
@@ -411,9 +411,9 @@  discard block
 block discarded – undo
411 411
 
412 412
 		$this->_isPersistentConnection = false;
413 413
 		if ($forceNew) {
414
-			if ($rez=$this->_nconnect($this->host, $this->user, $this->password, $this->database)) return true;
414
+			if ($rez = $this->_nconnect($this->host, $this->user, $this->password, $this->database)) return true;
415 415
 		} else {
416
-			 if ($rez=$this->_connect($this->host, $this->user, $this->password, $this->database)) return true;
416
+			 if ($rez = $this->_connect($this->host, $this->user, $this->password, $this->database)) return true;
417 417
 		}
418 418
 		if (isset($rez)) {
419 419
 			$err = $this->ErrorMsg();
@@ -424,11 +424,11 @@  discard block
 block discarded – undo
424 424
 			$ret = 0;
425 425
 		}
426 426
 		if ($fn = $this->raiseErrorFn)
427
-			$fn($this->databaseType,'CONNECT',$this->ErrorNo(),$err,$this->host,$this->database,$this);
427
+			$fn($this->databaseType, 'CONNECT', $this->ErrorNo(), $err, $this->host, $this->database, $this);
428 428
 
429 429
 
430 430
 		$this->_connectionID = false;
431
-		if ($this->debug) ADOConnection::outp( $this->host.': '.$err);
431
+		if ($this->debug) ADOConnection::outp($this->host.': '.$err);
432 432
 		return $ret;
433 433
 	}
434 434
 
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 	function PConnect($argHostname = "", $argUsername = "", $argPassword = "", $argDatabaseName = "")
467 467
 	{
468 468
 		if (defined('ADODB_NEVER_PERSIST'))
469
-			return $this->Connect($argHostname,$argUsername,$argPassword,$argDatabaseName);
469
+			return $this->Connect($argHostname, $argUsername, $argPassword, $argDatabaseName);
470 470
 
471 471
 		if ($argHostname != "") $this->host = $argHostname;
472 472
 		if ($argUsername != "") $this->user = $argUsername;
@@ -484,16 +484,16 @@  discard block
 block discarded – undo
484 484
 			$ret = 0;
485 485
 		}
486 486
 		if ($fn = $this->raiseErrorFn) {
487
-			$fn($this->databaseType,'PCONNECT',$this->ErrorNo(),$err,$this->host,$this->database,$this);
487
+			$fn($this->databaseType, 'PCONNECT', $this->ErrorNo(), $err, $this->host, $this->database, $this);
488 488
 		}
489 489
 
490 490
 		$this->_connectionID = false;
491
-		if ($this->debug) ADOConnection::outp( $this->host.': '.$err);
491
+		if ($this->debug) ADOConnection::outp($this->host.': '.$err);
492 492
 		return $ret;
493 493
 	}
494 494
 
495 495
 	// Format date column in sql string given an input format that understands Y M D
496
-	function SQLDate($fmt, $col=false)
496
+	function SQLDate($fmt, $col = false)
497 497
 	{
498 498
 		if (!$col) $col = $this->sysDate;
499 499
 		return $col; // child class implement
@@ -533,9 +533,9 @@  discard block
 block discarded – undo
533 533
 	 * 			if the database does not support prepare.
534 534
 	 *
535 535
 	 */
536
-	function PrepareSP($sql,$param=true)
536
+	function PrepareSP($sql, $param = true)
537 537
 	{
538
-		return $this->Prepare($sql,$param);
538
+		return $this->Prepare($sql, $param);
539 539
 	}
540 540
 
541 541
 	/**
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
 	*/
544 544
 	function Quote($s)
545 545
 	{
546
-		return $this->qstr($s,false);
546
+		return $this->qstr($s, false);
547 547
 	}
548 548
 
549 549
 	/**
@@ -551,12 +551,12 @@  discard block
 block discarded – undo
551 551
 	*/
552 552
 	function QMagic($s)
553 553
 	{
554
-		return $this->qstr($s,get_magic_quotes_gpc());
554
+		return $this->qstr($s, get_magic_quotes_gpc());
555 555
 	}
556 556
 
557 557
 	function q(&$s)
558 558
 	{
559
-		$s = $this->qstr($s,false);
559
+		$s = $this->qstr($s, false);
560 560
 	}
561 561
 
562 562
 	/**
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
 	*  @param $table	name of table to lock
584 584
 	*  @param $where	where clause to use, eg: "WHERE row=12". If left empty, will escalate to table lock
585 585
 	*/
586
-	function RowLock($table,$where)
586
+	function RowLock($table, $where)
587 587
 	{
588 588
 		return false;
589 589
 	}
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
 	/**
624 624
 	* PEAR DB Compat - do not use internally.
625 625
 	*/
626
-	function &Query($sql, $inputarr=false)
626
+	function &Query($sql, $inputarr = false)
627 627
 	{
628 628
 		$rs = &$this->Execute($sql, $inputarr);
629 629
 		if (!$rs && defined('ADODB_PEAR')) return ADODB_PEAR_Error();
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
 	/**
635 635
 	* PEAR DB Compat - do not use internally
636 636
 	*/
637
-	function &LimitQuery($sql, $offset, $count, $params=false)
637
+	function &LimitQuery($sql, $offset, $count, $params = false)
638 638
 	{
639 639
 		$rs = &$this->SelectLimit($sql, $count, $offset, $params);
640 640
 		if (!$rs && defined('ADODB_PEAR')) return ADODB_PEAR_Error();
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
 		 For databases that require positioned params, eg $1, $2, $3 for postgresql,
660 660
 		 	pass in Param(false) before setting the first parameter.
661 661
 	*/
662
-	function Param($name,$type='C')
662
+	function Param($name, $type = 'C')
663 663
 	{
664 664
 		return '?';
665 665
 	}
@@ -667,16 +667,16 @@  discard block
 block discarded – undo
667 667
 	/*
668 668
 		InParameter and OutParameter are self-documenting versions of Parameter().
669 669
 	*/
670
-	function InParameter(&$stmt,&$var,$name,$maxLen=4000,$type=false)
670
+	function InParameter(&$stmt, &$var, $name, $maxLen = 4000, $type = false)
671 671
 	{
672
-		return $this->Parameter($stmt,$var,$name,false,$maxLen,$type);
672
+		return $this->Parameter($stmt, $var, $name, false, $maxLen, $type);
673 673
 	}
674 674
 
675 675
 	/*
676 676
 	*/
677
-	function OutParameter(&$stmt,&$var,$name,$maxLen=4000,$type=false)
677
+	function OutParameter(&$stmt, &$var, $name, $maxLen = 4000, $type = false)
678 678
 	{
679
-		return $this->Parameter($stmt,$var,$name,true,$maxLen,$type);
679
+		return $this->Parameter($stmt, $var, $name, true, $maxLen, $type);
680 680
 
681 681
 	}
682 682
 
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
 		@param [$type] The data type of $var. Legal values depend on driver.
696 696
 
697 697
 	*/
698
-	function Parameter(&$stmt,&$var,$name,$isOutput=false,$maxLen=4000,$type=false)
698
+	function Parameter(&$stmt, &$var, $name, $isOutput = false, $maxLen = 4000, $type = false)
699 699
 	{
700 700
 		return false;
701 701
 	}
@@ -790,11 +790,11 @@  discard block
 block discarded – undo
790 790
 	 * @param [inputarr]	holds the input data to bind to. Null elements will be set to null.
791 791
 	 * @return 		RecordSet or false
792 792
 	 */
793
-	function &Execute($sql,$inputarr=false)
793
+	function &Execute($sql, $inputarr = false)
794 794
 	{
795 795
 		if ($this->fnExecute) {
796 796
 			$fn = $this->fnExecute;
797
-			$ret =& $fn($this,$sql,$inputarr);
797
+			$ret = & $fn($this, $sql, $inputarr);
798 798
 			if (isset($ret)) return $ret;
799 799
 		}
800 800
 		if ($inputarr) {
@@ -805,12 +805,12 @@  discard block
 block discarded – undo
805 805
 			$array_2d = is_array($element0) && !is_object(reset($element0));
806 806
 
807 807
 			if (!is_array($sql) && !$this->_bindInputArray) {
808
-				$sqlarr = explode('?',$sql);
808
+				$sqlarr = explode('?', $sql);
809 809
 
810 810
 				if (!$array_2d) $inputarr = array($inputarr);
811
-				foreach($inputarr as $arr) {
811
+				foreach ($inputarr as $arr) {
812 812
 					$sql = ''; $i = 0;
813
-					foreach($arr as $v) {
813
+					foreach ($arr as $v) {
814 814
 						$sql .= $sqlarr[$i];
815 815
 						// from Ron Baldwin <ron.baldwin#sourceprose.com>
816 816
 						// Only quote string types
@@ -818,7 +818,7 @@  discard block
 block discarded – undo
818 818
 						if ($typ == 'string')
819 819
 							$sql .= $this->qstr($v);
820 820
 						else if ($typ == 'double')
821
-							$sql .= str_replace(',','.',$v); // locales fix so 1.1 does not get converted to 1,1
821
+							$sql .= str_replace(',', '.', $v); // locales fix so 1.1 does not get converted to 1,1
822 822
 						else if ($typ == 'boolean')
823 823
 							$sql .= $v ? $this->true : $this->false;
824 824
 						else if ($v === null)
@@ -829,11 +829,11 @@  discard block
 block discarded – undo
829 829
 					}
830 830
 					if (isset($sqlarr[$i])) {
831 831
 						$sql .= $sqlarr[$i];
832
-						if ($i+1 != sizeof($sqlarr)) ADOConnection::outp( "Input Array does not match ?: ".htmlspecialchars($sql));
832
+						if ($i + 1 != sizeof($sqlarr)) ADOConnection::outp("Input Array does not match ?: ".htmlspecialchars($sql));
833 833
 					} else if ($i != sizeof($sqlarr))
834
-						ADOConnection::outp( "Input array does not match ?: ".htmlspecialchars($sql));
834
+						ADOConnection::outp("Input array does not match ?: ".htmlspecialchars($sql));
835 835
 
836
-					$ret =& $this->_Execute($sql);
836
+					$ret = & $this->_Execute($sql);
837 837
 					if (!$ret) return $ret;
838 838
 				}
839 839
 			} else {
@@ -843,31 +843,31 @@  discard block
 block discarded – undo
843 843
 					else
844 844
 						$stmt = $sql;
845 845
 
846
-					foreach($inputarr as $arr) {
847
-						$ret =& $this->_Execute($stmt,$arr);
846
+					foreach ($inputarr as $arr) {
847
+						$ret = & $this->_Execute($stmt, $arr);
848 848
 						if (!$ret) return $ret;
849 849
 					}
850 850
 				} else {
851
-					$ret =& $this->_Execute($sql,$inputarr);
851
+					$ret = & $this->_Execute($sql, $inputarr);
852 852
 				}
853 853
 			}
854 854
 		} else {
855
-			$ret =& $this->_Execute($sql,false);
855
+			$ret = & $this->_Execute($sql, false);
856 856
 		}
857 857
 
858 858
 		return $ret;
859 859
 	}
860 860
 
861 861
 
862
-	function &_Execute($sql,$inputarr=false)
862
+	function &_Execute($sql, $inputarr = false)
863 863
 	{
864 864
 
865 865
 		if ($this->debug) {
866 866
 			global $ADODB_INCLUDED_LIB;
867 867
 			if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
868
-			$this->_queryID = _adodb_debug_execute($this, $sql,$inputarr);
868
+			$this->_queryID = _adodb_debug_execute($this, $sql, $inputarr);
869 869
 		} else {
870
-			$this->_queryID = @$this->_query($sql,$inputarr);
870
+			$this->_queryID = @$this->_query($sql, $inputarr);
871 871
 		}
872 872
 
873 873
 		/************************
@@ -875,10 +875,10 @@  discard block
 block discarded – undo
875 875
 		*************************/
876 876
 
877 877
 		if ($this->_queryID === false) { // error handling if query fails
878
-			if ($this->debug == 99) adodb_backtrace(true,5);
878
+			if ($this->debug == 99) adodb_backtrace(true, 5);
879 879
 			$fn = $this->raiseErrorFn;
880 880
 			if ($fn) {
881
-				$fn($this->databaseType,'EXECUTE',$this->ErrorNo(),$this->ErrorMsg(),$sql,$inputarr,$this);
881
+				$fn($this->databaseType, 'EXECUTE', $this->ErrorNo(), $this->ErrorMsg(), $sql, $inputarr, $this);
882 882
 			}
883 883
 			$false = false;
884 884
 			return $false;
@@ -891,7 +891,7 @@  discard block
 block discarded – undo
891 891
 
892 892
 		// return real recordset from select statement
893 893
 		$rsclass = $this->rsPrefix.$this->databaseType;
894
-		$rs = new $rsclass($this->_queryID,$this->fetchMode);
894
+		$rs = new $rsclass($this->_queryID, $this->fetchMode);
895 895
 		$rs->connection = &$this; // Pablo suggestion
896 896
 		$rs->Init();
897 897
 		if (is_array($sql)) $rs->sql = $sql[0];
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
 		global $ADODB_COUNTRECS;
901 901
 			if ($ADODB_COUNTRECS) {
902 902
 				if (!$rs->EOF) {
903
-					$rs = &$this->_rs2rs($rs,-1,-1,!is_array($sql));
903
+					$rs = &$this->_rs2rs($rs, -1, -1, !is_array($sql));
904 904
 					$rs->_queryID = $this->_queryID;
905 905
 				} else
906 906
 					$rs->_numOfRows = 0;
@@ -909,16 +909,16 @@  discard block
 block discarded – undo
909 909
 		return $rs;
910 910
 	}
911 911
 
912
-	function CreateSequence($seqname='adodbseq',$startID=1)
912
+	function CreateSequence($seqname = 'adodbseq', $startID = 1)
913 913
 	{
914 914
 		if (empty($this->_genSeqSQL)) return false;
915
-		return $this->Execute(sprintf($this->_genSeqSQL,$seqname,$startID));
915
+		return $this->Execute(sprintf($this->_genSeqSQL, $seqname, $startID));
916 916
 	}
917 917
 
918
-	function DropSequence($seqname='adodbseq')
918
+	function DropSequence($seqname = 'adodbseq')
919 919
 	{
920 920
 		if (empty($this->_dropSeqSQL)) return false;
921
-		return $this->Execute(sprintf($this->_dropSeqSQL,$seqname));
921
+		return $this->Execute(sprintf($this->_dropSeqSQL, $seqname));
922 922
 	}
923 923
 
924 924
 	/**
@@ -929,13 +929,13 @@  discard block
 block discarded – undo
929 929
 	 * @param startID		if sequence does not exist, start at this ID
930 930
 	 * @return		0 if not supported, otherwise a sequence id
931 931
 	 */
932
-	function GenID($seqname='adodbseq',$startID=1)
932
+	function GenID($seqname = 'adodbseq', $startID = 1)
933 933
 	{
934 934
 		if (!$this->hasGenID) {
935 935
 			return 0; // formerly returns false pre 1.60
936 936
 		}
937 937
 
938
-		$getnext = sprintf($this->_genIDSQL,$seqname);
938
+		$getnext = sprintf($this->_genIDSQL, $seqname);
939 939
 
940 940
 		$holdtransOK = $this->_transOK;
941 941
 
@@ -946,7 +946,7 @@  discard block
 block discarded – undo
946 946
 
947 947
 		if (!$rs) {
948 948
 			$this->_transOK = $holdtransOK; //if the status was ok before reset
949
-			$createseq = $this->Execute(sprintf($this->_genSeqSQL,$seqname,$startID));
949
+			$createseq = $this->Execute(sprintf($this->_genSeqSQL, $seqname, $startID));
950 950
 			$rs = $this->Execute($getnext);
951 951
 		}
952 952
 		if ($rs && !$rs->EOF) $this->genID = reset($rs->fields);
@@ -962,12 +962,12 @@  discard block
 block discarded – undo
962 962
 	 * @param $column string name of the column, not needed by all databases (eg. mysql), default ''
963 963
 	 * @return  the last inserted ID. Not all databases support this.
964 964
 	 */
965
-	function Insert_ID($table='',$column='')
965
+	function Insert_ID($table = '', $column = '')
966 966
 	{
967 967
 		if ($this->_logsql && $this->lastInsID) return $this->lastInsID;
968
-		if ($this->hasInsertID) return $this->_insertid($table,$column);
968
+		if ($this->hasInsertID) return $this->_insertid($table, $column);
969 969
 		if ($this->debug) {
970
-			ADOConnection::outp( '<p>Insert_ID error</p>');
970
+			ADOConnection::outp('<p>Insert_ID error</p>');
971 971
 			adodb_backtrace();
972 972
 		}
973 973
 		return false;
@@ -980,10 +980,10 @@  discard block
 block discarded – undo
980 980
 	 * @return  the last inserted ID. All databases support this. But aware possible
981 981
 	 * problems in multiuser environments. Heavy test this before deploying.
982 982
 	 */
983
-	function PO_Insert_ID($table="", $id="")
983
+	function PO_Insert_ID($table = "", $id = "")
984 984
 	{
985
-	   if ($this->hasInsertID){
986
-		   return $this->Insert_ID($table,$id);
985
+	   if ($this->hasInsertID) {
986
+		   return $this->Insert_ID($table, $id);
987 987
 	   } else {
988 988
 		   return $this->GetOne("SELECT MAX($id) FROM $table");
989 989
 	   }
@@ -1002,7 +1002,7 @@  discard block
 block discarded – undo
1002 1002
 			return ($val < 0) ? false : $val;
1003 1003
 		}
1004 1004
 
1005
-		if ($this->debug) ADOConnection::outp( '<p>Affected_Rows error</p>',false);
1005
+		if ($this->debug) ADOConnection::outp('<p>Affected_Rows error</p>', false);
1006 1006
 		return false;
1007 1007
 	}
1008 1008
 
@@ -1025,11 +1025,11 @@  discard block
 block discarded – undo
1025 1025
 		return ($this->_errorMsg) ? -1 : 0;
1026 1026
 	}
1027 1027
 
1028
-	function MetaError($err=false)
1028
+	function MetaError($err = false)
1029 1029
 	{
1030 1030
 		include_once(ADODB_DIR."/adodb-error.inc.php");
1031 1031
 		if ($err === false) $err = $this->ErrorNo();
1032
-		return adodb_error($this->dataProvider,$this->databaseType,$err);
1032
+		return adodb_error($this->dataProvider, $this->databaseType, $err);
1033 1033
 	}
1034 1034
 
1035 1035
 	function MetaErrorMsg($errno)
@@ -1041,13 +1041,13 @@  discard block
 block discarded – undo
1041 1041
 	/**
1042 1042
 	 * @returns an array with the primary key columns in it.
1043 1043
 	 */
1044
-	function MetaPrimaryKeys($table, $owner=false)
1044
+	function MetaPrimaryKeys($table, $owner = false)
1045 1045
 	{
1046 1046
 	// owner not used in base class - see oci8
1047 1047
 		$p = array();
1048
-		$objs =& $this->MetaColumns($table);
1048
+		$objs = & $this->MetaColumns($table);
1049 1049
 		if ($objs) {
1050
-			foreach($objs as $v) {
1050
+			foreach ($objs as $v) {
1051 1051
 				if (!empty($v->primary_key))
1052 1052
 					$p[] = $v->name;
1053 1053
 			}
@@ -1061,7 +1061,7 @@  discard block
 block discarded – undo
1061 1061
 	/**
1062 1062
 	 * @returns assoc array where keys are tables, and values are foreign keys
1063 1063
 	 */
1064
-	function MetaForeignKeys($table, $owner=false, $upper=false)
1064
+	function MetaForeignKeys($table, $owner = false, $upper = false)
1065 1065
 	{
1066 1066
 		return false;
1067 1067
 	}
@@ -1072,7 +1072,7 @@  discard block
 block discarded – undo
1072 1072
 	 * @return 		true or false
1073 1073
 	 */
1074 1074
 	function SelectDB($dbName)
1075
-	{return false;}
1075
+	{return false; }
1076 1076
 
1077 1077
 
1078 1078
 	/**
@@ -1094,43 +1094,43 @@  discard block
 block discarded – undo
1094 1094
 	* @param [secs2cache]		is a private parameter only used by jlim
1095 1095
 	* @return		the recordset ($rs->databaseType == 'array')
1096 1096
  	*/
1097
-	function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0)
1097
+	function &SelectLimit($sql, $nrows = -1, $offset = -1, $inputarr = false, $secs2cache = 0)
1098 1098
 	{
1099 1099
 		if ($this->hasTop && $nrows > 0) {
1100 1100
 		// suggested by Reinhard Balling. Access requires top after distinct
1101 1101
 		 // Informix requires first before distinct - F Riosa
1102
-			$ismssql = (strpos($this->databaseType,'mssql') !== false);
1102
+			$ismssql = (strpos($this->databaseType, 'mssql') !== false);
1103 1103
 			if ($ismssql) $isaccess = false;
1104
-			else $isaccess = (strpos($this->databaseType,'access') !== false);
1104
+			else $isaccess = (strpos($this->databaseType, 'access') !== false);
1105 1105
 
1106 1106
 			if ($offset <= 0) {
1107 1107
 
1108 1108
 					// access includes ties in result
1109 1109
 					if ($isaccess) {
1110 1110
 						$sql = preg_replace(
1111
-						'/(^\s*select\s+(distinctrow|distinct)?)/i','\\1 '.$this->hasTop.' '.(int)$nrows.' ',$sql);
1111
+						'/(^\s*select\s+(distinctrow|distinct)?)/i', '\\1 '.$this->hasTop.' '.(int)$nrows.' ', $sql);
1112 1112
 
1113
-						if ($secs2cache>0) {
1114
-							$ret =& $this->CacheExecute($secs2cache, $sql,$inputarr);
1113
+						if ($secs2cache > 0) {
1114
+							$ret = & $this->CacheExecute($secs2cache, $sql, $inputarr);
1115 1115
 						} else {
1116
-							$ret =& $this->Execute($sql,$inputarr);
1116
+							$ret = & $this->Execute($sql, $inputarr);
1117 1117
 						}
1118 1118
 						return $ret; // PHP5 fix
1119
-					} else if ($ismssql){
1119
+					} else if ($ismssql) {
1120 1120
 						$sql = preg_replace(
1121
-						'/(^\s*select\s+(distinctrow|distinct)?)/i','\\1 '.$this->hasTop.' '.(int)$nrows.' ',$sql);
1121
+						'/(^\s*select\s+(distinctrow|distinct)?)/i', '\\1 '.$this->hasTop.' '.(int)$nrows.' ', $sql);
1122 1122
 					} else {
1123 1123
 						$sql = preg_replace(
1124
-						'/(^\s*select\s)/i','\\1 '.$this->hasTop.' '.(int)$nrows.' ',$sql);
1124
+						'/(^\s*select\s)/i', '\\1 '.$this->hasTop.' '.(int)$nrows.' ', $sql);
1125 1125
 					}
1126 1126
 			} else {
1127 1127
 				$nn = $nrows + $offset;
1128 1128
 				if ($isaccess || $ismssql) {
1129 1129
 					$sql = preg_replace(
1130
-					'/(^\s*select\s+(distinctrow|distinct)?)/i','\\1 '.$this->hasTop.' '.$nn.' ',$sql);
1130
+					'/(^\s*select\s+(distinctrow|distinct)?)/i', '\\1 '.$this->hasTop.' '.$nn.' ', $sql);
1131 1131
 				} else {
1132 1132
 					$sql = preg_replace(
1133
-					'/(^\s*select\s)/i','\\1 '.$this->hasTop.' '.$nn.' ',$sql);
1133
+					'/(^\s*select\s)/i', '\\1 '.$this->hasTop.' '.$nn.' ', $sql);
1134 1134
 				}
1135 1135
 			}
1136 1136
 		}
@@ -1142,16 +1142,16 @@  discard block
 block discarded – undo
1142 1142
 		$savec = $ADODB_COUNTRECS;
1143 1143
 		$ADODB_COUNTRECS = false;
1144 1144
 
1145
-		if ($offset>0){
1146
-			if ($secs2cache>0) $rs = &$this->CacheExecute($secs2cache,$sql,$inputarr);
1147
-			else $rs = &$this->Execute($sql,$inputarr);
1145
+		if ($offset > 0) {
1146
+			if ($secs2cache > 0) $rs = &$this->CacheExecute($secs2cache, $sql, $inputarr);
1147
+			else $rs = &$this->Execute($sql, $inputarr);
1148 1148
 		} else {
1149
-			if ($secs2cache>0) $rs = &$this->CacheExecute($secs2cache,$sql,$inputarr);
1150
-			else $rs = &$this->Execute($sql,$inputarr);
1149
+			if ($secs2cache > 0) $rs = &$this->CacheExecute($secs2cache, $sql, $inputarr);
1150
+			else $rs = &$this->Execute($sql, $inputarr);
1151 1151
 		}
1152 1152
 		$ADODB_COUNTRECS = $savec;
1153 1153
 		if ($rs && !$rs->EOF) {
1154
-			$rs =& $this->_rs2rs($rs,(int)$nrows,(int)$offset);
1154
+			$rs = & $this->_rs2rs($rs, (int)$nrows, (int)$offset);
1155 1155
 		}
1156 1156
 		//print_r($rs);
1157 1157
 		return $rs;
@@ -1164,9 +1164,9 @@  discard block
 block discarded – undo
1164 1164
 	*/
1165 1165
 	function &SerializableRS(&$rs)
1166 1166
 	{
1167
-		$rs2 =& $this->_rs2rs($rs);
1167
+		$rs2 = & $this->_rs2rs($rs);
1168 1168
 		$ignore = false;
1169
-		$rs2->connection =& $ignore;
1169
+		$rs2->connection = & $ignore;
1170 1170
 
1171 1171
 		return $rs2;
1172 1172
 	}
@@ -1181,15 +1181,15 @@  discard block
 block discarded – undo
1181 1181
 	* @param [offset] 	offset by number of rows (optional)
1182 1182
 	* @return 			the new recordset
1183 1183
 	*/
1184
-	function &_rs2rs(&$rs,$nrows=-1,$offset=-1,$close=true)
1184
+	function &_rs2rs(&$rs, $nrows = -1, $offset = -1, $close = true)
1185 1185
 	{
1186
-		if (! $rs) {
1186
+		if (!$rs) {
1187 1187
 			$false = false;
1188 1188
 			return $false;
1189 1189
 		}
1190 1190
 		$dbtype = $rs->databaseType;
1191 1191
 		if (!$dbtype) {
1192
-			$rs = &$rs;  // required to prevent crashing in 4.2.1, but does not happen in 4.3.1 -- why ?
1192
+			$rs = &$rs; // required to prevent crashing in 4.2.1, but does not happen in 4.3.1 -- why ?
1193 1193
 			return $rs;
1194 1194
 		}
1195 1195
 		if (($dbtype == 'array' || $dbtype == 'csv') && $nrows == -1 && $offset == -1) {
@@ -1198,11 +1198,11 @@  discard block
 block discarded – undo
1198 1198
 			return $rs;
1199 1199
 		}
1200 1200
 		$flds = array();
1201
-		for ($i=0, $max=$rs->FieldCount(); $i < $max; $i++) {
1201
+		for ($i = 0, $max = $rs->FieldCount(); $i < $max; $i++) {
1202 1202
 			$flds[] = $rs->FetchField($i);
1203 1203
 		}
1204 1204
 
1205
-		$arr =& $rs->GetArrayLimit($nrows,$offset);
1205
+		$arr = & $rs->GetArrayLimit($nrows, $offset);
1206 1206
 		//print_r($arr);
1207 1207
 		if ($close) $rs->Close();
1208 1208
 
@@ -1212,7 +1212,7 @@  discard block
 block discarded – undo
1212 1212
 		$rs2->connection = &$this;
1213 1213
 		$rs2->sql = $rs->sql;
1214 1214
 		$rs2->dataProvider = $this->dataProvider;
1215
-		$rs2->InitArrayFields($arr,$flds);
1215
+		$rs2->InitArrayFields($arr, $flds);
1216 1216
 		$rs2->fetchMode = isset($rs->adodbFetchMode) ? $rs->adodbFetchMode : $rs->fetchMode;
1217 1217
 		return $rs2;
1218 1218
 	}
@@ -1220,35 +1220,35 @@  discard block
 block discarded – undo
1220 1220
 	/*
1221 1221
 	* Return all rows. Compat with PEAR DB
1222 1222
 	*/
1223
-	function &GetAll($sql, $inputarr=false)
1223
+	function &GetAll($sql, $inputarr = false)
1224 1224
 	{
1225
-		$arr =& $this->GetArray($sql,$inputarr);
1225
+		$arr = & $this->GetArray($sql, $inputarr);
1226 1226
 		return $arr;
1227 1227
 	}
1228 1228
 
1229
-	function &GetAssoc($sql, $inputarr=false,$force_array = false, $first2cols = false)
1229
+	function &GetAssoc($sql, $inputarr = false, $force_array = false, $first2cols = false)
1230 1230
 	{
1231
-		$rs =& $this->Execute($sql, $inputarr);
1231
+		$rs = & $this->Execute($sql, $inputarr);
1232 1232
 		if (!$rs) {
1233 1233
 			$false = false;
1234 1234
 			return $false;
1235 1235
 		}
1236
-		$arr =& $rs->GetAssoc($force_array,$first2cols);
1236
+		$arr = & $rs->GetAssoc($force_array, $first2cols);
1237 1237
 		return $arr;
1238 1238
 	}
1239 1239
 
1240
-	function &CacheGetAssoc($secs2cache, $sql=false, $inputarr=false,$force_array = false, $first2cols = false)
1240
+	function &CacheGetAssoc($secs2cache, $sql = false, $inputarr = false, $force_array = false, $first2cols = false)
1241 1241
 	{
1242 1242
 		if (!is_numeric($secs2cache)) {
1243 1243
 			$first2cols = $force_array;
1244 1244
 			$force_array = $inputarr;
1245 1245
 		}
1246
-		$rs =& $this->CacheExecute($secs2cache, $sql, $inputarr);
1246
+		$rs = & $this->CacheExecute($secs2cache, $sql, $inputarr);
1247 1247
 		if (!$rs) {
1248 1248
 			$false = false;
1249 1249
 			return $false;
1250 1250
 		}
1251
-		$arr =& $rs->GetAssoc($force_array,$first2cols);
1251
+		$arr = & $rs->GetAssoc($force_array, $first2cols);
1252 1252
 		return $arr;
1253 1253
 	}
1254 1254
 
@@ -1259,14 +1259,14 @@  discard block
 block discarded – undo
1259 1259
 	* @param sql			SQL statement
1260 1260
 	* @param [inputarr]		input bind array
1261 1261
 	*/
1262
-	function GetOne($sql,$inputarr=false)
1262
+	function GetOne($sql, $inputarr = false)
1263 1263
 	{
1264 1264
 	global $ADODB_COUNTRECS;
1265 1265
 		$crecs = $ADODB_COUNTRECS;
1266 1266
 		$ADODB_COUNTRECS = false;
1267 1267
 
1268 1268
 		$ret = false;
1269
-		$rs = &$this->Execute($sql,$inputarr);
1269
+		$rs = &$this->Execute($sql, $inputarr);
1270 1270
 		if ($rs) {
1271 1271
 			if (!$rs->EOF) $ret = reset($rs->fields);
1272 1272
 			$rs->Close();
@@ -1275,10 +1275,10 @@  discard block
 block discarded – undo
1275 1275
 		return $ret;
1276 1276
 	}
1277 1277
 
1278
-	function CacheGetOne($secs2cache,$sql=false,$inputarr=false)
1278
+	function CacheGetOne($secs2cache, $sql = false, $inputarr = false)
1279 1279
 	{
1280 1280
 		$ret = false;
1281
-		$rs = &$this->CacheExecute($secs2cache,$sql,$inputarr);
1281
+		$rs = &$this->CacheExecute($secs2cache, $sql, $inputarr);
1282 1282
 		if ($rs) {
1283 1283
 			if (!$rs->EOF) $ret = reset($rs->fields);
1284 1284
 			$rs->Close();
@@ -1309,7 +1309,7 @@  discard block
 block discarded – undo
1309 1309
 	  	return $rv;
1310 1310
 	}
1311 1311
 
1312
-	function CacheGetCol($secs, $sql = false, $inputarr = false,$trim=false)
1312
+	function CacheGetCol($secs, $sql = false, $inputarr = false, $trim = false)
1313 1313
 	{
1314 1314
 	  	$rv = false;
1315 1315
 	  	$rs = &$this->CacheExecute($secs, $sql, $inputarr);
@@ -1337,7 +1337,7 @@  discard block
 block discarded – undo
1337 1337
 
1338 1338
 		If dayFraction=1.5 means 1.5 days from now, 1.0/24 for 1 hour.
1339 1339
 	*/
1340
-	function OffsetDate($dayFraction,$date=false)
1340
+	function OffsetDate($dayFraction, $date = false)
1341 1341
 	{
1342 1342
 		if (!$date) $date = $this->sysDate;
1343 1343
 		return  '('.$date.'+'.$dayFraction.')';
@@ -1349,13 +1349,13 @@  discard block
 block discarded – undo
1349 1349
 	* @param sql			SQL statement
1350 1350
 	* @param [inputarr]		input bind array
1351 1351
 	*/
1352
-	function &GetArray($sql,$inputarr=false)
1352
+	function &GetArray($sql, $inputarr = false)
1353 1353
 	{
1354 1354
 	global $ADODB_COUNTRECS;
1355 1355
 
1356 1356
 		$savec = $ADODB_COUNTRECS;
1357 1357
 		$ADODB_COUNTRECS = false;
1358
-		$rs =& $this->Execute($sql,$inputarr);
1358
+		$rs = & $this->Execute($sql, $inputarr);
1359 1359
 		$ADODB_COUNTRECS = $savec;
1360 1360
 		if (!$rs)
1361 1361
 			if (defined('ADODB_PEAR')) return ADODB_PEAR_Error();
@@ -1363,23 +1363,23 @@  discard block
 block discarded – undo
1363 1363
 				$false = false;
1364 1364
 				return $false;
1365 1365
 			}
1366
-		$arr =& $rs->GetArray();
1366
+		$arr = & $rs->GetArray();
1367 1367
 		$rs->Close();
1368 1368
 		return $arr;
1369 1369
 	}
1370 1370
 
1371
-	function &CacheGetAll($secs2cache,$sql=false,$inputarr=false)
1371
+	function &CacheGetAll($secs2cache, $sql = false, $inputarr = false)
1372 1372
 	{
1373
-		return $this->CacheGetArray($secs2cache,$sql,$inputarr);
1373
+		return $this->CacheGetArray($secs2cache, $sql, $inputarr);
1374 1374
 	}
1375 1375
 
1376
-	function &CacheGetArray($secs2cache,$sql=false,$inputarr=false)
1376
+	function &CacheGetArray($secs2cache, $sql = false, $inputarr = false)
1377 1377
 	{
1378 1378
 	global $ADODB_COUNTRECS;
1379 1379
 
1380 1380
 		$savec = $ADODB_COUNTRECS;
1381 1381
 		$ADODB_COUNTRECS = false;
1382
-		$rs =& $this->CacheExecute($secs2cache,$sql,$inputarr);
1382
+		$rs = & $this->CacheExecute($secs2cache, $sql, $inputarr);
1383 1383
 		$ADODB_COUNTRECS = $savec;
1384 1384
 
1385 1385
 		if (!$rs)
@@ -1388,7 +1388,7 @@  discard block
 block discarded – undo
1388 1388
 				$false = false;
1389 1389
 				return $false;
1390 1390
 			}
1391
-		$arr =& $rs->GetArray();
1391
+		$arr = & $rs->GetArray();
1392 1392
 		$rs->Close();
1393 1393
 		return $arr;
1394 1394
 	}
@@ -1401,13 +1401,13 @@  discard block
 block discarded – undo
1401 1401
 	* @param sql			SQL statement
1402 1402
 	* @param [inputarr]		input bind array
1403 1403
 	*/
1404
-	function &GetRow($sql,$inputarr=false)
1404
+	function &GetRow($sql, $inputarr = false)
1405 1405
 	{
1406 1406
 	global $ADODB_COUNTRECS;
1407 1407
 		$crecs = $ADODB_COUNTRECS;
1408 1408
 		$ADODB_COUNTRECS = false;
1409 1409
 
1410
-		$rs =& $this->Execute($sql,$inputarr);
1410
+		$rs = & $this->Execute($sql, $inputarr);
1411 1411
 
1412 1412
 		$ADODB_COUNTRECS = $crecs;
1413 1413
 		if ($rs) {
@@ -1421,9 +1421,9 @@  discard block
 block discarded – undo
1421 1421
 		return $false;
1422 1422
 	}
1423 1423
 
1424
-	function &CacheGetRow($secs2cache,$sql=false,$inputarr=false)
1424
+	function &CacheGetRow($secs2cache, $sql = false, $inputarr = false)
1425 1425
 	{
1426
-		$rs =& $this->CacheExecute($secs2cache,$sql,$inputarr);
1426
+		$rs = & $this->CacheExecute($secs2cache, $sql, $inputarr);
1427 1427
 		if ($rs) {
1428 1428
 			$arr = false;
1429 1429
 			if (!$rs->EOF) $arr = $rs->fields;
@@ -1454,7 +1454,7 @@  discard block
 block discarded – undo
1454 1454
 	* returns 0 = fail, 1 = update, 2 = insert
1455 1455
 	*/
1456 1456
 
1457
-	function Replace($table, $fieldArray, $keyCol, $autoQuote=false, $has_autoinc=false)
1457
+	function Replace($table, $fieldArray, $keyCol, $autoQuote = false, $has_autoinc = false)
1458 1458
 	{
1459 1459
 		global $ADODB_INCLUDED_LIB;
1460 1460
 		if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
@@ -1481,16 +1481,16 @@  discard block
 block discarded – undo
1481 1481
 	* @param [inputarr]	array of bind variables
1482 1482
 	* @return		the recordset ($rs->databaseType == 'array')
1483 1483
  	*/
1484
-	function &CacheSelectLimit($secs2cache,$sql,$nrows=-1,$offset=-1,$inputarr=false)
1484
+	function &CacheSelectLimit($secs2cache, $sql, $nrows = -1, $offset = -1, $inputarr = false)
1485 1485
 	{
1486 1486
 		if (!is_numeric($secs2cache)) {
1487 1487
 			if ($sql === false) $sql = -1;
1488 1488
 			if ($offset == -1) $offset = false;
1489 1489
 									  // sql,	nrows, offset,inputarr
1490
-			$rs =& $this->SelectLimit($secs2cache,$sql,$nrows,$offset,$this->cacheSecs);
1490
+			$rs = & $this->SelectLimit($secs2cache, $sql, $nrows, $offset, $this->cacheSecs);
1491 1491
 		} else {
1492
-			if ($sql === false) ADOConnection::outp( "Warning: \$sql missing from CacheSelectLimit()");
1493
-			$rs =& $this->SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache);
1492
+			if ($sql === false) ADOConnection::outp("Warning: \$sql missing from CacheSelectLimit()");
1493
+			$rs = & $this->SelectLimit($sql, $nrows, $offset, $inputarr, $secs2cache);
1494 1494
 		}
1495 1495
 		return $rs;
1496 1496
 	}
@@ -1499,20 +1499,20 @@  discard block
 block discarded – undo
1499 1499
 	* Flush cached recordsets that match a particular $sql statement.
1500 1500
 	* If $sql == false, then we purge all files in the cache.
1501 1501
  	*/
1502
-	function CacheFlush($sql=false,$inputarr=false)
1502
+	function CacheFlush($sql = false, $inputarr = false)
1503 1503
 	{
1504 1504
 	global $ADODB_CACHE_DIR;
1505 1505
 
1506 1506
 		if (strlen($ADODB_CACHE_DIR) > 1 && !$sql) {
1507
-			if (strncmp(PHP_OS,'WIN',3) === 0) {
1508
-				$cmd = 'del /s '.str_replace('/','\\',$ADODB_CACHE_DIR).'\adodb_*.cache';
1507
+			if (strncmp(PHP_OS, 'WIN', 3) === 0) {
1508
+				$cmd = 'del /s '.str_replace('/', '\\', $ADODB_CACHE_DIR).'\adodb_*.cache';
1509 1509
 			} else {
1510 1510
 				//$cmd = 'find "'.$ADODB_CACHE_DIR.'" -type f -maxdepth 1 -print0 | xargs -0 rm -f';
1511 1511
 				$cmd = 'rm -rf '.$ADODB_CACHE_DIR.'/[0-9a-f][0-9a-f]/';
1512 1512
 				// old version 'rm -f `find '.$ADODB_CACHE_DIR.' -name adodb_*.cache`';
1513 1513
 			}
1514 1514
 			if ($this->debug) {
1515
-				ADOConnection::outp( "CacheFlush: $cmd<br><pre>\n", system($cmd),"</pre>");
1515
+				ADOConnection::outp("CacheFlush: $cmd<br><pre>\n", system($cmd), "</pre>");
1516 1516
 			} else {
1517 1517
 				exec($cmd);
1518 1518
 			}
@@ -1522,10 +1522,10 @@  discard block
 block discarded – undo
1522 1522
 		global $ADODB_INCLUDED_CSV;
1523 1523
 		if (empty($ADODB_INCLUDED_CSV)) include_once(ADODB_DIR.'/adodb-csvlib.inc.php');
1524 1524
 
1525
-		$f = $this->_gencachename($sql.serialize($inputarr),false);
1526
-		adodb_write_file($f,''); // is adodb_write_file needed?
1525
+		$f = $this->_gencachename($sql.serialize($inputarr), false);
1526
+		adodb_write_file($f, ''); // is adodb_write_file needed?
1527 1527
 		if (!@unlink($f)) {
1528
-			if ($this->debug) ADOConnection::outp( "CacheFlush: failed for $f");
1528
+			if ($this->debug) ADOConnection::outp("CacheFlush: failed for $f");
1529 1529
 		}
1530 1530
 	}
1531 1531
 
@@ -1543,7 +1543,7 @@  discard block
 block discarded – undo
1543 1543
 	* Assuming that we can have 50,000 files per directory with good performance,
1544 1544
 	* then we can scale to 12.8 million unique cached recordsets. Wow!
1545 1545
  	*/
1546
-	function _gencachename($sql,$createdir)
1546
+	function _gencachename($sql, $createdir)
1547 1547
 	{
1548 1548
 	global $ADODB_CACHE_DIR;
1549 1549
 	static $notSafeMode;
@@ -1557,12 +1557,12 @@  discard block
 block discarded – undo
1557 1557
 		$m = md5($sql.$this->databaseType.$this->database.$this->user.$mode);
1558 1558
 
1559 1559
 		if (!isset($notSafeMode)) $notSafeMode = !ini_get('safe_mode');
1560
-		$dir = ($notSafeMode) ? $ADODB_CACHE_DIR.'/'.substr($m,0,2) : $ADODB_CACHE_DIR;
1560
+		$dir = ($notSafeMode) ? $ADODB_CACHE_DIR.'/'.substr($m, 0, 2) : $ADODB_CACHE_DIR;
1561 1561
 
1562 1562
 		if ($createdir && $notSafeMode && !file_exists($dir)) {
1563 1563
 			$oldu = umask(0);
1564
-			if (!mkdir($dir,0771))
1565
-				if ($this->debug) ADOConnection::outp( "Unable to mkdir $dir for $sql");
1564
+			if (!mkdir($dir, 0771))
1565
+				if ($this->debug) ADOConnection::outp("Unable to mkdir $dir for $sql");
1566 1566
 			umask($oldu);
1567 1567
 		}
1568 1568
 		return $dir.'/adodb_'.$m.'.cache';
@@ -1578,7 +1578,7 @@  discard block
 block discarded – undo
1578 1578
 	 * @param [inputarr]	holds the input data  to bind to
1579 1579
 	 * @return 		RecordSet or false
1580 1580
 	 */
1581
-	function &CacheExecute($secs2cache,$sql=false,$inputarr=false)
1581
+	function &CacheExecute($secs2cache, $sql = false, $inputarr = false)
1582 1582
 	{
1583 1583
 
1584 1584
 
@@ -1597,14 +1597,14 @@  discard block
 block discarded – undo
1597 1597
 		global $ADODB_INCLUDED_CSV;
1598 1598
 		if (empty($ADODB_INCLUDED_CSV)) include_once(ADODB_DIR.'/adodb-csvlib.inc.php');
1599 1599
 
1600
-		$md5file = $this->_gencachename($sql.serialize($inputarr),true);
1600
+		$md5file = $this->_gencachename($sql.serialize($inputarr), true);
1601 1601
 		$err = '';
1602 1602
 
1603
-		if ($secs2cache > 0){
1604
-			$rs = &csv2rs($md5file,$err,$secs2cache,$this->arrayClass);
1603
+		if ($secs2cache > 0) {
1604
+			$rs = &csv2rs($md5file, $err, $secs2cache, $this->arrayClass);
1605 1605
 			$this->numCacheHits += 1;
1606 1606
 		} else {
1607
-			$err='Timeout 1';
1607
+			$err = 'Timeout 1';
1608 1608
 			$rs = false;
1609 1609
 			$this->numCacheMisses += 1;
1610 1610
 		}
@@ -1614,21 +1614,21 @@  discard block
 block discarded – undo
1614 1614
 				if (get_magic_quotes_runtime()) {
1615 1615
 					ADOConnection::outp("Please disable magic_quotes_runtime - it corrupts cache files :(");
1616 1616
 				}
1617
-				if ($this->debug !== -1) ADOConnection::outp( " $md5file cache failure: $err (see sql below)");
1617
+				if ($this->debug !== -1) ADOConnection::outp(" $md5file cache failure: $err (see sql below)");
1618 1618
 			}
1619 1619
 
1620
-			$rs = &$this->Execute($sqlparam,$inputarr);
1620
+			$rs = &$this->Execute($sqlparam, $inputarr);
1621 1621
 
1622 1622
 			if ($rs) {
1623 1623
 				$eof = $rs->EOF;
1624 1624
 				$rs = &$this->_rs2rs($rs); // read entire recordset into memory immediately
1625
-				$txt = _rs2serialize($rs,false,$sql); // serialize
1625
+				$txt = _rs2serialize($rs, false, $sql); // serialize
1626 1626
 
1627
-				if (!adodb_write_file($md5file,$txt,$this->debug)) {
1627
+				if (!adodb_write_file($md5file, $txt, $this->debug)) {
1628 1628
 					if ($fn = $this->raiseErrorFn) {
1629
-						$fn($this->databaseType,'CacheExecute',-32000,"Cache write error",$md5file,$sql,$this);
1629
+						$fn($this->databaseType, 'CacheExecute', -32000, "Cache write error", $md5file, $sql, $this);
1630 1630
 					}
1631
-					if ($this->debug) ADOConnection::outp( " Cache write error");
1631
+					if ($this->debug) ADOConnection::outp(" Cache write error");
1632 1632
 				}
1633 1633
 				if ($rs->EOF && !$eof) {
1634 1634
 					$rs->MoveFirst();
@@ -1648,14 +1648,14 @@  discard block
 block discarded – undo
1648 1648
 			}
1649 1649
 		// ok, set cached object found
1650 1650
 			$rs->connection = &$this; // Pablo suggestion
1651
-			if ($this->debug){
1651
+			if ($this->debug) {
1652 1652
 
1653 1653
 				$inBrowser = isset($_SERVER['HTTP_USER_AGENT']);
1654 1654
 				$ttl = $rs->timeCreated + $secs2cache - time();
1655 1655
 				$s = is_array($sql) ? $sql[0] : $sql;
1656 1656
 				if ($inBrowser) $s = '<i>'.htmlspecialchars($s).'</i>';
1657 1657
 
1658
-				ADOConnection::outp( " $md5file reloaded, ttl=$ttl [ $s ]");
1658
+				ADOConnection::outp(" $md5file reloaded, ttl=$ttl [ $s ]");
1659 1659
 			}
1660 1660
 		}
1661 1661
 		return $rs;
@@ -1669,20 +1669,20 @@  discard block
 block discarded – undo
1669 1669
 
1670 1670
 		$forceUpdate means that even if the data has not changed, perform update.
1671 1671
 	 */
1672
-	function& AutoExecute($table, $fields_values, $mode = 'INSERT', $where = FALSE, $forceUpdate=true, $magicq=false)
1672
+	function& AutoExecute($table, $fields_values, $mode = 'INSERT', $where = FALSE, $forceUpdate = true, $magicq = false)
1673 1673
 	{
1674 1674
 		$sql = 'SELECT * FROM '.$table;
1675
-		if ($where!==FALSE) $sql .= ' WHERE '.$where;
1675
+		if ($where !== FALSE) $sql .= ' WHERE '.$where;
1676 1676
 		else if ($mode == 'UPDATE') {
1677 1677
 			ADOConnection::outp('AutoExecute: Illegal mode=UPDATE with empty WHERE clause');
1678 1678
 			return false;
1679 1679
 		}
1680 1680
 
1681
-		$rs =& $this->SelectLimit($sql,1);
1681
+		$rs = & $this->SelectLimit($sql, 1);
1682 1682
 		if (!$rs) return false; // table does not exist
1683 1683
 		$rs->tableName = $table;
1684 1684
 
1685
-		switch((string) $mode) {
1685
+		switch ((string)$mode) {
1686 1686
 		case 'UPDATE':
1687 1687
 		case '2':
1688 1688
 			$sql = $this->GetUpdateSQL($rs, $fields_values, $forceUpdate, $magicq);
@@ -1713,7 +1713,7 @@  discard block
 block discarded – undo
1713 1713
 	 *
1714 1714
 	 * "Jonathan Younger" <[email protected]>
1715 1715
   	 */
1716
-	function GetUpdateSQL(&$rs, $arrFields,$forceUpdate=false,$magicq=false,$force=null)
1716
+	function GetUpdateSQL(&$rs, $arrFields, $forceUpdate = false, $magicq = false, $force = null)
1717 1717
 	{
1718 1718
 		global $ADODB_INCLUDED_LIB;
1719 1719
 
@@ -1727,7 +1727,7 @@  discard block
 block discarded – undo
1727 1727
 		//********************************************************//
1728 1728
 
1729 1729
 		if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
1730
-		return _adodb_getupdatesql($this,$rs,$arrFields,$forceUpdate,$magicq,$force);
1730
+		return _adodb_getupdatesql($this, $rs, $arrFields, $forceUpdate, $magicq, $force);
1731 1731
 	}
1732 1732
 
1733 1733
 
@@ -1741,7 +1741,7 @@  discard block
 block discarded – undo
1741 1741
 	 * Note: This function should only be used on a recordset
1742 1742
 	 *	   that is run against a single table.
1743 1743
   	 */
1744
-	function GetInsertSQL(&$rs, $arrFields,$magicq=false,$force=null)
1744
+	function GetInsertSQL(&$rs, $arrFields, $magicq = false, $force = null)
1745 1745
 	{
1746 1746
 		global $ADODB_INCLUDED_LIB;
1747 1747
 		if (!isset($force)) {
@@ -1750,7 +1750,7 @@  discard block
 block discarded – undo
1750 1750
 
1751 1751
 		}
1752 1752
 		if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
1753
-		return _adodb_getinsertsql($this,$rs,$arrFields,$magicq,$force);
1753
+		return _adodb_getinsertsql($this, $rs, $arrFields, $magicq, $force);
1754 1754
 	}
1755 1755
 
1756 1756
 
@@ -1773,9 +1773,9 @@  discard block
 block discarded – undo
1773 1773
 	*	$conn->UpdateBlob('blobtable','blobcol',$blob,'id=1');
1774 1774
 	*/
1775 1775
 
1776
-	function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB')
1776
+	function UpdateBlob($table, $column, $val, $where, $blobtype = 'BLOB')
1777 1777
 	{
1778
-		return $this->Execute("UPDATE $table SET $column=? WHERE $where",array($val)) != false;
1778
+		return $this->Execute("UPDATE $table SET $column=? WHERE $where", array($val)) != false;
1779 1779
 	}
1780 1780
 
1781 1781
 	/**
@@ -1787,13 +1787,13 @@  discard block
 block discarded – undo
1787 1787
 	*	$conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)');
1788 1788
 	*	$conn->UpdateBlob('blobtable','blobcol',$blobpath,'id=1');
1789 1789
 	*/
1790
-	function UpdateBlobFile($table,$column,$path,$where,$blobtype='BLOB')
1790
+	function UpdateBlobFile($table, $column, $path, $where, $blobtype = 'BLOB')
1791 1791
 	{
1792
-		$fd = fopen($path,'rb');
1792
+		$fd = fopen($path, 'rb');
1793 1793
 		if ($fd === false) return false;
1794
-		$val = fread($fd,filesize($path));
1794
+		$val = fread($fd, filesize($path));
1795 1795
 		fclose($fd);
1796
-		return $this->UpdateBlob($table,$column,$val,$where,$blobtype);
1796
+		return $this->UpdateBlob($table, $column, $val, $where, $blobtype);
1797 1797
 	}
1798 1798
 
1799 1799
 	function BlobDecode($blob)
@@ -1811,12 +1811,12 @@  discard block
 block discarded – undo
1811 1811
 		return false;
1812 1812
 	}
1813 1813
 
1814
-	function IfNull( $field, $ifNull )
1814
+	function IfNull($field, $ifNull)
1815 1815
 	{
1816 1816
 		return " CASE WHEN $field is null THEN $ifNull ELSE $field END ";
1817 1817
 	}
1818 1818
 
1819
-	function LogSQL($enable=true)
1819
+	function LogSQL($enable = true)
1820 1820
 	{
1821 1821
 		include_once(ADODB_DIR.'/adodb-perf.inc.php');
1822 1822
 
@@ -1841,22 +1841,22 @@  discard block
 block discarded – undo
1841 1841
 	*	$conn->Execute('INSERT INTO clobtable (id, clobcol) VALUES (1, null)');
1842 1842
 	*	$conn->UpdateClob('clobtable','clobcol',$clob,'id=1');
1843 1843
 	*/
1844
-	function UpdateClob($table,$column,$val,$where)
1844
+	function UpdateClob($table, $column, $val, $where)
1845 1845
 	{
1846
-		return $this->UpdateBlob($table,$column,$val,$where,'CLOB');
1846
+		return $this->UpdateBlob($table, $column, $val, $where, 'CLOB');
1847 1847
 	}
1848 1848
 
1849 1849
 	// not the fastest implementation - quick and dirty - jlim
1850 1850
 	// for best performance, use the actual $rs->MetaType().
1851
-	function MetaType($t,$len=-1,$fieldobj=false)
1851
+	function MetaType($t, $len = -1, $fieldobj = false)
1852 1852
 	{
1853 1853
 
1854 1854
 		if (empty($this->_metars)) {
1855 1855
 			$rsclass = $this->rsPrefix.$this->databaseType;
1856
-			$this->_metars = new $rsclass(false,$this->fetchMode);
1856
+			$this->_metars = new $rsclass(false, $this->fetchMode);
1857 1857
 		}
1858 1858
 
1859
-		return $this->_metars->MetaType($t,$len,$fieldobj);
1859
+		return $this->_metars->MetaType($t, $len, $fieldobj);
1860 1860
 	}
1861 1861
 
1862 1862
 
@@ -1870,7 +1870,7 @@  discard block
 block discarded – undo
1870 1870
 		switch (strtoupper($locale))
1871 1871
 		{
1872 1872
 			case 'EN':
1873
-				$this->fmtDate="'Y-m-d'";
1873
+				$this->fmtDate = "'Y-m-d'";
1874 1874
 				$this->fmtTimeStamp = "'Y-m-d H:i:s'";
1875 1875
 				break;
1876 1876
 
@@ -1883,17 +1883,17 @@  discard block
 block discarded – undo
1883 1883
 			case 'FR':
1884 1884
 			case 'RO':
1885 1885
 			case 'IT':
1886
-				$this->fmtDate="'d-m-Y'";
1886
+				$this->fmtDate = "'d-m-Y'";
1887 1887
 				$this->fmtTimeStamp = "'d-m-Y H:i:s'";
1888 1888
 				break;
1889 1889
 
1890 1890
 			case 'GE':
1891
-				$this->fmtDate="'d.m.Y'";
1891
+				$this->fmtDate = "'d.m.Y'";
1892 1892
 				$this->fmtTimeStamp = "'d.m.Y H:i:s'";
1893 1893
 				break;
1894 1894
 
1895 1895
 			default:
1896
-				$this->fmtDate="'Y-m-d'";
1896
+				$this->fmtDate = "'Y-m-d'";
1897 1897
 				$this->fmtTimeStamp = "'Y-m-d H:i:s'";
1898 1898
 				break;
1899 1899
 		}
@@ -1915,7 +1915,7 @@  discard block
 block discarded – undo
1915 1915
 	 *
1916 1916
 	 * @return true if succeeded or false if database does not support transactions
1917 1917
 	 */
1918
-	function BeginTrans() {return false;}
1918
+	function BeginTrans() {return false; }
1919 1919
 
1920 1920
 
1921 1921
 	/**
@@ -1925,8 +1925,8 @@  discard block
 block discarded – undo
1925 1925
 	 *
1926 1926
 	 * @return true/false.
1927 1927
 	 */
1928
-	function CommitTrans($ok=true)
1929
-	{ return true;}
1928
+	function CommitTrans($ok = true)
1929
+	{ return true; }
1930 1930
 
1931 1931
 
1932 1932
 	/**
@@ -1935,7 +1935,7 @@  discard block
 block discarded – undo
1935 1935
 	 * @return true/false.
1936 1936
 	 */
1937 1937
 	function RollbackTrans()
1938
-	{ return false;}
1938
+	{ return false; }
1939 1939
 
1940 1940
 
1941 1941
 	/**
@@ -1974,7 +1974,7 @@  discard block
 block discarded – undo
1974 1974
 	 *
1975 1975
 	 * @return  array of tables for current database.
1976 1976
 	 */
1977
-	function &MetaTables($ttype=false,$showSchema=false,$mask=false)
1977
+	function &MetaTables($ttype = false, $showSchema = false, $mask = false)
1978 1978
 	{
1979 1979
 	global $ADODB_FETCH_MODE;
1980 1980
 
@@ -1994,19 +1994,19 @@  discard block
 block discarded – undo
1994 1994
 			$ADODB_FETCH_MODE = $save;
1995 1995
 
1996 1996
 			if ($rs === false) return $false;
1997
-			$arr =& $rs->GetArray();
1997
+			$arr = & $rs->GetArray();
1998 1998
 			$arr2 = array();
1999 1999
 
2000 2000
 			if ($hast = ($ttype && isset($arr[0][1]))) {
2001
-				$showt = strncmp($ttype,'T',1);
2001
+				$showt = strncmp($ttype, 'T', 1);
2002 2002
 			}
2003 2003
 
2004
-			for ($i=0; $i < sizeof($arr); $i++) {
2004
+			for ($i = 0; $i < sizeof($arr); $i++) {
2005 2005
 				if ($hast) {
2006 2006
 					if ($showt == 0) {
2007
-						if (strncmp($arr[$i][1],'T',1) == 0) $arr2[] = trim($arr[$i][0]);
2007
+						if (strncmp($arr[$i][1], 'T', 1) == 0) $arr2[] = trim($arr[$i][0]);
2008 2008
 					} else {
2009
-						if (strncmp($arr[$i][1],'V',1) == 0) $arr2[] = trim($arr[$i][0]);
2009
+						if (strncmp($arr[$i][1], 'V', 1) == 0) $arr2[] = trim($arr[$i][0]);
2010 2010
 					}
2011 2011
 				} else
2012 2012
 					$arr2[] = trim($arr[$i][0]);
@@ -2018,11 +2018,11 @@  discard block
 block discarded – undo
2018 2018
 	}
2019 2019
 
2020 2020
 
2021
-	function _findschema(&$table,&$schema)
2021
+	function _findschema(&$table, &$schema)
2022 2022
 	{
2023
-		if (!$schema && ($at = strpos($table,'.')) !== false) {
2024
-			$schema = substr($table,0,$at);
2025
-			$table = substr($table,$at+1);
2023
+		if (!$schema && ($at = strpos($table, '.')) !== false) {
2024
+			$schema = substr($table, 0, $at);
2025
+			$table = substr($table, $at + 1);
2026 2026
 		}
2027 2027
 	}
2028 2028
 
@@ -2036,7 +2036,7 @@  discard block
 block discarded – undo
2036 2036
 	 *
2037 2037
 	 * @return  array of ADOFieldObjects for current table.
2038 2038
 	 */
2039
-	function &MetaColumns($table,$upper=true)
2039
+	function &MetaColumns($table, $upper = true)
2040 2040
 	{
2041 2041
 	global $ADODB_FETCH_MODE;
2042 2042
 
@@ -2045,12 +2045,12 @@  discard block
 block discarded – undo
2045 2045
 		if (!empty($this->metaColumnsSQL)) {
2046 2046
 
2047 2047
 			$schema = false;
2048
-			$this->_findschema($table,$schema);
2048
+			$this->_findschema($table, $schema);
2049 2049
 
2050 2050
 			$save = $ADODB_FETCH_MODE;
2051 2051
 			$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
2052 2052
 			if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
2053
-			$rs = $this->Execute(sprintf($this->metaColumnsSQL,($upper)?strtoupper($table):$table));
2053
+			$rs = $this->Execute(sprintf($this->metaColumnsSQL, ($upper) ? strtoupper($table) : $table));
2054 2054
 			if (isset($savem)) $this->SetFetchMode($savem);
2055 2055
 			$ADODB_FETCH_MODE = $save;
2056 2056
 			if ($rs === false || $rs->EOF) return $false;
@@ -2061,9 +2061,9 @@  discard block
 block discarded – undo
2061 2061
 				$fld->name = $rs->fields[0];
2062 2062
 				$fld->type = $rs->fields[1];
2063 2063
 				if (isset($rs->fields[3]) && $rs->fields[3]) {
2064
-					if ($rs->fields[3]>0) $fld->max_length = $rs->fields[3];
2064
+					if ($rs->fields[3] > 0) $fld->max_length = $rs->fields[3];
2065 2065
 					$fld->scale = $rs->fields[4];
2066
-					if ($fld->scale>0) $fld->max_length += 1;
2066
+					if ($fld->scale > 0) $fld->max_length += 1;
2067 2067
 				} else
2068 2068
 					$fld->max_length = $rs->fields[2];
2069 2069
 
@@ -2107,9 +2107,9 @@  discard block
 block discarded – undo
2107 2107
 	 *
2108 2108
 	 * @return  array of column names for current table.
2109 2109
 	 */
2110
-	function &MetaColumnNames($table, $numIndexes=false)
2110
+	function &MetaColumnNames($table, $numIndexes = false)
2111 2111
 	{
2112
-		$objarr =& $this->MetaColumns($table);
2112
+		$objarr = & $this->MetaColumns($table);
2113 2113
 		if (!is_array($objarr)) {
2114 2114
 			$false = false;
2115 2115
 			return $false;
@@ -2117,9 +2117,9 @@  discard block
 block discarded – undo
2117 2117
 		$arr = array();
2118 2118
 		if ($numIndexes) {
2119 2119
 			$i = 0;
2120
-			foreach($objarr as $v) $arr[$i++] = $v->name;
2120
+			foreach ($objarr as $v) $arr[$i++] = $v->name;
2121 2121
 		} else
2122
-			foreach($objarr as $v) $arr[strtoupper($v->name)] = $v->name;
2122
+			foreach ($objarr as $v) $arr[strtoupper($v->name)] = $v->name;
2123 2123
 
2124 2124
 		return $arr;
2125 2125
 	}
@@ -2153,12 +2153,12 @@  discard block
 block discarded – undo
2153 2153
 		if (empty($d) && $d !== 0) return 'null';
2154 2154
 
2155 2155
 		if (is_string($d) && !is_numeric($d)) {
2156
-			if ($d === 'null' || strncmp($d,"'",1) === 0) return $d;
2156
+			if ($d === 'null' || strncmp($d, "'", 1) === 0) return $d;
2157 2157
 			if ($this->isoDates) return "'$d'";
2158 2158
 			$d = ADOConnection::UnixDate($d);
2159 2159
 		}
2160 2160
 
2161
-		return adodb_date($this->fmtDate,$d);
2161
+		return adodb_date($this->fmtDate, $d);
2162 2162
 	}
2163 2163
 
2164 2164
 
@@ -2174,14 +2174,14 @@  discard block
 block discarded – undo
2174 2174
 		if (empty($ts) && $ts !== 0) return 'null';
2175 2175
 
2176 2176
 		# strlen(14) allows YYYYMMDDHHMMSS format
2177
-		if (!is_string($ts) || (is_numeric($ts) && strlen($ts)<14))
2178
-			return adodb_date($this->fmtTimeStamp,$ts);
2177
+		if (!is_string($ts) || (is_numeric($ts) && strlen($ts) < 14))
2178
+			return adodb_date($this->fmtTimeStamp, $ts);
2179 2179
 
2180 2180
 		if ($ts === 'null') return $ts;
2181 2181
 		if ($this->isoDates && strlen($ts) !== 14) return "'$ts'";
2182 2182
 
2183 2183
 		$ts = ADOConnection::UnixTimeStamp($ts);
2184
-		return adodb_date($this->fmtTimeStamp,$ts);
2184
+		return adodb_date($this->fmtTimeStamp, $ts);
2185 2185
 	}
2186 2186
 
2187 2187
 	/**
@@ -2195,16 +2195,16 @@  discard block
 block discarded – undo
2195 2195
 		if (is_object($v)) {
2196 2196
 		// odbtp support
2197 2197
 		//( [year] => 2004 [month] => 9 [day] => 4 [hour] => 12 [minute] => 44 [second] => 8 [fraction] => 0 )
2198
-			return adodb_mktime($v->hour,$v->minute,$v->second,$v->month,$v->day, $v->year);
2198
+			return adodb_mktime($v->hour, $v->minute, $v->second, $v->month, $v->day, $v->year);
2199 2199
 		}
2200 2200
 
2201 2201
 		if (is_numeric($v) && strlen($v) !== 8) return $v;
2202
-		if (!preg_match( "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})|",
2202
+		if (!preg_match("|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})|",
2203 2203
 			($v), $rr)) return false;
2204 2204
 
2205 2205
 		if ($rr[1] <= TIMESTAMP_FIRST_YEAR) return 0;
2206 2206
 		// h-m-s-MM-DD-YY
2207
-		return @adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]);
2207
+		return @adodb_mktime(0, 0, 0, $rr[2], $rr[3], $rr[1]);
2208 2208
 	}
2209 2209
 
2210 2210
 
@@ -2219,18 +2219,18 @@  discard block
 block discarded – undo
2219 2219
 		if (is_object($v)) {
2220 2220
 		// odbtp support
2221 2221
 		//( [year] => 2004 [month] => 9 [day] => 4 [hour] => 12 [minute] => 44 [second] => 8 [fraction] => 0 )
2222
-			return adodb_mktime($v->hour,$v->minute,$v->second,$v->month,$v->day, $v->year);
2222
+			return adodb_mktime($v->hour, $v->minute, $v->second, $v->month, $v->day, $v->year);
2223 2223
 		}
2224 2224
 
2225 2225
 		if (!preg_match(
2226 2226
 			"|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})[ ,-]*(([0-9]{1,2}):?([0-9]{1,2}):?([0-9\.]{1,4}))?|",
2227 2227
 			($v), $rr)) return false;
2228 2228
 
2229
-		if ($rr[1] <= TIMESTAMP_FIRST_YEAR && $rr[2]<= 1) return 0;
2229
+		if ($rr[1] <= TIMESTAMP_FIRST_YEAR && $rr[2] <= 1) return 0;
2230 2230
 
2231 2231
 		// h-m-s-MM-DD-YY
2232
-		if (!isset($rr[5])) return  adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]);
2233
-		return  @adodb_mktime($rr[5],$rr[6],$rr[7],$rr[2],$rr[3],$rr[1]);
2232
+		if (!isset($rr[5])) return  adodb_mktime(0, 0, 0, $rr[2], $rr[3], $rr[1]);
2233
+		return  @adodb_mktime($rr[5], $rr[6], $rr[7], $rr[2], $rr[3], $rr[1]);
2234 2234
 	}
2235 2235
 
2236 2236
 	/**
@@ -2244,7 +2244,7 @@  discard block
 block discarded – undo
2244 2244
 	 * @return a date formated as user desires
2245 2245
 	 */
2246 2246
 
2247
-	function UserDate($v,$fmt='Y-m-d',$gmt=false)
2247
+	function UserDate($v, $fmt = 'Y-m-d', $gmt = false)
2248 2248
 	{
2249 2249
 		$tt = $this->UnixDate($v);
2250 2250
 
@@ -2254,7 +2254,7 @@  discard block
 block discarded – undo
2254 2254
 		else if ($tt == -1) { // pre-TIMESTAMP_FIRST_YEAR
2255 2255
 		}
2256 2256
 
2257
-		return ($gmt) ? adodb_gmdate($fmt,$tt) : adodb_date($fmt,$tt);
2257
+		return ($gmt) ? adodb_gmdate($fmt, $tt) : adodb_date($fmt, $tt);
2258 2258
 
2259 2259
 	}
2260 2260
 
@@ -2265,46 +2265,46 @@  discard block
 block discarded – undo
2265 2265
 	 *
2266 2266
 	 * @return a timestamp formated as user desires
2267 2267
 	 */
2268
-	function UserTimeStamp($v,$fmt='Y-m-d H:i:s',$gmt=false)
2268
+	function UserTimeStamp($v, $fmt = 'Y-m-d H:i:s', $gmt = false)
2269 2269
 	{
2270 2270
 		if (!isset($v)) return $this->emptyTimeStamp;
2271 2271
 		# strlen(14) allows YYYYMMDDHHMMSS format
2272
-		if (is_numeric($v) && strlen($v)<14) return ($gmt) ? adodb_gmdate($fmt,$v) : adodb_date($fmt,$v);
2272
+		if (is_numeric($v) && strlen($v) < 14) return ($gmt) ? adodb_gmdate($fmt, $v) : adodb_date($fmt, $v);
2273 2273
 		$tt = $this->UnixTimeStamp($v);
2274 2274
 		// $tt == -1 if pre TIMESTAMP_FIRST_YEAR
2275 2275
 		if (($tt === false || $tt == -1) && $v != false) return $v;
2276 2276
 		if ($tt == 0) return $this->emptyTimeStamp;
2277
-		return ($gmt) ? adodb_gmdate($fmt,$tt) : adodb_date($fmt,$tt);
2277
+		return ($gmt) ? adodb_gmdate($fmt, $tt) : adodb_date($fmt, $tt);
2278 2278
 	}
2279 2279
 
2280
-	function escape($s,$magic_quotes=false)
2280
+	function escape($s, $magic_quotes = false)
2281 2281
 	{
2282
-		return $this->addq($s,$magic_quotes);
2282
+		return $this->addq($s, $magic_quotes);
2283 2283
 	}
2284 2284
 
2285 2285
 	/**
2286 2286
 	* Quotes a string, without prefixing nor appending quotes.
2287 2287
 	*/
2288
-	function addq($s,$magic_quotes=false)
2288
+	function addq($s, $magic_quotes = false)
2289 2289
 	{
2290 2290
 		if (!$magic_quotes) {
2291 2291
 
2292
-			if ($this->replaceQuote[0] == '\\'){
2292
+			if ($this->replaceQuote[0] == '\\') {
2293 2293
 				// only since php 4.0.5
2294
-				$s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s);
2294
+				$s = adodb_str_replace(array('\\', "\0"), array('\\\\', "\\\0"), $s);
2295 2295
 				//$s = str_replace("\0","\\\0", str_replace('\\','\\\\',$s));
2296 2296
 			}
2297
-			return  str_replace("'",$this->replaceQuote,$s);
2297
+			return  str_replace("'", $this->replaceQuote, $s);
2298 2298
 		}
2299 2299
 
2300 2300
 		// undo magic quotes for "
2301
-		$s = str_replace('\\"','"',$s);
2301
+		$s = str_replace('\\"', '"', $s);
2302 2302
 
2303 2303
 		if ($this->replaceQuote == "\\'")  // ' already quoted, no need to change anything
2304 2304
 			return $s;
2305 2305
 		else {// change \' to '' for sybase/mssql
2306
-			$s = str_replace('\\\\','\\',$s);
2307
-			return str_replace("\\'",$this->replaceQuote,$s);
2306
+			$s = str_replace('\\\\', '\\', $s);
2307
+			return str_replace("\\'", $this->replaceQuote, $s);
2308 2308
 		}
2309 2309
 	}
2310 2310
 
@@ -2319,26 +2319,26 @@  discard block
 block discarded – undo
2319 2319
 	 *
2320 2320
 	 * @return  quoted string to be sent back to database
2321 2321
 	 */
2322
-	function qstr($s,$magic_quotes=false)
2322
+	function qstr($s, $magic_quotes = false)
2323 2323
 	{
2324 2324
 		if (!$magic_quotes) {
2325 2325
 
2326
-			if ($this->replaceQuote[0] == '\\'){
2326
+			if ($this->replaceQuote[0] == '\\') {
2327 2327
 				// only since php 4.0.5
2328
-				$s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s);
2328
+				$s = adodb_str_replace(array('\\', "\0"), array('\\\\', "\\\0"), $s);
2329 2329
 				//$s = str_replace("\0","\\\0", str_replace('\\','\\\\',$s));
2330 2330
 			}
2331
-			return  "'".str_replace("'",$this->replaceQuote,$s)."'";
2331
+			return  "'".str_replace("'", $this->replaceQuote, $s)."'";
2332 2332
 		}
2333 2333
 
2334 2334
 		// undo magic quotes for "
2335
-		$s = str_replace('\\"','"',$s);
2335
+		$s = str_replace('\\"', '"', $s);
2336 2336
 
2337 2337
 		if ($this->replaceQuote == "\\'")  // ' already quoted, no need to change anything
2338 2338
 			return "'$s'";
2339 2339
 		else {// change \' to '' for sybase/mssql
2340
-			$s = str_replace('\\\\','\\',$s);
2341
-			return "'".str_replace("\\'",$this->replaceQuote,$s)."'";
2340
+			$s = str_replace('\\\\', '\\', $s);
2341
+			return "'".str_replace("\\'", $this->replaceQuote, $s)."'";
2342 2342
 		}
2343 2343
 	}
2344 2344
 
@@ -2360,12 +2360,12 @@  discard block
 block discarded – undo
2360 2360
 	* NOTE: phpLens uses a different algorithm and does not use PageExecute().
2361 2361
 	*
2362 2362
 	*/
2363
-	function &PageExecute($sql, $nrows, $page, $inputarr=false, $secs2cache=0)
2363
+	function &PageExecute($sql, $nrows, $page, $inputarr = false, $secs2cache = 0)
2364 2364
 	{
2365 2365
 		global $ADODB_INCLUDED_LIB;
2366 2366
 		if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
2367
-		if ($this->pageExecuteCountRows) $rs =& _adodb_pageexecute_all_rows($this, $sql, $nrows, $page, $inputarr, $secs2cache);
2368
-		else $rs =& _adodb_pageexecute_no_last_page($this, $sql, $nrows, $page, $inputarr, $secs2cache);
2367
+		if ($this->pageExecuteCountRows) $rs = & _adodb_pageexecute_all_rows($this, $sql, $nrows, $page, $inputarr, $secs2cache);
2368
+		else $rs = & _adodb_pageexecute_no_last_page($this, $sql, $nrows, $page, $inputarr, $secs2cache);
2369 2369
 		return $rs;
2370 2370
 	}
2371 2371
 
@@ -2382,7 +2382,7 @@  discard block
 block discarded – undo
2382 2382
 	* @param [inputarr]	array of bind variables
2383 2383
 	* @return		the recordset ($rs->databaseType == 'array')
2384 2384
 	*/
2385
-	function &CachePageExecute($secs2cache, $sql, $nrows, $page,$inputarr=false)
2385
+	function &CachePageExecute($secs2cache, $sql, $nrows, $page, $inputarr = false)
2386 2386
 	{
2387 2387
 		/*switch($this->dataProvider) {
2388 2388
 		case 'postgres':
@@ -2390,7 +2390,7 @@  discard block
 block discarded – undo
2390 2390
 			break;
2391 2391
 		default: $secs2cache = 0; break;
2392 2392
 		}*/
2393
-		$rs =& $this->PageExecute($sql,$nrows,$page,$inputarr,$secs2cache);
2393
+		$rs = & $this->PageExecute($sql, $nrows, $page, $inputarr, $secs2cache);
2394 2394
 		return $rs;
2395 2395
 	}
2396 2396
 
@@ -2423,12 +2423,12 @@  discard block
 block discarded – undo
2423 2423
 		var $_numOfRows = 0;
2424 2424
 		var $fields = false;
2425 2425
 		var $connection = false;
2426
-		function RowCount() {return 0;}
2427
-		function RecordCount() {return 0;}
2428
-		function PO_RecordCount(){return 0;}
2429
-		function Close(){return true;}
2430
-		function FetchRow() {return false;}
2431
-		function FieldCount(){ return 0;}
2426
+		function RowCount() {return 0; }
2427
+		function RecordCount() {return 0; }
2428
+		function PO_RecordCount() {return 0; }
2429
+		function Close() {return true; }
2430
+		function FetchRow() {return false; }
2431
+		function FieldCount() { return 0; }
2432 2432
 		function Init() {}
2433 2433
 	}
2434 2434
 
@@ -2454,36 +2454,36 @@  discard block
 block discarded – undo
2454 2454
 	 * public variables
2455 2455
 	 */
2456 2456
 	var $dataProvider = "native";
2457
-	var $fields = false; 	/// holds the current row data
2458
-	var $blobSize = 100; 	/// any varchar/char field this size or greater is treated as a blob
2457
+	var $fields = false; /// holds the current row data
2458
+	var $blobSize = 100; /// any varchar/char field this size or greater is treated as a blob
2459 2459
 							/// in other words, we use a text area for editing.
2460
-	var $canSeek = false; 	/// indicates that seek is supported
2461
-	var $sql; 				/// sql text
2462
-	var $EOF = false;		/// Indicates that the current record position is after the last record in a Recordset object.
2460
+	var $canSeek = false; /// indicates that seek is supported
2461
+	var $sql; /// sql text
2462
+	var $EOF = false; /// Indicates that the current record position is after the last record in a Recordset object.
2463 2463
 
2464 2464
 	var $emptyTimeStamp = '&nbsp;'; /// what to display when $time==0
2465 2465
 	var $emptyDate = '&nbsp;'; /// what to display when $time==0
2466 2466
 	var $debug = false;
2467
-	var $timeCreated=0; 	/// datetime in Unix format rs created -- for cached recordsets
2467
+	var $timeCreated = 0; /// datetime in Unix format rs created -- for cached recordsets
2468 2468
 
2469
-	var $bind = false; 		/// used by Fields() to hold array - should be private?
2470
-	var $fetchMode;			/// default fetch mode
2469
+	var $bind = false; /// used by Fields() to hold array - should be private?
2470
+	var $fetchMode; /// default fetch mode
2471 2471
 	var $connection = false; /// the parent connection
2472 2472
 	/*
2473 2473
 	 *	private variables
2474 2474
 	 */
2475
-	var $_numOfRows = -1;	/** number of rows, or -1 */
2476
-	var $_numOfFields = -1;	/** number of fields in recordset */
2477
-	var $_queryID = -1;		/** This variable keeps the result link identifier.	*/
2478
-	var $_currentRow = -1;	/** This variable keeps the current row in the Recordset.	*/
2479
-	var $_closed = false; 	/** has recordset been closed */
2480
-	var $_inited = false; 	/** Init() should only be called once */
2481
-	var $_obj; 				/** Used by FetchObj */
2482
-	var $_names;			/** Used by FetchObj */
2483
-
2484
-	var $_currentPage = -1;	/** Added by Iv�n Oliva to implement recordset pagination */
2485
-	var $_atFirstPage = false;	/** Added by Iv�n Oliva to implement recordset pagination */
2486
-	var $_atLastPage = false;	/** Added by Iv�n Oliva to implement recordset pagination */
2475
+	var $_numOfRows = -1; /** number of rows, or -1 */
2476
+	var $_numOfFields = -1; /** number of fields in recordset */
2477
+	var $_queryID = -1; /** This variable keeps the result link identifier.	*/
2478
+	var $_currentRow = -1; /** This variable keeps the current row in the Recordset.	*/
2479
+	var $_closed = false; /** has recordset been closed */
2480
+	var $_inited = false; /** Init() should only be called once */
2481
+	var $_obj; /** Used by FetchObj */
2482
+	var $_names; /** Used by FetchObj */
2483
+
2484
+	var $_currentPage = -1; /** Added by Iv�n Oliva to implement recordset pagination */
2485
+	var $_atFirstPage = false; /** Added by Iv�n Oliva to implement recordset pagination */
2486
+	var $_atLastPage = false; /** Added by Iv�n Oliva to implement recordset pagination */
2487 2487
 	var $_lastPageNo = -1;
2488 2488
 	var $_maxRecordCount = 0;
2489 2489
 	var $datetime = false;
@@ -2542,13 +2542,13 @@  discard block
 block discarded – undo
2542 2542
 	 *
2543 2543
 	 * changes by [email protected] to support multiple hilited items
2544 2544
 	 */
2545
-	function GetMenu($name,$defstr='',$blank1stItem=true,$multiple=false,
2546
-			$size=0, $selectAttr='',$compareFields0=true)
2545
+	function GetMenu($name, $defstr = '', $blank1stItem = true, $multiple = false,
2546
+			$size = 0, $selectAttr = '', $compareFields0 = true)
2547 2547
 	{
2548 2548
 		global $ADODB_INCLUDED_LIB;
2549 2549
 		if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
2550
-		return _adodb_getmenu($this, $name,$defstr,$blank1stItem,$multiple,
2551
-			$size, $selectAttr,$compareFields0);
2550
+		return _adodb_getmenu($this, $name, $defstr, $blank1stItem, $multiple,
2551
+			$size, $selectAttr, $compareFields0);
2552 2552
 	}
2553 2553
 
2554 2554
 
@@ -2560,22 +2560,22 @@  discard block
 block discarded – undo
2560 2560
 	 * strings are compared with the SECOND column.
2561 2561
 	 *
2562 2562
 	 */
2563
-	function GetMenu2($name,$defstr='',$blank1stItem=true,$multiple=false,$size=0, $selectAttr='')
2563
+	function GetMenu2($name, $defstr = '', $blank1stItem = true, $multiple = false, $size = 0, $selectAttr = '')
2564 2564
 	{
2565
-		return $this->GetMenu($name,$defstr,$blank1stItem,$multiple,
2566
-			$size, $selectAttr,false);
2565
+		return $this->GetMenu($name, $defstr, $blank1stItem, $multiple,
2566
+			$size, $selectAttr, false);
2567 2567
 	}
2568 2568
 
2569 2569
 	/*
2570 2570
 		Grouped Menu
2571 2571
 	*/
2572
-	function GetMenu3($name,$defstr='',$blank1stItem=true,$multiple=false,
2573
-			$size=0, $selectAttr='')
2572
+	function GetMenu3($name, $defstr = '', $blank1stItem = true, $multiple = false,
2573
+			$size = 0, $selectAttr = '')
2574 2574
 	{
2575 2575
 		global $ADODB_INCLUDED_LIB;
2576 2576
 		if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
2577
-		return _adodb_getmenu_gp($this, $name,$defstr,$blank1stItem,$multiple,
2578
-			$size, $selectAttr,false);
2577
+		return _adodb_getmenu_gp($this, $name, $defstr, $blank1stItem, $multiple,
2578
+			$size, $selectAttr, false);
2579 2579
 	}
2580 2580
 
2581 2581
 	/**
@@ -2587,7 +2587,7 @@  discard block
 block discarded – undo
2587 2587
 	 */
2588 2588
 	function &GetArray($nRows = -1)
2589 2589
 	{
2590
-	global $ADODB_EXTENSION; if ($ADODB_EXTENSION) return adodb_getall($this,$nRows);
2590
+	global $ADODB_EXTENSION; if ($ADODB_EXTENSION) return adodb_getall($this, $nRows);
2591 2591
 
2592 2592
 		$results = array();
2593 2593
 		$cnt = 0;
@@ -2601,7 +2601,7 @@  discard block
 block discarded – undo
2601 2601
 
2602 2602
 	function &GetAll($nRows = -1)
2603 2603
 	{
2604
-		$arr =& $this->GetArray($nRows);
2604
+		$arr = & $this->GetArray($nRows);
2605 2605
 		return $arr;
2606 2606
 	}
2607 2607
 
@@ -2623,10 +2623,10 @@  discard block
 block discarded – undo
2623 2623
 	 *
2624 2624
 	 * @return an array indexed by the rows (0-based) from the recordset
2625 2625
 	 */
2626
-	function &GetArrayLimit($nrows,$offset=-1)
2626
+	function &GetArrayLimit($nrows, $offset = -1)
2627 2627
 	{
2628 2628
 		if ($offset <= 0) {
2629
-			$arr =& $this->GetArray($nrows);
2629
+			$arr = & $this->GetArray($nrows);
2630 2630
 			return $arr;
2631 2631
 		}
2632 2632
 
@@ -2652,7 +2652,7 @@  discard block
 block discarded – undo
2652 2652
 	 */
2653 2653
 	function &GetRows($nRows = -1)
2654 2654
 	{
2655
-		$arr =& $this->GetArray($nRows);
2655
+		$arr = & $this->GetArray($nRows);
2656 2656
 		return $arr;
2657 2657
 	}
2658 2658
 
@@ -2757,14 +2757,14 @@  discard block
 block discarded – undo
2757 2757
 	 *
2758 2758
 	 * @return a timestamp formated as user desires
2759 2759
 	 */
2760
-	function UserTimeStamp($v,$fmt='Y-m-d H:i:s')
2760
+	function UserTimeStamp($v, $fmt = 'Y-m-d H:i:s')
2761 2761
 	{
2762
-		if (is_numeric($v) && strlen($v)<14) return adodb_date($fmt,$v);
2762
+		if (is_numeric($v) && strlen($v) < 14) return adodb_date($fmt, $v);
2763 2763
 		$tt = $this->UnixTimeStamp($v);
2764 2764
 		// $tt == -1 if pre TIMESTAMP_FIRST_YEAR
2765 2765
 		if (($tt === false || $tt == -1) && $v != false) return $v;
2766 2766
 		if ($tt === 0) return $this->emptyTimeStamp;
2767
-		return adodb_date($fmt,$tt);
2767
+		return adodb_date($fmt, $tt);
2768 2768
 	}
2769 2769
 
2770 2770
 
@@ -2774,7 +2774,7 @@  discard block
 block discarded – undo
2774 2774
 	 *
2775 2775
 	 * @return a date formated as user desires
2776 2776
 	 */
2777
-	function UserDate($v,$fmt='Y-m-d')
2777
+	function UserDate($v, $fmt = 'Y-m-d')
2778 2778
 	{
2779 2779
 		$tt = $this->UnixDate($v);
2780 2780
 		// $tt == -1 if pre TIMESTAMP_FIRST_YEAR
@@ -2782,7 +2782,7 @@  discard block
 block discarded – undo
2782 2782
 		else if ($tt == 0) return $this->emptyDate;
2783 2783
 		else if ($tt == -1) { // pre-TIMESTAMP_FIRST_YEAR
2784 2784
 		}
2785
-		return adodb_date($fmt,$tt);
2785
+		return adodb_date($fmt, $tt);
2786 2786
 	}
2787 2787
 
2788 2788
 
@@ -2861,7 +2861,7 @@  discard block
 block discarded – undo
2861 2861
 	*/
2862 2862
 	function FetchInto(&$arr)
2863 2863
 	{
2864
-		if ($this->EOF) return (defined('PEAR_ERROR_RETURN')) ? new PEAR_Error('EOF',-1): false;
2864
+		if ($this->EOF) return (defined('PEAR_ERROR_RETURN')) ? new PEAR_Error('EOF', -1) : false;
2865 2865
 		$arr = $this->fields;
2866 2866
 		$this->MoveNext();
2867 2867
 		return 1; // DB_OK
@@ -2887,7 +2887,7 @@  discard block
 block discarded – undo
2887 2887
 	 */
2888 2888
 	function MoveLast()
2889 2889
 	{
2890
-		if ($this->_numOfRows >= 0) return $this->Move($this->_numOfRows-1);
2890
+		if ($this->_numOfRows >= 0) return $this->Move($this->_numOfRows - 1);
2891 2891
 		if ($this->EOF) return false;
2892 2892
 		while (!$this->EOF) {
2893 2893
 			$f = $this->fields;
@@ -2935,7 +2935,7 @@  discard block
 block discarded – undo
2935 2935
 		$this->EOF = false;
2936 2936
 		if ($rowNumber == $this->_currentRow) return true;
2937 2937
 		if ($rowNumber >= $this->_numOfRows)
2938
-	   		if ($this->_numOfRows != -1) $rowNumber = $this->_numOfRows-2;
2938
+	   		if ($this->_numOfRows != -1) $rowNumber = $this->_numOfRows - 2;
2939 2939
 
2940 2940
 		if ($this->canSeek) {
2941 2941
 
@@ -2957,7 +2957,7 @@  discard block
 block discarded – undo
2957 2957
 				}
2958 2958
 			} else {
2959 2959
 
2960
-				while (! $this->EOF && $this->_currentRow < $rowNumber) {
2960
+				while (!$this->EOF && $this->_currentRow < $rowNumber) {
2961 2961
 					$this->_currentRow++;
2962 2962
 
2963 2963
 					if (!$this->_fetch()) $this->EOF = true;
@@ -2985,10 +2985,10 @@  discard block
 block discarded – undo
2985 2985
 		return $this->fields[$colname];
2986 2986
 	}
2987 2987
 
2988
-	function GetAssocKeys($upper=true)
2988
+	function GetAssocKeys($upper = true)
2989 2989
 	{
2990 2990
 		$this->bind = array();
2991
-		for ($i=0; $i < $this->_numOfFields; $i++) {
2991
+		for ($i = 0; $i < $this->_numOfFields; $i++) {
2992 2992
 			$o = $this->FetchField($i);
2993 2993
 			if ($upper === 2) $this->bind[$o->name] = $i;
2994 2994
 			else $this->bind[($upper) ? strtoupper($o->name) : strtolower($o->name)] = $i;
@@ -3004,7 +3004,7 @@  discard block
 block discarded – undo
3004 3004
    *
3005 3005
    * $upper  0 = lowercase, 1 = uppercase, 2 = whatever is returned by FetchField
3006 3006
    */
3007
-	function &GetRowAssoc($upper=1)
3007
+	function &GetRowAssoc($upper = 1)
3008 3008
 	{
3009 3009
 		$record = array();
3010 3010
 	 //	if (!$this->fields) return $record;
@@ -3013,7 +3013,7 @@  discard block
 block discarded – undo
3013 3013
 			$this->GetAssocKeys($upper);
3014 3014
 		}
3015 3015
 
3016
-		foreach($this->bind as $k => $v) {
3016
+		foreach ($this->bind as $k => $v) {
3017 3017
 			$record[$k] = $this->fields[$v];
3018 3018
 		}
3019 3019
 
@@ -3043,7 +3043,7 @@  discard block
 block discarded – undo
3043 3043
 	 *
3044 3044
 	 * @return the number of rows or -1 if this is not supported
3045 3045
 	 */
3046
-	function RecordCount() {return $this->_numOfRows;}
3046
+	function RecordCount() {return $this->_numOfRows; }
3047 3047
 
3048 3048
 
3049 3049
 	/*
@@ -3060,7 +3060,7 @@  discard block
 block discarded – undo
3060 3060
 	 *
3061 3061
 	 * @return the number of rows or -1 if this is not supported
3062 3062
 	 */
3063
-	function RowCount() {return $this->_numOfRows;}
3063
+	function RowCount() {return $this->_numOfRows; }
3064 3064
 
3065 3065
 
3066 3066
 	 /**
@@ -3071,13 +3071,13 @@  discard block
 block discarded – undo
3071 3071
 	 * But aware possible problems in multiuser environments. For better speed the table
3072 3072
 	 * must be indexed by the condition. Heavy test this before deploying.
3073 3073
 	 */
3074
-	function PO_RecordCount($table="", $condition="") {
3074
+	function PO_RecordCount($table = "", $condition = "") {
3075 3075
 
3076 3076
 		$lnumrows = $this->_numOfRows;
3077 3077
 		// the database doesn't support native recordcount, so we do a workaround
3078 3078
 		if ($lnumrows == -1 && $this->connection) {
3079 3079
 			IF ($table) {
3080
-				if ($condition) $condition = " WHERE " . $condition;
3080
+				if ($condition) $condition = " WHERE ".$condition;
3081 3081
 				$resultrows = &$this->connection->Execute("SELECT COUNT(*) FROM $table $condition");
3082 3082
 				if ($resultrows) $lnumrows = reset($resultrows->fields);
3083 3083
 			}
@@ -3088,20 +3088,20 @@  discard block
 block discarded – undo
3088 3088
 	/**
3089 3089
 	 * @return the current row in the recordset. If at EOF, will return the last row. 0-based.
3090 3090
 	 */
3091
-	function CurrentRow() {return $this->_currentRow;}
3091
+	function CurrentRow() {return $this->_currentRow; }
3092 3092
 
3093 3093
 	/**
3094 3094
 	 * synonym for CurrentRow -- for ADO compat
3095 3095
 	 *
3096 3096
 	 * @return the current row in the recordset. If at EOF, will return the last row. 0-based.
3097 3097
 	 */
3098
-	function AbsolutePosition() {return $this->_currentRow;}
3098
+	function AbsolutePosition() {return $this->_currentRow; }
3099 3099
 
3100 3100
 	/**
3101 3101
 	 * @return the number of columns in the recordset. Some databases will set this to 0
3102 3102
 	 * if no records are returned, others will return the number of columns in the query.
3103 3103
 	 */
3104
-	function FieldCount() {return $this->_numOfFields;}
3104
+	function FieldCount() {return $this->_numOfFields; }
3105 3105
 
3106 3106
 
3107 3107
 	/**
@@ -3123,7 +3123,7 @@  discard block
 block discarded – undo
3123 3123
 	function& FieldTypesArray()
3124 3124
 	{
3125 3125
 		$arr = array();
3126
-		for ($i=0, $max=$this->_numOfFields; $i < $max; $i++)
3126
+		for ($i = 0, $max = $this->_numOfFields; $i < $max; $i++)
3127 3127
 			$arr[] = $this->FetchField($i);
3128 3128
 		return $arr;
3129 3129
 	}
@@ -3136,7 +3136,7 @@  discard block
 block discarded – undo
3136 3136
 	*/
3137 3137
 	function &FetchObj()
3138 3138
 	{
3139
-		$o =& $this->FetchObject(false);
3139
+		$o = & $this->FetchObject(false);
3140 3140
 		return $o;
3141 3141
 	}
3142 3142
 
@@ -3148,12 +3148,12 @@  discard block
 block discarded – undo
3148 3148
 	*
3149 3149
 	* @return the object with the properties set to the fields of the current row
3150 3150
 	*/
3151
-	function &FetchObject($isupper=true)
3151
+	function &FetchObject($isupper = true)
3152 3152
 	{
3153 3153
 		if (empty($this->_obj)) {
3154 3154
 			$this->_obj = new ADOFetchObj();
3155 3155
 			$this->_names = array();
3156
-			for ($i=0; $i <$this->_numOfFields; $i++) {
3156
+			for ($i = 0; $i < $this->_numOfFields; $i++) {
3157 3157
 				$f = $this->FetchField($i);
3158 3158
 				$this->_names[] = $f->name;
3159 3159
 			}
@@ -3162,7 +3162,7 @@  discard block
 block discarded – undo
3162 3162
 		if (PHP_VERSION >= 5) $o = clone($this->_obj);
3163 3163
 		else $o = $this->_obj;
3164 3164
 
3165
-		for ($i=0; $i <$this->_numOfFields; $i++) {
3165
+		for ($i = 0; $i < $this->_numOfFields; $i++) {
3166 3166
 			$name = $this->_names[$i];
3167 3167
 			if ($isupper) $n = strtoupper($name);
3168 3168
 			else $n = $name;
@@ -3183,7 +3183,7 @@  discard block
 block discarded – undo
3183 3183
 	*/
3184 3184
 	function &FetchNextObj()
3185 3185
 	{
3186
-		$o =& $this->FetchNextObject(false);
3186
+		$o = & $this->FetchNextObject(false);
3187 3187
 		return $o;
3188 3188
 	}
3189 3189
 
@@ -3199,7 +3199,7 @@  discard block
 block discarded – undo
3199 3199
 	*
3200 3200
 	* Fixed bug reported by [email protected]
3201 3201
 	*/
3202
-	function &FetchNextObject($isupper=true)
3202
+	function &FetchNextObject($isupper = true)
3203 3203
 	{
3204 3204
 		$o = false;
3205 3205
 		if ($this->_numOfRows != 0 && !$this->EOF) {
@@ -3235,7 +3235,7 @@  discard block
 block discarded – undo
3235 3235
 	 *
3236 3236
 	 *
3237 3237
 	*/
3238
-	function MetaType($t,$len=-1,$fieldobj=false)
3238
+	function MetaType($t, $len = -1, $fieldobj = false)
3239 3239
 	{
3240 3240
 		if (is_object($t)) {
3241 3241
 			$fieldobj = $t;
@@ -3254,7 +3254,7 @@  discard block
 block discarded – undo
3254 3254
 		'VARYING' => 'C',
3255 3255
 		'BPCHAR' => 'C',
3256 3256
 		'CHARACTER' => 'C',
3257
-		'INTERVAL' => 'C',  # Postgres
3257
+		'INTERVAL' => 'C', # Postgres
3258 3258
 		##
3259 3259
 		'LONGCHAR' => 'X',
3260 3260
 		'TEXT' => 'X',
@@ -3375,7 +3375,7 @@  discard block
 block discarded – undo
3375 3375
 	/**
3376 3376
 	 * set/returns the current recordset page when paginating
3377 3377
 	 */
3378
-	function AbsolutePage($page=-1)
3378
+	function AbsolutePage($page = -1)
3379 3379
 	{
3380 3380
 		if ($page != -1) $this->_currentPage = $page;
3381 3381
 		return $this->_currentPage;
@@ -3384,7 +3384,7 @@  discard block
 block discarded – undo
3384 3384
 	/**
3385 3385
 	 * set/returns the status of the atFirstPage flag when paginating
3386 3386
 	 */
3387
-	function AtFirstPage($status=false)
3387
+	function AtFirstPage($status = false)
3388 3388
 	{
3389 3389
 		if ($status != false) $this->_atFirstPage = $status;
3390 3390
 		return $this->_atFirstPage;
@@ -3399,7 +3399,7 @@  discard block
 block discarded – undo
3399 3399
 	/**
3400 3400
 	 * set/returns the status of the atLastPage flag when paginating
3401 3401
 	 */
3402
-	function AtLastPage($status=false)
3402
+	function AtLastPage($status = false)
3403 3403
 	{
3404 3404
 		if ($status != false) $this->_atLastPage = $status;
3405 3405
 		return $this->_atLastPage;
@@ -3411,14 +3411,14 @@  discard block
 block discarded – undo
3411 3411
 	 * @param $fetchmode=null ADODB_FETCH_{DEFAULT|ASSOC|NUM|BOTH}, default is to use currently selected fetch-mode
3412 3412
 	 * @return array|boolean false if there's nothing to fetch
3413 3413
 	 */
3414
-	function &fetch($fetchmode=null)
3414
+	function &fetch($fetchmode = null)
3415 3415
 	{
3416 3416
 		if (!is_null($fetchmode))
3417 3417
 		{
3418 3418
 			$save = $this->fetchMode;
3419 3419
 			$this->fetchMode = $fetchmode;
3420 3420
 		}
3421
-		$row =& $this->FetchRow();
3421
+		$row = & $this->FetchRow();
3422 3422
 		if (!is_null($fetchmode))
3423 3423
 		{
3424 3424
 			$this->fetchMode = $save;
@@ -3432,9 +3432,9 @@  discard block
 block discarded – undo
3432 3432
 	 * @param int $column_number=0
3433 3433
 	 * @return string|boolean false if there's nothing to fetch
3434 3434
 	 */
3435
-	function fetchColumn($column_number=0)
3435
+	function fetchColumn($column_number = 0)
3436 3436
 	{
3437
-		if(!($row = $this->FetchRow()))
3437
+		if (!($row = $this->FetchRow()))
3438 3438
 		{
3439 3439
 			return false;
3440 3440
 		}
@@ -3476,10 +3476,10 @@  discard block
 block discarded – undo
3476 3476
 	{
3477 3477
 		var $databaseType = 'array';
3478 3478
 
3479
-		var $_array; 	// holds the 2-dimensional data array
3480
-		var $_types;	// the array of types of each column (C B I L M)
3481
-		var $_colnames;	// names of each column in array
3482
-		var $_skiprow1;	// skip 1st row because it holds column names
3479
+		var $_array; // holds the 2-dimensional data array
3480
+		var $_types; // the array of types of each column (C B I L M)
3481
+		var $_colnames; // names of each column in array
3482
+		var $_skiprow1; // skip 1st row because it holds column names
3483 3483
 		var $_fieldarr; // holds array of field objects
3484 3484
 		var $canSeek = true;
3485 3485
 		var $affectedrows = false;
@@ -3490,9 +3490,9 @@  discard block
 block discarded – undo
3490 3490
 		 * Constructor
3491 3491
 		 *
3492 3492
 		 */
3493
-		function ADORecordSet_array($fakeid=1)
3493
+		function ADORecordSet_array($fakeid = 1)
3494 3494
 		{
3495
-		global $ADODB_FETCH_MODE,$ADODB_COMPAT_FETCH;
3495
+		global $ADODB_FETCH_MODE, $ADODB_COMPAT_FETCH;
3496 3496
 
3497 3497
 			// fetch() on EOF does not delete $this->fields
3498 3498
 			$this->compat = !empty($ADODB_COMPAT_FETCH);
@@ -3512,14 +3512,14 @@  discard block
 block discarded – undo
3512 3512
 		 * @param [colnames]	array of column names. If set, then the first row of
3513 3513
 		 *			$array should not hold the column names.
3514 3514
 		 */
3515
-		function InitArray($array,$typearr,$colnames=false)
3515
+		function InitArray($array, $typearr, $colnames = false)
3516 3516
 		{
3517 3517
 			$this->_array = $array;
3518 3518
 			$this->_types = $typearr;
3519 3519
 			if ($colnames) {
3520 3520
 				$this->_skiprow1 = false;
3521 3521
 				$this->_colnames = $colnames;
3522
-			} else  {
3522
+			} else {
3523 3523
 				$this->_skiprow1 = true;
3524 3524
 				$this->_colnames = $array[0];
3525 3525
 			}
@@ -3533,33 +3533,33 @@  discard block
 block discarded – undo
3533 3533
 		 *			unless paramter $colnames is used.
3534 3534
 		 * @param fieldarr	holds an array of ADOFieldObject's.
3535 3535
 		 */
3536
-		function InitArrayFields(&$array,&$fieldarr)
3536
+		function InitArrayFields(&$array, &$fieldarr)
3537 3537
 		{
3538
-			$this->_array =& $array;
3539
-			$this->_skiprow1= false;
3538
+			$this->_array = & $array;
3539
+			$this->_skiprow1 = false;
3540 3540
 			if ($fieldarr) {
3541
-				$this->_fieldobjects =& $fieldarr;
3541
+				$this->_fieldobjects = & $fieldarr;
3542 3542
 			}
3543 3543
 			$this->Init();
3544 3544
 		}
3545 3545
 
3546
-		function &GetArray($nRows=-1)
3546
+		function &GetArray($nRows = -1)
3547 3547
 		{
3548 3548
 			if ($nRows == -1 && $this->_currentRow <= 0 && !$this->_skiprow1) {
3549 3549
 				return $this->_array;
3550 3550
 			} else {
3551
-				$arr =& ADORecordSet::GetArray($nRows);
3551
+				$arr = & ADORecordSet::GetArray($nRows);
3552 3552
 				return $arr;
3553 3553
 			}
3554 3554
 		}
3555 3555
 
3556 3556
 		function _initrs()
3557 3557
 		{
3558
-			$this->_numOfRows =  sizeof($this->_array);
3558
+			$this->_numOfRows = sizeof($this->_array);
3559 3559
 			if ($this->_skiprow1) $this->_numOfRows -= 1;
3560 3560
 
3561
-			$this->_numOfFields =(isset($this->_fieldobjects)) ?
3562
-				 sizeof($this->_fieldobjects):sizeof($this->_types);
3561
+			$this->_numOfFields = (isset($this->_fieldobjects)) ?
3562
+				 sizeof($this->_fieldobjects) : sizeof($this->_types);
3563 3563
 		}
3564 3564
 
3565 3565
 		/* Use associative array to get fields array */
@@ -3567,13 +3567,13 @@  discard block
 block discarded – undo
3567 3567
 		{
3568 3568
 			$mode = isset($this->adodbFetchMode) ? $this->adodbFetchMode : $this->fetchMode;
3569 3569
 
3570
-			if ($mode & ADODB_FETCH_ASSOC) {
3570
+			if ($mode&ADODB_FETCH_ASSOC) {
3571 3571
 				if (!isset($this->fields[$colname])) $colname = strtolower($colname);
3572 3572
 				return $this->fields[$colname];
3573 3573
 			}
3574 3574
 			if (!$this->bind) {
3575 3575
 				$this->bind = array();
3576
-				for ($i=0; $i < $this->_numOfFields; $i++) {
3576
+				for ($i = 0; $i < $this->_numOfFields; $i++) {
3577 3577
 					$o = $this->FetchField($i);
3578 3578
 					$this->bind[strtoupper($o->name)] = $i;
3579 3579
 				}
@@ -3586,9 +3586,9 @@  discard block
 block discarded – undo
3586 3586
 			if (isset($this->_fieldobjects)) {
3587 3587
 				return $this->_fieldobjects[$fieldOffset];
3588 3588
 			}
3589
-			$o =  new ADOFieldObject();
3589
+			$o = new ADOFieldObject();
3590 3590
 			$o->name = $this->_colnames[$fieldOffset];
3591
-			$o->type =  $this->_types[$fieldOffset];
3591
+			$o->type = $this->_types[$fieldOffset];
3592 3592
 			$o->max_length = -1; // length not known
3593 3593
 
3594 3594
 			return $o;
@@ -3685,7 +3685,7 @@  discard block
 block discarded – undo
3685 3685
 		$file = ADODB_DIR."/drivers/adodb-".$db.".inc.php";
3686 3686
 		@include_once($file);
3687 3687
 		$ADODB_LASTDB = $class;
3688
-		if (class_exists("ADODB_" . $class)) return $class;
3688
+		if (class_exists("ADODB_".$class)) return $class;
3689 3689
 
3690 3690
 		//ADOConnection::outp(adodb_pr(get_declared_classes(),true));
3691 3691
 		if (!file_exists($file)) ADOConnection::outp("Missing file: $file");
@@ -3696,9 +3696,9 @@  discard block
 block discarded – undo
3696 3696
 	/**
3697 3697
 	 * synonym for ADONewConnection for people like me who cannot remember the correct name
3698 3698
 	 */
3699
-	function &NewADOConnection($db='')
3699
+	function &NewADOConnection($db = '')
3700 3700
 	{
3701
-		$tmp =& ADONewConnection($db);
3701
+		$tmp = & ADONewConnection($db);
3702 3702
 		return $tmp;
3703 3703
 	}
3704 3704
 
@@ -3710,20 +3710,20 @@  discard block
 block discarded – undo
3710 3710
 	 *
3711 3711
 	 * @return the freshly created instance of the Connection class.
3712 3712
 	 */
3713
-	function &ADONewConnection($db='')
3713
+	function &ADONewConnection($db = '')
3714 3714
 	{
3715 3715
 	GLOBAL $ADODB_NEWCONNECTION, $ADODB_LASTDB;
3716 3716
 
3717
-		if (!defined('ADODB_ASSOC_CASE')) define('ADODB_ASSOC_CASE',2);
3717
+		if (!defined('ADODB_ASSOC_CASE')) define('ADODB_ASSOC_CASE', 2);
3718 3718
 		$errorfn = (defined('ADODB_ERROR_HANDLER')) ? ADODB_ERROR_HANDLER : false;
3719 3719
 		$false = false;
3720
-		if (strpos($db,'://')) {
3720
+		if (strpos($db, '://')) {
3721 3721
 			$origdsn = $db;
3722 3722
 			$dsna = @parse_url($db);
3723 3723
 
3724 3724
 			if (!$dsna) {
3725 3725
 				// special handling of oracle, which might not have host
3726
-				$db = str_replace('@/','@adodb-fakehost/',$db);
3726
+				$db = str_replace('@/', '@adodb-fakehost/', $db);
3727 3727
 				$dsna = parse_url($db);
3728 3728
 				if (!$dsna) return $false;
3729 3729
 				$dsna['host'] = '';
@@ -3733,12 +3733,12 @@  discard block
 block discarded – undo
3733 3733
 			$dsna['host'] = isset($dsna['host']) ? rawurldecode($dsna['host']) : '';
3734 3734
 			$dsna['user'] = isset($dsna['user']) ? rawurldecode($dsna['user']) : '';
3735 3735
 			$dsna['pass'] = isset($dsna['pass']) ? rawurldecode($dsna['pass']) : '';
3736
-			$dsna['path'] = isset($dsna['path']) ? rawurldecode(substr($dsna['path'],1)) : ''; # strip off initial /
3736
+			$dsna['path'] = isset($dsna['path']) ? rawurldecode(substr($dsna['path'], 1)) : ''; # strip off initial /
3737 3737
 
3738 3738
 			if (isset($dsna['query'])) {
3739
-				$opt1 = explode('&',$dsna['query']);
3740
-				foreach($opt1 as $k => $v) {
3741
-					$arr = explode('=',$v);
3739
+				$opt1 = explode('&', $dsna['query']);
3740
+				foreach ($opt1 as $k => $v) {
3741
+					$arr = explode('=', $v);
3742 3742
 					$opt[$arr[0]] = isset($arr[1]) ? rawurldecode($arr[1]) : 1;
3743 3743
 				}
3744 3744
 			} else $opt = array();
@@ -3770,9 +3770,9 @@  discard block
 block discarded – undo
3770 3770
 					$ignore = false;
3771 3771
 					$errorfn('ADONewConnection', 'ADONewConnection', -998,
3772 3772
 							 "could not load the database driver for '$db'",
3773
-							 $db,false,$ignore);
3773
+							 $db, false, $ignore);
3774 3774
 				} else
3775
-					 ADOConnection::outp( "<p>ADONewConnection: Unable to load database driver '$db'</p>",false);
3775
+					 ADOConnection::outp("<p>ADONewConnection: Unable to load database driver '$db'</p>", false);
3776 3776
 
3777 3777
 				return $false;
3778 3778
 			}
@@ -3791,15 +3791,15 @@  discard block
 block discarded – undo
3791 3791
 			if ($errorfn)  $obj->raiseErrorFn = $errorfn;
3792 3792
 			if (isset($dsna)) {
3793 3793
 				if (isset($dsna['port'])) $obj->port = $dsna['port'];
3794
-				foreach($opt as $k => $v) {
3795
-					switch(strtolower($k)) {
3794
+				foreach ($opt as $k => $v) {
3795
+					switch (strtolower($k)) {
3796 3796
 					case 'persist':
3797 3797
 					case 'persistent': 	$persist = $v; break;
3798
-					case 'debug':		$obj->debug = (integer) $v; break;
3798
+					case 'debug':		$obj->debug = (integer)$v; break;
3799 3799
 					#ibase
3800 3800
 					case 'role':		$obj->role = $v; break;
3801
-					case 'dialect': 	$obj->dialect = (integer) $v; break;
3802
-					case 'charset':		$obj->charset = $v; $obj->charSet=$v; break;
3801
+					case 'dialect': 	$obj->dialect = (integer)$v; break;
3802
+					case 'charset':		$obj->charset = $v; $obj->charSet = $v; break;
3803 3803
 					case 'buffers':		$obj->buffers = $v; break;
3804 3804
 					case 'fetchmode':   $obj->SetFetchMode($v); break;
3805 3805
 					#ado
@@ -3828,18 +3828,18 @@  discard block
 block discarded – undo
3828 3828
 
3829 3829
 
3830 3830
 	// $perf == true means called by NewPerfMonitor(), otherwise for data dictionary
3831
-	function _adodb_getdriver($provider,$drivername,$perf=false)
3831
+	function _adodb_getdriver($provider, $drivername, $perf = false)
3832 3832
 	{
3833 3833
 		switch ($provider) {
3834
-		case 'odbtp':   if (strncmp('odbtp_',$drivername,6)==0) return substr($drivername,6);
3835
-		case 'odbc' :   if (strncmp('odbc_',$drivername,5)==0) return substr($drivername,5);
3836
-		case 'ado'  :   if (strncmp('ado_',$drivername,4)==0) return substr($drivername,4);
3834
+		case 'odbtp':   if (strncmp('odbtp_', $drivername, 6) == 0) return substr($drivername, 6);
3835
+		case 'odbc' :   if (strncmp('odbc_', $drivername, 5) == 0) return substr($drivername, 5);
3836
+		case 'ado'  :   if (strncmp('ado_', $drivername, 4) == 0) return substr($drivername, 4);
3837 3837
 		case 'native':  break;
3838 3838
 		default:
3839 3839
 			return $provider;
3840 3840
 		}
3841 3841
 
3842
-		switch($drivername) {
3842
+		switch ($drivername) {
3843 3843
 		case 'firebird15': $drivername = 'firebird'; break;
3844 3844
 		case 'oracle': $drivername = 'oci8'; break;
3845 3845
 		case 'access': if ($perf) $drivername = ''; break;
@@ -3856,7 +3856,7 @@  discard block
 block discarded – undo
3856 3856
 	function &NewPerfMonitor(&$conn)
3857 3857
 	{
3858 3858
 		$false = false;
3859
-		$drivername = _adodb_getdriver($conn->dataProvider,$conn->databaseType,true);
3859
+		$drivername = _adodb_getdriver($conn->dataProvider, $conn->databaseType, true);
3860 3860
 		if (!$drivername || $drivername == 'generic') return $false;
3861 3861
 		include_once(ADODB_DIR.'/adodb-perf.inc.php');
3862 3862
 		@include_once(ADODB_DIR."/perf/perf-$drivername.inc.php");
@@ -3867,10 +3867,10 @@  discard block
 block discarded – undo
3867 3867
 		return $perf;
3868 3868
 	}
3869 3869
 
3870
-	function &NewDataDictionary(&$conn,$drivername=false)
3870
+	function &NewDataDictionary(&$conn, $drivername = false)
3871 3871
 	{
3872 3872
 		$false = false;
3873
-		if (!$drivername) $drivername = _adodb_getdriver($conn->dataProvider,$conn->databaseType);
3873
+		if (!$drivername) $drivername = _adodb_getdriver($conn->dataProvider, $conn->databaseType);
3874 3874
 
3875 3875
 		include_once(ADODB_DIR.'/adodb-lib.inc.php');
3876 3876
 		include_once(ADODB_DIR.'/adodb-datadict.inc.php');
@@ -3898,12 +3898,12 @@  discard block
 block discarded – undo
3898 3898
 	/*
3899 3899
 		Perform a print_r, with pre tags for better formatting.
3900 3900
 	*/
3901
-	function adodb_pr($var,$as_string=false)
3901
+	function adodb_pr($var, $as_string = false)
3902 3902
 	{
3903 3903
 		if ($as_string) ob_start();
3904 3904
 
3905 3905
 		if (isset($_SERVER['HTTP_USER_AGENT'])) {
3906
-			echo " <pre>\n";print_r($var);echo "</pre>\n";
3906
+			echo " <pre>\n"; print_r($var); echo "</pre>\n";
3907 3907
 		} else
3908 3908
 			print_r($var);
3909 3909
 
@@ -3920,11 +3920,11 @@  discard block
 block discarded – undo
3920 3920
 		@param printOrArr  Pass in a boolean to indicate print, or an $exception->trace array (assumes that print is true then).
3921 3921
 		@param levels Number of levels to display
3922 3922
 	*/
3923
-	function adodb_backtrace($printOrArr=true,$levels=9999)
3923
+	function adodb_backtrace($printOrArr = true, $levels = 9999)
3924 3924
 	{
3925 3925
 		global $ADODB_INCLUDED_LIB;
3926 3926
 		if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
3927
-		return _adodb_backtrace($printOrArr,$levels);
3927
+		return _adodb_backtrace($printOrArr, $levels);
3928 3928
 	}
3929 3929
 
3930 3930
 } // defined
Please login to merge, or discard this patch.
Braces   +1489 added lines, -505 removed lines patch added patch discarded remove patch
@@ -33,7 +33,8 @@  discard block
 block discarded – undo
33 33
 
34 34
  */
35 35
 
36
- if (!defined('_ADODB_LAYER')) {
36
+ if (!defined('_ADODB_LAYER'))
37
+ {
37 38
  	define('_ADODB_LAYER',1);
38 39
 
39 40
 	//==============================================================================================
@@ -45,7 +46,10 @@  discard block
 block discarded – undo
45 46
 	 * Set ADODB_DIR to the directory where this file resides...
46 47
 	 * This constant was formerly called $ADODB_RootPath
47 48
 	 */
48
-	if (!defined('ADODB_DIR')) define('ADODB_DIR',dirname(__FILE__));
49
+	if (!defined('ADODB_DIR'))
50
+	{
51
+		define('ADODB_DIR',dirname(__FILE__));
52
+	}
49 53
 
50 54
 	//==============================================================================================
51 55
 	// GLOBAL VARIABLES
@@ -82,7 +86,8 @@  discard block
 block discarded – undo
82 86
     //********************************************************//
83 87
 
84 88
 
85
-	if (!$ADODB_EXTENSION || ADODB_EXTENSION < 4.0) {
89
+	if (!$ADODB_EXTENSION || ADODB_EXTENSION < 4.0)
90
+	{
86 91
 
87 92
 		define('ADODB_BAD_RS','<p>Bad $rs in %s. Connection or SQL invalid. Try using $connection->debug=true;</p>');
88 93
 
@@ -90,7 +95,10 @@  discard block
 block discarded – undo
90 95
 		define('ADODB_TABLE_REGEX','([]0-9a-z_\:\"\`\.\@\[-]*)');
91 96
 
92 97
 	// prefetching used by oracle
93
-		if (!defined('ADODB_PREFETCH_ROWS')) define('ADODB_PREFETCH_ROWS',10);
98
+		if (!defined('ADODB_PREFETCH_ROWS'))
99
+		{
100
+			define('ADODB_PREFETCH_ROWS',10);
101
+		}
94 102
 
95 103
 
96 104
 	/*
@@ -107,19 +115,33 @@  discard block
 block discarded – undo
107 115
 		define('ADODB_FETCH_ASSOC',2);
108 116
 		define('ADODB_FETCH_BOTH',3);
109 117
 
110
-		if (!defined('TIMESTAMP_FIRST_YEAR')) define('TIMESTAMP_FIRST_YEAR',100);
118
+		if (!defined('TIMESTAMP_FIRST_YEAR'))
119
+		{
120
+			define('TIMESTAMP_FIRST_YEAR',100);
121
+		}
111 122
 
112 123
 		// PHP's version scheme makes converting to numbers difficult - workaround
113 124
 		$_adodb_ver = (float) PHP_VERSION;
114
-		if ($_adodb_ver >= 5.0) {
125
+		if ($_adodb_ver >= 5.0)
126
+		{
115 127
 			define('ADODB_PHPVER',0x5000);
116
-		} else if ($_adodb_ver > 4.299999) { # 4.3
128
+		}
129
+		else if ($_adodb_ver > 4.299999)
130
+		{
131
+# 4.3
117 132
 			define('ADODB_PHPVER',0x4300);
118
-		} else if ($_adodb_ver > 4.199999) { # 4.2
133
+		}
134
+		else if ($_adodb_ver > 4.199999)
135
+		{
136
+# 4.2
119 137
 			define('ADODB_PHPVER',0x4200);
120
-		} else if (strnatcmp(PHP_VERSION,'4.0.5')>=0) {
138
+		}
139
+		else if (strnatcmp(PHP_VERSION,'4.0.5')>=0)
140
+		{
121 141
 			define('ADODB_PHPVER',0x4050);
122
-		} else {
142
+		}
143
+		else
144
+		{
123 145
 			define('ADODB_PHPVER',0x4000);
124 146
 		}
125 147
 	}
@@ -132,11 +154,15 @@  discard block
 block discarded – undo
132 154
 	*/
133 155
 	function ADODB_str_replace($src, $dest, $data)
134 156
 	{
135
-		if (ADODB_PHPVER >= 0x4050) return str_replace($src,$dest,$data);
157
+		if (ADODB_PHPVER >= 0x4050)
158
+		{
159
+			return str_replace($src,$dest,$data);
160
+		}
136 161
 
137 162
 		$s = reset($src);
138 163
 		$d = reset($dest);
139
-		while ($s !== false) {
164
+		while ($s !== false)
165
+		{
140 166
 			$data = str_replace($s,$d,$data);
141 167
 			$s = next($src);
142 168
 			$d = next($dest);
@@ -157,12 +183,17 @@  discard block
 block discarded – undo
157 183
 		$ADODB_FORCE_TYPE = ADODB_FORCE_VALUE;
158 184
 
159 185
 
160
-		if (!isset($ADODB_CACHE_DIR)) {
186
+		if (!isset($ADODB_CACHE_DIR))
187
+		{
161 188
 			$ADODB_CACHE_DIR = '/tmp'; //(isset($_ENV['TMP'])) ? $_ENV['TMP'] : '/tmp';
162
-		} else {
189
+		}
190
+		else
191
+		{
163 192
 			// do not accept url based paths, eg. http:/ or ftp:/
164 193
 			if (strpos($ADODB_CACHE_DIR,'://') !== false)
165
-				die("Illegal path http:// or ftp://");
194
+			{
195
+							die("Illegal path http:// or ftp://");
196
+			}
166 197
 		}
167 198
 
168 199
 
@@ -179,7 +210,10 @@  discard block
 block discarded – undo
179 210
 		 * Set to false for highest performance -- RecordCount() will always return -1 then
180 211
 		 * for databases that provide "virtual" recordcounts...
181 212
 		 */
182
-		if (!isset($ADODB_COUNTRECS)) $ADODB_COUNTRECS = true;
213
+		if (!isset($ADODB_COUNTRECS))
214
+		{
215
+			$ADODB_COUNTRECS = true;
216
+		}
183 217
 	}
184 218
 
185 219
 
@@ -195,7 +229,8 @@  discard block
 block discarded – undo
195 229
 	/**
196 230
 	 * Helper class for FetchFields -- holds info on a column
197 231
 	 */
198
-	class ADOFieldObject {
232
+	class ADOFieldObject
233
+	{
199 234
 		var $name = '';
200 235
 		var $max_length=0;
201 236
 		var $type="";
@@ -217,7 +252,8 @@  discard block
 block discarded – undo
217 252
 	{
218 253
 		//print "Errorno ($fn errno=$errno m=$errmsg) ";
219 254
 		$thisConnection->_transOK = false;
220
-		if ($thisConnection->_oldRaiseFn) {
255
+		if ($thisConnection->_oldRaiseFn)
256
+		{
221 257
 			$fn = $thisConnection->_oldRaiseFn;
222 258
 			$fn($dbms, $fn, $errno, $errmsg, $p1, $p2,$thisConnection);
223 259
 		}
@@ -230,7 +266,8 @@  discard block
 block discarded – undo
230 266
 	/**
231 267
 	 * Connection object. For connecting to databases, and executing queries.
232 268
 	 */
233
-	class ADOConnection {
269
+	class ADOConnection
270
+	{
234 271
 	//
235 272
 	// PUBLIC VARS
236 273
 	//
@@ -351,8 +388,13 @@  discard block
 block discarded – undo
351 388
 
352 389
 	function _findvers($str)
353 390
 	{
354
-		if (preg_match('/([0-9]+\.([0-9\.])+)/',$str, $arr)) return $arr[1];
355
-		else return '';
391
+		if (preg_match('/([0-9]+\.([0-9\.])+)/',$str, $arr))
392
+		{
393
+			return $arr[1];
394
+		}
395
+		else {
396
+			return '';
397
+		}
356 398
 	}
357 399
 
358 400
 	/**
@@ -363,30 +405,48 @@  discard block
 block discarded – undo
363 405
 	{
364 406
 	global $ADODB_FLUSH,$ADODB_OUTP;
365 407
 
366
-		if (defined('ADODB_OUTP')) {
408
+		if (defined('ADODB_OUTP'))
409
+		{
367 410
 			$fn = ADODB_OUTP;
368 411
 			$fn($msg,$newline);
369 412
 			return;
370
-		} else if (isset($ADODB_OUTP)) {
413
+		}
414
+		else if (isset($ADODB_OUTP))
415
+		{
371 416
 			$fn = $ADODB_OUTP;
372 417
 			$fn($msg,$newline);
373 418
 			return;
374 419
 		}
375 420
 
376
-		if ($newline) $msg .= "<br>\n";
421
+		if ($newline)
422
+		{
423
+			$msg .= "<br>\n";
424
+		}
377 425
 
378
-		if (isset($_SERVER['HTTP_USER_AGENT']) || !$newline) echo $msg;
379
-		else echo strip_tags($msg);
426
+		if (isset($_SERVER['HTTP_USER_AGENT']) || !$newline)
427
+		{
428
+			echo $msg;
429
+		}
430
+		else {
431
+			echo strip_tags($msg);
432
+		}
380 433
 
381 434
 
382
-		if (!empty($ADODB_FLUSH) && ob_get_length() !== false) flush(); //  do not flush if output buffering enabled - useless - thx to Jesse Mullan
435
+		if (!empty($ADODB_FLUSH) && ob_get_length() !== false)
436
+		{
437
+			flush();
438
+		}
439
+		//  do not flush if output buffering enabled - useless - thx to Jesse Mullan
383 440
 
384 441
 	}
385 442
 
386 443
 	function Time()
387 444
 	{
388 445
 		$rs =& $this->_Execute("select $this->sysTimeStamp");
389
-		if ($rs && !$rs->EOF) return $this->UnixTimeStamp(reset($rs->fields));
446
+		if ($rs && !$rs->EOF)
447
+		{
448
+			return $this->UnixTimeStamp(reset($rs->fields));
449
+		}
390 450
 
391 451
 		return false;
392 452
 	}
@@ -404,31 +464,64 @@  discard block
 block discarded – undo
404 464
 	 */
405 465
 	function Connect($argHostname = "", $argUsername = "", $argPassword = "", $argDatabaseName = "", $forceNew = false)
406 466
 	{
407
-		if ($argHostname != "") $this->host = $argHostname;
408
-		if ($argUsername != "") $this->user = $argUsername;
409
-		if ($argPassword != "") $this->password = $argPassword; // not stored for security reasons
410
-		if ($argDatabaseName != "") $this->database = $argDatabaseName;
467
+		if ($argHostname != "")
468
+		{
469
+			$this->host = $argHostname;
470
+		}
471
+		if ($argUsername != "")
472
+		{
473
+			$this->user = $argUsername;
474
+		}
475
+		if ($argPassword != "")
476
+		{
477
+			$this->password = $argPassword;
478
+		}
479
+		// not stored for security reasons
480
+		if ($argDatabaseName != "")
481
+		{
482
+			$this->database = $argDatabaseName;
483
+		}
411 484
 
412 485
 		$this->_isPersistentConnection = false;
413
-		if ($forceNew) {
414
-			if ($rez=$this->_nconnect($this->host, $this->user, $this->password, $this->database)) return true;
415
-		} else {
416
-			 if ($rez=$this->_connect($this->host, $this->user, $this->password, $this->database)) return true;
486
+		if ($forceNew)
487
+		{
488
+			if ($rez=$this->_nconnect($this->host, $this->user, $this->password, $this->database))
489
+			{
490
+				return true;
491
+			}
492
+		}
493
+		else
494
+		{
495
+			 if ($rez=$this->_connect($this->host, $this->user, $this->password, $this->database))
496
+			 {
497
+			 	return true;
498
+			 }
417 499
 		}
418
-		if (isset($rez)) {
500
+		if (isset($rez))
501
+		{
419 502
 			$err = $this->ErrorMsg();
420
-			if (empty($err)) $err = "Connection error to server '$argHostname' with user '$argUsername'";
503
+			if (empty($err))
504
+			{
505
+				$err = "Connection error to server '$argHostname' with user '$argUsername'";
506
+			}
421 507
 			$ret = false;
422
-		} else {
508
+		}
509
+		else
510
+		{
423 511
 			$err = "Missing extension for ".$this->dataProvider;
424 512
 			$ret = 0;
425 513
 		}
426 514
 		if ($fn = $this->raiseErrorFn)
427
-			$fn($this->databaseType,'CONNECT',$this->ErrorNo(),$err,$this->host,$this->database,$this);
515
+		{
516
+					$fn($this->databaseType,'CONNECT',$this->ErrorNo(),$err,$this->host,$this->database,$this);
517
+		}
428 518
 
429 519
 
430 520
 		$this->_connectionID = false;
431
-		if ($this->debug) ADOConnection::outp( $this->host.': '.$err);
521
+		if ($this->debug)
522
+		{
523
+			ADOConnection::outp( $this->host.': '.$err);
524
+		}
432 525
 		return $ret;
433 526
 	}
434 527
 
@@ -466,36 +559,66 @@  discard block
 block discarded – undo
466 559
 	function PConnect($argHostname = "", $argUsername = "", $argPassword = "", $argDatabaseName = "")
467 560
 	{
468 561
 		if (defined('ADODB_NEVER_PERSIST'))
469
-			return $this->Connect($argHostname,$argUsername,$argPassword,$argDatabaseName);
562
+		{
563
+					return $this->Connect($argHostname,$argUsername,$argPassword,$argDatabaseName);
564
+		}
470 565
 
471
-		if ($argHostname != "") $this->host = $argHostname;
472
-		if ($argUsername != "") $this->user = $argUsername;
473
-		if ($argPassword != "") $this->password = $argPassword;
474
-		if ($argDatabaseName != "") $this->database = $argDatabaseName;
566
+		if ($argHostname != "")
567
+		{
568
+			$this->host = $argHostname;
569
+		}
570
+		if ($argUsername != "")
571
+		{
572
+			$this->user = $argUsername;
573
+		}
574
+		if ($argPassword != "")
575
+		{
576
+			$this->password = $argPassword;
577
+		}
578
+		if ($argDatabaseName != "")
579
+		{
580
+			$this->database = $argDatabaseName;
581
+		}
475 582
 
476 583
 		$this->_isPersistentConnection = true;
477
-		if ($rez = $this->_pconnect($this->host, $this->user, $this->password, $this->database)) return true;
478
-		if (isset($rez)) {
584
+		if ($rez = $this->_pconnect($this->host, $this->user, $this->password, $this->database))
585
+		{
586
+			return true;
587
+		}
588
+		if (isset($rez))
589
+		{
479 590
 			$err = $this->ErrorMsg();
480
-			if (empty($err)) $err = "Connection error to server '$argHostname' with user '$argUsername'";
591
+			if (empty($err))
592
+			{
593
+				$err = "Connection error to server '$argHostname' with user '$argUsername'";
594
+			}
481 595
 			$ret = false;
482
-		} else {
596
+		}
597
+		else
598
+		{
483 599
 			$err = "Missing extension for ".$this->dataProvider;
484 600
 			$ret = 0;
485 601
 		}
486
-		if ($fn = $this->raiseErrorFn) {
602
+		if ($fn = $this->raiseErrorFn)
603
+		{
487 604
 			$fn($this->databaseType,'PCONNECT',$this->ErrorNo(),$err,$this->host,$this->database,$this);
488 605
 		}
489 606
 
490 607
 		$this->_connectionID = false;
491
-		if ($this->debug) ADOConnection::outp( $this->host.': '.$err);
608
+		if ($this->debug)
609
+		{
610
+			ADOConnection::outp( $this->host.': '.$err);
611
+		}
492 612
 		return $ret;
493 613
 	}
494 614
 
495 615
 	// Format date column in sql string given an input format that understands Y M D
496 616
 	function SQLDate($fmt, $col=false)
497 617
 	{
498
-		if (!$col) $col = $this->sysDate;
618
+		if (!$col)
619
+		{
620
+			$col = $this->sysDate;
621
+		}
499 622
 		return $col; // child class implement
500 623
 	}
501 624
 
@@ -612,7 +735,8 @@  discard block
 block discarded – undo
612 735
 		$old = $this->fetchMode;
613 736
 		$this->fetchMode = $mode;
614 737
 
615
-		if ($old === false) {
738
+		if ($old === false)
739
+		{
616 740
 		global $ADODB_FETCH_MODE;
617 741
 			return $ADODB_FETCH_MODE;
618 742
 		}
@@ -626,7 +750,10 @@  discard block
 block discarded – undo
626 750
 	function &Query($sql, $inputarr=false)
627 751
 	{
628 752
 		$rs = &$this->Execute($sql, $inputarr);
629
-		if (!$rs && defined('ADODB_PEAR')) return ADODB_PEAR_Error();
753
+		if (!$rs && defined('ADODB_PEAR'))
754
+		{
755
+			return ADODB_PEAR_Error();
756
+		}
630 757
 		return $rs;
631 758
 	}
632 759
 
@@ -637,7 +764,10 @@  discard block
 block discarded – undo
637 764
 	function &LimitQuery($sql, $offset, $count, $params=false)
638 765
 	{
639 766
 		$rs = &$this->SelectLimit($sql, $count, $offset, $params);
640
-		if (!$rs && defined('ADODB_PEAR')) return ADODB_PEAR_Error();
767
+		if (!$rs && defined('ADODB_PEAR'))
768
+		{
769
+			return ADODB_PEAR_Error();
770
+		}
641 771
 		return $rs;
642 772
 	}
643 773
 
@@ -712,7 +842,8 @@  discard block
 block discarded – undo
712 842
 	*/
713 843
 	function StartTrans($errfn = 'ADODB_TransMonitor')
714 844
 	{
715
-		if ($this->transOff > 0) {
845
+		if ($this->transOff > 0)
846
+		{
716 847
 			$this->transOff += 1;
717 848
 			return;
718 849
 		}
@@ -721,7 +852,10 @@  discard block
 block discarded – undo
721 852
 		$this->raiseErrorFn = $errfn;
722 853
 		$this->_transOK = true;
723 854
 
724
-		if ($this->debug && $this->transCnt > 0) ADOConnection::outp("Bad Transaction: StartTrans called within BeginTrans");
855
+		if ($this->debug && $this->transCnt > 0)
856
+		{
857
+			ADOConnection::outp("Bad Transaction: StartTrans called within BeginTrans");
858
+		}
725 859
 		$this->BeginTrans();
726 860
 		$this->transOff = 1;
727 861
 	}
@@ -737,23 +871,38 @@  discard block
 block discarded – undo
737 871
 	*/
738 872
 	function CompleteTrans($autoComplete = true)
739 873
 	{
740
-		if ($this->transOff > 1) {
874
+		if ($this->transOff > 1)
875
+		{
741 876
 			$this->transOff -= 1;
742 877
 			return true;
743 878
 		}
744 879
 		$this->raiseErrorFn = $this->_oldRaiseFn;
745 880
 
746 881
 		$this->transOff = 0;
747
-		if ($this->_transOK && $autoComplete) {
748
-			if (!$this->CommitTrans()) {
882
+		if ($this->_transOK && $autoComplete)
883
+		{
884
+			if (!$this->CommitTrans())
885
+			{
749 886
 				$this->_transOK = false;
750
-				if ($this->debug) ADOConnection::outp("Smart Commit failed");
751
-			} else
752
-				if ($this->debug) ADOConnection::outp("Smart Commit occurred");
753
-		} else {
887
+				if ($this->debug)
888
+				{
889
+					ADOConnection::outp("Smart Commit failed");
890
+				}
891
+			}
892
+			else
893
+				if ($this->debug)
894
+				{
895
+					ADOConnection::outp("Smart Commit occurred");
896
+				}
897
+		}
898
+		else
899
+		{
754 900
 			$this->_transOK = false;
755 901
 			$this->RollbackTrans();
756
-			if ($this->debug) ADOCOnnection::outp("Smart Rollback occurred");
902
+			if ($this->debug)
903
+			{
904
+				ADOCOnnection::outp("Smart Rollback occurred");
905
+			}
757 906
 		}
758 907
 
759 908
 		return $this->_transOK;
@@ -765,9 +914,13 @@  discard block
 block discarded – undo
765 914
 	function FailTrans()
766 915
 	{
767 916
 		if ($this->debug)
768
-			if ($this->transOff == 0) {
917
+		{
918
+					if ($this->transOff == 0) {
769 919
 				ADOConnection::outp("FailTrans outside StartTrans/CompleteTrans");
770
-			} else {
920
+		}
921
+			}
922
+			else
923
+			{
771 924
 				ADOConnection::outp("FailTrans was called");
772 925
 				adodb_backtrace();
773 926
 			}
@@ -779,7 +932,10 @@  discard block
 block discarded – undo
779 932
 	*/
780 933
 	function HasFailedTrans()
781 934
 	{
782
-		if ($this->transOff > 0) return $this->_transOK == false;
935
+		if ($this->transOff > 0)
936
+		{
937
+			return $this->_transOK == false;
938
+		}
783 939
 		return false;
784 940
 	}
785 941
 
@@ -792,66 +948,114 @@  discard block
 block discarded – undo
792 948
 	 */
793 949
 	function &Execute($sql,$inputarr=false)
794 950
 	{
795
-		if ($this->fnExecute) {
951
+		if ($this->fnExecute)
952
+		{
796 953
 			$fn = $this->fnExecute;
797 954
 			$ret =& $fn($this,$sql,$inputarr);
798
-			if (isset($ret)) return $ret;
955
+			if (isset($ret))
956
+			{
957
+				return $ret;
958
+			}
799 959
 		}
800
-		if ($inputarr) {
801
-			if (!is_array($inputarr)) $inputarr = array($inputarr);
960
+		if ($inputarr)
961
+		{
962
+			if (!is_array($inputarr))
963
+			{
964
+				$inputarr = array($inputarr);
965
+			}
802 966
 
803 967
 			$element0 = reset($inputarr);
804 968
 			# is_object check because oci8 descriptors can be passed in
805 969
 			$array_2d = is_array($element0) && !is_object(reset($element0));
806 970
 
807
-			if (!is_array($sql) && !$this->_bindInputArray) {
971
+			if (!is_array($sql) && !$this->_bindInputArray)
972
+			{
808 973
 				$sqlarr = explode('?',$sql);
809 974
 
810
-				if (!$array_2d) $inputarr = array($inputarr);
811
-				foreach($inputarr as $arr) {
975
+				if (!$array_2d)
976
+				{
977
+					$inputarr = array($inputarr);
978
+				}
979
+				foreach($inputarr as $arr)
980
+				{
812 981
 					$sql = ''; $i = 0;
813
-					foreach($arr as $v) {
982
+					foreach($arr as $v)
983
+					{
814 984
 						$sql .= $sqlarr[$i];
815 985
 						// from Ron Baldwin <ron.baldwin#sourceprose.com>
816 986
 						// Only quote string types
817 987
 						$typ = gettype($v);
818 988
 						if ($typ == 'string')
819
-							$sql .= $this->qstr($v);
989
+						{
990
+													$sql .= $this->qstr($v);
991
+						}
820 992
 						else if ($typ == 'double')
821
-							$sql .= str_replace(',','.',$v); // locales fix so 1.1 does not get converted to 1,1
993
+						{
994
+													$sql .= str_replace(',','.',$v);
995
+						}
996
+						// locales fix so 1.1 does not get converted to 1,1
822 997
 						else if ($typ == 'boolean')
823
-							$sql .= $v ? $this->true : $this->false;
998
+						{
999
+													$sql .= $v ? $this->true : $this->false;
1000
+						}
824 1001
 						else if ($v === null)
825
-							$sql .= 'NULL';
826
-						else
827
-							$sql .= $v;
1002
+						{
1003
+													$sql .= 'NULL';
1004
+						}
1005
+						else {
1006
+													$sql .= $v;
1007
+						}
828 1008
 						$i += 1;
829 1009
 					}
830
-					if (isset($sqlarr[$i])) {
1010
+					if (isset($sqlarr[$i]))
1011
+					{
831 1012
 						$sql .= $sqlarr[$i];
832
-						if ($i+1 != sizeof($sqlarr)) ADOConnection::outp( "Input Array does not match ?: ".htmlspecialchars($sql));
833
-					} else if ($i != sizeof($sqlarr))
834
-						ADOConnection::outp( "Input array does not match ?: ".htmlspecialchars($sql));
1013
+						if ($i+1 != sizeof($sqlarr))
1014
+						{
1015
+							ADOConnection::outp( "Input Array does not match ?: ".htmlspecialchars($sql));
1016
+						}
1017
+					}
1018
+					else if ($i != sizeof($sqlarr))
1019
+					{
1020
+											ADOConnection::outp( "Input array does not match ?: ".htmlspecialchars($sql));
1021
+					}
835 1022
 
836 1023
 					$ret =& $this->_Execute($sql);
837
-					if (!$ret) return $ret;
1024
+					if (!$ret)
1025
+					{
1026
+						return $ret;
1027
+					}
838 1028
 				}
839
-			} else {
840
-				if ($array_2d) {
1029
+			}
1030
+			else
1031
+			{
1032
+				if ($array_2d)
1033
+				{
841 1034
 					if (is_string($sql))
842
-						$stmt = $this->Prepare($sql);
843
-					else
844
-						$stmt = $sql;
1035
+					{
1036
+											$stmt = $this->Prepare($sql);
1037
+					}
1038
+					else {
1039
+											$stmt = $sql;
1040
+					}
845 1041
 
846
-					foreach($inputarr as $arr) {
1042
+					foreach($inputarr as $arr)
1043
+					{
847 1044
 						$ret =& $this->_Execute($stmt,$arr);
848
-						if (!$ret) return $ret;
1045
+						if (!$ret)
1046
+						{
1047
+							return $ret;
1048
+						}
849 1049
 					}
850
-				} else {
1050
+				}
1051
+				else
1052
+				{
851 1053
 					$ret =& $this->_Execute($sql,$inputarr);
852 1054
 				}
853 1055
 			}
854
-		} else {
1056
+		}
1057
+		else
1058
+		{
855 1059
 			$ret =& $this->_Execute($sql,false);
856 1060
 		}
857 1061
 
@@ -862,11 +1066,17 @@  discard block
 block discarded – undo
862 1066
 	function &_Execute($sql,$inputarr=false)
863 1067
 	{
864 1068
 
865
-		if ($this->debug) {
1069
+		if ($this->debug)
1070
+		{
866 1071
 			global $ADODB_INCLUDED_LIB;
867
-			if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
1072
+			if (empty($ADODB_INCLUDED_LIB))
1073
+			{
1074
+				include_once(ADODB_DIR.'/adodb-lib.inc.php');
1075
+			}
868 1076
 			$this->_queryID = _adodb_debug_execute($this, $sql,$inputarr);
869
-		} else {
1077
+		}
1078
+		else
1079
+		{
870 1080
 			$this->_queryID = @$this->_query($sql,$inputarr);
871 1081
 		}
872 1082
 
@@ -874,17 +1084,25 @@  discard block
 block discarded – undo
874 1084
 		// OK, query executed
875 1085
 		*************************/
876 1086
 
877
-		if ($this->_queryID === false) { // error handling if query fails
878
-			if ($this->debug == 99) adodb_backtrace(true,5);
1087
+		if ($this->_queryID === false)
1088
+		{
1089
+// error handling if query fails
1090
+			if ($this->debug == 99)
1091
+			{
1092
+				adodb_backtrace(true,5);
1093
+			}
879 1094
 			$fn = $this->raiseErrorFn;
880
-			if ($fn) {
1095
+			if ($fn)
1096
+			{
881 1097
 				$fn($this->databaseType,'EXECUTE',$this->ErrorNo(),$this->ErrorMsg(),$sql,$inputarr,$this);
882 1098
 			}
883 1099
 			$false = false;
884 1100
 			return $false;
885 1101
 		}
886 1102
 
887
-		if ($this->_queryID === true) { // return simplified recordset for inserts/updates/deletes with lower overhead
1103
+		if ($this->_queryID === true)
1104
+		{
1105
+// return simplified recordset for inserts/updates/deletes with lower overhead
888 1106
 			$rs = new ADORecordSet_empty();
889 1107
 			return $rs;
890 1108
 		}
@@ -894,16 +1112,26 @@  discard block
 block discarded – undo
894 1112
 		$rs = new $rsclass($this->_queryID,$this->fetchMode);
895 1113
 		$rs->connection = &$this; // Pablo suggestion
896 1114
 		$rs->Init();
897
-		if (is_array($sql)) $rs->sql = $sql[0];
898
-		else $rs->sql = $sql;
899
-		if ($rs->_numOfRows <= 0) {
1115
+		if (is_array($sql))
1116
+		{
1117
+			$rs->sql = $sql[0];
1118
+		}
1119
+		else {
1120
+			$rs->sql = $sql;
1121
+		}
1122
+		if ($rs->_numOfRows <= 0)
1123
+		{
900 1124
 		global $ADODB_COUNTRECS;
901
-			if ($ADODB_COUNTRECS) {
902
-				if (!$rs->EOF) {
1125
+			if ($ADODB_COUNTRECS)
1126
+			{
1127
+				if (!$rs->EOF)
1128
+				{
903 1129
 					$rs = &$this->_rs2rs($rs,-1,-1,!is_array($sql));
904 1130
 					$rs->_queryID = $this->_queryID;
905
-				} else
906
-					$rs->_numOfRows = 0;
1131
+				}
1132
+				else {
1133
+									$rs->_numOfRows = 0;
1134
+				}
907 1135
 			}
908 1136
 		}
909 1137
 		return $rs;
@@ -911,13 +1139,19 @@  discard block
 block discarded – undo
911 1139
 
912 1140
 	function CreateSequence($seqname='adodbseq',$startID=1)
913 1141
 	{
914
-		if (empty($this->_genSeqSQL)) return false;
1142
+		if (empty($this->_genSeqSQL))
1143
+		{
1144
+			return false;
1145
+		}
915 1146
 		return $this->Execute(sprintf($this->_genSeqSQL,$seqname,$startID));
916 1147
 	}
917 1148
 
918 1149
 	function DropSequence($seqname='adodbseq')
919 1150
 	{
920
-		if (empty($this->_dropSeqSQL)) return false;
1151
+		if (empty($this->_dropSeqSQL))
1152
+		{
1153
+			return false;
1154
+		}
921 1155
 		return $this->Execute(sprintf($this->_dropSeqSQL,$seqname));
922 1156
 	}
923 1157
 
@@ -931,7 +1165,8 @@  discard block
 block discarded – undo
931 1165
 	 */
932 1166
 	function GenID($seqname='adodbseq',$startID=1)
933 1167
 	{
934
-		if (!$this->hasGenID) {
1168
+		if (!$this->hasGenID)
1169
+		{
935 1170
 			return 0; // formerly returns false pre 1.60
936 1171
 		}
937 1172
 
@@ -944,15 +1179,25 @@  discard block
 block discarded – undo
944 1179
 		@($rs = $this->Execute($getnext));
945 1180
 		$this->raiseErrorFn = $save_handler;
946 1181
 
947
-		if (!$rs) {
1182
+		if (!$rs)
1183
+		{
948 1184
 			$this->_transOK = $holdtransOK; //if the status was ok before reset
949 1185
 			$createseq = $this->Execute(sprintf($this->_genSeqSQL,$seqname,$startID));
950 1186
 			$rs = $this->Execute($getnext);
951 1187
 		}
952
-		if ($rs && !$rs->EOF) $this->genID = reset($rs->fields);
953
-		else $this->genID = 0; // false
1188
+		if ($rs && !$rs->EOF)
1189
+		{
1190
+			$this->genID = reset($rs->fields);
1191
+		}
1192
+		else {
1193
+			$this->genID = 0;
1194
+		}
1195
+		// false
954 1196
 
955
-		if ($rs) $rs->Close();
1197
+		if ($rs)
1198
+		{
1199
+			$rs->Close();
1200
+		}
956 1201
 
957 1202
 		return $this->genID;
958 1203
 	}
@@ -964,9 +1209,16 @@  discard block
 block discarded – undo
964 1209
 	 */
965 1210
 	function Insert_ID($table='',$column='')
966 1211
 	{
967
-		if ($this->_logsql && $this->lastInsID) return $this->lastInsID;
968
-		if ($this->hasInsertID) return $this->_insertid($table,$column);
969
-		if ($this->debug) {
1212
+		if ($this->_logsql && $this->lastInsID)
1213
+		{
1214
+			return $this->lastInsID;
1215
+		}
1216
+		if ($this->hasInsertID)
1217
+		{
1218
+			return $this->_insertid($table,$column);
1219
+		}
1220
+		if ($this->debug)
1221
+		{
970 1222
 			ADOConnection::outp( '<p>Insert_ID error</p>');
971 1223
 			adodb_backtrace();
972 1224
 		}
@@ -982,9 +1234,12 @@  discard block
 block discarded – undo
982 1234
 	 */
983 1235
 	function PO_Insert_ID($table="", $id="")
984 1236
 	{
985
-	   if ($this->hasInsertID){
1237
+	   if ($this->hasInsertID)
1238
+	   {
986 1239
 		   return $this->Insert_ID($table,$id);
987
-	   } else {
1240
+	   }
1241
+	   else
1242
+	   {
988 1243
 		   return $this->GetOne("SELECT MAX($id) FROM $table");
989 1244
 	   }
990 1245
 	}
@@ -994,15 +1249,23 @@  discard block
 block discarded – undo
994 1249
 	*/
995 1250
 	function Affected_Rows()
996 1251
 	{
997
-		if ($this->hasAffectedRows) {
998
-			if ($this->fnExecute === 'adodb_log_sql') {
999
-				if ($this->_logsql && $this->_affected !== false) return $this->_affected;
1252
+		if ($this->hasAffectedRows)
1253
+		{
1254
+			if ($this->fnExecute === 'adodb_log_sql')
1255
+			{
1256
+				if ($this->_logsql && $this->_affected !== false)
1257
+				{
1258
+					return $this->_affected;
1259
+				}
1000 1260
 			}
1001 1261
 			$val = $this->_affectedrows();
1002 1262
 			return ($val < 0) ? false : $val;
1003 1263
 		}
1004 1264
 
1005
-		if ($this->debug) ADOConnection::outp( '<p>Affected_Rows error</p>',false);
1265
+		if ($this->debug)
1266
+		{
1267
+			ADOConnection::outp( '<p>Affected_Rows error</p>',false);
1268
+		}
1006 1269
 		return false;
1007 1270
 	}
1008 1271
 
@@ -1012,8 +1275,13 @@  discard block
 block discarded – undo
1012 1275
 	 */
1013 1276
 	function ErrorMsg()
1014 1277
 	{
1015
-		if ($this->_errorMsg) return '!! '.strtoupper($this->dataProvider.' '.$this->databaseType).': '.$this->_errorMsg;
1016
-		else return '';
1278
+		if ($this->_errorMsg)
1279
+		{
1280
+			return '!! '.strtoupper($this->dataProvider.' '.$this->databaseType).': '.$this->_errorMsg;
1281
+		}
1282
+		else {
1283
+			return '';
1284
+		}
1017 1285
 	}
1018 1286
 
1019 1287
 
@@ -1028,7 +1296,10 @@  discard block
 block discarded – undo
1028 1296
 	function MetaError($err=false)
1029 1297
 	{
1030 1298
 		include_once(ADODB_DIR."/adodb-error.inc.php");
1031
-		if ($err === false) $err = $this->ErrorNo();
1299
+		if ($err === false)
1300
+		{
1301
+			$err = $this->ErrorNo();
1302
+		}
1032 1303
 		return adodb_error($this->dataProvider,$this->databaseType,$err);
1033 1304
 	}
1034 1305
 
@@ -1046,15 +1317,24 @@  discard block
 block discarded – undo
1046 1317
 	// owner not used in base class - see oci8
1047 1318
 		$p = array();
1048 1319
 		$objs =& $this->MetaColumns($table);
1049
-		if ($objs) {
1050
-			foreach($objs as $v) {
1320
+		if ($objs)
1321
+		{
1322
+			foreach($objs as $v)
1323
+			{
1051 1324
 				if (!empty($v->primary_key))
1052
-					$p[] = $v->name;
1325
+				{
1326
+									$p[] = $v->name;
1327
+				}
1053 1328
 			}
1054 1329
 		}
1055
-		if (sizeof($p)) return $p;
1330
+		if (sizeof($p))
1331
+		{
1332
+			return $p;
1333
+		}
1056 1334
 		if (function_exists('ADODB_VIEW_PRIMARYKEYS'))
1057
-			return ADODB_VIEW_PRIMARYKEYS($this->databaseType, $this->database, $table, $owner);
1335
+		{
1336
+					return ADODB_VIEW_PRIMARYKEYS($this->databaseType, $this->database, $table, $owner);
1337
+		}
1058 1338
 		return false;
1059 1339
 	}
1060 1340
 
@@ -1072,7 +1352,8 @@  discard block
 block discarded – undo
1072 1352
 	 * @return 		true or false
1073 1353
 	 */
1074 1354
 	function SelectDB($dbName)
1075
-	{return false;}
1355
+	{
1356
+return false;}
1076 1357
 
1077 1358
 
1078 1359
 	/**
@@ -1096,39 +1377,59 @@  discard block
 block discarded – undo
1096 1377
  	*/
1097 1378
 	function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0)
1098 1379
 	{
1099
-		if ($this->hasTop && $nrows > 0) {
1380
+		if ($this->hasTop && $nrows > 0)
1381
+		{
1100 1382
 		// suggested by Reinhard Balling. Access requires top after distinct
1101 1383
 		 // Informix requires first before distinct - F Riosa
1102 1384
 			$ismssql = (strpos($this->databaseType,'mssql') !== false);
1103
-			if ($ismssql) $isaccess = false;
1104
-			else $isaccess = (strpos($this->databaseType,'access') !== false);
1385
+			if ($ismssql)
1386
+			{
1387
+				$isaccess = false;
1388
+			}
1389
+			else {
1390
+				$isaccess = (strpos($this->databaseType,'access') !== false);
1391
+			}
1105 1392
 
1106
-			if ($offset <= 0) {
1393
+			if ($offset <= 0)
1394
+			{
1107 1395
 
1108 1396
 					// access includes ties in result
1109
-					if ($isaccess) {
1397
+					if ($isaccess)
1398
+					{
1110 1399
 						$sql = preg_replace(
1111 1400
 						'/(^\s*select\s+(distinctrow|distinct)?)/i','\\1 '.$this->hasTop.' '.(int)$nrows.' ',$sql);
1112 1401
 
1113
-						if ($secs2cache>0) {
1402
+						if ($secs2cache>0)
1403
+						{
1114 1404
 							$ret =& $this->CacheExecute($secs2cache, $sql,$inputarr);
1115
-						} else {
1405
+						}
1406
+						else
1407
+						{
1116 1408
 							$ret =& $this->Execute($sql,$inputarr);
1117 1409
 						}
1118 1410
 						return $ret; // PHP5 fix
1119
-					} else if ($ismssql){
1411
+					}
1412
+					else if ($ismssql)
1413
+					{
1120 1414
 						$sql = preg_replace(
1121 1415
 						'/(^\s*select\s+(distinctrow|distinct)?)/i','\\1 '.$this->hasTop.' '.(int)$nrows.' ',$sql);
1122
-					} else {
1416
+					}
1417
+					else
1418
+					{
1123 1419
 						$sql = preg_replace(
1124 1420
 						'/(^\s*select\s)/i','\\1 '.$this->hasTop.' '.(int)$nrows.' ',$sql);
1125 1421
 					}
1126
-			} else {
1422
+			}
1423
+			else
1424
+			{
1127 1425
 				$nn = $nrows + $offset;
1128
-				if ($isaccess || $ismssql) {
1426
+				if ($isaccess || $ismssql)
1427
+				{
1129 1428
 					$sql = preg_replace(
1130 1429
 					'/(^\s*select\s+(distinctrow|distinct)?)/i','\\1 '.$this->hasTop.' '.$nn.' ',$sql);
1131
-				} else {
1430
+				}
1431
+				else
1432
+				{
1132 1433
 					$sql = preg_replace(
1133 1434
 					'/(^\s*select\s)/i','\\1 '.$this->hasTop.' '.$nn.' ',$sql);
1134 1435
 				}
@@ -1142,15 +1443,29 @@  discard block
 block discarded – undo
1142 1443
 		$savec = $ADODB_COUNTRECS;
1143 1444
 		$ADODB_COUNTRECS = false;
1144 1445
 
1145
-		if ($offset>0){
1146
-			if ($secs2cache>0) $rs = &$this->CacheExecute($secs2cache,$sql,$inputarr);
1147
-			else $rs = &$this->Execute($sql,$inputarr);
1148
-		} else {
1149
-			if ($secs2cache>0) $rs = &$this->CacheExecute($secs2cache,$sql,$inputarr);
1150
-			else $rs = &$this->Execute($sql,$inputarr);
1446
+		if ($offset>0)
1447
+		{
1448
+			if ($secs2cache>0)
1449
+			{
1450
+				$rs = &$this->CacheExecute($secs2cache,$sql,$inputarr);
1451
+			}
1452
+			else {
1453
+				$rs = &$this->Execute($sql,$inputarr);
1454
+			}
1455
+		}
1456
+		else
1457
+		{
1458
+			if ($secs2cache>0)
1459
+			{
1460
+				$rs = &$this->CacheExecute($secs2cache,$sql,$inputarr);
1461
+			}
1462
+			else {
1463
+				$rs = &$this->Execute($sql,$inputarr);
1464
+			}
1151 1465
 		}
1152 1466
 		$ADODB_COUNTRECS = $savec;
1153
-		if ($rs && !$rs->EOF) {
1467
+		if ($rs && !$rs->EOF)
1468
+		{
1154 1469
 			$rs =& $this->_rs2rs($rs,(int)$nrows,(int)$offset);
1155 1470
 		}
1156 1471
 		//print_r($rs);
@@ -1183,28 +1498,35 @@  discard block
 block discarded – undo
1183 1498
 	*/
1184 1499
 	function &_rs2rs(&$rs,$nrows=-1,$offset=-1,$close=true)
1185 1500
 	{
1186
-		if (! $rs) {
1501
+		if (! $rs)
1502
+		{
1187 1503
 			$false = false;
1188 1504
 			return $false;
1189 1505
 		}
1190 1506
 		$dbtype = $rs->databaseType;
1191
-		if (!$dbtype) {
1507
+		if (!$dbtype)
1508
+		{
1192 1509
 			$rs = &$rs;  // required to prevent crashing in 4.2.1, but does not happen in 4.3.1 -- why ?
1193 1510
 			return $rs;
1194 1511
 		}
1195
-		if (($dbtype == 'array' || $dbtype == 'csv') && $nrows == -1 && $offset == -1) {
1512
+		if (($dbtype == 'array' || $dbtype == 'csv') && $nrows == -1 && $offset == -1)
1513
+		{
1196 1514
 			$rs->MoveFirst();
1197 1515
 			$rs = &$rs; // required to prevent crashing in 4.2.1, but does not happen in 4.3.1-- why ?
1198 1516
 			return $rs;
1199 1517
 		}
1200 1518
 		$flds = array();
1201
-		for ($i=0, $max=$rs->FieldCount(); $i < $max; $i++) {
1519
+		for ($i=0, $max=$rs->FieldCount(); $i < $max; $i++)
1520
+		{
1202 1521
 			$flds[] = $rs->FetchField($i);
1203 1522
 		}
1204 1523
 
1205 1524
 		$arr =& $rs->GetArrayLimit($nrows,$offset);
1206 1525
 		//print_r($arr);
1207
-		if ($close) $rs->Close();
1526
+		if ($close)
1527
+		{
1528
+			$rs->Close();
1529
+		}
1208 1530
 
1209 1531
 		$arrayClass = $this->arrayClass;
1210 1532
 
@@ -1229,7 +1551,8 @@  discard block
 block discarded – undo
1229 1551
 	function &GetAssoc($sql, $inputarr=false,$force_array = false, $first2cols = false)
1230 1552
 	{
1231 1553
 		$rs =& $this->Execute($sql, $inputarr);
1232
-		if (!$rs) {
1554
+		if (!$rs)
1555
+		{
1233 1556
 			$false = false;
1234 1557
 			return $false;
1235 1558
 		}
@@ -1239,12 +1562,14 @@  discard block
 block discarded – undo
1239 1562
 
1240 1563
 	function &CacheGetAssoc($secs2cache, $sql=false, $inputarr=false,$force_array = false, $first2cols = false)
1241 1564
 	{
1242
-		if (!is_numeric($secs2cache)) {
1565
+		if (!is_numeric($secs2cache))
1566
+		{
1243 1567
 			$first2cols = $force_array;
1244 1568
 			$force_array = $inputarr;
1245 1569
 		}
1246 1570
 		$rs =& $this->CacheExecute($secs2cache, $sql, $inputarr);
1247
-		if (!$rs) {
1571
+		if (!$rs)
1572
+		{
1248 1573
 			$false = false;
1249 1574
 			return $false;
1250 1575
 		}
@@ -1267,8 +1592,12 @@  discard block
 block discarded – undo
1267 1592
 
1268 1593
 		$ret = false;
1269 1594
 		$rs = &$this->Execute($sql,$inputarr);
1270
-		if ($rs) {
1271
-			if (!$rs->EOF) $ret = reset($rs->fields);
1595
+		if ($rs)
1596
+		{
1597
+			if (!$rs->EOF)
1598
+			{
1599
+				$ret = reset($rs->fields);
1600
+			}
1272 1601
 			$rs->Close();
1273 1602
 		}
1274 1603
 		$ADODB_COUNTRECS = $crecs;
@@ -1279,8 +1608,12 @@  discard block
 block discarded – undo
1279 1608
 	{
1280 1609
 		$ret = false;
1281 1610
 		$rs = &$this->CacheExecute($secs2cache,$sql,$inputarr);
1282
-		if ($rs) {
1283
-			if (!$rs->EOF) $ret = reset($rs->fields);
1611
+		if ($rs)
1612
+		{
1613
+			if (!$rs->EOF)
1614
+			{
1615
+				$ret = reset($rs->fields);
1616
+			}
1284 1617
 			$rs->Close();
1285 1618
 		}
1286 1619
 
@@ -1291,15 +1624,21 @@  discard block
 block discarded – undo
1291 1624
 	{
1292 1625
 	  	$rv = false;
1293 1626
 	  	$rs = &$this->Execute($sql, $inputarr);
1294
-	  	if ($rs) {
1627
+	  	if ($rs)
1628
+	  	{
1295 1629
 			$rv = array();
1296
-	   		if ($trim) {
1297
-				while (!$rs->EOF) {
1630
+	   		if ($trim)
1631
+	   		{
1632
+				while (!$rs->EOF)
1633
+				{
1298 1634
 					$rv[] = trim(reset($rs->fields));
1299 1635
 					$rs->MoveNext();
1300 1636
 		   		}
1301
-			} else {
1302
-				while (!$rs->EOF) {
1637
+			}
1638
+			else
1639
+			{
1640
+				while (!$rs->EOF)
1641
+				{
1303 1642
 					$rv[] = reset($rs->fields);
1304 1643
 					$rs->MoveNext();
1305 1644
 		   		}
@@ -1313,14 +1652,20 @@  discard block
 block discarded – undo
1313 1652
 	{
1314 1653
 	  	$rv = false;
1315 1654
 	  	$rs = &$this->CacheExecute($secs, $sql, $inputarr);
1316
-	  	if ($rs) {
1317
-			if ($trim) {
1318
-				while (!$rs->EOF) {
1655
+	  	if ($rs)
1656
+	  	{
1657
+			if ($trim)
1658
+			{
1659
+				while (!$rs->EOF)
1660
+				{
1319 1661
 					$rv[] = trim(reset($rs->fields));
1320 1662
 					$rs->MoveNext();
1321 1663
 		   		}
1322
-			} else {
1323
-				while (!$rs->EOF) {
1664
+			}
1665
+			else
1666
+			{
1667
+				while (!$rs->EOF)
1668
+				{
1324 1669
 					$rv[] = reset($rs->fields);
1325 1670
 					$rs->MoveNext();
1326 1671
 		   		}
@@ -1339,7 +1684,10 @@  discard block
 block discarded – undo
1339 1684
 	*/
1340 1685
 	function OffsetDate($dayFraction,$date=false)
1341 1686
 	{
1342
-		if (!$date) $date = $this->sysDate;
1687
+		if (!$date)
1688
+		{
1689
+			$date = $this->sysDate;
1690
+		}
1343 1691
 		return  '('.$date.'+'.$dayFraction.')';
1344 1692
 	}
1345 1693
 
@@ -1358,8 +1706,11 @@  discard block
 block discarded – undo
1358 1706
 		$rs =& $this->Execute($sql,$inputarr);
1359 1707
 		$ADODB_COUNTRECS = $savec;
1360 1708
 		if (!$rs)
1361
-			if (defined('ADODB_PEAR')) return ADODB_PEAR_Error();
1362
-			else {
1709
+		{
1710
+					if (defined('ADODB_PEAR')) return ADODB_PEAR_Error();
1711
+		}
1712
+			else
1713
+			{
1363 1714
 				$false = false;
1364 1715
 				return $false;
1365 1716
 			}
@@ -1383,8 +1734,11 @@  discard block
 block discarded – undo
1383 1734
 		$ADODB_COUNTRECS = $savec;
1384 1735
 
1385 1736
 		if (!$rs)
1386
-			if (defined('ADODB_PEAR')) return ADODB_PEAR_Error();
1387
-			else {
1737
+		{
1738
+					if (defined('ADODB_PEAR')) return ADODB_PEAR_Error();
1739
+		}
1740
+			else
1741
+			{
1388 1742
 				$false = false;
1389 1743
 				return $false;
1390 1744
 			}
@@ -1410,9 +1764,15 @@  discard block
 block discarded – undo
1410 1764
 		$rs =& $this->Execute($sql,$inputarr);
1411 1765
 
1412 1766
 		$ADODB_COUNTRECS = $crecs;
1413
-		if ($rs) {
1414
-			if (!$rs->EOF) $arr = $rs->fields;
1415
-			else $arr = array();
1767
+		if ($rs)
1768
+		{
1769
+			if (!$rs->EOF)
1770
+			{
1771
+				$arr = $rs->fields;
1772
+			}
1773
+			else {
1774
+				$arr = array();
1775
+			}
1416 1776
 			$rs->Close();
1417 1777
 			return $arr;
1418 1778
 		}
@@ -1424,9 +1784,13 @@  discard block
 block discarded – undo
1424 1784
 	function &CacheGetRow($secs2cache,$sql=false,$inputarr=false)
1425 1785
 	{
1426 1786
 		$rs =& $this->CacheExecute($secs2cache,$sql,$inputarr);
1427
-		if ($rs) {
1787
+		if ($rs)
1788
+		{
1428 1789
 			$arr = false;
1429
-			if (!$rs->EOF) $arr = $rs->fields;
1790
+			if (!$rs->EOF)
1791
+			{
1792
+				$arr = $rs->fields;
1793
+			}
1430 1794
 			$rs->Close();
1431 1795
 			return $arr;
1432 1796
 		}
@@ -1457,7 +1821,10 @@  discard block
 block discarded – undo
1457 1821
 	function Replace($table, $fieldArray, $keyCol, $autoQuote=false, $has_autoinc=false)
1458 1822
 	{
1459 1823
 		global $ADODB_INCLUDED_LIB;
1460
-		if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
1824
+		if (empty($ADODB_INCLUDED_LIB))
1825
+		{
1826
+			include_once(ADODB_DIR.'/adodb-lib.inc.php');
1827
+		}
1461 1828
 
1462 1829
 		return _adodb_replace($this, $table, $fieldArray, $keyCol, $autoQuote, $has_autoinc);
1463 1830
 	}
@@ -1483,13 +1850,25 @@  discard block
 block discarded – undo
1483 1850
  	*/
1484 1851
 	function &CacheSelectLimit($secs2cache,$sql,$nrows=-1,$offset=-1,$inputarr=false)
1485 1852
 	{
1486
-		if (!is_numeric($secs2cache)) {
1487
-			if ($sql === false) $sql = -1;
1488
-			if ($offset == -1) $offset = false;
1853
+		if (!is_numeric($secs2cache))
1854
+		{
1855
+			if ($sql === false)
1856
+			{
1857
+				$sql = -1;
1858
+			}
1859
+			if ($offset == -1)
1860
+			{
1861
+				$offset = false;
1862
+			}
1489 1863
 									  // sql,	nrows, offset,inputarr
1490 1864
 			$rs =& $this->SelectLimit($secs2cache,$sql,$nrows,$offset,$this->cacheSecs);
1491
-		} else {
1492
-			if ($sql === false) ADOConnection::outp( "Warning: \$sql missing from CacheSelectLimit()");
1865
+		}
1866
+		else
1867
+		{
1868
+			if ($sql === false)
1869
+			{
1870
+				ADOConnection::outp( "Warning: \$sql missing from CacheSelectLimit()");
1871
+			}
1493 1872
 			$rs =& $this->SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache);
1494 1873
 		}
1495 1874
 		return $rs;
@@ -1503,29 +1882,43 @@  discard block
 block discarded – undo
1503 1882
 	{
1504 1883
 	global $ADODB_CACHE_DIR;
1505 1884
 
1506
-		if (strlen($ADODB_CACHE_DIR) > 1 && !$sql) {
1507
-			if (strncmp(PHP_OS,'WIN',3) === 0) {
1885
+		if (strlen($ADODB_CACHE_DIR) > 1 && !$sql)
1886
+		{
1887
+			if (strncmp(PHP_OS,'WIN',3) === 0)
1888
+			{
1508 1889
 				$cmd = 'del /s '.str_replace('/','\\',$ADODB_CACHE_DIR).'\adodb_*.cache';
1509
-			} else {
1890
+			}
1891
+			else
1892
+			{
1510 1893
 				//$cmd = 'find "'.$ADODB_CACHE_DIR.'" -type f -maxdepth 1 -print0 | xargs -0 rm -f';
1511 1894
 				$cmd = 'rm -rf '.$ADODB_CACHE_DIR.'/[0-9a-f][0-9a-f]/';
1512 1895
 				// old version 'rm -f `find '.$ADODB_CACHE_DIR.' -name adodb_*.cache`';
1513 1896
 			}
1514
-			if ($this->debug) {
1897
+			if ($this->debug)
1898
+			{
1515 1899
 				ADOConnection::outp( "CacheFlush: $cmd<br><pre>\n", system($cmd),"</pre>");
1516
-			} else {
1900
+			}
1901
+			else
1902
+			{
1517 1903
 				exec($cmd);
1518 1904
 			}
1519 1905
 			return;
1520 1906
 		}
1521 1907
 
1522 1908
 		global $ADODB_INCLUDED_CSV;
1523
-		if (empty($ADODB_INCLUDED_CSV)) include_once(ADODB_DIR.'/adodb-csvlib.inc.php');
1909
+		if (empty($ADODB_INCLUDED_CSV))
1910
+		{
1911
+			include_once(ADODB_DIR.'/adodb-csvlib.inc.php');
1912
+		}
1524 1913
 
1525 1914
 		$f = $this->_gencachename($sql.serialize($inputarr),false);
1526 1915
 		adodb_write_file($f,''); // is adodb_write_file needed?
1527
-		if (!@unlink($f)) {
1528
-			if ($this->debug) ADOConnection::outp( "CacheFlush: failed for $f");
1916
+		if (!@unlink($f))
1917
+		{
1918
+			if ($this->debug)
1919
+			{
1920
+				ADOConnection::outp( "CacheFlush: failed for $f");
1921
+			}
1529 1922
 		}
1530 1923
 	}
1531 1924
 
@@ -1548,21 +1941,30 @@  discard block
 block discarded – undo
1548 1941
 	global $ADODB_CACHE_DIR;
1549 1942
 	static $notSafeMode;
1550 1943
 
1551
-		if ($this->fetchMode === false) {
1944
+		if ($this->fetchMode === false)
1945
+		{
1552 1946
 		global $ADODB_FETCH_MODE;
1553 1947
 			$mode = $ADODB_FETCH_MODE;
1554
-		} else {
1948
+		}
1949
+		else
1950
+		{
1555 1951
 			$mode = $this->fetchMode;
1556 1952
 		}
1557 1953
 		$m = md5($sql.$this->databaseType.$this->database.$this->user.$mode);
1558 1954
 
1559
-		if (!isset($notSafeMode)) $notSafeMode = !ini_get('safe_mode');
1955
+		if (!isset($notSafeMode))
1956
+		{
1957
+			$notSafeMode = !ini_get('safe_mode');
1958
+		}
1560 1959
 		$dir = ($notSafeMode) ? $ADODB_CACHE_DIR.'/'.substr($m,0,2) : $ADODB_CACHE_DIR;
1561 1960
 
1562
-		if ($createdir && $notSafeMode && !file_exists($dir)) {
1961
+		if ($createdir && $notSafeMode && !file_exists($dir))
1962
+		{
1563 1963
 			$oldu = umask(0);
1564 1964
 			if (!mkdir($dir,0771))
1565
-				if ($this->debug) ADOConnection::outp( "Unable to mkdir $dir for $sql");
1965
+			{
1966
+							if ($this->debug) ADOConnection::outp( "Unable to mkdir $dir for $sql");
1967
+			}
1566 1968
 			umask($oldu);
1567 1969
 		}
1568 1970
 		return $dir.'/adodb_'.$m.'.cache';
@@ -1582,78 +1984,110 @@  discard block
 block discarded – undo
1582 1984
 	{
1583 1985
 
1584 1986
 
1585
-		if (!is_numeric($secs2cache)) {
1987
+		if (!is_numeric($secs2cache))
1988
+		{
1586 1989
 			$inputarr = $sql;
1587 1990
 			$sql = $secs2cache;
1588 1991
 			$secs2cache = $this->cacheSecs;
1589 1992
 		}
1590 1993
 
1591
-		if (is_array($sql)) {
1994
+		if (is_array($sql))
1995
+		{
1592 1996
 			$sqlparam = $sql;
1593 1997
 			$sql = $sql[0];
1594
-		} else
1595
-			$sqlparam = $sql;
1998
+		}
1999
+		else {
2000
+					$sqlparam = $sql;
2001
+		}
1596 2002
 
1597 2003
 		global $ADODB_INCLUDED_CSV;
1598
-		if (empty($ADODB_INCLUDED_CSV)) include_once(ADODB_DIR.'/adodb-csvlib.inc.php');
2004
+		if (empty($ADODB_INCLUDED_CSV))
2005
+		{
2006
+			include_once(ADODB_DIR.'/adodb-csvlib.inc.php');
2007
+		}
1599 2008
 
1600 2009
 		$md5file = $this->_gencachename($sql.serialize($inputarr),true);
1601 2010
 		$err = '';
1602 2011
 
1603
-		if ($secs2cache > 0){
2012
+		if ($secs2cache > 0)
2013
+		{
1604 2014
 			$rs = &csv2rs($md5file,$err,$secs2cache,$this->arrayClass);
1605 2015
 			$this->numCacheHits += 1;
1606
-		} else {
2016
+		}
2017
+		else
2018
+		{
1607 2019
 			$err='Timeout 1';
1608 2020
 			$rs = false;
1609 2021
 			$this->numCacheMisses += 1;
1610 2022
 		}
1611
-		if (!$rs) {
2023
+		if (!$rs)
2024
+		{
1612 2025
 		// no cached rs found
1613
-			if ($this->debug) {
1614
-				if (get_magic_quotes_runtime()) {
2026
+			if ($this->debug)
2027
+			{
2028
+				if (get_magic_quotes_runtime())
2029
+				{
1615 2030
 					ADOConnection::outp("Please disable magic_quotes_runtime - it corrupts cache files :(");
1616 2031
 				}
1617
-				if ($this->debug !== -1) ADOConnection::outp( " $md5file cache failure: $err (see sql below)");
2032
+				if ($this->debug !== -1)
2033
+				{
2034
+					ADOConnection::outp( " $md5file cache failure: $err (see sql below)");
2035
+				}
1618 2036
 			}
1619 2037
 
1620 2038
 			$rs = &$this->Execute($sqlparam,$inputarr);
1621 2039
 
1622
-			if ($rs) {
2040
+			if ($rs)
2041
+			{
1623 2042
 				$eof = $rs->EOF;
1624 2043
 				$rs = &$this->_rs2rs($rs); // read entire recordset into memory immediately
1625 2044
 				$txt = _rs2serialize($rs,false,$sql); // serialize
1626 2045
 
1627
-				if (!adodb_write_file($md5file,$txt,$this->debug)) {
1628
-					if ($fn = $this->raiseErrorFn) {
2046
+				if (!adodb_write_file($md5file,$txt,$this->debug))
2047
+				{
2048
+					if ($fn = $this->raiseErrorFn)
2049
+					{
1629 2050
 						$fn($this->databaseType,'CacheExecute',-32000,"Cache write error",$md5file,$sql,$this);
1630 2051
 					}
1631
-					if ($this->debug) ADOConnection::outp( " Cache write error");
2052
+					if ($this->debug)
2053
+					{
2054
+						ADOConnection::outp( " Cache write error");
2055
+					}
1632 2056
 				}
1633
-				if ($rs->EOF && !$eof) {
2057
+				if ($rs->EOF && !$eof)
2058
+				{
1634 2059
 					$rs->MoveFirst();
1635 2060
 					//$rs = &csv2rs($md5file,$err);
1636 2061
 					$rs->connection = &$this; // Pablo suggestion
1637 2062
 				}
1638 2063
 
1639
-			} else
1640
-				@unlink($md5file);
1641
-		} else {
2064
+			}
2065
+			else {
2066
+							@unlink($md5file);
2067
+			}
2068
+		}
2069
+		else
2070
+		{
1642 2071
 			$this->_errorMsg = '';
1643 2072
 			$this->_errorCode = 0;
1644 2073
 
1645
-			if ($this->fnCacheExecute) {
2074
+			if ($this->fnCacheExecute)
2075
+			{
1646 2076
 				$fn = $this->fnCacheExecute;
1647 2077
 				$fn($this, $secs2cache, $sql, $inputarr);
1648 2078
 			}
1649 2079
 		// ok, set cached object found
1650 2080
 			$rs->connection = &$this; // Pablo suggestion
1651
-			if ($this->debug){
2081
+			if ($this->debug)
2082
+			{
1652 2083
 
1653 2084
 				$inBrowser = isset($_SERVER['HTTP_USER_AGENT']);
1654 2085
 				$ttl = $rs->timeCreated + $secs2cache - time();
1655 2086
 				$s = is_array($sql) ? $sql[0] : $sql;
1656
-				if ($inBrowser) $s = '<i>'.htmlspecialchars($s).'</i>';
2087
+				if ($inBrowser)
2088
+				{
2089
+					$s = '<i>'.htmlspecialchars($s).'</i>';
2090
+				}
1657 2091
 
1658 2092
 				ADOConnection::outp( " $md5file reloaded, ttl=$ttl [ $s ]");
1659 2093
 			}
@@ -1672,17 +2106,26 @@  discard block
 block discarded – undo
1672 2106
 	function& AutoExecute($table, $fields_values, $mode = 'INSERT', $where = FALSE, $forceUpdate=true, $magicq=false)
1673 2107
 	{
1674 2108
 		$sql = 'SELECT * FROM '.$table;
1675
-		if ($where!==FALSE) $sql .= ' WHERE '.$where;
1676
-		else if ($mode == 'UPDATE') {
2109
+		if ($where!==FALSE)
2110
+		{
2111
+			$sql .= ' WHERE '.$where;
2112
+		}
2113
+		else if ($mode == 'UPDATE')
2114
+		{
1677 2115
 			ADOConnection::outp('AutoExecute: Illegal mode=UPDATE with empty WHERE clause');
1678 2116
 			return false;
1679 2117
 		}
1680 2118
 
1681 2119
 		$rs =& $this->SelectLimit($sql,1);
1682
-		if (!$rs) return false; // table does not exist
2120
+		if (!$rs)
2121
+		{
2122
+			return false;
2123
+		}
2124
+		// table does not exist
1683 2125
 		$rs->tableName = $table;
1684 2126
 
1685
-		switch((string) $mode) {
2127
+		switch((string) $mode)
2128
+		{
1686 2129
 		case 'UPDATE':
1687 2130
 		case '2':
1688 2131
 			$sql = $this->GetUpdateSQL($rs, $fields_values, $forceUpdate, $magicq);
@@ -1696,8 +2139,14 @@  discard block
 block discarded – undo
1696 2139
 			return false;
1697 2140
 		}
1698 2141
 		$ret = false;
1699
-		if ($sql) $ret = $this->Execute($sql);
1700
-		if ($ret) $ret = true;
2142
+		if ($sql)
2143
+		{
2144
+			$ret = $this->Execute($sql);
2145
+		}
2146
+		if ($ret)
2147
+		{
2148
+			$ret = true;
2149
+		}
1701 2150
 		return $ret;
1702 2151
 	}
1703 2152
 
@@ -1720,13 +2169,17 @@  discard block
 block discarded – undo
1720 2169
         //********************************************************//
1721 2170
         //This is here to maintain compatibility
1722 2171
         //with older adodb versions. Sets force type to force nulls if $forcenulls is set.
1723
-		if (!isset($force)) {
2172
+		if (!isset($force))
2173
+		{
1724 2174
 				global $ADODB_FORCE_TYPE;
1725 2175
 			    $force = $ADODB_FORCE_TYPE;
1726 2176
 		}
1727 2177
 		//********************************************************//
1728 2178
 
1729
-		if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
2179
+		if (empty($ADODB_INCLUDED_LIB))
2180
+		{
2181
+			include_once(ADODB_DIR.'/adodb-lib.inc.php');
2182
+		}
1730 2183
 		return _adodb_getupdatesql($this,$rs,$arrFields,$forceUpdate,$magicq,$force);
1731 2184
 	}
1732 2185
 
@@ -1744,12 +2197,16 @@  discard block
 block discarded – undo
1744 2197
 	function GetInsertSQL(&$rs, $arrFields,$magicq=false,$force=null)
1745 2198
 	{
1746 2199
 		global $ADODB_INCLUDED_LIB;
1747
-		if (!isset($force)) {
2200
+		if (!isset($force))
2201
+		{
1748 2202
 			global $ADODB_FORCE_TYPE;
1749 2203
 			$force = $ADODB_FORCE_TYPE;
1750 2204
 
1751 2205
 		}
1752
-		if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
2206
+		if (empty($ADODB_INCLUDED_LIB))
2207
+		{
2208
+			include_once(ADODB_DIR.'/adodb-lib.inc.php');
2209
+		}
1753 2210
 		return _adodb_getinsertsql($this,$rs,$arrFields,$magicq,$force);
1754 2211
 	}
1755 2212
 
@@ -1790,7 +2247,10 @@  discard block
 block discarded – undo
1790 2247
 	function UpdateBlobFile($table,$column,$path,$where,$blobtype='BLOB')
1791 2248
 	{
1792 2249
 		$fd = fopen($path,'rb');
1793
-		if ($fd === false) return false;
2250
+		if ($fd === false)
2251
+		{
2252
+			return false;
2253
+		}
1794 2254
 		$val = fread($fd,filesize($path));
1795 2255
 		fclose($fd);
1796 2256
 		return $this->UpdateBlob($table,$column,$val,$where,$blobtype);
@@ -1820,12 +2280,20 @@  discard block
 block discarded – undo
1820 2280
 	{
1821 2281
 		include_once(ADODB_DIR.'/adodb-perf.inc.php');
1822 2282
 
1823
-		if ($enable) $this->fnExecute = 'adodb_log_sql';
1824
-		else $this->fnExecute = false;
2283
+		if ($enable)
2284
+		{
2285
+			$this->fnExecute = 'adodb_log_sql';
2286
+		}
2287
+		else {
2288
+			$this->fnExecute = false;
2289
+		}
1825 2290
 
1826 2291
 		$old = $this->_logsql;
1827 2292
 		$this->_logsql = $enable;
1828
-		if ($enable && !$old) $this->_affected = false;
2293
+		if ($enable && !$old)
2294
+		{
2295
+			$this->_affected = false;
2296
+		}
1829 2297
 		return $old;
1830 2298
 	}
1831 2299
 
@@ -1851,7 +2319,8 @@  discard block
 block discarded – undo
1851 2319
 	function MetaType($t,$len=-1,$fieldobj=false)
1852 2320
 	{
1853 2321
 
1854
-		if (empty($this->_metars)) {
2322
+		if (empty($this->_metars))
2323
+		{
1855 2324
 			$rsclass = $this->rsPrefix.$this->databaseType;
1856 2325
 			$this->_metars = new $rsclass(false,$this->fetchMode);
1857 2326
 		}
@@ -1915,7 +2384,9 @@  discard block
 block discarded – undo
1915 2384
 	 *
1916 2385
 	 * @return true if succeeded or false if database does not support transactions
1917 2386
 	 */
1918
-	function BeginTrans() {return false;}
2387
+	function BeginTrans()
2388
+	{
2389
+return false;}
1919 2390
 
1920 2391
 
1921 2392
 	/**
@@ -1926,7 +2397,8 @@  discard block
 block discarded – undo
1926 2397
 	 * @return true/false.
1927 2398
 	 */
1928 2399
 	function CommitTrans($ok=true)
1929
-	{ return true;}
2400
+	{
2401
+return true;}
1930 2402
 
1931 2403
 
1932 2404
 	/**
@@ -1935,7 +2407,8 @@  discard block
 block discarded – undo
1935 2407
 	 * @return true/false.
1936 2408
 	 */
1937 2409
 	function RollbackTrans()
1938
-	{ return false;}
2410
+	{
2411
+return false;}
1939 2412
 
1940 2413
 
1941 2414
 	/**
@@ -1948,14 +2421,21 @@  discard block
 block discarded – undo
1948 2421
 		{
1949 2422
 		global $ADODB_FETCH_MODE;
1950 2423
 
1951
-			if ($this->metaDatabasesSQL) {
2424
+			if ($this->metaDatabasesSQL)
2425
+			{
1952 2426
 				$save = $ADODB_FETCH_MODE;
1953 2427
 				$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
1954 2428
 
1955
-				if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
2429
+				if ($this->fetchMode !== false)
2430
+				{
2431
+					$savem = $this->SetFetchMode(false);
2432
+				}
1956 2433
 
1957 2434
 				$arr = $this->GetCol($this->metaDatabasesSQL);
1958
-				if (isset($savem)) $this->SetFetchMode($savem);
2435
+				if (isset($savem))
2436
+				{
2437
+					$this->SetFetchMode($savem);
2438
+				}
1959 2439
 				$ADODB_FETCH_MODE = $save;
1960 2440
 
1961 2441
 				return $arr;
@@ -1980,36 +2460,61 @@  discard block
 block discarded – undo
1980 2460
 
1981 2461
 
1982 2462
 		$false = false;
1983
-		if ($mask) {
2463
+		if ($mask)
2464
+		{
1984 2465
 			return $false;
1985 2466
 		}
1986
-		if ($this->metaTablesSQL) {
2467
+		if ($this->metaTablesSQL)
2468
+		{
1987 2469
 			$save = $ADODB_FETCH_MODE;
1988 2470
 			$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
1989 2471
 
1990
-			if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
2472
+			if ($this->fetchMode !== false)
2473
+			{
2474
+				$savem = $this->SetFetchMode(false);
2475
+			}
1991 2476
 
1992 2477
 			$rs = $this->Execute($this->metaTablesSQL);
1993
-			if (isset($savem)) $this->SetFetchMode($savem);
2478
+			if (isset($savem))
2479
+			{
2480
+				$this->SetFetchMode($savem);
2481
+			}
1994 2482
 			$ADODB_FETCH_MODE = $save;
1995 2483
 
1996
-			if ($rs === false) return $false;
2484
+			if ($rs === false)
2485
+			{
2486
+				return $false;
2487
+			}
1997 2488
 			$arr =& $rs->GetArray();
1998 2489
 			$arr2 = array();
1999 2490
 
2000
-			if ($hast = ($ttype && isset($arr[0][1]))) {
2491
+			if ($hast = ($ttype && isset($arr[0][1])))
2492
+			{
2001 2493
 				$showt = strncmp($ttype,'T',1);
2002 2494
 			}
2003 2495
 
2004
-			for ($i=0; $i < sizeof($arr); $i++) {
2005
-				if ($hast) {
2006
-					if ($showt == 0) {
2007
-						if (strncmp($arr[$i][1],'T',1) == 0) $arr2[] = trim($arr[$i][0]);
2008
-					} else {
2009
-						if (strncmp($arr[$i][1],'V',1) == 0) $arr2[] = trim($arr[$i][0]);
2496
+			for ($i=0; $i < sizeof($arr); $i++)
2497
+			{
2498
+				if ($hast)
2499
+				{
2500
+					if ($showt == 0)
2501
+					{
2502
+						if (strncmp($arr[$i][1],'T',1) == 0)
2503
+						{
2504
+							$arr2[] = trim($arr[$i][0]);
2505
+						}
2506
+					}
2507
+					else
2508
+					{
2509
+						if (strncmp($arr[$i][1],'V',1) == 0)
2510
+						{
2511
+							$arr2[] = trim($arr[$i][0]);
2512
+						}
2010 2513
 					}
2011
-				} else
2012
-					$arr2[] = trim($arr[$i][0]);
2514
+				}
2515
+				else {
2516
+									$arr2[] = trim($arr[$i][0]);
2517
+				}
2013 2518
 			}
2014 2519
 			$rs->Close();
2015 2520
 			return $arr2;
@@ -2020,7 +2525,8 @@  discard block
 block discarded – undo
2020 2525
 
2021 2526
 	function _findschema(&$table,&$schema)
2022 2527
 	{
2023
-		if (!$schema && ($at = strpos($table,'.')) !== false) {
2528
+		if (!$schema && ($at = strpos($table,'.')) !== false)
2529
+		{
2024 2530
 			$schema = substr($table,0,$at);
2025 2531
 			$table = substr($table,$at+1);
2026 2532
 		}
@@ -2042,33 +2548,59 @@  discard block
 block discarded – undo
2042 2548
 
2043 2549
 		$false = false;
2044 2550
 
2045
-		if (!empty($this->metaColumnsSQL)) {
2551
+		if (!empty($this->metaColumnsSQL))
2552
+		{
2046 2553
 
2047 2554
 			$schema = false;
2048 2555
 			$this->_findschema($table,$schema);
2049 2556
 
2050 2557
 			$save = $ADODB_FETCH_MODE;
2051 2558
 			$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
2052
-			if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
2559
+			if ($this->fetchMode !== false)
2560
+			{
2561
+				$savem = $this->SetFetchMode(false);
2562
+			}
2053 2563
 			$rs = $this->Execute(sprintf($this->metaColumnsSQL,($upper)?strtoupper($table):$table));
2054
-			if (isset($savem)) $this->SetFetchMode($savem);
2564
+			if (isset($savem))
2565
+			{
2566
+				$this->SetFetchMode($savem);
2567
+			}
2055 2568
 			$ADODB_FETCH_MODE = $save;
2056
-			if ($rs === false || $rs->EOF) return $false;
2569
+			if ($rs === false || $rs->EOF)
2570
+			{
2571
+				return $false;
2572
+			}
2057 2573
 
2058 2574
 			$retarr = array();
2059
-			while (!$rs->EOF) { //print_r($rs->fields);
2575
+			while (!$rs->EOF)
2576
+			{
2577
+//print_r($rs->fields);
2060 2578
 				$fld = new ADOFieldObject();
2061 2579
 				$fld->name = $rs->fields[0];
2062 2580
 				$fld->type = $rs->fields[1];
2063
-				if (isset($rs->fields[3]) && $rs->fields[3]) {
2064
-					if ($rs->fields[3]>0) $fld->max_length = $rs->fields[3];
2581
+				if (isset($rs->fields[3]) && $rs->fields[3])
2582
+				{
2583
+					if ($rs->fields[3]>0)
2584
+					{
2585
+						$fld->max_length = $rs->fields[3];
2586
+					}
2065 2587
 					$fld->scale = $rs->fields[4];
2066
-					if ($fld->scale>0) $fld->max_length += 1;
2067
-				} else
2068
-					$fld->max_length = $rs->fields[2];
2588
+					if ($fld->scale>0)
2589
+					{
2590
+						$fld->max_length += 1;
2591
+					}
2592
+				}
2593
+				else {
2594
+									$fld->max_length = $rs->fields[2];
2595
+				}
2069 2596
 
2070
-				if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld;
2071
-				else $retarr[strtoupper($fld->name)] = $fld;
2597
+				if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM)
2598
+				{
2599
+					$retarr[] = $fld;
2600
+				}
2601
+				else {
2602
+					$retarr[strtoupper($fld->name)] = $fld;
2603
+				}
2072 2604
 				$rs->MoveNext();
2073 2605
 			}
2074 2606
 			$rs->Close();
@@ -2110,16 +2642,23 @@  discard block
 block discarded – undo
2110 2642
 	function &MetaColumnNames($table, $numIndexes=false)
2111 2643
 	{
2112 2644
 		$objarr =& $this->MetaColumns($table);
2113
-		if (!is_array($objarr)) {
2645
+		if (!is_array($objarr))
2646
+		{
2114 2647
 			$false = false;
2115 2648
 			return $false;
2116 2649
 		}
2117 2650
 		$arr = array();
2118
-		if ($numIndexes) {
2651
+		if ($numIndexes)
2652
+		{
2119 2653
 			$i = 0;
2120
-			foreach($objarr as $v) $arr[$i++] = $v->name;
2121
-		} else
2122
-			foreach($objarr as $v) $arr[strtoupper($v->name)] = $v->name;
2654
+			foreach($objarr as $v)
2655
+			{
2656
+				$arr[$i++] = $v->name;
2657
+			}
2658
+		}
2659
+		else {
2660
+					foreach($objarr as $v) $arr[strtoupper($v->name)] = $v->name;
2661
+		}
2123 2662
 
2124 2663
 		return $arr;
2125 2664
 	}
@@ -2150,11 +2689,21 @@  discard block
 block discarded – undo
2150 2689
 	 */
2151 2690
 	function DBDate($d)
2152 2691
 	{
2153
-		if (empty($d) && $d !== 0) return 'null';
2692
+		if (empty($d) && $d !== 0)
2693
+		{
2694
+			return 'null';
2695
+		}
2154 2696
 
2155
-		if (is_string($d) && !is_numeric($d)) {
2156
-			if ($d === 'null' || strncmp($d,"'",1) === 0) return $d;
2157
-			if ($this->isoDates) return "'$d'";
2697
+		if (is_string($d) && !is_numeric($d))
2698
+		{
2699
+			if ($d === 'null' || strncmp($d,"'",1) === 0)
2700
+			{
2701
+				return $d;
2702
+			}
2703
+			if ($this->isoDates)
2704
+			{
2705
+				return "'$d'";
2706
+			}
2158 2707
 			$d = ADOConnection::UnixDate($d);
2159 2708
 		}
2160 2709
 
@@ -2171,14 +2720,25 @@  discard block
 block discarded – undo
2171 2720
 	 */
2172 2721
 	function DBTimeStamp($ts)
2173 2722
 	{
2174
-		if (empty($ts) && $ts !== 0) return 'null';
2723
+		if (empty($ts) && $ts !== 0)
2724
+		{
2725
+			return 'null';
2726
+		}
2175 2727
 
2176 2728
 		# strlen(14) allows YYYYMMDDHHMMSS format
2177 2729
 		if (!is_string($ts) || (is_numeric($ts) && strlen($ts)<14))
2178
-			return adodb_date($this->fmtTimeStamp,$ts);
2730
+		{
2731
+					return adodb_date($this->fmtTimeStamp,$ts);
2732
+		}
2179 2733
 
2180
-		if ($ts === 'null') return $ts;
2181
-		if ($this->isoDates && strlen($ts) !== 14) return "'$ts'";
2734
+		if ($ts === 'null')
2735
+		{
2736
+			return $ts;
2737
+		}
2738
+		if ($this->isoDates && strlen($ts) !== 14)
2739
+		{
2740
+			return "'$ts'";
2741
+		}
2182 2742
 
2183 2743
 		$ts = ADOConnection::UnixTimeStamp($ts);
2184 2744
 		return adodb_date($this->fmtTimeStamp,$ts);
@@ -2192,17 +2752,27 @@  discard block
 block discarded – undo
2192 2752
 	 */
2193 2753
 	function UnixDate($v)
2194 2754
 	{
2195
-		if (is_object($v)) {
2755
+		if (is_object($v))
2756
+		{
2196 2757
 		// odbtp support
2197 2758
 		//( [year] => 2004 [month] => 9 [day] => 4 [hour] => 12 [minute] => 44 [second] => 8 [fraction] => 0 )
2198 2759
 			return adodb_mktime($v->hour,$v->minute,$v->second,$v->month,$v->day, $v->year);
2199 2760
 		}
2200 2761
 
2201
-		if (is_numeric($v) && strlen($v) !== 8) return $v;
2762
+		if (is_numeric($v) && strlen($v) !== 8)
2763
+		{
2764
+			return $v;
2765
+		}
2202 2766
 		if (!preg_match( "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})|",
2203
-			($v), $rr)) return false;
2767
+			($v), $rr))
2768
+		{
2769
+			return false;
2770
+		}
2204 2771
 
2205
-		if ($rr[1] <= TIMESTAMP_FIRST_YEAR) return 0;
2772
+		if ($rr[1] <= TIMESTAMP_FIRST_YEAR)
2773
+		{
2774
+			return 0;
2775
+		}
2206 2776
 		// h-m-s-MM-DD-YY
2207 2777
 		return @adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]);
2208 2778
 	}
@@ -2216,7 +2786,8 @@  discard block
 block discarded – undo
2216 2786
 	 */
2217 2787
 	function UnixTimeStamp($v)
2218 2788
 	{
2219
-		if (is_object($v)) {
2789
+		if (is_object($v))
2790
+		{
2220 2791
 		// odbtp support
2221 2792
 		//( [year] => 2004 [month] => 9 [day] => 4 [hour] => 12 [minute] => 44 [second] => 8 [fraction] => 0 )
2222 2793
 			return adodb_mktime($v->hour,$v->minute,$v->second,$v->month,$v->day, $v->year);
@@ -2224,12 +2795,21 @@  discard block
 block discarded – undo
2224 2795
 
2225 2796
 		if (!preg_match(
2226 2797
 			"|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})[ ,-]*(([0-9]{1,2}):?([0-9]{1,2}):?([0-9\.]{1,4}))?|",
2227
-			($v), $rr)) return false;
2798
+			($v), $rr))
2799
+		{
2800
+			return false;
2801
+		}
2228 2802
 
2229
-		if ($rr[1] <= TIMESTAMP_FIRST_YEAR && $rr[2]<= 1) return 0;
2803
+		if ($rr[1] <= TIMESTAMP_FIRST_YEAR && $rr[2]<= 1)
2804
+		{
2805
+			return 0;
2806
+		}
2230 2807
 
2231 2808
 		// h-m-s-MM-DD-YY
2232
-		if (!isset($rr[5])) return  adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]);
2809
+		if (!isset($rr[5]))
2810
+		{
2811
+			return  adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]);
2812
+		}
2233 2813
 		return  @adodb_mktime($rr[5],$rr[6],$rr[7],$rr[2],$rr[3],$rr[1]);
2234 2814
 	}
2235 2815
 
@@ -2249,9 +2829,17 @@  discard block
 block discarded – undo
2249 2829
 		$tt = $this->UnixDate($v);
2250 2830
 
2251 2831
 		// $tt == -1 if pre TIMESTAMP_FIRST_YEAR
2252
-		if (($tt === false || $tt == -1) && $v != false) return $v;
2253
-		else if ($tt == 0) return $this->emptyDate;
2254
-		else if ($tt == -1) { // pre-TIMESTAMP_FIRST_YEAR
2832
+		if (($tt === false || $tt == -1) && $v != false)
2833
+		{
2834
+			return $v;
2835
+		}
2836
+		else if ($tt == 0)
2837
+		{
2838
+			return $this->emptyDate;
2839
+		}
2840
+		else if ($tt == -1)
2841
+		{
2842
+// pre-TIMESTAMP_FIRST_YEAR
2255 2843
 		}
2256 2844
 
2257 2845
 		return ($gmt) ? adodb_gmdate($fmt,$tt) : adodb_date($fmt,$tt);
@@ -2267,13 +2855,25 @@  discard block
 block discarded – undo
2267 2855
 	 */
2268 2856
 	function UserTimeStamp($v,$fmt='Y-m-d H:i:s',$gmt=false)
2269 2857
 	{
2270
-		if (!isset($v)) return $this->emptyTimeStamp;
2858
+		if (!isset($v))
2859
+		{
2860
+			return $this->emptyTimeStamp;
2861
+		}
2271 2862
 		# strlen(14) allows YYYYMMDDHHMMSS format
2272
-		if (is_numeric($v) && strlen($v)<14) return ($gmt) ? adodb_gmdate($fmt,$v) : adodb_date($fmt,$v);
2863
+		if (is_numeric($v) && strlen($v)<14)
2864
+		{
2865
+			return ($gmt) ? adodb_gmdate($fmt,$v) : adodb_date($fmt,$v);
2866
+		}
2273 2867
 		$tt = $this->UnixTimeStamp($v);
2274 2868
 		// $tt == -1 if pre TIMESTAMP_FIRST_YEAR
2275
-		if (($tt === false || $tt == -1) && $v != false) return $v;
2276
-		if ($tt == 0) return $this->emptyTimeStamp;
2869
+		if (($tt === false || $tt == -1) && $v != false)
2870
+		{
2871
+			return $v;
2872
+		}
2873
+		if ($tt == 0)
2874
+		{
2875
+			return $this->emptyTimeStamp;
2876
+		}
2277 2877
 		return ($gmt) ? adodb_gmdate($fmt,$tt) : adodb_date($fmt,$tt);
2278 2878
 	}
2279 2879
 
@@ -2287,9 +2887,11 @@  discard block
 block discarded – undo
2287 2887
 	*/
2288 2888
 	function addq($s,$magic_quotes=false)
2289 2889
 	{
2290
-		if (!$magic_quotes) {
2890
+		if (!$magic_quotes)
2891
+		{
2291 2892
 
2292
-			if ($this->replaceQuote[0] == '\\'){
2893
+			if ($this->replaceQuote[0] == '\\')
2894
+			{
2293 2895
 				// only since php 4.0.5
2294 2896
 				$s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s);
2295 2897
 				//$s = str_replace("\0","\\\0", str_replace('\\','\\\\',$s));
@@ -2300,9 +2902,14 @@  discard block
 block discarded – undo
2300 2902
 		// undo magic quotes for "
2301 2903
 		$s = str_replace('\\"','"',$s);
2302 2904
 
2303
-		if ($this->replaceQuote == "\\'")  // ' already quoted, no need to change anything
2905
+		if ($this->replaceQuote == "\\'")
2906
+		{
2907
+			// ' already quoted, no need to change anything
2304 2908
 			return $s;
2305
-		else {// change \' to '' for sybase/mssql
2909
+		}
2910
+		else
2911
+		{
2912
+// change \' to '' for sybase/mssql
2306 2913
 			$s = str_replace('\\\\','\\',$s);
2307 2914
 			return str_replace("\\'",$this->replaceQuote,$s);
2308 2915
 		}
@@ -2321,9 +2928,11 @@  discard block
 block discarded – undo
2321 2928
 	 */
2322 2929
 	function qstr($s,$magic_quotes=false)
2323 2930
 	{
2324
-		if (!$magic_quotes) {
2931
+		if (!$magic_quotes)
2932
+		{
2325 2933
 
2326
-			if ($this->replaceQuote[0] == '\\'){
2934
+			if ($this->replaceQuote[0] == '\\')
2935
+			{
2327 2936
 				// only since php 4.0.5
2328 2937
 				$s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s);
2329 2938
 				//$s = str_replace("\0","\\\0", str_replace('\\','\\\\',$s));
@@ -2334,9 +2943,14 @@  discard block
 block discarded – undo
2334 2943
 		// undo magic quotes for "
2335 2944
 		$s = str_replace('\\"','"',$s);
2336 2945
 
2337
-		if ($this->replaceQuote == "\\'")  // ' already quoted, no need to change anything
2946
+		if ($this->replaceQuote == "\\'")
2947
+		{
2948
+			// ' already quoted, no need to change anything
2338 2949
 			return "'$s'";
2339
-		else {// change \' to '' for sybase/mssql
2950
+		}
2951
+		else
2952
+		{
2953
+// change \' to '' for sybase/mssql
2340 2954
 			$s = str_replace('\\\\','\\',$s);
2341 2955
 			return "'".str_replace("\\'",$this->replaceQuote,$s)."'";
2342 2956
 		}
@@ -2363,9 +2977,17 @@  discard block
 block discarded – undo
2363 2977
 	function &PageExecute($sql, $nrows, $page, $inputarr=false, $secs2cache=0)
2364 2978
 	{
2365 2979
 		global $ADODB_INCLUDED_LIB;
2366
-		if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
2367
-		if ($this->pageExecuteCountRows) $rs =& _adodb_pageexecute_all_rows($this, $sql, $nrows, $page, $inputarr, $secs2cache);
2368
-		else $rs =& _adodb_pageexecute_no_last_page($this, $sql, $nrows, $page, $inputarr, $secs2cache);
2980
+		if (empty($ADODB_INCLUDED_LIB))
2981
+		{
2982
+			include_once(ADODB_DIR.'/adodb-lib.inc.php');
2983
+		}
2984
+		if ($this->pageExecuteCountRows)
2985
+		{
2986
+			$rs =& _adodb_pageexecute_all_rows($this, $sql, $nrows, $page, $inputarr, $secs2cache);
2987
+		}
2988
+		else {
2989
+			$rs =& _adodb_pageexecute_no_last_page($this, $sql, $nrows, $page, $inputarr, $secs2cache);
2990
+		}
2369 2991
 		return $rs;
2370 2992
 	}
2371 2993
 
@@ -2405,7 +3027,8 @@  discard block
 block discarded – undo
2405 3027
 	/**
2406 3028
 	* Internal placeholder for record objects. Used by ADORecordSet->FetchObj().
2407 3029
 	*/
2408
-	class ADOFetchObj {
3030
+	class ADOFetchObj
3031
+	{
2409 3032
 	};
2410 3033
 
2411 3034
 	//==============================================================================================
@@ -2423,13 +3046,27 @@  discard block
 block discarded – undo
2423 3046
 		var $_numOfRows = 0;
2424 3047
 		var $fields = false;
2425 3048
 		var $connection = false;
2426
-		function RowCount() {return 0;}
2427
-		function RecordCount() {return 0;}
2428
-		function PO_RecordCount(){return 0;}
2429
-		function Close(){return true;}
2430
-		function FetchRow() {return false;}
2431
-		function FieldCount(){ return 0;}
2432
-		function Init() {}
3049
+		function RowCount()
3050
+		{
3051
+return 0;}
3052
+		function RecordCount()
3053
+		{
3054
+return 0;}
3055
+		function PO_RecordCount()
3056
+		{
3057
+return 0;}
3058
+		function Close()
3059
+		{
3060
+return true;}
3061
+		function FetchRow()
3062
+		{
3063
+return false;}
3064
+		function FieldCount()
3065
+		{
3066
+return 0;}
3067
+		function Init()
3068
+		{
3069
+}
2433 3070
 	}
2434 3071
 
2435 3072
 	//==============================================================================================
@@ -2441,15 +3078,21 @@  discard block
 block discarded – undo
2441 3078
 	// CLASS ADORecordSet
2442 3079
 	//==============================================================================================
2443 3080
 
2444
-	if (PHP_VERSION < 5) include_once(ADODB_DIR.'/adodb-php4.inc.php');
2445
-	else include_once(ADODB_DIR.'/adodb-iterator.inc.php');
3081
+	if (PHP_VERSION < 5)
3082
+	{
3083
+		include_once(ADODB_DIR.'/adodb-php4.inc.php');
3084
+	}
3085
+	else {
3086
+		include_once(ADODB_DIR.'/adodb-iterator.inc.php');
3087
+	}
2446 3088
    /**
2447 3089
 	 * RecordSet class that represents the dataset returned by the database.
2448 3090
 	 * To keep memory overhead low, this class holds only the current row in memory.
2449 3091
 	 * No prefetching of data is done, so the RecordCount() can return -1 ( which
2450 3092
 	 * means recordcount not known).
2451 3093
 	 */
2452
-	class ADORecordSet extends ADODB_BASE_RS {
3094
+	class ADORecordSet extends ADODB_BASE_RS
3095
+	{
2453 3096
 	/*
2454 3097
 	 * public variables
2455 3098
 	 */
@@ -2503,20 +3146,31 @@  discard block
 block discarded – undo
2503 3146
 
2504 3147
 	function Init()
2505 3148
 	{
2506
-		if ($this->_inited) return;
3149
+		if ($this->_inited)
3150
+		{
3151
+			return;
3152
+		}
2507 3153
 		$this->_inited = true;
2508
-		if ($this->_queryID) @$this->_initrs();
2509
-		else {
3154
+		if ($this->_queryID)
3155
+		{
3156
+			@$this->_initrs();
3157
+		}
3158
+		else
3159
+		{
2510 3160
 			$this->_numOfRows = 0;
2511 3161
 			$this->_numOfFields = 0;
2512 3162
 		}
2513
-		if ($this->_numOfRows != 0 && $this->_numOfFields && $this->_currentRow == -1) {
3163
+		if ($this->_numOfRows != 0 && $this->_numOfFields && $this->_currentRow == -1)
3164
+		{
2514 3165
 
2515 3166
 			$this->_currentRow = 0;
2516
-			if ($this->EOF = ($this->_fetch() === false)) {
3167
+			if ($this->EOF = ($this->_fetch() === false))
3168
+			{
2517 3169
 				$this->_numOfRows = 0; // _numOfRows could be -1
2518 3170
 			}
2519
-		} else {
3171
+		}
3172
+		else
3173
+		{
2520 3174
 			$this->EOF = true;
2521 3175
 		}
2522 3176
 	}
@@ -2546,7 +3200,10 @@  discard block
 block discarded – undo
2546 3200
 			$size=0, $selectAttr='',$compareFields0=true)
2547 3201
 	{
2548 3202
 		global $ADODB_INCLUDED_LIB;
2549
-		if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
3203
+		if (empty($ADODB_INCLUDED_LIB))
3204
+		{
3205
+			include_once(ADODB_DIR.'/adodb-lib.inc.php');
3206
+		}
2550 3207
 		return _adodb_getmenu($this, $name,$defstr,$blank1stItem,$multiple,
2551 3208
 			$size, $selectAttr,$compareFields0);
2552 3209
 	}
@@ -2573,7 +3230,10 @@  discard block
 block discarded – undo
2573 3230
 			$size=0, $selectAttr='')
2574 3231
 	{
2575 3232
 		global $ADODB_INCLUDED_LIB;
2576
-		if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
3233
+		if (empty($ADODB_INCLUDED_LIB))
3234
+		{
3235
+			include_once(ADODB_DIR.'/adodb-lib.inc.php');
3236
+		}
2577 3237
 		return _adodb_getmenu_gp($this, $name,$defstr,$blank1stItem,$multiple,
2578 3238
 			$size, $selectAttr,false);
2579 3239
 	}
@@ -2587,11 +3247,15 @@  discard block
 block discarded – undo
2587 3247
 	 */
2588 3248
 	function &GetArray($nRows = -1)
2589 3249
 	{
2590
-	global $ADODB_EXTENSION; if ($ADODB_EXTENSION) return adodb_getall($this,$nRows);
3250
+	global $ADODB_EXTENSION; if ($ADODB_EXTENSION)
3251
+	{
3252
+		return adodb_getall($this,$nRows);
3253
+	}
2591 3254
 
2592 3255
 		$results = array();
2593 3256
 		$cnt = 0;
2594
-		while (!$this->EOF && $nRows != $cnt) {
3257
+		while (!$this->EOF && $nRows != $cnt)
3258
+		{
2595 3259
 			$results[] = $this->fields;
2596 3260
 			$this->MoveNext();
2597 3261
 			$cnt++;
@@ -2625,7 +3289,8 @@  discard block
 block discarded – undo
2625 3289
 	 */
2626 3290
 	function &GetArrayLimit($nrows,$offset=-1)
2627 3291
 	{
2628
-		if ($offset <= 0) {
3292
+		if ($offset <= 0)
3293
+		{
2629 3294
 			$arr =& $this->GetArray($nrows);
2630 3295
 			return $arr;
2631 3296
 		}
@@ -2634,7 +3299,8 @@  discard block
 block discarded – undo
2634 3299
 
2635 3300
 		$results = array();
2636 3301
 		$cnt = 0;
2637
-		while (!$this->EOF && $nrows != $cnt) {
3302
+		while (!$this->EOF && $nrows != $cnt)
3303
+		{
2638 3304
 			$results[$cnt++] = $this->fields;
2639 3305
 			$this->MoveNext();
2640 3306
 		}
@@ -2677,50 +3343,73 @@  discard block
 block discarded – undo
2677 3343
 	global $ADODB_EXTENSION;
2678 3344
 
2679 3345
 		$cols = $this->_numOfFields;
2680
-		if ($cols < 2) {
3346
+		if ($cols < 2)
3347
+		{
2681 3348
 			$false = false;
2682 3349
 			return $false;
2683 3350
 		}
2684 3351
 		$numIndex = isset($this->fields[0]);
2685 3352
 		$results = array();
2686 3353
 
2687
-		if (!$first2cols && ($cols > 2 || $force_array)) {
2688
-			if ($ADODB_EXTENSION) {
2689
-				if ($numIndex) {
2690
-					while (!$this->EOF) {
3354
+		if (!$first2cols && ($cols > 2 || $force_array))
3355
+		{
3356
+			if ($ADODB_EXTENSION)
3357
+			{
3358
+				if ($numIndex)
3359
+				{
3360
+					while (!$this->EOF)
3361
+					{
2691 3362
 						$results[trim($this->fields[0])] = array_slice($this->fields, 1);
2692 3363
 						adodb_movenext($this);
2693 3364
 					}
2694
-				} else {
2695
-					while (!$this->EOF) {
3365
+				}
3366
+				else
3367
+				{
3368
+					while (!$this->EOF)
3369
+					{
2696 3370
 						$results[trim(reset($this->fields))] = array_slice($this->fields, 1);
2697 3371
 						adodb_movenext($this);
2698 3372
 					}
2699 3373
 				}
2700
-			} else {
2701
-				if ($numIndex) {
2702
-					while (!$this->EOF) {
3374
+			}
3375
+			else
3376
+			{
3377
+				if ($numIndex)
3378
+				{
3379
+					while (!$this->EOF)
3380
+					{
2703 3381
 						$results[trim($this->fields[0])] = array_slice($this->fields, 1);
2704 3382
 						$this->MoveNext();
2705 3383
 					}
2706
-				} else {
2707
-					while (!$this->EOF) {
3384
+				}
3385
+				else
3386
+				{
3387
+					while (!$this->EOF)
3388
+					{
2708 3389
 						$results[trim(reset($this->fields))] = array_slice($this->fields, 1);
2709 3390
 						$this->MoveNext();
2710 3391
 					}
2711 3392
 				}
2712 3393
 			}
2713
-		} else {
2714
-			if ($ADODB_EXTENSION) {
3394
+		}
3395
+		else
3396
+		{
3397
+			if ($ADODB_EXTENSION)
3398
+			{
2715 3399
 				// return scalar values
2716
-				if ($numIndex) {
2717
-					while (!$this->EOF) {
3400
+				if ($numIndex)
3401
+				{
3402
+					while (!$this->EOF)
3403
+					{
2718 3404
 					// some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string
2719 3405
 						$results[trim(($this->fields[0]))] = $this->fields[1];
2720 3406
 						adodb_movenext($this);
2721 3407
 					}
2722
-				} else {
2723
-					while (!$this->EOF) {
3408
+				}
3409
+				else
3410
+				{
3411
+					while (!$this->EOF)
3412
+					{
2724 3413
 					// some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string
2725 3414
 						$v1 = trim(reset($this->fields));
2726 3415
 						$v2 = ''.next($this->fields);
@@ -2728,15 +3417,22 @@  discard block
 block discarded – undo
2728 3417
 						adodb_movenext($this);
2729 3418
 					}
2730 3419
 				}
2731
-			} else {
2732
-				if ($numIndex) {
2733
-					while (!$this->EOF) {
3420
+			}
3421
+			else
3422
+			{
3423
+				if ($numIndex)
3424
+				{
3425
+					while (!$this->EOF)
3426
+					{
2734 3427
 					// some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string
2735 3428
 						$results[trim(($this->fields[0]))] = $this->fields[1];
2736 3429
 						$this->MoveNext();
2737 3430
 					}
2738
-				} else {
2739
-					while (!$this->EOF) {
3431
+				}
3432
+				else
3433
+				{
3434
+					while (!$this->EOF)
3435
+					{
2740 3436
 					// some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string
2741 3437
 						$v1 = trim(reset($this->fields));
2742 3438
 						$v2 = ''.next($this->fields);
@@ -2759,11 +3455,20 @@  discard block
 block discarded – undo
2759 3455
 	 */
2760 3456
 	function UserTimeStamp($v,$fmt='Y-m-d H:i:s')
2761 3457
 	{
2762
-		if (is_numeric($v) && strlen($v)<14) return adodb_date($fmt,$v);
3458
+		if (is_numeric($v) && strlen($v)<14)
3459
+		{
3460
+			return adodb_date($fmt,$v);
3461
+		}
2763 3462
 		$tt = $this->UnixTimeStamp($v);
2764 3463
 		// $tt == -1 if pre TIMESTAMP_FIRST_YEAR
2765
-		if (($tt === false || $tt == -1) && $v != false) return $v;
2766
-		if ($tt === 0) return $this->emptyTimeStamp;
3464
+		if (($tt === false || $tt == -1) && $v != false)
3465
+		{
3466
+			return $v;
3467
+		}
3468
+		if ($tt === 0)
3469
+		{
3470
+			return $this->emptyTimeStamp;
3471
+		}
2767 3472
 		return adodb_date($fmt,$tt);
2768 3473
 	}
2769 3474
 
@@ -2778,9 +3483,17 @@  discard block
 block discarded – undo
2778 3483
 	{
2779 3484
 		$tt = $this->UnixDate($v);
2780 3485
 		// $tt == -1 if pre TIMESTAMP_FIRST_YEAR
2781
-		if (($tt === false || $tt == -1) && $v != false) return $v;
2782
-		else if ($tt == 0) return $this->emptyDate;
2783
-		else if ($tt == -1) { // pre-TIMESTAMP_FIRST_YEAR
3486
+		if (($tt === false || $tt == -1) && $v != false)
3487
+		{
3488
+			return $v;
3489
+		}
3490
+		else if ($tt == 0)
3491
+		{
3492
+			return $this->emptyDate;
3493
+		}
3494
+		else if ($tt == -1)
3495
+		{
3496
+// pre-TIMESTAMP_FIRST_YEAR
2784 3497
 		}
2785 3498
 		return adodb_date($fmt,$tt);
2786 3499
 	}
@@ -2842,13 +3555,17 @@  discard block
 block discarded – undo
2842 3555
 	*/
2843 3556
 	function &FetchRow()
2844 3557
 	{
2845
-		if ($this->EOF) {
3558
+		if ($this->EOF)
3559
+		{
2846 3560
 			$false = false;
2847 3561
 			return $false;
2848 3562
 		}
2849 3563
 		$arr = $this->fields;
2850 3564
 		$this->_currentRow++;
2851
-		if (!$this->_fetch()) $this->EOF = true;
3565
+		if (!$this->_fetch())
3566
+		{
3567
+			$this->EOF = true;
3568
+		}
2852 3569
 		return $arr;
2853 3570
 	}
2854 3571
 
@@ -2861,7 +3578,10 @@  discard block
 block discarded – undo
2861 3578
 	*/
2862 3579
 	function FetchInto(&$arr)
2863 3580
 	{
2864
-		if ($this->EOF) return (defined('PEAR_ERROR_RETURN')) ? new PEAR_Error('EOF',-1): false;
3581
+		if ($this->EOF)
3582
+		{
3583
+			return (defined('PEAR_ERROR_RETURN')) ? new PEAR_Error('EOF',-1): false;
3584
+		}
2865 3585
 		$arr = $this->fields;
2866 3586
 		$this->MoveNext();
2867 3587
 		return 1; // DB_OK
@@ -2875,7 +3595,10 @@  discard block
 block discarded – undo
2875 3595
 	 */
2876 3596
 	function MoveFirst()
2877 3597
 	{
2878
-		if ($this->_currentRow == 0) return true;
3598
+		if ($this->_currentRow == 0)
3599
+		{
3600
+			return true;
3601
+		}
2879 3602
 		return $this->Move(0);
2880 3603
 	}
2881 3604
 
@@ -2887,9 +3610,16 @@  discard block
 block discarded – undo
2887 3610
 	 */
2888 3611
 	function MoveLast()
2889 3612
 	{
2890
-		if ($this->_numOfRows >= 0) return $this->Move($this->_numOfRows-1);
2891
-		if ($this->EOF) return false;
2892
-		while (!$this->EOF) {
3613
+		if ($this->_numOfRows >= 0)
3614
+		{
3615
+			return $this->Move($this->_numOfRows-1);
3616
+		}
3617
+		if ($this->EOF)
3618
+		{
3619
+			return false;
3620
+		}
3621
+		while (!$this->EOF)
3622
+		{
2893 3623
 			$f = $this->fields;
2894 3624
 			$this->MoveNext();
2895 3625
 		}
@@ -2906,9 +3636,13 @@  discard block
 block discarded – undo
2906 3636
 	 */
2907 3637
 	function MoveNext()
2908 3638
 	{
2909
-		if (!$this->EOF) {
3639
+		if (!$this->EOF)
3640
+		{
2910 3641
 			$this->_currentRow++;
2911
-			if ($this->_fetch()) return true;
3642
+			if ($this->_fetch())
3643
+			{
3644
+				return true;
3645
+			}
2912 3646
 		}
2913 3647
 		$this->EOF = true;
2914 3648
 		/* -- tested error handling when scrolling cursor -- seems useless.
@@ -2933,34 +3667,57 @@  discard block
 block discarded – undo
2933 3667
 	function Move($rowNumber = 0)
2934 3668
 	{
2935 3669
 		$this->EOF = false;
2936
-		if ($rowNumber == $this->_currentRow) return true;
3670
+		if ($rowNumber == $this->_currentRow)
3671
+		{
3672
+			return true;
3673
+		}
2937 3674
 		if ($rowNumber >= $this->_numOfRows)
2938
-	   		if ($this->_numOfRows != -1) $rowNumber = $this->_numOfRows-2;
3675
+		{
3676
+			   		if ($this->_numOfRows != -1) $rowNumber = $this->_numOfRows-2;
3677
+		}
2939 3678
 
2940
-		if ($this->canSeek) {
3679
+		if ($this->canSeek)
3680
+		{
2941 3681
 
2942
-			if ($this->_seek($rowNumber)) {
3682
+			if ($this->_seek($rowNumber))
3683
+			{
2943 3684
 				$this->_currentRow = $rowNumber;
2944
-				if ($this->_fetch()) {
3685
+				if ($this->_fetch())
3686
+				{
2945 3687
 					return true;
2946 3688
 				}
2947
-			} else {
3689
+			}
3690
+			else
3691
+			{
2948 3692
 				$this->EOF = true;
2949 3693
 				return false;
2950 3694
 			}
2951
-		} else {
2952
-			if ($rowNumber < $this->_currentRow) return false;
3695
+		}
3696
+		else
3697
+		{
3698
+			if ($rowNumber < $this->_currentRow)
3699
+			{
3700
+				return false;
3701
+			}
2953 3702
 			global $ADODB_EXTENSION;
2954
-			if ($ADODB_EXTENSION) {
2955
-				while (!$this->EOF && $this->_currentRow < $rowNumber) {
3703
+			if ($ADODB_EXTENSION)
3704
+			{
3705
+				while (!$this->EOF && $this->_currentRow < $rowNumber)
3706
+				{
2956 3707
 					adodb_movenext($this);
2957 3708
 				}
2958
-			} else {
3709
+			}
3710
+			else
3711
+			{
2959 3712
 
2960
-				while (! $this->EOF && $this->_currentRow < $rowNumber) {
3713
+				while (! $this->EOF && $this->_currentRow < $rowNumber)
3714
+				{
2961 3715
 					$this->_currentRow++;
2962 3716
 
2963
-					if (!$this->_fetch()) $this->EOF = true;
3717
+					if (!$this->_fetch())
3718
+					{
3719
+						$this->EOF = true;
3720
+					}
2964 3721
 				}
2965 3722
 			}
2966 3723
 			return !($this->EOF);
@@ -2988,10 +3745,16 @@  discard block
 block discarded – undo
2988 3745
 	function GetAssocKeys($upper=true)
2989 3746
 	{
2990 3747
 		$this->bind = array();
2991
-		for ($i=0; $i < $this->_numOfFields; $i++) {
3748
+		for ($i=0; $i < $this->_numOfFields; $i++)
3749
+		{
2992 3750
 			$o = $this->FetchField($i);
2993
-			if ($upper === 2) $this->bind[$o->name] = $i;
2994
-			else $this->bind[($upper) ? strtoupper($o->name) : strtolower($o->name)] = $i;
3751
+			if ($upper === 2)
3752
+			{
3753
+				$this->bind[$o->name] = $i;
3754
+			}
3755
+			else {
3756
+				$this->bind[($upper) ? strtoupper($o->name) : strtolower($o->name)] = $i;
3757
+			}
2995 3758
 		}
2996 3759
 	}
2997 3760
 
@@ -3009,11 +3772,13 @@  discard block
 block discarded – undo
3009 3772
 		$record = array();
3010 3773
 	 //	if (!$this->fields) return $record;
3011 3774
 
3012
-	   	if (!$this->bind) {
3775
+	   	if (!$this->bind)
3776
+	   	{
3013 3777
 			$this->GetAssocKeys($upper);
3014 3778
 		}
3015 3779
 
3016
-		foreach($this->bind as $k => $v) {
3780
+		foreach($this->bind as $k => $v)
3781
+		{
3017 3782
 			$record[$k] = $this->fields[$v];
3018 3783
 		}
3019 3784
 
@@ -3031,11 +3796,14 @@  discard block
 block discarded – undo
3031 3796
 		// free connection object - this seems to globally free the object
3032 3797
 		// and not merely the reference, so don't do this...
3033 3798
 		// $this->connection = false;
3034
-		if (!$this->_closed) {
3799
+		if (!$this->_closed)
3800
+		{
3035 3801
 			$this->_closed = true;
3036 3802
 			return $this->_close();
3037
-		} else
3038
-			return true;
3803
+		}
3804
+		else {
3805
+					return true;
3806
+		}
3039 3807
 	}
3040 3808
 
3041 3809
 	/**
@@ -3043,7 +3811,9 @@  discard block
 block discarded – undo
3043 3811
 	 *
3044 3812
 	 * @return the number of rows or -1 if this is not supported
3045 3813
 	 */
3046
-	function RecordCount() {return $this->_numOfRows;}
3814
+	function RecordCount()
3815
+	{
3816
+return $this->_numOfRows;}
3047 3817
 
3048 3818
 
3049 3819
 	/*
@@ -3060,7 +3830,9 @@  discard block
 block discarded – undo
3060 3830
 	 *
3061 3831
 	 * @return the number of rows or -1 if this is not supported
3062 3832
 	 */
3063
-	function RowCount() {return $this->_numOfRows;}
3833
+	function RowCount()
3834
+	{
3835
+return $this->_numOfRows;}
3064 3836
 
3065 3837
 
3066 3838
 	 /**
@@ -3071,15 +3843,24 @@  discard block
 block discarded – undo
3071 3843
 	 * But aware possible problems in multiuser environments. For better speed the table
3072 3844
 	 * must be indexed by the condition. Heavy test this before deploying.
3073 3845
 	 */
3074
-	function PO_RecordCount($table="", $condition="") {
3846
+	function PO_RecordCount($table="", $condition="")
3847
+	{
3075 3848
 
3076 3849
 		$lnumrows = $this->_numOfRows;
3077 3850
 		// the database doesn't support native recordcount, so we do a workaround
3078
-		if ($lnumrows == -1 && $this->connection) {
3079
-			IF ($table) {
3080
-				if ($condition) $condition = " WHERE " . $condition;
3851
+		if ($lnumrows == -1 && $this->connection)
3852
+		{
3853
+			IF ($table)
3854
+			{
3855
+				if ($condition)
3856
+				{
3857
+					$condition = " WHERE " . $condition;
3858
+				}
3081 3859
 				$resultrows = &$this->connection->Execute("SELECT COUNT(*) FROM $table $condition");
3082
-				if ($resultrows) $lnumrows = reset($resultrows->fields);
3860
+				if ($resultrows)
3861
+				{
3862
+					$lnumrows = reset($resultrows->fields);
3863
+				}
3083 3864
 			}
3084 3865
 		}
3085 3866
 		return $lnumrows;
@@ -3088,20 +3869,26 @@  discard block
 block discarded – undo
3088 3869
 	/**
3089 3870
 	 * @return the current row in the recordset. If at EOF, will return the last row. 0-based.
3090 3871
 	 */
3091
-	function CurrentRow() {return $this->_currentRow;}
3872
+	function CurrentRow()
3873
+	{
3874
+return $this->_currentRow;}
3092 3875
 
3093 3876
 	/**
3094 3877
 	 * synonym for CurrentRow -- for ADO compat
3095 3878
 	 *
3096 3879
 	 * @return the current row in the recordset. If at EOF, will return the last row. 0-based.
3097 3880
 	 */
3098
-	function AbsolutePosition() {return $this->_currentRow;}
3881
+	function AbsolutePosition()
3882
+	{
3883
+return $this->_currentRow;}
3099 3884
 
3100 3885
 	/**
3101 3886
 	 * @return the number of columns in the recordset. Some databases will set this to 0
3102 3887
 	 * if no records are returned, others will return the number of columns in the query.
3103 3888
 	 */
3104
-	function FieldCount() {return $this->_numOfFields;}
3889
+	function FieldCount()
3890
+	{
3891
+return $this->_numOfFields;}
3105 3892
 
3106 3893
 
3107 3894
 	/**
@@ -3124,7 +3911,9 @@  discard block
 block discarded – undo
3124 3911
 	{
3125 3912
 		$arr = array();
3126 3913
 		for ($i=0, $max=$this->_numOfFields; $i < $max; $i++)
3127
-			$arr[] = $this->FetchField($i);
3914
+		{
3915
+					$arr[] = $this->FetchField($i);
3916
+		}
3128 3917
 		return $arr;
3129 3918
 	}
3130 3919
 
@@ -3150,22 +3939,35 @@  discard block
 block discarded – undo
3150 3939
 	*/
3151 3940
 	function &FetchObject($isupper=true)
3152 3941
 	{
3153
-		if (empty($this->_obj)) {
3942
+		if (empty($this->_obj))
3943
+		{
3154 3944
 			$this->_obj = new ADOFetchObj();
3155 3945
 			$this->_names = array();
3156
-			for ($i=0; $i <$this->_numOfFields; $i++) {
3946
+			for ($i=0; $i <$this->_numOfFields; $i++)
3947
+			{
3157 3948
 				$f = $this->FetchField($i);
3158 3949
 				$this->_names[] = $f->name;
3159 3950
 			}
3160 3951
 		}
3161 3952
 		$i = 0;
3162
-		if (PHP_VERSION >= 5) $o = clone($this->_obj);
3163
-		else $o = $this->_obj;
3953
+		if (PHP_VERSION >= 5)
3954
+		{
3955
+			$o = clone($this->_obj);
3956
+		}
3957
+		else {
3958
+			$o = $this->_obj;
3959
+		}
3164 3960
 
3165
-		for ($i=0; $i <$this->_numOfFields; $i++) {
3961
+		for ($i=0; $i <$this->_numOfFields; $i++)
3962
+		{
3166 3963
 			$name = $this->_names[$i];
3167
-			if ($isupper) $n = strtoupper($name);
3168
-			else $n = $name;
3964
+			if ($isupper)
3965
+			{
3966
+				$n = strtoupper($name);
3967
+			}
3968
+			else {
3969
+				$n = $name;
3970
+			}
3169 3971
 
3170 3972
 			$o->$n = $this->Fields($name);
3171 3973
 		}
@@ -3202,10 +4004,14 @@  discard block
 block discarded – undo
3202 4004
 	function &FetchNextObject($isupper=true)
3203 4005
 	{
3204 4006
 		$o = false;
3205
-		if ($this->_numOfRows != 0 && !$this->EOF) {
4007
+		if ($this->_numOfRows != 0 && !$this->EOF)
4008
+		{
3206 4009
 			$o = $this->FetchObject($isupper);
3207 4010
 			$this->_currentRow++;
3208
-			if ($this->_fetch()) return $o;
4011
+			if ($this->_fetch())
4012
+			{
4013
+				return $o;
4014
+			}
3209 4015
 		}
3210 4016
 		$this->EOF = true;
3211 4017
 		return $o;
@@ -3237,7 +4043,8 @@  discard block
 block discarded – undo
3237 4043
 	*/
3238 4044
 	function MetaType($t,$len=-1,$fieldobj=false)
3239 4045
 	{
3240
-		if (is_object($t)) {
4046
+		if (is_object($t))
4047
+		{
3241 4048
 			$fieldobj = $t;
3242 4049
 			$t = $fieldobj->type;
3243 4050
 			$len = $fieldobj->max_length;
@@ -3337,19 +4144,29 @@  discard block
 block discarded – undo
3337 4144
 		$tmap = false;
3338 4145
 		$t = strtoupper($t);
3339 4146
 		$tmap = (isset($typeMap[$t])) ? $typeMap[$t] : 'N';
3340
-		switch ($tmap) {
4147
+		switch ($tmap)
4148
+		{
3341 4149
 		case 'C':
3342 4150
 
3343 4151
 			// is the char field is too long, return as text field...
3344
-			if ($this->blobSize >= 0) {
3345
-				if ($len > $this->blobSize) return 'X';
3346
-			} else if ($len > 250) {
4152
+			if ($this->blobSize >= 0)
4153
+			{
4154
+				if ($len > $this->blobSize)
4155
+				{
4156
+					return 'X';
4157
+				}
4158
+			}
4159
+			else if ($len > 250)
4160
+			{
3347 4161
 				return 'X';
3348 4162
 			}
3349 4163
 			return 'C';
3350 4164
 
3351 4165
 		case 'I':
3352
-			if (!empty($fieldobj->primary_key)) return 'R';
4166
+			if (!empty($fieldobj->primary_key))
4167
+			{
4168
+				return 'R';
4169
+			}
3353 4170
 			return 'I';
3354 4171
 
3355 4172
 		case false:
@@ -3357,27 +4174,40 @@  discard block
 block discarded – undo
3357 4174
 
3358 4175
 		case 'B':
3359 4176
 			 if (isset($fieldobj->binary))
3360
-				 return ($fieldobj->binary) ? 'B' : 'X';
4177
+			 {
4178
+			 				 return ($fieldobj->binary) ? 'B' : 'X';
4179
+			 }
3361 4180
 			return 'B';
3362 4181
 
3363 4182
 		case 'D':
3364
-			if (!empty($this->datetime)) return 'T';
4183
+			if (!empty($this->datetime))
4184
+			{
4185
+				return 'T';
4186
+			}
3365 4187
 			return 'D';
3366 4188
 
3367 4189
 		default:
3368
-			if ($t == 'LONG' && $this->dataProvider == 'oci8') return 'B';
4190
+			if ($t == 'LONG' && $this->dataProvider == 'oci8')
4191
+			{
4192
+				return 'B';
4193
+			}
3369 4194
 			return $tmap;
3370 4195
 		}
3371 4196
 	}
3372 4197
 
3373
-	function _close() {}
4198
+	function _close()
4199
+	{
4200
+}
3374 4201
 
3375 4202
 	/**
3376 4203
 	 * set/returns the current recordset page when paginating
3377 4204
 	 */
3378 4205
 	function AbsolutePage($page=-1)
3379 4206
 	{
3380
-		if ($page != -1) $this->_currentPage = $page;
4207
+		if ($page != -1)
4208
+		{
4209
+			$this->_currentPage = $page;
4210
+		}
3381 4211
 		return $this->_currentPage;
3382 4212
 	}
3383 4213
 
@@ -3386,13 +4216,19 @@  discard block
 block discarded – undo
3386 4216
 	 */
3387 4217
 	function AtFirstPage($status=false)
3388 4218
 	{
3389
-		if ($status != false) $this->_atFirstPage = $status;
4219
+		if ($status != false)
4220
+		{
4221
+			$this->_atFirstPage = $status;
4222
+		}
3390 4223
 		return $this->_atFirstPage;
3391 4224
 	}
3392 4225
 
3393 4226
 	function LastPageNo($page = false)
3394 4227
 	{
3395
-		if ($page != false) $this->_lastPageNo = $page;
4228
+		if ($page != false)
4229
+		{
4230
+			$this->_lastPageNo = $page;
4231
+		}
3396 4232
 		return $this->_lastPageNo;
3397 4233
 	}
3398 4234
 
@@ -3401,7 +4237,10 @@  discard block
 block discarded – undo
3401 4237
 	 */
3402 4238
 	function AtLastPage($status=false)
3403 4239
 	{
3404
-		if ($status != false) $this->_atLastPage = $status;
4240
+		if ($status != false)
4241
+		{
4242
+			$this->_atLastPage = $status;
4243
+		}
3405 4244
 		return $this->_atLastPage;
3406 4245
 	}
3407 4246
 
@@ -3442,7 +4281,10 @@  discard block
 block discarded – undo
3442 4281
 		{
3443 4282
 			$ret = array_shift($row);
3444 4283
 
3445
-			if ($this->fetchMode == ADODB_FETCH_BOTH) array_shift($row);
4284
+			if ($this->fetchMode == ADODB_FETCH_BOTH)
4285
+			{
4286
+				array_shift($row);
4287
+			}
3446 4288
 		}
3447 4289
 		return $ret;
3448 4290
 	}
@@ -3516,10 +4358,13 @@  discard block
 block discarded – undo
3516 4358
 		{
3517 4359
 			$this->_array = $array;
3518 4360
 			$this->_types = $typearr;
3519
-			if ($colnames) {
4361
+			if ($colnames)
4362
+			{
3520 4363
 				$this->_skiprow1 = false;
3521 4364
 				$this->_colnames = $colnames;
3522
-			} else  {
4365
+			}
4366
+			else
4367
+			{
3523 4368
 				$this->_skiprow1 = true;
3524 4369
 				$this->_colnames = $array[0];
3525 4370
 			}
@@ -3537,7 +4382,8 @@  discard block
 block discarded – undo
3537 4382
 		{
3538 4383
 			$this->_array =& $array;
3539 4384
 			$this->_skiprow1= false;
3540
-			if ($fieldarr) {
4385
+			if ($fieldarr)
4386
+			{
3541 4387
 				$this->_fieldobjects =& $fieldarr;
3542 4388
 			}
3543 4389
 			$this->Init();
@@ -3545,9 +4391,12 @@  discard block
 block discarded – undo
3545 4391
 
3546 4392
 		function &GetArray($nRows=-1)
3547 4393
 		{
3548
-			if ($nRows == -1 && $this->_currentRow <= 0 && !$this->_skiprow1) {
4394
+			if ($nRows == -1 && $this->_currentRow <= 0 && !$this->_skiprow1)
4395
+			{
3549 4396
 				return $this->_array;
3550
-			} else {
4397
+			}
4398
+			else
4399
+			{
3551 4400
 				$arr =& ADORecordSet::GetArray($nRows);
3552 4401
 				return $arr;
3553 4402
 			}
@@ -3556,7 +4405,10 @@  discard block
 block discarded – undo
3556 4405
 		function _initrs()
3557 4406
 		{
3558 4407
 			$this->_numOfRows =  sizeof($this->_array);
3559
-			if ($this->_skiprow1) $this->_numOfRows -= 1;
4408
+			if ($this->_skiprow1)
4409
+			{
4410
+				$this->_numOfRows -= 1;
4411
+			}
3560 4412
 
3561 4413
 			$this->_numOfFields =(isset($this->_fieldobjects)) ?
3562 4414
 				 sizeof($this->_fieldobjects):sizeof($this->_types);
@@ -3567,13 +4419,19 @@  discard block
 block discarded – undo
3567 4419
 		{
3568 4420
 			$mode = isset($this->adodbFetchMode) ? $this->adodbFetchMode : $this->fetchMode;
3569 4421
 
3570
-			if ($mode & ADODB_FETCH_ASSOC) {
3571
-				if (!isset($this->fields[$colname])) $colname = strtolower($colname);
4422
+			if ($mode & ADODB_FETCH_ASSOC)
4423
+			{
4424
+				if (!isset($this->fields[$colname]))
4425
+				{
4426
+					$colname = strtolower($colname);
4427
+				}
3572 4428
 				return $this->fields[$colname];
3573 4429
 			}
3574
-			if (!$this->bind) {
4430
+			if (!$this->bind)
4431
+			{
3575 4432
 				$this->bind = array();
3576
-				for ($i=0; $i < $this->_numOfFields; $i++) {
4433
+				for ($i=0; $i < $this->_numOfFields; $i++)
4434
+				{
3577 4435
 					$o = $this->FetchField($i);
3578 4436
 					$this->bind[strtoupper($o->name)] = $i;
3579 4437
 				}
@@ -3583,7 +4441,8 @@  discard block
 block discarded – undo
3583 4441
 
3584 4442
 		function &FetchField($fieldOffset = -1)
3585 4443
 		{
3586
-			if (isset($this->_fieldobjects)) {
4444
+			if (isset($this->_fieldobjects))
4445
+			{
3587 4446
 				return $this->_fieldobjects[$fieldOffset];
3588 4447
 			}
3589 4448
 			$o =  new ADOFieldObject();
@@ -3596,9 +4455,13 @@  discard block
 block discarded – undo
3596 4455
 
3597 4456
 		function _seek($row)
3598 4457
 		{
3599
-			if (sizeof($this->_array) && 0 <= $row && $row < $this->_numOfRows) {
4458
+			if (sizeof($this->_array) && 0 <= $row && $row < $this->_numOfRows)
4459
+			{
3600 4460
 				$this->_currentRow = $row;
3601
-				if ($this->_skiprow1) $row += 1;
4461
+				if ($this->_skiprow1)
4462
+				{
4463
+					$row += 1;
4464
+				}
3602 4465
 				$this->fields = $this->_array[$row];
3603 4466
 				return true;
3604 4467
 			}
@@ -3607,15 +4470,25 @@  discard block
 block discarded – undo
3607 4470
 
3608 4471
 		function MoveNext()
3609 4472
 		{
3610
-			if (!$this->EOF) {
4473
+			if (!$this->EOF)
4474
+			{
3611 4475
 				$this->_currentRow++;
3612 4476
 
3613 4477
 				$pos = $this->_currentRow;
3614 4478
 
3615
-				if ($this->_numOfRows <= $pos) {
3616
-					if (!$this->compat) $this->fields = false;
3617
-				} else {
3618
-					if ($this->_skiprow1) $pos += 1;
4479
+				if ($this->_numOfRows <= $pos)
4480
+				{
4481
+					if (!$this->compat)
4482
+					{
4483
+						$this->fields = false;
4484
+					}
4485
+				}
4486
+				else
4487
+				{
4488
+					if ($this->_skiprow1)
4489
+					{
4490
+						$pos += 1;
4491
+					}
3619 4492
 					$this->fields = $this->_array[$pos];
3620 4493
 					return true;
3621 4494
 				}
@@ -3629,11 +4502,18 @@  discard block
 block discarded – undo
3629 4502
 		{
3630 4503
 			$pos = $this->_currentRow;
3631 4504
 
3632
-			if ($this->_numOfRows <= $pos) {
3633
-				if (!$this->compat) $this->fields = false;
4505
+			if ($this->_numOfRows <= $pos)
4506
+			{
4507
+				if (!$this->compat)
4508
+				{
4509
+					$this->fields = false;
4510
+				}
3634 4511
 				return false;
3635 4512
 			}
3636
-			if ($this->_skiprow1) $pos += 1;
4513
+			if ($this->_skiprow1)
4514
+			{
4515
+				$pos += 1;
4516
+			}
3637 4517
 			$this->fields = $this->_array[$pos];
3638 4518
 			return true;
3639 4519
 		}
@@ -3666,11 +4546,18 @@  discard block
 block discarded – undo
3666 4546
 	{
3667 4547
 	global $ADODB_LASTDB;
3668 4548
 
3669
-		if (!$dbType) return false;
4549
+		if (!$dbType)
4550
+		{
4551
+			return false;
4552
+		}
3670 4553
 		$db = strtolower($dbType);
3671
-		switch ($db) {
4554
+		switch ($db)
4555
+		{
3672 4556
 			case 'ado':
3673
-				if (PHP_VERSION >= 5) $db = 'ado5';
4557
+				if (PHP_VERSION >= 5)
4558
+				{
4559
+					$db = 'ado5';
4560
+				}
3674 4561
 				$class = 'ado';
3675 4562
 				break;
3676 4563
 			case 'ifx':
@@ -3685,11 +4572,19 @@  discard block
 block discarded – undo
3685 4572
 		$file = ADODB_DIR."/drivers/adodb-".$db.".inc.php";
3686 4573
 		@include_once($file);
3687 4574
 		$ADODB_LASTDB = $class;
3688
-		if (class_exists("ADODB_" . $class)) return $class;
4575
+		if (class_exists("ADODB_" . $class))
4576
+		{
4577
+			return $class;
4578
+		}
3689 4579
 
3690 4580
 		//ADOConnection::outp(adodb_pr(get_declared_classes(),true));
3691
-		if (!file_exists($file)) ADOConnection::outp("Missing file: $file");
3692
-		else ADOConnection::outp("Syntax error in file: $file");
4581
+		if (!file_exists($file))
4582
+		{
4583
+			ADOConnection::outp("Missing file: $file");
4584
+		}
4585
+		else {
4586
+			ADOConnection::outp("Syntax error in file: $file");
4587
+		}
3693 4588
 		return false;
3694 4589
 	}
3695 4590
 
@@ -3714,34 +4609,50 @@  discard block
 block discarded – undo
3714 4609
 	{
3715 4610
 	GLOBAL $ADODB_NEWCONNECTION, $ADODB_LASTDB;
3716 4611
 
3717
-		if (!defined('ADODB_ASSOC_CASE')) define('ADODB_ASSOC_CASE',2);
4612
+		if (!defined('ADODB_ASSOC_CASE'))
4613
+		{
4614
+			define('ADODB_ASSOC_CASE',2);
4615
+		}
3718 4616
 		$errorfn = (defined('ADODB_ERROR_HANDLER')) ? ADODB_ERROR_HANDLER : false;
3719 4617
 		$false = false;
3720
-		if (strpos($db,'://')) {
4618
+		if (strpos($db,'://'))
4619
+		{
3721 4620
 			$origdsn = $db;
3722 4621
 			$dsna = @parse_url($db);
3723 4622
 
3724
-			if (!$dsna) {
4623
+			if (!$dsna)
4624
+			{
3725 4625
 				// special handling of oracle, which might not have host
3726 4626
 				$db = str_replace('@/','@adodb-fakehost/',$db);
3727 4627
 				$dsna = parse_url($db);
3728
-				if (!$dsna) return $false;
4628
+				if (!$dsna)
4629
+				{
4630
+					return $false;
4631
+				}
3729 4632
 				$dsna['host'] = '';
3730 4633
 			}
3731 4634
 			$db = @$dsna['scheme'];
3732
-			if (!$db) return $false;
4635
+			if (!$db)
4636
+			{
4637
+				return $false;
4638
+			}
3733 4639
 			$dsna['host'] = isset($dsna['host']) ? rawurldecode($dsna['host']) : '';
3734 4640
 			$dsna['user'] = isset($dsna['user']) ? rawurldecode($dsna['user']) : '';
3735 4641
 			$dsna['pass'] = isset($dsna['pass']) ? rawurldecode($dsna['pass']) : '';
3736 4642
 			$dsna['path'] = isset($dsna['path']) ? rawurldecode(substr($dsna['path'],1)) : ''; # strip off initial /
3737 4643
 
3738
-			if (isset($dsna['query'])) {
4644
+			if (isset($dsna['query']))
4645
+			{
3739 4646
 				$opt1 = explode('&',$dsna['query']);
3740
-				foreach($opt1 as $k => $v) {
4647
+				foreach($opt1 as $k => $v)
4648
+				{
3741 4649
 					$arr = explode('=',$v);
3742 4650
 					$opt[$arr[0]] = isset($arr[1]) ? rawurldecode($arr[1]) : 1;
3743 4651
 				}
3744
-			} else $opt = array();
4652
+			}
4653
+			else {
4654
+				$opt = array();
4655
+			}
3745 4656
 		}
3746 4657
 
3747 4658
 	/*
@@ -3753,32 +4664,52 @@  discard block
 block discarded – undo
3753 4664
 	 *  username: User name for login
3754 4665
 	 *  password: Password for login
3755 4666
 	 */
3756
-		if (!empty($ADODB_NEWCONNECTION)) {
4667
+		if (!empty($ADODB_NEWCONNECTION))
4668
+		{
3757 4669
 			$obj = $ADODB_NEWCONNECTION($db);
3758 4670
 
3759
-		} else {
4671
+		}
4672
+		else
4673
+		{
3760 4674
 
3761
-			if (!isset($ADODB_LASTDB)) $ADODB_LASTDB = '';
3762
-			if (empty($db)) $db = $ADODB_LASTDB;
4675
+			if (!isset($ADODB_LASTDB))
4676
+			{
4677
+				$ADODB_LASTDB = '';
4678
+			}
4679
+			if (empty($db))
4680
+			{
4681
+				$db = $ADODB_LASTDB;
4682
+			}
3763 4683
 
3764
-			if ($db != $ADODB_LASTDB) $db = ADOLoadCode($db);
4684
+			if ($db != $ADODB_LASTDB)
4685
+			{
4686
+				$db = ADOLoadCode($db);
4687
+			}
3765 4688
 
3766
-			if (!$db) {
3767
-				if (isset($origdsn)) $db = $origdsn;
3768
-				if ($errorfn) {
4689
+			if (!$db)
4690
+			{
4691
+				if (isset($origdsn))
4692
+				{
4693
+					$db = $origdsn;
4694
+				}
4695
+				if ($errorfn)
4696
+				{
3769 4697
 					// raise an error
3770 4698
 					$ignore = false;
3771 4699
 					$errorfn('ADONewConnection', 'ADONewConnection', -998,
3772 4700
 							 "could not load the database driver for '$db'",
3773 4701
 							 $db,false,$ignore);
3774
-				} else
3775
-					 ADOConnection::outp( "<p>ADONewConnection: Unable to load database driver '$db'</p>",false);
4702
+				}
4703
+				else {
4704
+									 ADOConnection::outp( "<p>ADONewConnection: Unable to load database driver '$db'</p>",false);
4705
+				}
3776 4706
 
3777 4707
 				return $false;
3778 4708
 			}
3779 4709
 
3780 4710
 			$cls = 'ADODB_'.$db;
3781
-			if (!class_exists($cls)) {
4711
+			if (!class_exists($cls))
4712
+			{
3782 4713
 				adodb_backtrace();
3783 4714
 				return $false;
3784 4715
 			}
@@ -3787,12 +4718,22 @@  discard block
 block discarded – undo
3787 4718
 		}
3788 4719
 
3789 4720
 		# constructor should not fail
3790
-		if ($obj) {
3791
-			if ($errorfn)  $obj->raiseErrorFn = $errorfn;
3792
-			if (isset($dsna)) {
3793
-				if (isset($dsna['port'])) $obj->port = $dsna['port'];
3794
-				foreach($opt as $k => $v) {
3795
-					switch(strtolower($k)) {
4721
+		if ($obj)
4722
+		{
4723
+			if ($errorfn)
4724
+			{
4725
+				$obj->raiseErrorFn = $errorfn;
4726
+			}
4727
+			if (isset($dsna))
4728
+			{
4729
+				if (isset($dsna['port']))
4730
+				{
4731
+					$obj->port = $dsna['port'];
4732
+				}
4733
+				foreach($opt as $k => $v)
4734
+				{
4735
+					switch(strtolower($k))
4736
+					{
3796 4737
 					case 'persist':
3797 4738
 					case 'persistent': 	$persist = $v; break;
3798 4739
 					case 'debug':		$obj->debug = (integer) $v; break;
@@ -3815,11 +4756,17 @@  discard block
 block discarded – undo
3815 4756
 					}
3816 4757
 				}
3817 4758
 				if (empty($persist))
3818
-					$ok = $obj->Connect($dsna['host'], $dsna['user'], $dsna['pass'], $dsna['path']);
3819
-				else
3820
-					$ok = $obj->PConnect($dsna['host'], $dsna['user'], $dsna['pass'], $dsna['path']);
4759
+				{
4760
+									$ok = $obj->Connect($dsna['host'], $dsna['user'], $dsna['pass'], $dsna['path']);
4761
+				}
4762
+				else {
4763
+									$ok = $obj->PConnect($dsna['host'], $dsna['user'], $dsna['pass'], $dsna['path']);
4764
+				}
3821 4765
 
3822
-				if (!$ok) return $false;
4766
+				if (!$ok)
4767
+				{
4768
+					return $false;
4769
+				}
3823 4770
 			}
3824 4771
 		}
3825 4772
 		return $obj;
@@ -3830,19 +4777,34 @@  discard block
 block discarded – undo
3830 4777
 	// $perf == true means called by NewPerfMonitor(), otherwise for data dictionary
3831 4778
 	function _adodb_getdriver($provider,$drivername,$perf=false)
3832 4779
 	{
3833
-		switch ($provider) {
3834
-		case 'odbtp':   if (strncmp('odbtp_',$drivername,6)==0) return substr($drivername,6);
3835
-		case 'odbc' :   if (strncmp('odbc_',$drivername,5)==0) return substr($drivername,5);
3836
-		case 'ado'  :   if (strncmp('ado_',$drivername,4)==0) return substr($drivername,4);
4780
+		switch ($provider)
4781
+		{
4782
+		case 'odbtp':   if (strncmp('odbtp_',$drivername,6)==0)
4783
+		{
4784
+			return substr($drivername,6);
4785
+		}
4786
+		case 'odbc' :   if (strncmp('odbc_',$drivername,5)==0)
4787
+		{
4788
+			return substr($drivername,5);
4789
+		}
4790
+		case 'ado'  :   if (strncmp('ado_',$drivername,4)==0)
4791
+		{
4792
+			return substr($drivername,4);
4793
+		}
3837 4794
 		case 'native':  break;
3838 4795
 		default:
3839 4796
 			return $provider;
3840 4797
 		}
3841 4798
 
3842
-		switch($drivername) {
4799
+		switch($drivername)
4800
+		{
3843 4801
 		case 'firebird15': $drivername = 'firebird'; break;
3844 4802
 		case 'oracle': $drivername = 'oci8'; break;
3845
-		case 'access': if ($perf) $drivername = ''; break;
4803
+		case 'access': if ($perf)
4804
+		{
4805
+			$drivername = '';
4806
+		}
4807
+		break;
3846 4808
 		case 'db2'   : break;
3847 4809
 		case 'sapdb' : break;
3848 4810
 		case 'mysqli': $drivername = 'mysql'; break;
@@ -3857,11 +4819,17 @@  discard block
 block discarded – undo
3857 4819
 	{
3858 4820
 		$false = false;
3859 4821
 		$drivername = _adodb_getdriver($conn->dataProvider,$conn->databaseType,true);
3860
-		if (!$drivername || $drivername == 'generic') return $false;
4822
+		if (!$drivername || $drivername == 'generic')
4823
+		{
4824
+			return $false;
4825
+		}
3861 4826
 		include_once(ADODB_DIR.'/adodb-perf.inc.php');
3862 4827
 		@include_once(ADODB_DIR."/perf/perf-$drivername.inc.php");
3863 4828
 		$class = "Perf_$drivername";
3864
-		if (!class_exists($class)) return $false;
4829
+		if (!class_exists($class))
4830
+		{
4831
+			return $false;
4832
+		}
3865 4833
 		$perf = new $class($conn);
3866 4834
 
3867 4835
 		return $perf;
@@ -3870,13 +4838,17 @@  discard block
 block discarded – undo
3870 4838
 	function &NewDataDictionary(&$conn,$drivername=false)
3871 4839
 	{
3872 4840
 		$false = false;
3873
-		if (!$drivername) $drivername = _adodb_getdriver($conn->dataProvider,$conn->databaseType);
4841
+		if (!$drivername)
4842
+		{
4843
+			$drivername = _adodb_getdriver($conn->dataProvider,$conn->databaseType);
4844
+		}
3874 4845
 
3875 4846
 		include_once(ADODB_DIR.'/adodb-lib.inc.php');
3876 4847
 		include_once(ADODB_DIR.'/adodb-datadict.inc.php');
3877 4848
 		$path = ADODB_DIR."/datadict/datadict-$drivername.inc.php";
3878 4849
 
3879
-		if (!file_exists($path)) {
4850
+		if (!file_exists($path))
4851
+		{
3880 4852
 			ADOConnection::outp("Database driver '$path' not available");
3881 4853
 			return $false;
3882 4854
 		}
@@ -3888,7 +4860,9 @@  discard block
 block discarded – undo
3888 4860
 		$dict->upperName = strtoupper($drivername);
3889 4861
 		$dict->quote = $conn->nameQuote;
3890 4862
 		if (!empty($conn->_connectionID))
3891
-			$dict->serverInfo = $conn->ServerInfo();
4863
+		{
4864
+					$dict->serverInfo = $conn->ServerInfo();
4865
+		}
3892 4866
 
3893 4867
 		return $dict;
3894 4868
 	}
@@ -3900,14 +4874,21 @@  discard block
 block discarded – undo
3900 4874
 	*/
3901 4875
 	function adodb_pr($var,$as_string=false)
3902 4876
 	{
3903
-		if ($as_string) ob_start();
4877
+		if ($as_string)
4878
+		{
4879
+			ob_start();
4880
+		}
3904 4881
 
3905
-		if (isset($_SERVER['HTTP_USER_AGENT'])) {
4882
+		if (isset($_SERVER['HTTP_USER_AGENT']))
4883
+		{
3906 4884
 			echo " <pre>\n";print_r($var);echo "</pre>\n";
3907
-		} else
3908
-			print_r($var);
4885
+		}
4886
+		else {
4887
+					print_r($var);
4888
+		}
3909 4889
 
3910
-		if ($as_string) {
4890
+		if ($as_string)
4891
+		{
3911 4892
 			$s = ob_get_contents();
3912 4893
 			ob_end_clean();
3913 4894
 			return $s;
@@ -3923,7 +4904,10 @@  discard block
 block discarded – undo
3923 4904
 	function adodb_backtrace($printOrArr=true,$levels=9999)
3924 4905
 	{
3925 4906
 		global $ADODB_INCLUDED_LIB;
3926
-		if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
4907
+		if (empty($ADODB_INCLUDED_LIB))
4908
+		{
4909
+			include_once(ADODB_DIR.'/adodb-lib.inc.php');
4910
+		}
3927 4911
 		return _adodb_backtrace($printOrArr,$levels);
3928 4912
 	}
3929 4913
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	// GLOBAL VARIABLES
52 52
 	//==============================================================================================
53 53
 
54
-	GLOBAL
54
+	global
55 55
 		$ADODB_vers, 		// database version
56 56
 		$ADODB_COUNTRECS,	// count number of records returned - slows down query
57 57
 		$ADODB_CACHE_DIR,	// directory to cache recordsets
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 
147 147
 	function ADODB_Setup()
148 148
 	{
149
-	GLOBAL
149
+	global
150 150
 		$ADODB_vers, 		// database version
151 151
 		$ADODB_COUNTRECS,	// count number of records returned - slows down query
152 152
 		$ADODB_CACHE_DIR,	// directory to cache recordsets
@@ -1775,7 +1775,7 @@  discard block
 block discarded – undo
1775 1775
 
1776 1776
 	function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB')
1777 1777
 	{
1778
-		return $this->Execute("UPDATE $table SET $column=? WHERE $where",array($val)) != false;
1778
+		return $this->Execute("update $table SET $column=? WHERE $where",array($val)) != false;
1779 1779
 	}
1780 1780
 
1781 1781
 	/**
@@ -3076,7 +3076,7 @@  discard block
 block discarded – undo
3076 3076
 		$lnumrows = $this->_numOfRows;
3077 3077
 		// the database doesn't support native recordcount, so we do a workaround
3078 3078
 		if ($lnumrows == -1 && $this->connection) {
3079
-			IF ($table) {
3079
+			if ($table) {
3080 3080
 				if ($condition) $condition = " WHERE " . $condition;
3081 3081
 				$resultrows = &$this->connection->Execute("SELECT COUNT(*) FROM $table $condition");
3082 3082
 				if ($resultrows) $lnumrows = reset($resultrows->fields);
@@ -3712,7 +3712,7 @@  discard block
 block discarded – undo
3712 3712
 	 */
3713 3713
 	function &ADONewConnection($db='')
3714 3714
 	{
3715
-	GLOBAL $ADODB_NEWCONNECTION, $ADODB_LASTDB;
3715
+	global $ADODB_NEWCONNECTION, $ADODB_LASTDB;
3716 3716
 
3717 3717
 		if (!defined('ADODB_ASSOC_CASE')) define('ADODB_ASSOC_CASE',2);
3718 3718
 		$errorfn = (defined('ADODB_ERROR_HANDLER')) ? ADODB_ERROR_HANDLER : false;
Please login to merge, or discard this patch.
phpgwapi/inc/adodb/datadict/datadict-postgres.inc.php 5 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -86,6 +86,9 @@  discard block
 block discarded – undo
86 86
 		}
87 87
 	}
88 88
 
89
+ 	/**
90
+ 	 * @param string $meta
91
+ 	 */
89 92
  	function ActualType($meta)
90 93
 	{
91 94
 		switch($meta) {
@@ -261,6 +264,9 @@  discard block
 block discarded – undo
261 264
 		return $aSql;
262 265
 	}
263 266
 
267
+	/**
268
+	 * @param string $tabname
269
+	 */
264 270
 	function DropTableSQL($tabname)
265 271
 	{
266 272
 		$sql = ADODB_DataDict::DropTableSQL($tabname);
Please login to merge, or discard this patch.
Indentation   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,8 +7,7 @@
 block discarded – undo
7 7
   the BSD license will take precedence.
8 8
 
9 9
   Set tabs to 4 for best viewing.
10
-
11
-*/
10
+ */
12 11
 
13 12
 // security - hide paths
14 13
 if (!defined('ADODB_DIR')) die();
Please login to merge, or discard this patch.
Switch Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -89,29 +89,29 @@
 block discarded – undo
89 89
  	function ActualType($meta)
90 90
 	{
91 91
 		switch($meta) {
92
-		case 'C': return 'VARCHAR';
93
-		case 'XL':
94
-		case 'X': return 'TEXT';
92
+			case 'C': return 'VARCHAR';
93
+			case 'XL':
94
+			case 'X': return 'TEXT';
95 95
 
96
-		case 'C2': return 'VARCHAR';
97
-		case 'X2': return 'TEXT';
96
+			case 'C2': return 'VARCHAR';
97
+			case 'X2': return 'TEXT';
98 98
 
99
-		case 'B': return 'BYTEA';
99
+			case 'B': return 'BYTEA';
100 100
 
101
-		case 'D': return 'DATE';
102
-		case 'T': return 'TIMESTAMP';
101
+			case 'D': return 'DATE';
102
+			case 'T': return 'TIMESTAMP';
103 103
 
104
-		case 'L': return 'BOOLEAN';
105
-		case 'I': return 'INTEGER';
106
-		case 'I1': return 'SMALLINT';
107
-		case 'I2': return 'INT2';
108
-		case 'I4': return 'INT4';
109
-		case 'I8': return 'INT8';
104
+			case 'L': return 'BOOLEAN';
105
+			case 'I': return 'INTEGER';
106
+			case 'I1': return 'SMALLINT';
107
+			case 'I2': return 'INT2';
108
+			case 'I4': return 'INT4';
109
+			case 'I8': return 'INT8';
110 110
 
111
-		case 'F': return 'FLOAT8';
112
-		case 'N': return 'NUMERIC';
113
-		default:
114
-			return $meta;
111
+			case 'F': return 'FLOAT8';
112
+			case 'N': return 'NUMERIC';
113
+			default:
114
+				return $meta;
115 115
 		}
116 116
 	}
117 117
 
Please login to merge, or discard this patch.
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	var $quote = '"';
23 23
 	var $renameTable = 'ALTER TABLE %s RENAME TO %s'; // at least since 7.1
24 24
 
25
-	function MetaType($t,$len=-1,$fieldobj=false)
25
+	function MetaType($t, $len = -1, $fieldobj = false)
26 26
 	{
27 27
 		if (is_object($t)) {
28 28
 			$fieldobj = $t;
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 			$len = $fieldobj->max_length;
31 31
 		}
32 32
 		$is_serial = is_object($fieldobj) && $fieldobj->primary_key && $fieldobj->unique &&
33
-			$fieldobj->has_default && substr($fieldobj->default_value,0,8) == 'nextval(';
33
+			$fieldobj->has_default && substr($fieldobj->default_value, 0, 8) == 'nextval(';
34 34
 
35 35
 		switch (strtoupper($t)) {
36 36
 			case 'INTERVAL':
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 
89 89
  	function ActualType($meta)
90 90
 	{
91
-		switch($meta) {
91
+		switch ($meta) {
92 92
 		case 'C': return 'VARCHAR';
93 93
 		case 'XL':
94 94
 		case 'X': return 'TEXT';
@@ -126,24 +126,24 @@  discard block
 block discarded – undo
126 126
 	 */
127 127
 	function AddColumnSQL($tabname, $flds)
128 128
 	{
129
-		$tabname = $this->TableName ($tabname);
129
+		$tabname = $this->TableName($tabname);
130 130
 		$sql = array();
131
-		list($lines,$pkey) = $this->_GenFields($flds);
132
-		$alter = 'ALTER TABLE ' . $tabname . $this->addCol . ' ';
133
-		foreach($lines as $v) {
134
-			if (($not_null = preg_match('/NOT NULL/i',$v))) {
135
-				$v = preg_replace('/NOT NULL/i','',$v);
131
+		list($lines, $pkey) = $this->_GenFields($flds);
132
+		$alter = 'ALTER TABLE '.$tabname.$this->addCol.' ';
133
+		foreach ($lines as $v) {
134
+			if (($not_null = preg_match('/NOT NULL/i', $v))) {
135
+				$v = preg_replace('/NOT NULL/i', '', $v);
136 136
 			}
137
-			if (preg_match('/^([^ ]+) .*DEFAULT ([^ ]+)/',$v,$matches)) {
138
-				list(,$colname,$default) = $matches;
139
-				$sql[] = $alter . str_replace('DEFAULT '.$default,'',$v);
137
+			if (preg_match('/^([^ ]+) .*DEFAULT ([^ ]+)/', $v, $matches)) {
138
+				list(,$colname, $default) = $matches;
139
+				$sql[] = $alter.str_replace('DEFAULT '.$default, '', $v);
140 140
 				$sql[] = 'UPDATE '.$tabname.' SET '.$colname.'='.$default;
141
-				$sql[] = 'ALTER TABLE '.$tabname.' ALTER COLUMN '.$colname.' SET DEFAULT ' . $default;
141
+				$sql[] = 'ALTER TABLE '.$tabname.' ALTER COLUMN '.$colname.' SET DEFAULT '.$default;
142 142
 			} else {
143
-				$sql[] = $alter . $v;
143
+				$sql[] = $alter.$v;
144 144
 			}
145 145
 			if ($not_null) {
146
-				list($colname) = explode(' ',$v);
146
+				list($colname) = explode(' ', $v);
147 147
 				$sql[] = 'ALTER TABLE '.$tabname.' ALTER COLUMN '.$colname.' SET NOT NULL';
148 148
 			}
149 149
 		}
@@ -161,13 +161,13 @@  discard block
 block discarded – undo
161 161
 	 * @param array/ $tableoptions options for the new table see CreateTableSQL, default ''
162 162
 	 * @return array with SQL strings
163 163
 	 */
164
-	function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
164
+	function AlterColumnSQL($tabname, $flds, $tableflds = '', $tableoptions = '')
165 165
 	{
166 166
 		if (!$tableflds) {
167 167
 			if ($this->debug) ADOConnection::outp("AlterColumnSQL needs a complete table-definiton for PostgreSQL");
168 168
 			return array();
169 169
 		}
170
-		return $this->_recreate_copy_table($tabname,False,$tableflds,$tableoptions);
170
+		return $this->_recreate_copy_table($tabname, False, $tableflds, $tableoptions);
171 171
 	}
172 172
 
173 173
 	/**
@@ -181,9 +181,9 @@  discard block
 block discarded – undo
181 181
 	 * @param array/ $tableoptions options for the new table see CreateTableSQL, default ''
182 182
 	 * @return array with SQL strings
183 183
 	 */
184
-	function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
184
+	function DropColumnSQL($tabname, $flds, $tableflds = '', $tableoptions = '')
185 185
 	{
186
-		$has_drop_column = 7.3 <= (float) @$this->serverInfo['version'];
186
+		$has_drop_column = 7.3 <= (float)@$this->serverInfo['version'];
187 187
 		if (!$has_drop_column && !$tableflds) {
188 188
 			if ($this->debug) ADOConnection::outp("DropColumnSQL needs complete table-definiton for PostgreSQL < 7.3");
189 189
 		return array();
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 		if ($has_drop_column) {
192 192
 			return ADODB_DataDict::DropColumnSQL($tabname, $flds);
193 193
 		}
194
-		return $this->_recreate_copy_table($tabname,$flds,$tableflds,$tableoptions);
194
+		return $this->_recreate_copy_table($tabname, $flds, $tableflds, $tableoptions);
195 195
 	}
196 196
 
197 197
 	/**
@@ -206,17 +206,17 @@  discard block
 block discarded – undo
206 206
 	 * @param array/string $tableoptions options for the new table see CreateTableSQL, default ''
207 207
 	 * @return array with SQL strings
208 208
 	 */
209
-	function _recreate_copy_table($tabname,$dropflds,$tableflds,$tableoptions='')
209
+	function _recreate_copy_table($tabname, $dropflds, $tableflds, $tableoptions = '')
210 210
 	{
211
-		if ($dropflds && !is_array($dropflds)) $dropflds = explode(',',$dropflds);
211
+		if ($dropflds && !is_array($dropflds)) $dropflds = explode(',', $dropflds);
212 212
 		$copyflds = array();
213
-		foreach(($meta=$this->MetaColumns($tabname)) as $fld) {
214
-			if (!$dropflds || !in_array($fld->name,$dropflds)) {
213
+		foreach (($meta = $this->MetaColumns($tabname)) as $fld) {
214
+			if (!$dropflds || !in_array($fld->name, $dropflds)) {
215 215
 				// we need to explicit convert varchar to a number to be able to do an AlterColumn of a char column to a nummeric one
216
-				if (preg_match('/'.$fld->name.' (I|I2|I4|I8|N|F)/i',$tableflds,$matches) &&
217
-					in_array($fld->type,array('varchar','char','text','bytea'))) {
216
+				if (preg_match('/'.$fld->name.' (I|I2|I4|I8|N|F)/i', $tableflds, $matches) &&
217
+					in_array($fld->type, array('varchar', 'char', 'text', 'bytea'))) {
218 218
 					$copyflds[] = "to_number($fld->name,'S9999999999999D99')";
219
-				} elseif (preg_match('/'.$fld->name.' ([\w]+)/i',$tableflds,$matches) &&
219
+				} elseif (preg_match('/'.$fld->name.' ([\w]+)/i', $tableflds, $matches) &&
220 220
 					strtoupper($fld->type) != ($type = $this->ActualType($matches[1]))) {
221 221
 					if ($type == 'BYTEA' && $fld->type == 'text') {
222 222
 						$copyflds[] = "DECODE($fld->name, 'escape')";
@@ -230,30 +230,30 @@  discard block
 block discarded – undo
230 230
 				}
231 231
 				// identify the sequence name and the fld its on
232 232
 				if ($fld->primary_key && $fld->has_default &&
233
-					preg_match("/nextval\('([^']+)'::(text|regclass)\)/",$fld->default_value,$matches)) {
233
+					preg_match("/nextval\('([^']+)'::(text|regclass)\)/", $fld->default_value, $matches)) {
234 234
 					$seq_name = $matches[1];
235 235
 					$seq_fld = $fld->name;
236 236
 				}
237 237
 			}
238 238
 		}
239
-		$copyflds = implode(', ',$copyflds);
239
+		$copyflds = implode(', ', $copyflds);
240 240
 
241 241
 		$tempname = $tabname.'_tmp';
242
-		$aSql[] = 'BEGIN';		// we use a transaction, to make sure not to loose the content of the table
242
+		$aSql[] = 'BEGIN'; // we use a transaction, to make sure not to loose the content of the table
243 243
 		$aSql[] = "SELECT * INTO TEMPORARY TABLE $tempname FROM $tabname";
244
-		$aSql = array_merge($aSql,$this->DropTableSQL($tabname));
245
-		$aSql = array_merge($aSql,$this->CreateTableSQL($tabname,$tableflds,$tableoptions));
244
+		$aSql = array_merge($aSql, $this->DropTableSQL($tabname));
245
+		$aSql = array_merge($aSql, $this->CreateTableSQL($tabname, $tableflds, $tableoptions));
246 246
 		$aSql[] = "INSERT INTO $tabname SELECT $copyflds FROM $tempname";
247 247
 		if ($seq_name && $seq_fld) {	// if we have a sequence we need to set it again
248
-			$seq_name = $tabname.'_'.$seq_fld.'_seq';	// has to be the name of the new implicit sequence
248
+			$seq_name = $tabname.'_'.$seq_fld.'_seq'; // has to be the name of the new implicit sequence
249 249
 			$aSql[] = "SELECT setval('$seq_name',MAX($seq_fld)) FROM $tabname";
250 250
 		}
251 251
 		$aSql[] = "DROP TABLE $tempname";
252 252
 		// recreate the indexes, if they not contain one of the droped columns
253
-		foreach($this->MetaIndexes($tabname) as $idx_name => $idx_data)
253
+		foreach ($this->MetaIndexes($tabname) as $idx_name => $idx_data)
254 254
 		{
255
-			if (substr($idx_name,-5) != '_pkey' && (!$dropflds || !count(array_intersect($dropflds,$idx_data['columns'])))) {
256
-				$aSql = array_merge($aSql,$this->CreateIndexSQL($idx_name,$tabname,$idx_data['columns'],
255
+			if (substr($idx_name, -5) != '_pkey' && (!$dropflds || !count(array_intersect($dropflds, $idx_data['columns'])))) {
256
+				$aSql = array_merge($aSql, $this->CreateIndexSQL($idx_name, $tabname, $idx_data['columns'],
257 257
 					$idx_data['unique'] ? array('UNIQUE') : False));
258 258
 			}
259 259
 		}
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 	}
273 273
 
274 274
 	// return string must begin with space
275
-	function _CreateSuffix($fname, &$ftype, $fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
275
+	function _CreateSuffix($fname, &$ftype, $fnotnull, $fdefault, $fautoinc, $fconstraint, $funsigned)
276 276
 	{
277 277
 		if ($fautoinc) {
278 278
 			$ftype = 'SERIAL';
@@ -338,29 +338,29 @@  discard block
 block discarded – undo
338 338
 	{
339 339
 		$sql = array();
340 340
 
341
-		if ( isset($idxoptions['REPLACE']) || isset($idxoptions['DROP']) ) {
342
-			$sql[] = sprintf ($this->dropIndex, $idxname, $tabname);
343
-			if ( isset($idxoptions['DROP']) )
341
+		if (isset($idxoptions['REPLACE']) || isset($idxoptions['DROP'])) {
342
+			$sql[] = sprintf($this->dropIndex, $idxname, $tabname);
343
+			if (isset($idxoptions['DROP']))
344 344
 				return $sql;
345 345
 		}
346 346
 
347
-		if ( empty ($flds) ) {
347
+		if (empty ($flds)) {
348 348
 			return $sql;
349 349
 		}
350 350
 
351 351
 		$unique = isset($idxoptions['UNIQUE']) ? ' UNIQUE' : '';
352 352
 
353
-		$s = 'CREATE' . $unique . ' INDEX ' . $idxname . ' ON ' . $tabname . ' ';
353
+		$s = 'CREATE'.$unique.' INDEX '.$idxname.' ON '.$tabname.' ';
354 354
 
355 355
 		if (isset($idxoptions['HASH']))
356 356
 			$s .= 'USING HASH ';
357 357
 
358
-		if ( isset($idxoptions[$this->upperName]) )
358
+		if (isset($idxoptions[$this->upperName]))
359 359
 			$s .= $idxoptions[$this->upperName];
360 360
 
361
-		if ( is_array($flds) )
362
-			$flds = implode(', ',$flds);
363
-		$s .= '(' . $flds . ')';
361
+		if (is_array($flds))
362
+			$flds = implode(', ', $flds);
363
+		$s .= '('.$flds.')';
364 364
 		$sql[] = $s;
365 365
 
366 366
 		return $sql;
Please login to merge, or discard this patch.
Braces   +110 added lines, -42 removed lines patch added patch discarded remove patch
@@ -11,9 +11,13 @@  discard block
 block discarded – undo
11 11
 */
12 12
 
13 13
 // security - hide paths
14
-if (!defined('ADODB_DIR')) die();
14
+if (!defined('ADODB_DIR'))
15
+{
16
+	die();
17
+}
15 18
 
16
-class ADODB2_postgres extends ADODB_DataDict {
19
+class ADODB2_postgres extends ADODB_DataDict
20
+{
17 21
 
18 22
 	var $databaseType = 'postgres';
19 23
 	var $seqField = false;
@@ -24,7 +28,8 @@  discard block
 block discarded – undo
24 28
 
25 29
 	function MetaType($t,$len=-1,$fieldobj=false)
26 30
 	{
27
-		if (is_object($t)) {
31
+		if (is_object($t))
32
+		{
28 33
 			$fieldobj = $t;
29 34
 			$t = $fieldobj->type;
30 35
 			$len = $fieldobj->max_length;
@@ -32,14 +37,18 @@  discard block
 block discarded – undo
32 37
 		$is_serial = is_object($fieldobj) && $fieldobj->primary_key && $fieldobj->unique &&
33 38
 			$fieldobj->has_default && substr($fieldobj->default_value,0,8) == 'nextval(';
34 39
 
35
-		switch (strtoupper($t)) {
40
+		switch (strtoupper($t))
41
+		{
36 42
 			case 'INTERVAL':
37 43
 			case 'CHAR':
38 44
 			case 'CHARACTER':
39 45
 			case 'VARCHAR':
40 46
 			case 'NAME':
41 47
 	   		case 'BPCHAR':
42
-				if ($len <= $this->blobSize) return 'C';
48
+				if ($len <= $this->blobSize)
49
+				{
50
+					return 'C';
51
+				}
43 52
 
44 53
 			case 'TEXT':
45 54
 				return 'X';
@@ -87,8 +96,9 @@  discard block
 block discarded – undo
87 96
 	}
88 97
 
89 98
  	function ActualType($meta)
90
-	{
91
-		switch($meta) {
99
+ 	{
100
+		switch($meta)
101
+		{
92 102
 		case 'C': return 'VARCHAR';
93 103
 		case 'XL':
94 104
 		case 'X': return 'TEXT';
@@ -130,19 +140,25 @@  discard block
 block discarded – undo
130 140
 		$sql = array();
131 141
 		list($lines,$pkey) = $this->_GenFields($flds);
132 142
 		$alter = 'ALTER TABLE ' . $tabname . $this->addCol . ' ';
133
-		foreach($lines as $v) {
134
-			if (($not_null = preg_match('/NOT NULL/i',$v))) {
143
+		foreach($lines as $v)
144
+		{
145
+			if (($not_null = preg_match('/NOT NULL/i',$v)))
146
+			{
135 147
 				$v = preg_replace('/NOT NULL/i','',$v);
136 148
 			}
137
-			if (preg_match('/^([^ ]+) .*DEFAULT ([^ ]+)/',$v,$matches)) {
149
+			if (preg_match('/^([^ ]+) .*DEFAULT ([^ ]+)/',$v,$matches))
150
+			{
138 151
 				list(,$colname,$default) = $matches;
139 152
 				$sql[] = $alter . str_replace('DEFAULT '.$default,'',$v);
140 153
 				$sql[] = 'UPDATE '.$tabname.' SET '.$colname.'='.$default;
141 154
 				$sql[] = 'ALTER TABLE '.$tabname.' ALTER COLUMN '.$colname.' SET DEFAULT ' . $default;
142
-			} else {
155
+			}
156
+			else
157
+			{
143 158
 				$sql[] = $alter . $v;
144 159
 			}
145
-			if ($not_null) {
160
+			if ($not_null)
161
+			{
146 162
 				list($colname) = explode(' ',$v);
147 163
 				$sql[] = 'ALTER TABLE '.$tabname.' ALTER COLUMN '.$colname.' SET NOT NULL';
148 164
 			}
@@ -163,8 +179,12 @@  discard block
 block discarded – undo
163 179
 	 */
164 180
 	function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
165 181
 	{
166
-		if (!$tableflds) {
167
-			if ($this->debug) ADOConnection::outp("AlterColumnSQL needs a complete table-definiton for PostgreSQL");
182
+		if (!$tableflds)
183
+		{
184
+			if ($this->debug)
185
+			{
186
+				ADOConnection::outp("AlterColumnSQL needs a complete table-definiton for PostgreSQL");
187
+			}
168 188
 			return array();
169 189
 		}
170 190
 		return $this->_recreate_copy_table($tabname,False,$tableflds,$tableoptions);
@@ -184,11 +204,16 @@  discard block
 block discarded – undo
184 204
 	function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
185 205
 	{
186 206
 		$has_drop_column = 7.3 <= (float) @$this->serverInfo['version'];
187
-		if (!$has_drop_column && !$tableflds) {
188
-			if ($this->debug) ADOConnection::outp("DropColumnSQL needs complete table-definiton for PostgreSQL < 7.3");
207
+		if (!$has_drop_column && !$tableflds)
208
+		{
209
+			if ($this->debug)
210
+			{
211
+				ADOConnection::outp("DropColumnSQL needs complete table-definiton for PostgreSQL < 7.3");
212
+			}
189 213
 		return array();
190 214
 	}
191
-		if ($has_drop_column) {
215
+		if ($has_drop_column)
216
+		{
192 217
 			return ADODB_DataDict::DropColumnSQL($tabname, $flds);
193 218
 		}
194 219
 		return $this->_recreate_copy_table($tabname,$flds,$tableflds,$tableoptions);
@@ -208,29 +233,45 @@  discard block
 block discarded – undo
208 233
 	 */
209 234
 	function _recreate_copy_table($tabname,$dropflds,$tableflds,$tableoptions='')
210 235
 	{
211
-		if ($dropflds && !is_array($dropflds)) $dropflds = explode(',',$dropflds);
236
+		if ($dropflds && !is_array($dropflds))
237
+		{
238
+			$dropflds = explode(',',$dropflds);
239
+		}
212 240
 		$copyflds = array();
213
-		foreach(($meta=$this->MetaColumns($tabname)) as $fld) {
214
-			if (!$dropflds || !in_array($fld->name,$dropflds)) {
241
+		foreach(($meta=$this->MetaColumns($tabname)) as $fld)
242
+		{
243
+			if (!$dropflds || !in_array($fld->name,$dropflds))
244
+			{
215 245
 				// we need to explicit convert varchar to a number to be able to do an AlterColumn of a char column to a nummeric one
216 246
 				if (preg_match('/'.$fld->name.' (I|I2|I4|I8|N|F)/i',$tableflds,$matches) &&
217
-					in_array($fld->type,array('varchar','char','text','bytea'))) {
247
+					in_array($fld->type,array('varchar','char','text','bytea')))
248
+				{
218 249
 					$copyflds[] = "to_number($fld->name,'S9999999999999D99')";
219
-				} elseif (preg_match('/'.$fld->name.' ([\w]+)/i',$tableflds,$matches) &&
220
-					strtoupper($fld->type) != ($type = $this->ActualType($matches[1]))) {
221
-					if ($type == 'BYTEA' && $fld->type == 'text') {
250
+				}
251
+				elseif (preg_match('/'.$fld->name.' ([\w]+)/i',$tableflds,$matches) &&
252
+					strtoupper($fld->type) != ($type = $this->ActualType($matches[1])))
253
+				{
254
+					if ($type == 'BYTEA' && $fld->type == 'text')
255
+					{
222 256
 						$copyflds[] = "DECODE($fld->name, 'escape')";
223
-					} elseif ($fld->type == 'bytea' && $type == 'TEXT') {
257
+					}
258
+					elseif ($fld->type == 'bytea' && $type == 'TEXT')
259
+					{
224 260
 						$copyflds[] = "ENCODE($fld->name, 'escape')";
225
-					} else {
261
+					}
262
+					else
263
+					{
226 264
 						$copyflds[] = "CAST($fld->name AS $type)";
227 265
 					}
228
-				} else {
266
+				}
267
+				else
268
+				{
229 269
 					$copyflds[] = $fld->name;
230 270
 				}
231 271
 				// identify the sequence name and the fld its on
232 272
 				if ($fld->primary_key && $fld->has_default &&
233
-					preg_match("/nextval\('([^']+)'::(text|regclass)\)/",$fld->default_value,$matches)) {
273
+					preg_match("/nextval\('([^']+)'::(text|regclass)\)/",$fld->default_value,$matches))
274
+				{
234 275
 					$seq_name = $matches[1];
235 276
 					$seq_fld = $fld->name;
236 277
 				}
@@ -244,7 +285,9 @@  discard block
 block discarded – undo
244 285
 		$aSql = array_merge($aSql,$this->DropTableSQL($tabname));
245 286
 		$aSql = array_merge($aSql,$this->CreateTableSQL($tabname,$tableflds,$tableoptions));
246 287
 		$aSql[] = "INSERT INTO $tabname SELECT $copyflds FROM $tempname";
247
-		if ($seq_name && $seq_fld) {	// if we have a sequence we need to set it again
288
+		if ($seq_name && $seq_fld)
289
+		{
290
+// if we have a sequence we need to set it again
248 291
 			$seq_name = $tabname.'_'.$seq_fld.'_seq';	// has to be the name of the new implicit sequence
249 292
 			$aSql[] = "SELECT setval('$seq_name',MAX($seq_fld)) FROM $tabname";
250 293
 		}
@@ -252,7 +295,8 @@  discard block
 block discarded – undo
252 295
 		// recreate the indexes, if they not contain one of the droped columns
253 296
 		foreach($this->MetaIndexes($tabname) as $idx_name => $idx_data)
254 297
 		{
255
-			if (substr($idx_name,-5) != '_pkey' && (!$dropflds || !count(array_intersect($dropflds,$idx_data['columns'])))) {
298
+			if (substr($idx_name,-5) != '_pkey' && (!$dropflds || !count(array_intersect($dropflds,$idx_data['columns']))))
299
+			{
256 300
 				$aSql = array_merge($aSql,$this->CreateIndexSQL($idx_name,$tabname,$idx_data['columns'],
257 301
 					$idx_data['unique'] ? array('UNIQUE') : False));
258 302
 			}
@@ -266,7 +310,10 @@  discard block
 block discarded – undo
266 310
 		$sql = ADODB_DataDict::DropTableSQL($tabname);
267 311
 
268 312
 		$drop_seq = $this->_DropAutoIncrement($tabname);
269
-		if ($drop_seq) $sql[] = $drop_seq;
313
+		if ($drop_seq)
314
+		{
315
+			$sql[] = $drop_seq;
316
+		}
270 317
 
271 318
 		return $sql;
272 319
 	}
@@ -274,14 +321,24 @@  discard block
 block discarded – undo
274 321
 	// return string must begin with space
275 322
 	function _CreateSuffix($fname, &$ftype, $fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
276 323
 	{
277
-		if ($fautoinc) {
324
+		if ($fautoinc)
325
+		{
278 326
 			$ftype = 'SERIAL';
279 327
 			return '';
280 328
 		}
281 329
 		$suffix = '';
282
-		if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
283
-		if ($fnotnull) $suffix .= ' NOT NULL';
284
-		if ($fconstraint) $suffix .= ' '.$fconstraint;
330
+		if (strlen($fdefault))
331
+		{
332
+			$suffix .= " DEFAULT $fdefault";
333
+		}
334
+		if ($fnotnull)
335
+		{
336
+			$suffix .= ' NOT NULL';
337
+		}
338
+		if ($fconstraint)
339
+		{
340
+			$suffix .= ' '.$fconstraint;
341
+		}
285 342
 		return $suffix;
286 343
 	}
287 344
 
@@ -295,7 +352,8 @@  discard block
 block discarded – undo
295 352
 		$seq = $this->connection->GetOne("SELECT relname FROM pg_class WHERE NOT relname ~ 'pg_.*' AND relname LIKE $tabname AND relkind='S'");
296 353
 
297 354
 		// check if a tables depends on the sequenz and it therefor cant and dont need to be droped separatly
298
-		if (!$seq || $this->connection->GetOne("SELECT relname FROM pg_class JOIN pg_depend ON pg_class.oid=pg_depend.objid WHERE relname='$seq' AND relkind='S' AND refclassid = (SELECT oid FROM pg_class WHERE relname = 'pg_class')")) {
355
+		if (!$seq || $this->connection->GetOne("SELECT relname FROM pg_class JOIN pg_depend ON pg_class.oid=pg_depend.objid WHERE relname='$seq' AND relkind='S' AND refclassid = (SELECT oid FROM pg_class WHERE relname = 'pg_class')"))
356
+		{
299 357
 			return False;
300 358
 		}
301 359
 		return "DROP SEQUENCE ".$seq;
@@ -338,13 +396,17 @@  discard block
 block discarded – undo
338 396
 	{
339 397
 		$sql = array();
340 398
 
341
-		if ( isset($idxoptions['REPLACE']) || isset($idxoptions['DROP']) ) {
399
+		if ( isset($idxoptions['REPLACE']) || isset($idxoptions['DROP']) )
400
+		{
342 401
 			$sql[] = sprintf ($this->dropIndex, $idxname, $tabname);
343 402
 			if ( isset($idxoptions['DROP']) )
344
-				return $sql;
403
+			{
404
+							return $sql;
405
+			}
345 406
 		}
346 407
 
347
-		if ( empty ($flds) ) {
408
+		if ( empty ($flds) )
409
+		{
348 410
 			return $sql;
349 411
 		}
350 412
 
@@ -353,13 +415,19 @@  discard block
 block discarded – undo
353 415
 		$s = 'CREATE' . $unique . ' INDEX ' . $idxname . ' ON ' . $tabname . ' ';
354 416
 
355 417
 		if (isset($idxoptions['HASH']))
356
-			$s .= 'USING HASH ';
418
+		{
419
+					$s .= 'USING HASH ';
420
+		}
357 421
 
358 422
 		if ( isset($idxoptions[$this->upperName]) )
359
-			$s .= $idxoptions[$this->upperName];
423
+		{
424
+					$s .= $idxoptions[$this->upperName];
425
+		}
360 426
 
361 427
 		if ( is_array($flds) )
362
-			$flds = implode(', ',$flds);
428
+		{
429
+					$flds = implode(', ',$flds);
430
+		}
363 431
 		$s .= '(' . $flds . ')';
364 432
 		$sql[] = $s;
365 433
 
Please login to merge, or discard this patch.
phpgwapi/inc/adodb/drivers/adodb-ibase.inc.php 6 patches
Doc Comments   +5 added lines patch added patch discarded remove patch
@@ -379,6 +379,11 @@
 block discarded – undo
379 379
 	 }
380 380
 	
381 381
 	//OPN STUFF start
382
+
383
+	/**
384
+	 * @param ADOFieldObject $fld
385
+	 * @param boolean $dialect3
386
+	 */
382 387
 	function _ConvertFieldType(&$fld, $ftype, $flen, $fscale, $fsubtype, $fprecision, $dialect3)
383 388
 	{
384 389
 		$fscale = abs($fscale);
Please login to merge, or discard this patch.
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -189,55 +189,55 @@  discard block
 block discarded – undo
189 189
 	
190 190
 	function &MetaIndexes ($table, $primary = FALSE, $owner=false)
191 191
 	{
192
-        // save old fetch mode
193
-        global $ADODB_FETCH_MODE;
194
-        $false = false;
195
-        $save = $ADODB_FETCH_MODE;
196
-        $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
197
-        if ($this->fetchMode !== FALSE) {
198
-               $savem = $this->SetFetchMode(FALSE);
199
-        }
200
-        $table = strtoupper($table);
201
-        $sql = "SELECT * FROM RDB\$INDICES WHERE RDB\$RELATION_NAME = '".$table."'";
202
-        if (!$primary) {
203
-        	$sql .= " AND RDB\$INDEX_NAME NOT LIKE 'RDB\$%'";
204
-        } else {
205
-        	$sql .= " AND RDB\$INDEX_NAME NOT LIKE 'RDB\$FOREIGN%'";
206
-        }
207
-        // get index details
208
-        $rs = $this->Execute($sql);
209
-        if (!is_object($rs)) {
210
-	        // restore fetchmode
211
-	        if (isset($savem)) {
212
-	            $this->SetFetchMode($savem);
213
-	        }
214
-	        $ADODB_FETCH_MODE = $save;
215
-            return $false;
216
-        }
192
+		// save old fetch mode
193
+		global $ADODB_FETCH_MODE;
194
+		$false = false;
195
+		$save = $ADODB_FETCH_MODE;
196
+		$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
197
+		if ($this->fetchMode !== FALSE) {
198
+			   $savem = $this->SetFetchMode(FALSE);
199
+		}
200
+		$table = strtoupper($table);
201
+		$sql = "SELECT * FROM RDB\$INDICES WHERE RDB\$RELATION_NAME = '".$table."'";
202
+		if (!$primary) {
203
+			$sql .= " AND RDB\$INDEX_NAME NOT LIKE 'RDB\$%'";
204
+		} else {
205
+			$sql .= " AND RDB\$INDEX_NAME NOT LIKE 'RDB\$FOREIGN%'";
206
+		}
207
+		// get index details
208
+		$rs = $this->Execute($sql);
209
+		if (!is_object($rs)) {
210
+			// restore fetchmode
211
+			if (isset($savem)) {
212
+				$this->SetFetchMode($savem);
213
+			}
214
+			$ADODB_FETCH_MODE = $save;
215
+			return $false;
216
+		}
217 217
         
218
-        $indexes = array ();
218
+		$indexes = array ();
219 219
 		while ($row = $rs->FetchRow()) {
220 220
 			$index = $row[0];
221
-             if (!isset($indexes[$index])) {
222
-             		if (is_null($row[3])) {$row[3] = 0;}
223
-                     $indexes[$index] = array(
224
-                             'unique' => ($row[3] == 1),
225
-                             'columns' => array()
226
-                     );
227
-             }
221
+			 if (!isset($indexes[$index])) {
222
+			 		if (is_null($row[3])) {$row[3] = 0;}
223
+					 $indexes[$index] = array(
224
+							 'unique' => ($row[3] == 1),
225
+							 'columns' => array()
226
+					 );
227
+			 }
228 228
 			$sql = "SELECT * FROM RDB\$INDEX_SEGMENTS WHERE RDB\$INDEX_NAME = '".$name."' ORDER BY RDB\$FIELD_POSITION ASC";
229 229
 			$rs1 = $this->Execute($sql);
230
-            while ($row1 = $rs1->FetchRow()) {
231
-             	$indexes[$index]['columns'][$row1[2]] = $row1[1];
232
-        	}
230
+			while ($row1 = $rs1->FetchRow()) {
231
+			 	$indexes[$index]['columns'][$row1[2]] = $row1[1];
232
+			}
233
+		}
234
+		// restore fetchmode
235
+		if (isset($savem)) {
236
+			$this->SetFetchMode($savem);
233 237
 		}
234
-        // restore fetchmode
235
-        if (isset($savem)) {
236
-            $this->SetFetchMode($savem);
237
-        }
238
-        $ADODB_FETCH_MODE = $save;
238
+		$ADODB_FETCH_MODE = $save;
239 239
         
240
-        return $indexes;
240
+		return $indexes;
241 241
 	}
242 242
 
243 243
 	
@@ -388,24 +388,24 @@  discard block
 block discarded – undo
388 388
 			case 7: 
389 389
 			case 8:
390 390
 				if ($dialect3) {
391
-				    switch($fsubtype){
392
-				    	case 0: 
393
-				    		$fld->type = ($ftype == 7 ? 'smallint' : 'integer');
394
-				    		break;
395
-				    	case 1: 
396
-				    		$fld->type = 'numeric';
391
+					switch($fsubtype){
392
+						case 0: 
393
+							$fld->type = ($ftype == 7 ? 'smallint' : 'integer');
394
+							break;
395
+						case 1: 
396
+							$fld->type = 'numeric';
397 397
 							$fld->max_length = $fprecision;
398 398
 							$fld->scale = $fscale;
399
-				    		break;
400
-				    	case 2:
401
-				    		$fld->type = 'decimal';
399
+							break;
400
+						case 2:
401
+							$fld->type = 'decimal';
402 402
 							$fld->max_length = $fprecision;
403 403
 							$fld->scale = $fscale;
404
-				    		break;
405
-				    } // switch
404
+							break;
405
+					} // switch
406 406
 				} else {
407 407
 					if ($fscale !=0) {
408
-					    $fld->type = 'decimal';
408
+						$fld->type = 'decimal';
409 409
 						$fld->scale = $fscale;
410 410
 						$fld->max_length = ($ftype == 7 ? 4 : 9);
411 411
 					} else {
@@ -415,23 +415,23 @@  discard block
 block discarded – undo
415 415
 				break;
416 416
 			case 16: 
417 417
 				if ($dialect3) {
418
-				    switch($fsubtype){
419
-				    	case 0: 
420
-				    		$fld->type = 'decimal';
418
+					switch($fsubtype){
419
+						case 0: 
420
+							$fld->type = 'decimal';
421 421
 							$fld->max_length = 18;
422 422
 							$fld->scale = 0;
423
-				    		break;
424
-				    	case 1: 
425
-				    		$fld->type = 'numeric';
423
+							break;
424
+						case 1: 
425
+							$fld->type = 'numeric';
426 426
 							$fld->max_length = $fprecision;
427 427
 							$fld->scale = $fscale;
428
-				    		break;
429
-				    	case 2:
430
-				    		$fld->type = 'decimal';
428
+							break;
429
+						case 2:
430
+							$fld->type = 'decimal';
431 431
 							$fld->max_length = $fprecision;
432 432
 							$fld->scale = $fscale;
433
-				    		break;
434
-				    } // switch
433
+							break;
434
+					} // switch
435 435
 				}
436 436
 				break;
437 437
 			case 10:
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 				break;
443 443
 			case 27:
444 444
 				if ($fscale !=0) {
445
-				    $fld->type = 'decimal';
445
+					$fld->type = 'decimal';
446 446
 					$fld->max_length = 15;
447 447
 					$fld->scale = 5;
448 448
 				} else {
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 				break;
452 452
 			case 35:
453 453
 				if ($dialect3) {
454
-				    $fld->type = 'timestamp';
454
+					$fld->type = 'timestamp';
455 455
 				} else {
456 456
 					$fld->type = 'date';
457 457
 				}
Please login to merge, or discard this patch.
Switch Indentation   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -122,11 +122,11 @@  discard block
 block discarded – undo
122 122
 	{
123 123
 		$arr['dialect'] = $this->dialect;
124 124
 		switch($arr['dialect']) {
125
-		case '': 
126
-		case '1': $s = 'Interbase 5.5 or earlier'; break;
127
-		case '2': $s = 'Interbase 5.6'; break;
128
-		default:
129
-		case '3': $s = 'Interbase 6.0'; break;
125
+			case '': 
126
+			case '1': $s = 'Interbase 5.5 or earlier'; break;
127
+			case '2': $s = 'Interbase 5.6'; break;
128
+			default:
129
+			case '3': $s = 'Interbase 6.0'; break;
130 130
 		}
131 131
 		$arr['version'] = ADOConnection::_findvers($s);
132 132
 		$arr['description'] = $s;
@@ -330,15 +330,15 @@  discard block
 block discarded – undo
330 330
 					$ret = call_user_func_array($fn,$fnarr);
331 331
 				} else {
332 332
 					switch(sizeof($iarr)) {
333
-					case 1: $ret = $fn($sql,$iarr[0]); break;
334
-					case 2: $ret = $fn($sql,$iarr[0],$iarr[1]); break;
335
-					case 3: $ret = $fn($sql,$iarr[0],$iarr[1],$iarr[2]); break;
336
-					case 4: $ret = $fn($sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3]); break;
337
-					case 5: $ret = $fn($sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4]); break;
338
-					case 6: $ret = $fn($sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5]); break;
339
-					case 7: $ret = $fn($sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5],$iarr[6]); break;
340
-					default: ADOConnection::outp( "Too many parameters to ibase query $sql");
341
-					case 8: $ret = $fn($sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5],$iarr[6],$iarr[7]); break;
333
+						case 1: $ret = $fn($sql,$iarr[0]); break;
334
+						case 2: $ret = $fn($sql,$iarr[0],$iarr[1]); break;
335
+						case 3: $ret = $fn($sql,$iarr[0],$iarr[1],$iarr[2]); break;
336
+						case 4: $ret = $fn($sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3]); break;
337
+						case 5: $ret = $fn($sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4]); break;
338
+						case 6: $ret = $fn($sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5]); break;
339
+						case 7: $ret = $fn($sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5],$iarr[6]); break;
340
+						default: ADOConnection::outp( "Too many parameters to ibase query $sql");
341
+						case 8: $ret = $fn($sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5],$iarr[6],$iarr[7]); break;
342 342
 					}
343 343
 				}
344 344
 			} else $ret = $fn($sql); 
@@ -352,15 +352,15 @@  discard block
 block discarded – undo
352 352
 					$ret = call_user_func_array($fn,$fnarr);
353 353
 				} else {
354 354
 					switch(sizeof($iarr)) {
355
-					case 1: $ret = $fn($conn,$sql,$iarr[0]); break;
356
-					case 2: $ret = $fn($conn,$sql,$iarr[0],$iarr[1]); break;
357
-					case 3: $ret = $fn($conn,$sql,$iarr[0],$iarr[1],$iarr[2]); break;
358
-					case 4: $ret = $fn($conn,$sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3]); break;
359
-					case 5: $ret = $fn($conn,$sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4]); break;
360
-					case 6: $ret = $fn($conn,$sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5]); break;
361
-					case 7: $ret = $fn($conn,$sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5],$iarr[6]); break;
362
-					default: ADOConnection::outp( "Too many parameters to ibase query $sql");
363
-					case 8: $ret = $fn($conn,$sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5],$iarr[6],$iarr[7]); break;
355
+						case 1: $ret = $fn($conn,$sql,$iarr[0]); break;
356
+						case 2: $ret = $fn($conn,$sql,$iarr[0],$iarr[1]); break;
357
+						case 3: $ret = $fn($conn,$sql,$iarr[0],$iarr[1],$iarr[2]); break;
358
+						case 4: $ret = $fn($conn,$sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3]); break;
359
+						case 5: $ret = $fn($conn,$sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4]); break;
360
+						case 6: $ret = $fn($conn,$sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5]); break;
361
+						case 7: $ret = $fn($conn,$sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5],$iarr[6]); break;
362
+						default: ADOConnection::outp( "Too many parameters to ibase query $sql");
363
+						case 8: $ret = $fn($conn,$sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5],$iarr[6],$iarr[7]); break;
364 364
 					}
365 365
 				}
366 366
 			} else $ret = $fn($conn,$sql); 
@@ -509,15 +509,15 @@  discard block
 block discarded – undo
509 509
 				$d = substr($rs->fields[2],strlen('default '));
510 510
 				switch ($fld->type)
511 511
 				{
512
-				case 'smallint':
513
-				case 'integer': $fld->default_value = (int) $d; break;
514
-				case 'char': 
515
-				case 'blob':
516
-				case 'text':
517
-				case 'varchar': $fld->default_value = (string) substr($d,1,strlen($d)-2); break;
518
-				case 'double':
519
-				case 'float': $fld->default_value = (float) $d; break;
520
-				default: $fld->default_value = $d; break;
512
+					case 'smallint':
513
+					case 'integer': $fld->default_value = (int) $d; break;
514
+					case 'char': 
515
+					case 'blob':
516
+					case 'text':
517
+					case 'varchar': $fld->default_value = (string) substr($d,1,strlen($d)-2); break;
518
+					case 'double':
519
+					case 'float': $fld->default_value = (float) $d; break;
520
+					default: $fld->default_value = $d; break;
521 521
 				}
522 522
 		//	case 35:$tt = 'TIMESTAMP'; break;
523 523
 			}
@@ -651,42 +651,42 @@  discard block
 block discarded – undo
651 651
 			if ($s) $s .= '||';
652 652
 			$ch = $fmt[$i];
653 653
 			switch($ch) {
654
-			case 'Y':
655
-			case 'y':
656
-				$s .= "extract(year from $col)";
657
-				break;
658
-			case 'M':
659
-			case 'm':
660
-				$s .= "extract(month from $col)";
661
-				break;
662
-			case 'Q':
663
-			case 'q':
664
-				$s .= "cast(((extract(month from $col)+2) / 3) as integer)";
665
-				break;
666
-			case 'D':
667
-			case 'd':
668
-				$s .= "(extract(day from $col))";
669
-				break;
670
-			case 'H':
671
-			case 'h':
672
-			  $s .= "(extract(hour from $col))";
673
-			  break;                        
674
-			case 'I':
675
-			case 'i':
676
-			  $s .= "(extract(minute from $col))";
677
-			  break;                
678
-			case 'S':
679
-			case 's':
680
-			  $s .= "CAST((extract(second from $col)) AS INTEGER)";
681
-			  break;        
654
+				case 'Y':
655
+				case 'y':
656
+					$s .= "extract(year from $col)";
657
+					break;
658
+				case 'M':
659
+				case 'm':
660
+					$s .= "extract(month from $col)";
661
+					break;
662
+				case 'Q':
663
+				case 'q':
664
+					$s .= "cast(((extract(month from $col)+2) / 3) as integer)";
665
+					break;
666
+				case 'D':
667
+				case 'd':
668
+					$s .= "(extract(day from $col))";
669
+					break;
670
+				case 'H':
671
+				case 'h':
672
+			  	$s .= "(extract(hour from $col))";
673
+			  	break;                        
674
+				case 'I':
675
+				case 'i':
676
+			  	$s .= "(extract(minute from $col))";
677
+			  	break;                
678
+				case 'S':
679
+				case 's':
680
+			  	$s .= "CAST((extract(second from $col)) AS INTEGER)";
681
+			  	break;        
682 682
 
683
-			default:
684
-				if ($ch == '\\') {
685
-					$i++;
686
-					$ch = substr($fmt,$i,1);
687
-				}
688
-				$s .= $this->qstr($ch);
689
-				break;
683
+				default:
684
+					if ($ch == '\\') {
685
+						$i++;
686
+						$ch = substr($fmt,$i,1);
687
+					}
688
+					$s .= $this->qstr($ch);
689
+					break;
690 690
 			}
691 691
 		}
692 692
 		return $s;
@@ -722,18 +722,18 @@  discard block
 block discarded – undo
722 722
 			 $fld = new ADOFieldObject;
723 723
 			 $ibf = ibase_field_info($this->_queryID,$fieldOffset);
724 724
 			 switch (ADODB_ASSOC_CASE) {
725
-			 case 2: // the default
726
-			 	$fld->name = ($ibf['alias']);
727
-				 if (empty($fld->name)) $fld->name = ($ibf['name']);
728
-				 break;
729
-			 case 0: 
730
-				 $fld->name = strtoupper($ibf['alias']);
731
-				 if (empty($fld->name)) $fld->name = strtoupper($ibf['name']);
732
-				 break;
733
-			 case 1: 
734
-			 	$fld->name = strtolower($ibf['alias']);
735
-				 if (empty($fld->name)) $fld->name = strtolower($ibf['name']);
736
-				 break;
725
+			 	case 2: // the default
726
+			 		$fld->name = ($ibf['alias']);
727
+				 	if (empty($fld->name)) $fld->name = ($ibf['name']);
728
+				 	break;
729
+			 	case 0: 
730
+				 	$fld->name = strtoupper($ibf['alias']);
731
+				 	if (empty($fld->name)) $fld->name = strtoupper($ibf['name']);
732
+				 	break;
733
+			 	case 1: 
734
+			 		$fld->name = strtolower($ibf['alias']);
735
+				 	if (empty($fld->name)) $fld->name = strtolower($ibf['name']);
736
+				 	break;
737 737
 			 }
738 738
 			 
739 739
 			 $fld->type = $ibf['type'];
@@ -833,27 +833,27 @@  discard block
 block discarded – undo
833 833
 			$len = $fieldobj->max_length;
834 834
 		}
835 835
 		switch (strtoupper($t)) {
836
-		case 'CHAR':
837
-			return 'C';
836
+			case 'CHAR':
837
+				return 'C';
838 838
 			
839
-		case 'TEXT':
840
-		case 'VARCHAR':
841
-		case 'VARYING':
842
-		if ($len <= $this->blobSize) return 'C';
843
-			return 'X';
844
-		case 'BLOB':
845
-			return 'B';
839
+			case 'TEXT':
840
+			case 'VARCHAR':
841
+			case 'VARYING':
842
+			if ($len <= $this->blobSize) return 'C';
843
+				return 'X';
844
+			case 'BLOB':
845
+				return 'B';
846 846
 			   
847
-		case 'TIMESTAMP':
848
-		case 'DATE': return 'D';
849
-		case 'TIME': return 'T';
850
-				//case 'T': return 'T';
847
+			case 'TIMESTAMP':
848
+			case 'DATE': return 'D';
849
+			case 'TIME': return 'T';
850
+					//case 'T': return 'T';
851 851
 
852
-				//case 'L': return 'L';
853
-		case 'INT': 
854
-		case 'SHORT':
855
-		case 'INTEGER': return 'I';
856
-		default: return 'N';
852
+					//case 'L': return 'L';
853
+			case 'INT': 
854
+			case 'SHORT':
855
+			case 'INTEGER': return 'I';
856
+			default: return 'N';
857 857
 		}
858 858
 	}
859 859
 
Please login to merge, or discard this patch.
Spacing   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	var $ibase_timestampfmt = "%Y-%m-%d %H:%M:%S";
36 36
 	var $ibase_timefmt = "%H:%M:%S";
37 37
 	var $fmtTimeStamp = "'Y-m-d, H:i:s'";
38
-	var $concat_operator='||';
38
+	var $concat_operator = '||';
39 39
 	var $_transactionID;
40 40
 	var $metaTablesSQL = "select rdb\$relation_name from rdb\$relations where rdb\$relation_name not like 'RDB\$%'";
41 41
 	//OPN STUFF start
@@ -61,17 +61,17 @@  discard block
 block discarded – undo
61 61
 	
62 62
 	
63 63
 	   // returns true or false
64
-	function _connect($argHostname, $argUsername, $argPassword, $argDatabasename,$persist=false)
64
+	function _connect($argHostname, $argUsername, $argPassword, $argDatabasename, $persist = false)
65 65
 	{  
66 66
 		if (!function_exists('ibase_pconnect')) return null;
67 67
 		if ($argDatabasename) $argHostname .= ':'.$argDatabasename;
68
-		$fn = ($persist) ? 'ibase_pconnect':'ibase_connect';
68
+		$fn = ($persist) ? 'ibase_pconnect' : 'ibase_connect';
69 69
 		if ($this->role)
70
-			$this->_connectionID = $fn($argHostname,$argUsername,$argPassword,
71
-					$this->charSet,$this->buffers,$this->dialect,$this->role);
70
+			$this->_connectionID = $fn($argHostname, $argUsername, $argPassword,
71
+					$this->charSet, $this->buffers, $this->dialect, $this->role);
72 72
 		else	
73
-			$this->_connectionID = $fn($argHostname,$argUsername,$argPassword,
74
-					$this->charSet,$this->buffers,$this->dialect);
73
+			$this->_connectionID = $fn($argHostname, $argUsername, $argPassword,
74
+					$this->charSet, $this->buffers, $this->dialect);
75 75
 		
76 76
 		if ($this->dialect != 1) { // http://www.ibphoenix.com/ibp_60_del_id_ds.html
77 77
 			$this->replaceQuote = "''";
@@ -83,10 +83,10 @@  discard block
 block discarded – undo
83 83
 		
84 84
 		// PHP5 change.
85 85
 		if (function_exists('ibase_timefmt')) {
86
-			ibase_timefmt($this->ibase_datefmt,IBASE_DATE );
87
-			if ($this->dialect == 1) ibase_timefmt($this->ibase_datefmt,IBASE_TIMESTAMP );
88
-			else ibase_timefmt($this->ibase_timestampfmt,IBASE_TIMESTAMP );
89
-			ibase_timefmt($this->ibase_timefmt,IBASE_TIME );
86
+			ibase_timefmt($this->ibase_datefmt, IBASE_DATE);
87
+			if ($this->dialect == 1) ibase_timefmt($this->ibase_datefmt, IBASE_TIMESTAMP);
88
+			else ibase_timefmt($this->ibase_timestampfmt, IBASE_TIMESTAMP);
89
+			ibase_timefmt($this->ibase_timefmt, IBASE_TIME);
90 90
 			
91 91
 		} else {
92 92
 			ini_set("ibase.timestampformat", $this->ibase_timestampfmt);
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
 	   // returns true or false
99 99
 	function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
100 100
 	{
101
-		return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename,true);
101
+		return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename, true);
102 102
 	}	
103 103
 	
104 104
 	
105
-	function MetaPrimaryKeys($table,$owner_notused=false,$internalKey=false)
105
+	function MetaPrimaryKeys($table, $owner_notused = false, $internalKey = false)
106 106
 	{	
107 107
 		if ($internalKey) return array('RDB$DB_KEY');
108 108
 		
@@ -113,15 +113,15 @@  discard block
 block discarded – undo
113 113
 	WHERE I.RDB$RELATION_NAME=\''.$table.'\' and I.RDB$INDEX_NAME like \'RDB$PRIMARY%\'
114 114
 	ORDER BY I.RDB$INDEX_NAME,S.RDB$FIELD_POSITION';
115 115
 
116
-		$a = $this->GetCol($sql,false,true);
117
-		if ($a && sizeof($a)>0) return $a;
116
+		$a = $this->GetCol($sql, false, true);
117
+		if ($a && sizeof($a) > 0) return $a;
118 118
 		return false;	  
119 119
 	}
120 120
 	
121 121
 	function ServerInfo()
122 122
 	{
123 123
 		$arr['dialect'] = $this->dialect;
124
-		switch($arr['dialect']) {
124
+		switch ($arr['dialect']) {
125 125
 		case '': 
126 126
 		case '1': $s = 'Interbase 5.5 or earlier'; break;
127 127
 		case '2': $s = 'Interbase 5.6'; break;
@@ -138,11 +138,11 @@  discard block
 block discarded – undo
138 138
 		if ($this->transOff) return true;
139 139
 		$this->transCnt += 1;
140 140
 		$this->autoCommit = false;
141
-	 	$this->_transactionID = $this->_connectionID;//ibase_trans($this->ibasetrans, $this->_connectionID);
141
+	 	$this->_transactionID = $this->_connectionID; //ibase_trans($this->ibasetrans, $this->_connectionID);
142 142
 		return $this->_transactionID;
143 143
 	}
144 144
 	
145
-	function CommitTrans($ok=true) 
145
+	function CommitTrans($ok = true) 
146 146
 	{ 
147 147
 		if (!$ok) return $this->RollbackTrans();
148 148
 		if ($this->transOff) return true;
@@ -159,17 +159,17 @@  discard block
 block discarded – undo
159 159
 	
160 160
 	// there are some compat problems with ADODB_COUNTRECS=false and $this->_logsql currently.
161 161
 	// it appears that ibase extension cannot support multiple concurrent queryid's
162
-	function &_Execute($sql,$inputarr=false) 
162
+	function &_Execute($sql, $inputarr = false) 
163 163
 	{
164 164
 	global $ADODB_COUNTRECS;
165 165
 	
166 166
 		if ($this->_logsql) {
167 167
 			$savecrecs = $ADODB_COUNTRECS;
168 168
 			$ADODB_COUNTRECS = true; // force countrecs
169
-			$ret =& ADOConnection::_Execute($sql,$inputarr);
169
+			$ret = & ADOConnection::_Execute($sql, $inputarr);
170 170
 			$ADODB_COUNTRECS = $savecrecs;
171 171
 		} else {
172
-			$ret =& ADOConnection::_Execute($sql,$inputarr);
172
+			$ret = & ADOConnection::_Execute($sql, $inputarr);
173 173
 		}
174 174
 		return $ret;
175 175
 	}
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 		return $ret;
188 188
 	}
189 189
 	
190
-	function &MetaIndexes ($table, $primary = FALSE, $owner=false)
190
+	function &MetaIndexes($table, $primary = FALSE, $owner = false)
191 191
 	{
192 192
         // save old fetch mode
193 193
         global $ADODB_FETCH_MODE;
@@ -215,11 +215,11 @@  discard block
 block discarded – undo
215 215
             return $false;
216 216
         }
217 217
         
218
-        $indexes = array ();
218
+        $indexes = array();
219 219
 		while ($row = $rs->FetchRow()) {
220 220
 			$index = $row[0];
221 221
              if (!isset($indexes[$index])) {
222
-             		if (is_null($row[3])) {$row[3] = 0;}
222
+             		if (is_null($row[3])) {$row[3] = 0; }
223 223
                      $indexes[$index] = array(
224 224
                              'unique' => ($row[3] == 1),
225 225
                              'columns' => array()
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 
243 243
 	
244 244
 	// See http://community.borland.com/article/0,1410,25844,00.html
245
-	function RowLock($tables,$where,$col)
245
+	function RowLock($tables, $where, $col)
246 246
 	{
247 247
 		if ($this->autoCommit) $this->BeginTrans();
248 248
 		$this->Execute("UPDATE $table SET $col=$col WHERE $where "); // is this correct - jlim?
@@ -250,11 +250,11 @@  discard block
 block discarded – undo
250 250
 	}
251 251
 	
252 252
 	
253
-	function CreateSequence($seqname,$startID=1)
253
+	function CreateSequence($seqname, $startID = 1)
254 254
 	{
255
-		$ok = $this->Execute(("INSERT INTO RDB\$GENERATORS (RDB\$GENERATOR_NAME) VALUES (UPPER('$seqname'))" ));
255
+		$ok = $this->Execute(("INSERT INTO RDB\$GENERATORS (RDB\$GENERATOR_NAME) VALUES (UPPER('$seqname'))"));
256 256
 		if (!$ok) return false;
257
-		return $this->Execute("SET GENERATOR $seqname TO ".($startID-1).';');
257
+		return $this->Execute("SET GENERATOR $seqname TO ".($startID - 1).';');
258 258
 	}
259 259
 	
260 260
 	function DropSequence($seqname)
@@ -263,16 +263,16 @@  discard block
 block discarded – undo
263 263
 		$this->Execute("delete from RDB\$GENERATORS where RDB\$GENERATOR_NAME='$seqname'");
264 264
 	}
265 265
 	
266
-	function GenID($seqname='adodbseq',$startID=1)
266
+	function GenID($seqname = 'adodbseq', $startID = 1)
267 267
 	{
268 268
 		$getnext = ("SELECT Gen_ID($seqname,1) FROM RDB\$DATABASE");
269 269
 		$rs = @$this->Execute($getnext);
270 270
 		if (!$rs) {
271
-			$this->Execute(("INSERT INTO RDB\$GENERATORS (RDB\$GENERATOR_NAME) VALUES (UPPER('$seqname'))" ));
272
-			$this->Execute("SET GENERATOR $seqname TO ".($startID-1).';');
271
+			$this->Execute(("INSERT INTO RDB\$GENERATORS (RDB\$GENERATOR_NAME) VALUES (UPPER('$seqname'))"));
272
+			$this->Execute("SET GENERATOR $seqname TO ".($startID - 1).';');
273 273
 			$rs = $this->Execute($getnext);
274 274
 		}
275
-		if ($rs && !$rs->EOF) $this->genID = (integer) reset($rs->fields);
275
+		if ($rs && !$rs->EOF) $this->genID = (integer)reset($rs->fields);
276 276
 		else $this->genID = 0; // false
277 277
 		
278 278
 		if ($rs) $rs->Close();
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 
293 293
 	function ErrorNo() 
294 294
 	{
295
-		if (preg_match('/error code = ([\-0-9]*)/i', $this->_errorMsg,$arr)) return (integer) $arr[1];
295
+		if (preg_match('/error code = ([\-0-9]*)/i', $this->_errorMsg, $arr)) return (integer)$arr[1];
296 296
 		else return 0;
297 297
 	}
298 298
 
@@ -303,14 +303,14 @@  discard block
 block discarded – undo
303 303
 
304 304
 	function Prepare($sql)
305 305
 	{
306
-		$stmt = ibase_prepare($this->_connectionID,$sql);
306
+		$stmt = ibase_prepare($this->_connectionID, $sql);
307 307
 		if (!$stmt) return false;
308
-		return array($sql,$stmt);
308
+		return array($sql, $stmt);
309 309
 	}
310 310
 
311 311
 	   // returns query ID if successful, otherwise false
312 312
 	   // there have been reports of problems with nested queries - the code is probably not re-entrant?
313
-	function _query($sql,$iarr=false)
313
+	function _query($sql, $iarr = false)
314 314
 	{ 
315 315
 
316 316
 		if (!$this->autoCommit && $this->_transactionID) {
@@ -324,21 +324,21 @@  discard block
 block discarded – undo
324 324
 			$fn = 'ibase_execute';
325 325
 			$sql = $sql[1];
326 326
 			if (is_array($iarr)) {
327
-				if  (ADODB_PHPVER >= 0x4050) { // actually 4.0.4
328
-					if ( !isset($iarr[0]) ) $iarr[0] = ''; // PHP5 compat hack
329
-					$fnarr =& array_merge( array($sql) , $iarr);
330
-					$ret = call_user_func_array($fn,$fnarr);
327
+				if (ADODB_PHPVER >= 0x4050) { // actually 4.0.4
328
+					if (!isset($iarr[0])) $iarr[0] = ''; // PHP5 compat hack
329
+					$fnarr = & array_merge(array($sql), $iarr);
330
+					$ret = call_user_func_array($fn, $fnarr);
331 331
 				} else {
332
-					switch(sizeof($iarr)) {
333
-					case 1: $ret = $fn($sql,$iarr[0]); break;
334
-					case 2: $ret = $fn($sql,$iarr[0],$iarr[1]); break;
335
-					case 3: $ret = $fn($sql,$iarr[0],$iarr[1],$iarr[2]); break;
336
-					case 4: $ret = $fn($sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3]); break;
337
-					case 5: $ret = $fn($sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4]); break;
338
-					case 6: $ret = $fn($sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5]); break;
339
-					case 7: $ret = $fn($sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5],$iarr[6]); break;
340
-					default: ADOConnection::outp( "Too many parameters to ibase query $sql");
341
-					case 8: $ret = $fn($sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5],$iarr[6],$iarr[7]); break;
332
+					switch (sizeof($iarr)) {
333
+					case 1: $ret = $fn($sql, $iarr[0]); break;
334
+					case 2: $ret = $fn($sql, $iarr[0], $iarr[1]); break;
335
+					case 3: $ret = $fn($sql, $iarr[0], $iarr[1], $iarr[2]); break;
336
+					case 4: $ret = $fn($sql, $iarr[0], $iarr[1], $iarr[2], $iarr[3]); break;
337
+					case 5: $ret = $fn($sql, $iarr[0], $iarr[1], $iarr[2], $iarr[3], $iarr[4]); break;
338
+					case 6: $ret = $fn($sql, $iarr[0], $iarr[1], $iarr[2], $iarr[3], $iarr[4], $iarr[5]); break;
339
+					case 7: $ret = $fn($sql, $iarr[0], $iarr[1], $iarr[2], $iarr[3], $iarr[4], $iarr[5], $iarr[6]); break;
340
+					default: ADOConnection::outp("Too many parameters to ibase query $sql");
341
+					case 8: $ret = $fn($sql, $iarr[0], $iarr[1], $iarr[2], $iarr[3], $iarr[4], $iarr[5], $iarr[6], $iarr[7]); break;
342 342
 					}
343 343
 				}
344 344
 			} else $ret = $fn($sql); 
@@ -348,22 +348,22 @@  discard block
 block discarded – undo
348 348
 			if (is_array($iarr)) {	
349 349
 				if (ADODB_PHPVER >= 0x4050) { // actually 4.0.4
350 350
 					if (sizeof($iarr) == 0) $iarr[0] = ''; // PHP5 compat hack
351
-					$fnarr =& array_merge( array($conn,$sql) , $iarr);
352
-					$ret = call_user_func_array($fn,$fnarr);
351
+					$fnarr = & array_merge(array($conn, $sql), $iarr);
352
+					$ret = call_user_func_array($fn, $fnarr);
353 353
 				} else {
354
-					switch(sizeof($iarr)) {
355
-					case 1: $ret = $fn($conn,$sql,$iarr[0]); break;
356
-					case 2: $ret = $fn($conn,$sql,$iarr[0],$iarr[1]); break;
357
-					case 3: $ret = $fn($conn,$sql,$iarr[0],$iarr[1],$iarr[2]); break;
358
-					case 4: $ret = $fn($conn,$sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3]); break;
359
-					case 5: $ret = $fn($conn,$sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4]); break;
360
-					case 6: $ret = $fn($conn,$sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5]); break;
361
-					case 7: $ret = $fn($conn,$sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5],$iarr[6]); break;
362
-					default: ADOConnection::outp( "Too many parameters to ibase query $sql");
363
-					case 8: $ret = $fn($conn,$sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5],$iarr[6],$iarr[7]); break;
354
+					switch (sizeof($iarr)) {
355
+					case 1: $ret = $fn($conn, $sql, $iarr[0]); break;
356
+					case 2: $ret = $fn($conn, $sql, $iarr[0], $iarr[1]); break;
357
+					case 3: $ret = $fn($conn, $sql, $iarr[0], $iarr[1], $iarr[2]); break;
358
+					case 4: $ret = $fn($conn, $sql, $iarr[0], $iarr[1], $iarr[2], $iarr[3]); break;
359
+					case 5: $ret = $fn($conn, $sql, $iarr[0], $iarr[1], $iarr[2], $iarr[3], $iarr[4]); break;
360
+					case 6: $ret = $fn($conn, $sql, $iarr[0], $iarr[1], $iarr[2], $iarr[3], $iarr[4], $iarr[5]); break;
361
+					case 7: $ret = $fn($conn, $sql, $iarr[0], $iarr[1], $iarr[2], $iarr[3], $iarr[4], $iarr[5], $iarr[6]); break;
362
+					default: ADOConnection::outp("Too many parameters to ibase query $sql");
363
+					case 8: $ret = $fn($conn, $sql, $iarr[0], $iarr[1], $iarr[2], $iarr[3], $iarr[4], $iarr[5], $iarr[6], $iarr[7]); break;
364 364
 					}
365 365
 				}
366
-			} else $ret = $fn($conn,$sql); 
366
+			} else $ret = $fn($conn, $sql); 
367 367
 		}
368 368
 		if ($docommit && $ret === true) ibase_commit($this->_connectionID);
369 369
 
@@ -384,11 +384,11 @@  discard block
 block discarded – undo
384 384
 		$fscale = abs($fscale);
385 385
 		$fld->max_length = $flen;
386 386
 		$fld->scale = null;
387
-		switch($ftype){
387
+		switch ($ftype) {
388 388
 			case 7: 
389 389
 			case 8:
390 390
 				if ($dialect3) {
391
-				    switch($fsubtype){
391
+				    switch ($fsubtype) {
392 392
 				    	case 0: 
393 393
 				    		$fld->type = ($ftype == 7 ? 'smallint' : 'integer');
394 394
 				    		break;
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 				    		break;
405 405
 				    } // switch
406 406
 				} else {
407
-					if ($fscale !=0) {
407
+					if ($fscale != 0) {
408 408
 					    $fld->type = 'decimal';
409 409
 						$fld->scale = $fscale;
410 410
 						$fld->max_length = ($ftype == 7 ? 4 : 9);
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 				break;
416 416
 			case 16: 
417 417
 				if ($dialect3) {
418
-				    switch($fsubtype){
418
+				    switch ($fsubtype) {
419 419
 				    	case 0: 
420 420
 				    		$fld->type = 'decimal';
421 421
 							$fld->max_length = 18;
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
 				$fld->type = 'char';
442 442
 				break;
443 443
 			case 27:
444
-				if ($fscale !=0) {
444
+				if ($fscale != 0) {
445 445
 				    $fld->type = 'decimal';
446 446
 					$fld->max_length = 15;
447 447
 					$fld->scale = 5;
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
 		$save = $ADODB_FETCH_MODE;
484 484
 		$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
485 485
 	
486
-		$rs = $this->Execute(sprintf($this->metaColumnsSQL,strtoupper($table)));
486
+		$rs = $this->Execute(sprintf($this->metaColumnsSQL, strtoupper($table)));
487 487
 	
488 488
 		$ADODB_FETCH_MODE = $save;
489 489
 		$false = false;
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
 		
494 494
 		$retarr = array();
495 495
 		//OPN STUFF start
496
-		$dialect3 = ($this->dialect==3 ? true : false);
496
+		$dialect3 = ($this->dialect == 3 ? true : false);
497 497
 		//OPN STUFF end
498 498
 		while (!$rs->EOF) { //print_r($rs->fields);
499 499
 			$fld = new ADOFieldObject();
@@ -506,17 +506,17 @@  discard block
 block discarded – undo
506 506
 			if (isset($rs->fields[2])) {
507 507
 				
508 508
 				$fld->has_default = true;
509
-				$d = substr($rs->fields[2],strlen('default '));
509
+				$d = substr($rs->fields[2], strlen('default '));
510 510
 				switch ($fld->type)
511 511
 				{
512 512
 				case 'smallint':
513
-				case 'integer': $fld->default_value = (int) $d; break;
513
+				case 'integer': $fld->default_value = (int)$d; break;
514 514
 				case 'char': 
515 515
 				case 'blob':
516 516
 				case 'text':
517
-				case 'varchar': $fld->default_value = (string) substr($d,1,strlen($d)-2); break;
517
+				case 'varchar': $fld->default_value = (string)substr($d, 1, strlen($d) - 2); break;
518 518
 				case 'double':
519
-				case 'float': $fld->default_value = (float) $d; break;
519
+				case 'float': $fld->default_value = (float)$d; break;
520 520
 				default: $fld->default_value = $d; break;
521 521
 				}
522 522
 		//	case 35:$tt = 'TIMESTAMP'; break;
@@ -533,15 +533,15 @@  discard block
 block discarded – undo
533 533
 			$rs->MoveNext();
534 534
 		}
535 535
 		$rs->Close();
536
-		if ( empty($retarr)) return $false;
536
+		if (empty($retarr)) return $false;
537 537
 		else return $retarr;	
538 538
 	}
539 539
 	
540
-	function BlobEncode( $blob ) 
540
+	function BlobEncode($blob) 
541 541
 	{
542
-		$blobid = ibase_blob_create( $this->_connectionID);
543
-		ibase_blob_add( $blobid, $blob );
544
-		return ibase_blob_close( $blobid );
542
+		$blobid = ibase_blob_create($this->_connectionID);
543
+		ibase_blob_add($blobid, $blob);
544
+		return ibase_blob_close($blobid);
545 545
 	}
546 546
 	
547 547
 	// since we auto-decode all blob's since 2.42, 
@@ -556,27 +556,27 @@  discard block
 block discarded – undo
556 556
 	
557 557
 	// old blobdecode function
558 558
 	// still used to auto-decode all blob's
559
-	function _BlobDecode( $blob ) 
559
+	function _BlobDecode($blob) 
560 560
 	{
561
-		$blobid = ibase_blob_open( $blob );
562
-		$realblob = ibase_blob_get( $blobid,$this->maxblobsize); // 2nd param is max size of blob -- Kevin Boillet <[email protected]>
563
-		while($string = ibase_blob_get($blobid, 8192)){ 
561
+		$blobid = ibase_blob_open($blob);
562
+		$realblob = ibase_blob_get($blobid, $this->maxblobsize); // 2nd param is max size of blob -- Kevin Boillet <[email protected]>
563
+		while ($string = ibase_blob_get($blobid, 8192)) { 
564 564
 			$realblob .= $string; 
565 565
 		}
566
-		ibase_blob_close( $blobid );
566
+		ibase_blob_close($blobid);
567 567
 
568
-		return( $realblob );
568
+		return($realblob);
569 569
 	} 
570 570
 	
571
-	function UpdateBlobFile($table,$column,$path,$where,$blobtype='BLOB') 
571
+	function UpdateBlobFile($table, $column, $path, $where, $blobtype = 'BLOB') 
572 572
 	{ 
573
-		$fd = fopen($path,'rb'); 
573
+		$fd = fopen($path, 'rb'); 
574 574
 		if ($fd === false) return false; 
575 575
 		$blob_id = ibase_blob_create($this->_connectionID); 
576 576
 		
577 577
 		/* fill with data */ 
578 578
 		
579
-		while ($val = fread($fd,32768)){ 
579
+		while ($val = fread($fd, 32768)) { 
580 580
 			ibase_blob_add($blob_id, $val); 
581 581
 		} 
582 582
 		
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
 		$blob_id_str = ibase_blob_close($blob_id); 
585 585
 		
586 586
 		fclose($fd); 
587
-		return $this->Execute("UPDATE $table SET $column=(?) WHERE $where",array($blob_id_str)) != false; 
587
+		return $this->Execute("UPDATE $table SET $column=(?) WHERE $where", array($blob_id_str)) != false; 
588 588
 	} 
589 589
 	
590 590
 	/*
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
 		$conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)');
597 597
 		$conn->UpdateBlob('blobtable','blobcol',$blob,'id=1');
598 598
 	*/
599
-	function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB') 
599
+	function UpdateBlob($table, $column, $val, $where, $blobtype = 'BLOB') 
600 600
 	{ 
601 601
 	$blob_id = ibase_blob_create($this->_connectionID); 
602 602
 	
@@ -625,32 +625,32 @@  discard block
 block discarded – undo
625 625
 	
626 626
 	$blob_id_str = ibase_blob_close($blob_id); 
627 627
 	
628
-	return $this->Execute("UPDATE $table SET $column=(?) WHERE $where",array($blob_id_str)) != false; 
628
+	return $this->Execute("UPDATE $table SET $column=(?) WHERE $where", array($blob_id_str)) != false; 
629 629
 	
630 630
 	} 
631 631
 	
632 632
 	
633
-	function OldUpdateBlob($table,$column,$val,$where,$blobtype='BLOB')
633
+	function OldUpdateBlob($table, $column, $val, $where, $blobtype = 'BLOB')
634 634
 	{
635 635
 		$blob_id = ibase_blob_create($this->_connectionID);
636 636
 		ibase_blob_add($blob_id, $val);
637 637
 		$blob_id_str = ibase_blob_close($blob_id);
638
-		return $this->Execute("UPDATE $table SET $column=(?) WHERE $where",array($blob_id_str)) != false;
638
+		return $this->Execute("UPDATE $table SET $column=(?) WHERE $where", array($blob_id_str)) != false;
639 639
 	}
640 640
 	
641 641
 	// Format date column in sql string given an input format that understands Y M D
642 642
 	// Only since Interbase 6.0 - uses EXTRACT
643 643
 	// problem - does not zero-fill the day and month yet
644
-	function SQLDate($fmt, $col=false)
644
+	function SQLDate($fmt, $col = false)
645 645
 	{	
646 646
 		if (!$col) $col = $this->sysDate;
647 647
 		$s = '';
648 648
 		
649 649
 		$len = strlen($fmt);
650
-		for ($i=0; $i < $len; $i++) {
650
+		for ($i = 0; $i < $len; $i++) {
651 651
 			if ($s) $s .= '||';
652 652
 			$ch = $fmt[$i];
653
-			switch($ch) {
653
+			switch ($ch) {
654 654
 			case 'Y':
655 655
 			case 'y':
656 656
 				$s .= "extract(year from $col)";
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
 			default:
684 684
 				if ($ch == '\\') {
685 685
 					$i++;
686
-					$ch = substr($fmt,$i,1);
686
+					$ch = substr($fmt, $i, 1);
687 687
 				}
688 688
 				$s .= $this->qstr($ch);
689 689
 				break;
@@ -701,10 +701,10 @@  discard block
 block discarded – undo
701 701
 {
702 702
 
703 703
 	var $databaseType = "ibase";
704
-	var $bind=false;
704
+	var $bind = false;
705 705
 	var $_cacheType;
706 706
 	
707
-	function ADORecordset_ibase($id,$mode=false)
707
+	function ADORecordset_ibase($id, $mode = false)
708 708
 	{
709 709
 	global $ADODB_FETCH_MODE;
710 710
 	
@@ -720,7 +720,7 @@  discard block
 block discarded – undo
720 720
 	function &FetchField($fieldOffset = -1)
721 721
 	{
722 722
 			 $fld = new ADOFieldObject;
723
-			 $ibf = ibase_field_info($this->_queryID,$fieldOffset);
723
+			 $ibf = ibase_field_info($this->_queryID, $fieldOffset);
724 724
 			 switch (ADODB_ASSOC_CASE) {
725 725
 			 case 2: // the default
726 726
 			 	$fld->name = ($ibf['alias']);
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
 		$this->_numOfFields = @ibase_num_fields($this->_queryID);
753 753
 
754 754
 		// cache types for blob decode check
755
-		for ($i=0, $max = $this->_numOfFields; $i < $max; $i++) { 
755
+		for ($i = 0, $max = $this->_numOfFields; $i < $max; $i++) { 
756 756
 			$f1 = $this->FetchField($i); 
757 757
 			$this->_cacheType[] = $f1->type;
758 758
 		}				
@@ -777,8 +777,8 @@  discard block
 block discarded – undo
777 777
 		//$ADODB_ANSI_PADDING_OFF=1;
778 778
 		$rtrim = !empty($ADODB_ANSI_PADDING_OFF);
779 779
 		
780
-		for ($i=0, $max = $this->_numOfFields; $i < $max; $i++) { 
781
-			if ($this->_cacheType[$i]=="BLOB") {
780
+		for ($i = 0, $max = $this->_numOfFields; $i < $max; $i++) { 
781
+			if ($this->_cacheType[$i] == "BLOB") {
782 782
 				if (isset($f[$i])) { 
783 783
 					$f[$i] = $this->connection->_BlobDecode($f[$i]); 
784 784
 				} else { 
@@ -798,7 +798,7 @@  discard block
 block discarded – undo
798 798
 		if ($this->fetchMode == ADODB_FETCH_ASSOC) {
799 799
 			$this->fields = &$this->GetRowAssoc(ADODB_ASSOC_CASE);
800 800
 		} else if ($this->fetchMode == ADODB_FETCH_BOTH) {
801
-			$this->fields =& array_merge($this->fields,$this->GetRowAssoc(ADODB_ASSOC_CASE));
801
+			$this->fields = & array_merge($this->fields, $this->GetRowAssoc(ADODB_ASSOC_CASE));
802 802
 		}
803 803
 		return true;
804 804
 	}
@@ -806,10 +806,10 @@  discard block
 block discarded – undo
806 806
 	/* Use associative array to get fields array */
807 807
 	function Fields($colname)
808 808
 	{
809
-		if ($this->fetchMode & ADODB_FETCH_ASSOC) return $this->fields[$colname];
809
+		if ($this->fetchMode&ADODB_FETCH_ASSOC) return $this->fields[$colname];
810 810
 		if (!$this->bind) {
811 811
 			$this->bind = array();
812
-			for ($i=0; $i < $this->_numOfFields; $i++) {
812
+			for ($i = 0; $i < $this->_numOfFields; $i++) {
813 813
 				$o = $this->FetchField($i);
814 814
 				$this->bind[strtoupper($o->name)] = $i;
815 815
 			}
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
 			return @ibase_free_result($this->_queryID);
826 826
 	}
827 827
 
828
-	function MetaType($t,$len=-1,$fieldobj=false)
828
+	function MetaType($t, $len = -1, $fieldobj = false)
829 829
 	{
830 830
 		if (is_object($t)) {
831 831
 			$fieldobj = $t;
Please login to merge, or discard this patch.
Braces   +355 added lines, -138 removed lines patch added patch discarded remove patch
@@ -24,9 +24,13 @@  discard block
 block discarded – undo
24 24
 */
25 25
 
26 26
 // security - hide paths
27
-if (!defined('ADODB_DIR')) die();
27
+if (!defined('ADODB_DIR'))
28
+{
29
+	die();
30
+}
28 31
 
29
-class ADODB_ibase extends ADOConnection {
32
+class ADODB_ibase extends ADOConnection
33
+{
30 34
 	var $databaseType = "ibase";
31 35
 	var $dataProvider = "ibase";
32 36
 	var $replaceQuote = "''"; // string to use to replace quotes
@@ -54,41 +58,64 @@  discard block
 block discarded – undo
54 58
 	var $blobEncodeType = 'C';
55 59
 	var $role = false;
56 60
 	
57
-	function ADODB_ibase() 
61
+	function ADODB_ibase()
58 62
 	{
59
-		 if (defined('IBASE_DEFAULT')) $this->ibasetrans = IBASE_DEFAULT;
63
+		 if (defined('IBASE_DEFAULT'))
64
+		 {
65
+		 	$this->ibasetrans = IBASE_DEFAULT;
66
+		 }
60 67
   	}
61 68
 	
62 69
 	
63 70
 	   // returns true or false
64 71
 	function _connect($argHostname, $argUsername, $argPassword, $argDatabasename,$persist=false)
65
-	{  
66
-		if (!function_exists('ibase_pconnect')) return null;
67
-		if ($argDatabasename) $argHostname .= ':'.$argDatabasename;
72
+	{
73
+		if (!function_exists('ibase_pconnect'))
74
+		{
75
+			return null;
76
+		}
77
+		if ($argDatabasename)
78
+		{
79
+			$argHostname .= ':'.$argDatabasename;
80
+		}
68 81
 		$fn = ($persist) ? 'ibase_pconnect':'ibase_connect';
69 82
 		if ($this->role)
70
-			$this->_connectionID = $fn($argHostname,$argUsername,$argPassword,
83
+		{
84
+					$this->_connectionID = $fn($argHostname,$argUsername,$argPassword,
71 85
 					$this->charSet,$this->buffers,$this->dialect,$this->role);
72
-		else	
73
-			$this->_connectionID = $fn($argHostname,$argUsername,$argPassword,
86
+		}
87
+		else {
88
+					$this->_connectionID = $fn($argHostname,$argUsername,$argPassword,
74 89
 					$this->charSet,$this->buffers,$this->dialect);
90
+		}
75 91
 		
76
-		if ($this->dialect != 1) { // http://www.ibphoenix.com/ibp_60_del_id_ds.html
92
+		if ($this->dialect != 1)
93
+		{
94
+// http://www.ibphoenix.com/ibp_60_del_id_ds.html
77 95
 			$this->replaceQuote = "''";
78 96
 		}
79
-		if ($this->_connectionID === false) {
97
+		if ($this->_connectionID === false)
98
+		{
80 99
 			$this->_handleerror();
81 100
 			return false;
82 101
 		}
83 102
 		
84 103
 		// PHP5 change.
85
-		if (function_exists('ibase_timefmt')) {
104
+		if (function_exists('ibase_timefmt'))
105
+		{
86 106
 			ibase_timefmt($this->ibase_datefmt,IBASE_DATE );
87
-			if ($this->dialect == 1) ibase_timefmt($this->ibase_datefmt,IBASE_TIMESTAMP );
88
-			else ibase_timefmt($this->ibase_timestampfmt,IBASE_TIMESTAMP );
107
+			if ($this->dialect == 1)
108
+			{
109
+				ibase_timefmt($this->ibase_datefmt,IBASE_TIMESTAMP );
110
+			}
111
+			else {
112
+				ibase_timefmt($this->ibase_timestampfmt,IBASE_TIMESTAMP );
113
+			}
89 114
 			ibase_timefmt($this->ibase_timefmt,IBASE_TIME );
90 115
 			
91
-		} else {
116
+		}
117
+		else
118
+		{
92 119
 			ini_set("ibase.timestampformat", $this->ibase_timestampfmt);
93 120
 			ini_set("ibase.dateformat", $this->ibase_datefmt);
94 121
 			ini_set("ibase.timeformat", $this->ibase_timefmt);
@@ -103,8 +130,11 @@  discard block
 block discarded – undo
103 130
 	
104 131
 	
105 132
 	function MetaPrimaryKeys($table,$owner_notused=false,$internalKey=false)
106
-	{	
107
-		if ($internalKey) return array('RDB$DB_KEY');
133
+	{
134
+		if ($internalKey)
135
+		{
136
+			return array('RDB$DB_KEY');
137
+		}
108 138
 		
109 139
 		$table = strtoupper($table);
110 140
 		
@@ -114,14 +144,18 @@  discard block
 block discarded – undo
114 144
 	ORDER BY I.RDB$INDEX_NAME,S.RDB$FIELD_POSITION';
115 145
 
116 146
 		$a = $this->GetCol($sql,false,true);
117
-		if ($a && sizeof($a)>0) return $a;
147
+		if ($a && sizeof($a)>0)
148
+		{
149
+			return $a;
150
+		}
118 151
 		return false;	  
119 152
 	}
120 153
 	
121 154
 	function ServerInfo()
122 155
 	{
123 156
 		$arr['dialect'] = $this->dialect;
124
-		switch($arr['dialect']) {
157
+		switch($arr['dialect'])
158
+		{
125 159
 		case '': 
126 160
 		case '1': $s = 'Interbase 5.5 or earlier'; break;
127 161
 		case '2': $s = 'Interbase 5.6'; break;
@@ -134,22 +168,35 @@  discard block
 block discarded – undo
134 168
 	}
135 169
 
136 170
 	function BeginTrans()
137
-	{	 
138
-		if ($this->transOff) return true;
171
+	{
172
+		if ($this->transOff)
173
+		{
174
+			return true;
175
+		}
139 176
 		$this->transCnt += 1;
140 177
 		$this->autoCommit = false;
141 178
 	 	$this->_transactionID = $this->_connectionID;//ibase_trans($this->ibasetrans, $this->_connectionID);
142 179
 		return $this->_transactionID;
143 180
 	}
144 181
 	
145
-	function CommitTrans($ok=true) 
146
-	{ 
147
-		if (!$ok) return $this->RollbackTrans();
148
-		if ($this->transOff) return true;
149
-		if ($this->transCnt) $this->transCnt -= 1;
182
+	function CommitTrans($ok=true)
183
+	{
184
+		if (!$ok)
185
+		{
186
+			return $this->RollbackTrans();
187
+		}
188
+		if ($this->transOff)
189
+		{
190
+			return true;
191
+		}
192
+		if ($this->transCnt)
193
+		{
194
+			$this->transCnt -= 1;
195
+		}
150 196
 		$ret = false;
151 197
 		$this->autoCommit = true;
152
-		if ($this->_transactionID) {
198
+		if ($this->_transactionID)
199
+		{
153 200
 			   		//print ' commit ';
154 201
 			$ret = ibase_commit($this->_transactionID);
155 202
 		}
@@ -163,12 +210,15 @@  discard block
 block discarded – undo
163 210
 	{
164 211
 	global $ADODB_COUNTRECS;
165 212
 	
166
-		if ($this->_logsql) {
213
+		if ($this->_logsql)
214
+		{
167 215
 			$savecrecs = $ADODB_COUNTRECS;
168 216
 			$ADODB_COUNTRECS = true; // force countrecs
169 217
 			$ret =& ADOConnection::_Execute($sql,$inputarr);
170 218
 			$ADODB_COUNTRECS = $savecrecs;
171
-		} else {
219
+		}
220
+		else
221
+		{
172 222
 			$ret =& ADOConnection::_Execute($sql,$inputarr);
173 223
 		}
174 224
 		return $ret;
@@ -176,12 +226,20 @@  discard block
 block discarded – undo
176 226
 	
177 227
 	function RollbackTrans()
178 228
 	{
179
-		if ($this->transOff) return true;
180
-		if ($this->transCnt) $this->transCnt -= 1;
229
+		if ($this->transOff)
230
+		{
231
+			return true;
232
+		}
233
+		if ($this->transCnt)
234
+		{
235
+			$this->transCnt -= 1;
236
+		}
181 237
 		$ret = false;
182 238
 		$this->autoCommit = true;
183
-		if ($this->_transactionID) 
184
-				  $ret = ibase_rollback($this->_transactionID);
239
+		if ($this->_transactionID)
240
+		{
241
+						  $ret = ibase_rollback($this->_transactionID);
242
+		}
185 243
 		$this->_transactionID = false;   
186 244
 		
187 245
 		return $ret;
@@ -194,21 +252,27 @@  discard block
 block discarded – undo
194 252
         $false = false;
195 253
         $save = $ADODB_FETCH_MODE;
196 254
         $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
197
-        if ($this->fetchMode !== FALSE) {
255
+        if ($this->fetchMode !== FALSE)
256
+        {
198 257
                $savem = $this->SetFetchMode(FALSE);
199 258
         }
200 259
         $table = strtoupper($table);
201 260
         $sql = "SELECT * FROM RDB\$INDICES WHERE RDB\$RELATION_NAME = '".$table."'";
202
-        if (!$primary) {
261
+        if (!$primary)
262
+        {
203 263
         	$sql .= " AND RDB\$INDEX_NAME NOT LIKE 'RDB\$%'";
204
-        } else {
264
+        }
265
+        else
266
+        {
205 267
         	$sql .= " AND RDB\$INDEX_NAME NOT LIKE 'RDB\$FOREIGN%'";
206 268
         }
207 269
         // get index details
208 270
         $rs = $this->Execute($sql);
209
-        if (!is_object($rs)) {
271
+        if (!is_object($rs))
272
+        {
210 273
 	        // restore fetchmode
211
-	        if (isset($savem)) {
274
+	        if (isset($savem))
275
+	        {
212 276
 	            $this->SetFetchMode($savem);
213 277
 	        }
214 278
 	        $ADODB_FETCH_MODE = $save;
@@ -216,10 +280,14 @@  discard block
 block discarded – undo
216 280
         }
217 281
         
218 282
         $indexes = array ();
219
-		while ($row = $rs->FetchRow()) {
283
+		while ($row = $rs->FetchRow())
284
+		{
220 285
 			$index = $row[0];
221
-             if (!isset($indexes[$index])) {
222
-             		if (is_null($row[3])) {$row[3] = 0;}
286
+             if (!isset($indexes[$index]))
287
+             {
288
+             		if (is_null($row[3]))
289
+             		{
290
+$row[3] = 0;}
223 291
                      $indexes[$index] = array(
224 292
                              'unique' => ($row[3] == 1),
225 293
                              'columns' => array()
@@ -227,12 +295,14 @@  discard block
 block discarded – undo
227 295
              }
228 296
 			$sql = "SELECT * FROM RDB\$INDEX_SEGMENTS WHERE RDB\$INDEX_NAME = '".$name."' ORDER BY RDB\$FIELD_POSITION ASC";
229 297
 			$rs1 = $this->Execute($sql);
230
-            while ($row1 = $rs1->FetchRow()) {
298
+            while ($row1 = $rs1->FetchRow())
299
+            {
231 300
              	$indexes[$index]['columns'][$row1[2]] = $row1[1];
232 301
         	}
233 302
 		}
234 303
         // restore fetchmode
235
-        if (isset($savem)) {
304
+        if (isset($savem))
305
+        {
236 306
             $this->SetFetchMode($savem);
237 307
         }
238 308
         $ADODB_FETCH_MODE = $save;
@@ -244,7 +314,10 @@  discard block
 block discarded – undo
244 314
 	// See http://community.borland.com/article/0,1410,25844,00.html
245 315
 	function RowLock($tables,$where,$col)
246 316
 	{
247
-		if ($this->autoCommit) $this->BeginTrans();
317
+		if ($this->autoCommit)
318
+		{
319
+			$this->BeginTrans();
320
+		}
248 321
 		$this->Execute("UPDATE $table SET $col=$col WHERE $where "); // is this correct - jlim?
249 322
 		return 1;
250 323
 	}
@@ -253,7 +326,10 @@  discard block
 block discarded – undo
253 326
 	function CreateSequence($seqname,$startID=1)
254 327
 	{
255 328
 		$ok = $this->Execute(("INSERT INTO RDB\$GENERATORS (RDB\$GENERATOR_NAME) VALUES (UPPER('$seqname'))" ));
256
-		if (!$ok) return false;
329
+		if (!$ok)
330
+		{
331
+			return false;
332
+		}
257 333
 		return $this->Execute("SET GENERATOR $seqname TO ".($startID-1).';');
258 334
 	}
259 335
 	
@@ -267,20 +343,30 @@  discard block
 block discarded – undo
267 343
 	{
268 344
 		$getnext = ("SELECT Gen_ID($seqname,1) FROM RDB\$DATABASE");
269 345
 		$rs = @$this->Execute($getnext);
270
-		if (!$rs) {
346
+		if (!$rs)
347
+		{
271 348
 			$this->Execute(("INSERT INTO RDB\$GENERATORS (RDB\$GENERATOR_NAME) VALUES (UPPER('$seqname'))" ));
272 349
 			$this->Execute("SET GENERATOR $seqname TO ".($startID-1).';');
273 350
 			$rs = $this->Execute($getnext);
274 351
 		}
275
-		if ($rs && !$rs->EOF) $this->genID = (integer) reset($rs->fields);
276
-		else $this->genID = 0; // false
352
+		if ($rs && !$rs->EOF)
353
+		{
354
+			$this->genID = (integer) reset($rs->fields);
355
+		}
356
+		else {
357
+			$this->genID = 0;
358
+		}
359
+		// false
277 360
 		
278
-		if ($rs) $rs->Close();
361
+		if ($rs)
362
+		{
363
+			$rs->Close();
364
+		}
279 365
 		
280 366
 		return $this->genID;
281 367
 	}
282 368
 
283
-	function SelectDB($dbName) 
369
+	function SelectDB($dbName)
284 370
 	{
285 371
 		   return false;
286 372
 	}
@@ -290,13 +376,18 @@  discard block
 block discarded – undo
290 376
 		$this->_errorMsg = ibase_errmsg();
291 377
 	}
292 378
 
293
-	function ErrorNo() 
379
+	function ErrorNo()
294 380
 	{
295
-		if (preg_match('/error code = ([\-0-9]*)/i', $this->_errorMsg,$arr)) return (integer) $arr[1];
296
-		else return 0;
381
+		if (preg_match('/error code = ([\-0-9]*)/i', $this->_errorMsg,$arr))
382
+		{
383
+			return (integer) $arr[1];
384
+		}
385
+		else {
386
+			return 0;
387
+		}
297 388
 	}
298 389
 
299
-	function ErrorMsg() 
390
+	function ErrorMsg()
300 391
 	{
301 392
 			return $this->_errorMsg;
302 393
 	}
@@ -304,32 +395,49 @@  discard block
 block discarded – undo
304 395
 	function Prepare($sql)
305 396
 	{
306 397
 		$stmt = ibase_prepare($this->_connectionID,$sql);
307
-		if (!$stmt) return false;
398
+		if (!$stmt)
399
+		{
400
+			return false;
401
+		}
308 402
 		return array($sql,$stmt);
309 403
 	}
310 404
 
311 405
 	   // returns query ID if successful, otherwise false
312 406
 	   // there have been reports of problems with nested queries - the code is probably not re-entrant?
313 407
 	function _query($sql,$iarr=false)
314
-	{ 
408
+	{
315 409
 
316
-		if (!$this->autoCommit && $this->_transactionID) {
410
+		if (!$this->autoCommit && $this->_transactionID)
411
+		{
317 412
 			$conn = $this->_transactionID;
318 413
 			$docommit = false;
319
-		} else {
414
+		}
415
+		else
416
+		{
320 417
 			$conn = $this->_connectionID;
321 418
 			$docommit = true;
322 419
 		}
323
-		if (is_array($sql)) {
420
+		if (is_array($sql))
421
+		{
324 422
 			$fn = 'ibase_execute';
325 423
 			$sql = $sql[1];
326
-			if (is_array($iarr)) {
327
-				if  (ADODB_PHPVER >= 0x4050) { // actually 4.0.4
328
-					if ( !isset($iarr[0]) ) $iarr[0] = ''; // PHP5 compat hack
424
+			if (is_array($iarr))
425
+			{
426
+				if  (ADODB_PHPVER >= 0x4050)
427
+				{
428
+// actually 4.0.4
429
+					if ( !isset($iarr[0]) )
430
+					{
431
+						$iarr[0] = '';
432
+					}
433
+					// PHP5 compat hack
329 434
 					$fnarr =& array_merge( array($sql) , $iarr);
330 435
 					$ret = call_user_func_array($fn,$fnarr);
331
-				} else {
332
-					switch(sizeof($iarr)) {
436
+				}
437
+				else
438
+				{
439
+					switch(sizeof($iarr))
440
+					{
333 441
 					case 1: $ret = $fn($sql,$iarr[0]); break;
334 442
 					case 2: $ret = $fn($sql,$iarr[0],$iarr[1]); break;
335 443
 					case 3: $ret = $fn($sql,$iarr[0],$iarr[1],$iarr[2]); break;
@@ -341,17 +449,32 @@  discard block
 block discarded – undo
341 449
 					case 8: $ret = $fn($sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5],$iarr[6],$iarr[7]); break;
342 450
 					}
343 451
 				}
344
-			} else $ret = $fn($sql); 
345
-		} else {
452
+			}
453
+			else {
454
+				$ret = $fn($sql);
455
+			}
456
+		}
457
+		else
458
+		{
346 459
 			$fn = 'ibase_query';
347 460
 		
348
-			if (is_array($iarr)) {	
349
-				if (ADODB_PHPVER >= 0x4050) { // actually 4.0.4
350
-					if (sizeof($iarr) == 0) $iarr[0] = ''; // PHP5 compat hack
461
+			if (is_array($iarr))
462
+			{
463
+				if (ADODB_PHPVER >= 0x4050)
464
+				{
465
+// actually 4.0.4
466
+					if (sizeof($iarr) == 0)
467
+					{
468
+						$iarr[0] = '';
469
+					}
470
+					// PHP5 compat hack
351 471
 					$fnarr =& array_merge( array($conn,$sql) , $iarr);
352 472
 					$ret = call_user_func_array($fn,$fnarr);
353
-				} else {
354
-					switch(sizeof($iarr)) {
473
+				}
474
+				else
475
+				{
476
+					switch(sizeof($iarr))
477
+					{
355 478
 					case 1: $ret = $fn($conn,$sql,$iarr[0]); break;
356 479
 					case 2: $ret = $fn($conn,$sql,$iarr[0],$iarr[1]); break;
357 480
 					case 3: $ret = $fn($conn,$sql,$iarr[0],$iarr[1],$iarr[2]); break;
@@ -363,9 +486,15 @@  discard block
 block discarded – undo
363 486
 					case 8: $ret = $fn($conn,$sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5],$iarr[6],$iarr[7]); break;
364 487
 					}
365 488
 				}
366
-			} else $ret = $fn($conn,$sql); 
489
+			}
490
+			else {
491
+				$ret = $fn($conn,$sql);
492
+			}
493
+		}
494
+		if ($docommit && $ret === true)
495
+		{
496
+			ibase_commit($this->_connectionID);
367 497
 		}
368
-		if ($docommit && $ret === true) ibase_commit($this->_connectionID);
369 498
 
370 499
 		$this->_handleerror();
371 500
 		return $ret;
@@ -373,8 +502,11 @@  discard block
 block discarded – undo
373 502
 
374 503
 	 // returns true or false
375 504
 	 function _close()
376
-	 {	   
377
-		if (!$this->autoCommit) @ibase_rollback($this->_connectionID);
505
+	 {
506
+		if (!$this->autoCommit)
507
+		{
508
+			@ibase_rollback($this->_connectionID);
509
+		}
378 510
 		return @ibase_close($this->_connectionID);
379 511
 	 }
380 512
 	
@@ -384,11 +516,14 @@  discard block
 block discarded – undo
384 516
 		$fscale = abs($fscale);
385 517
 		$fld->max_length = $flen;
386 518
 		$fld->scale = null;
387
-		switch($ftype){
519
+		switch($ftype)
520
+		{
388 521
 			case 7: 
389 522
 			case 8:
390
-				if ($dialect3) {
391
-				    switch($fsubtype){
523
+				if ($dialect3)
524
+				{
525
+				    switch($fsubtype)
526
+				    {
392 527
 				    	case 0: 
393 528
 				    		$fld->type = ($ftype == 7 ? 'smallint' : 'integer');
394 529
 				    		break;
@@ -403,19 +538,26 @@  discard block
 block discarded – undo
403 538
 							$fld->scale = $fscale;
404 539
 				    		break;
405 540
 				    } // switch
406
-				} else {
407
-					if ($fscale !=0) {
541
+				}
542
+				else
543
+				{
544
+					if ($fscale !=0)
545
+					{
408 546
 					    $fld->type = 'decimal';
409 547
 						$fld->scale = $fscale;
410 548
 						$fld->max_length = ($ftype == 7 ? 4 : 9);
411
-					} else {
549
+					}
550
+					else
551
+					{
412 552
 						$fld->type = ($ftype == 7 ? 'smallint' : 'integer');
413 553
 					}
414 554
 				}
415 555
 				break;
416 556
 			case 16: 
417
-				if ($dialect3) {
418
-				    switch($fsubtype){
557
+				if ($dialect3)
558
+				{
559
+				    switch($fsubtype)
560
+				    {
419 561
 				    	case 0: 
420 562
 				    		$fld->type = 'decimal';
421 563
 							$fld->max_length = 18;
@@ -441,18 +583,24 @@  discard block
 block discarded – undo
441 583
 				$fld->type = 'char';
442 584
 				break;
443 585
 			case 27:
444
-				if ($fscale !=0) {
586
+				if ($fscale !=0)
587
+				{
445 588
 				    $fld->type = 'decimal';
446 589
 					$fld->max_length = 15;
447 590
 					$fld->scale = 5;
448
-				} else {
591
+				}
592
+				else
593
+				{
449 594
 					$fld->type = 'double';
450 595
 				}
451 596
 				break;
452 597
 			case 35:
453
-				if ($dialect3) {
598
+				if ($dialect3)
599
+				{
454 600
 				    $fld->type = 'timestamp';
455
-				} else {
601
+				}
602
+				else
603
+				{
456 604
 					$fld->type = 'date';
457 605
 				}
458 606
 				break;
@@ -487,7 +635,8 @@  discard block
 block discarded – undo
487 635
 	
488 636
 		$ADODB_FETCH_MODE = $save;
489 637
 		$false = false;
490
-		if ($rs === false) {
638
+		if ($rs === false)
639
+		{
491 640
 			return $false;
492 641
 		}
493 642
 		
@@ -495,15 +644,19 @@  discard block
 block discarded – undo
495 644
 		//OPN STUFF start
496 645
 		$dialect3 = ($this->dialect==3 ? true : false);
497 646
 		//OPN STUFF end
498
-		while (!$rs->EOF) { //print_r($rs->fields);
647
+		while (!$rs->EOF)
648
+		{
649
+//print_r($rs->fields);
499 650
 			$fld = new ADOFieldObject();
500 651
 			$fld->name = trim($rs->fields[0]);
501 652
 			//OPN STUFF start
502 653
 			$this->_ConvertFieldType($fld, $rs->fields[7], $rs->fields[3], $rs->fields[4], $rs->fields[5], $rs->fields[6], $dialect3);
503
-			if (isset($rs->fields[1]) && $rs->fields[1]) {
654
+			if (isset($rs->fields[1]) && $rs->fields[1])
655
+			{
504 656
 				$fld->not_null = true;
505 657
 			}				
506
-			if (isset($rs->fields[2])) {
658
+			if (isset($rs->fields[2]))
659
+			{
507 660
 				
508 661
 				$fld->has_default = true;
509 662
 				$d = substr($rs->fields[2],strlen('default '));
@@ -521,23 +674,36 @@  discard block
 block discarded – undo
521 674
 				}
522 675
 		//	case 35:$tt = 'TIMESTAMP'; break;
523 676
 			}
524
-			if ((isset($rs->fields[5])) && ($fld->type == 'blob')) {
677
+			if ((isset($rs->fields[5])) && ($fld->type == 'blob'))
678
+			{
525 679
 				$fld->sub_type = $rs->fields[5];
526
-			} else {
680
+			}
681
+			else
682
+			{
527 683
 				$fld->sub_type = null;
528 684
 			}
529 685
 			//OPN STUFF end
530
-			if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld;	
531
-			else $retarr[strtoupper($fld->name)] = $fld;
686
+			if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM)
687
+			{
688
+				$retarr[] = $fld;
689
+			}
690
+			else {
691
+				$retarr[strtoupper($fld->name)] = $fld;
692
+			}
532 693
 			
533 694
 			$rs->MoveNext();
534 695
 		}
535 696
 		$rs->Close();
536
-		if ( empty($retarr)) return $false;
537
-		else return $retarr;	
697
+		if ( empty($retarr))
698
+		{
699
+			return $false;
700
+		}
701
+		else {
702
+			return $retarr;
703
+		}
538 704
 	}
539 705
 	
540
-	function BlobEncode( $blob ) 
706
+	function BlobEncode( $blob )
541 707
 	{
542 708
 		$blobid = ibase_blob_create( $this->_connectionID);
543 709
 		ibase_blob_add( $blobid, $blob );
@@ -556,11 +722,12 @@  discard block
 block discarded – undo
556 722
 	
557 723
 	// old blobdecode function
558 724
 	// still used to auto-decode all blob's
559
-	function _BlobDecode( $blob ) 
725
+	function _BlobDecode( $blob )
560 726
 	{
561 727
 		$blobid = ibase_blob_open( $blob );
562 728
 		$realblob = ibase_blob_get( $blobid,$this->maxblobsize); // 2nd param is max size of blob -- Kevin Boillet <[email protected]>
563
-		while($string = ibase_blob_get($blobid, 8192)){ 
729
+		while($string = ibase_blob_get($blobid, 8192))
730
+		{
564 731
 			$realblob .= $string; 
565 732
 		}
566 733
 		ibase_blob_close( $blobid );
@@ -568,15 +735,19 @@  discard block
 block discarded – undo
568 735
 		return( $realblob );
569 736
 	} 
570 737
 	
571
-	function UpdateBlobFile($table,$column,$path,$where,$blobtype='BLOB') 
572
-	{ 
738
+	function UpdateBlobFile($table,$column,$path,$where,$blobtype='BLOB')
739
+	{
573 740
 		$fd = fopen($path,'rb'); 
574
-		if ($fd === false) return false; 
741
+		if ($fd === false)
742
+		{
743
+			return false;
744
+		}
575 745
 		$blob_id = ibase_blob_create($this->_connectionID); 
576 746
 		
577 747
 		/* fill with data */ 
578 748
 		
579
-		while ($val = fread($fd,32768)){ 
749
+		while ($val = fread($fd,32768))
750
+		{
580 751
 			ibase_blob_add($blob_id, $val); 
581 752
 		} 
582 753
 		
@@ -596,8 +767,8 @@  discard block
 block discarded – undo
596 767
 		$conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)');
597 768
 		$conn->UpdateBlob('blobtable','blobcol',$blob,'id=1');
598 769
 	*/
599
-	function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB') 
600
-	{ 
770
+	function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB')
771
+	{
601 772
 	$blob_id = ibase_blob_create($this->_connectionID); 
602 773
 	
603 774
 	// ibase_blob_add($blob_id, $val); 
@@ -610,13 +781,15 @@  discard block
 block discarded – undo
610 781
 	$tail_size = $len % $chunk_size; 
611 782
 	$n_chunks = ($len - $tail_size) / $chunk_size; 
612 783
 	
613
-	for ($n = 0; $n < $n_chunks; $n++) { 
784
+	for ($n = 0; $n < $n_chunks; $n++)
785
+	{
614 786
 		$start = $n * $chunk_size; 
615 787
 		$data = substr($val, $start, $chunk_size); 
616 788
 		ibase_blob_add($blob_id, $data); 
617 789
 	} 
618 790
 	
619
-	if ($tail_size) {
791
+	if ($tail_size)
792
+	{
620 793
 		$start = $n_chunks * $chunk_size; 
621 794
 		$data = substr($val, $start, $tail_size); 
622 795
 		ibase_blob_add($blob_id, $data); 
@@ -642,15 +815,23 @@  discard block
 block discarded – undo
642 815
 	// Only since Interbase 6.0 - uses EXTRACT
643 816
 	// problem - does not zero-fill the day and month yet
644 817
 	function SQLDate($fmt, $col=false)
645
-	{	
646
-		if (!$col) $col = $this->sysDate;
818
+	{
819
+		if (!$col)
820
+		{
821
+			$col = $this->sysDate;
822
+		}
647 823
 		$s = '';
648 824
 		
649 825
 		$len = strlen($fmt);
650
-		for ($i=0; $i < $len; $i++) {
651
-			if ($s) $s .= '||';
826
+		for ($i=0; $i < $len; $i++)
827
+		{
828
+			if ($s)
829
+			{
830
+				$s .= '||';
831
+			}
652 832
 			$ch = $fmt[$i];
653
-			switch($ch) {
833
+			switch($ch)
834
+			{
654 835
 			case 'Y':
655 836
 			case 'y':
656 837
 				$s .= "extract(year from $col)";
@@ -681,7 +862,8 @@  discard block
 block discarded – undo
681 862
 			  break;        
682 863
 
683 864
 			default:
684
-				if ($ch == '\\') {
865
+				if ($ch == '\\')
866
+				{
685 867
 					$i++;
686 868
 					$ch = substr($fmt,$i,1);
687 869
 				}
@@ -721,18 +903,28 @@  discard block
 block discarded – undo
721 903
 	{
722 904
 			 $fld = new ADOFieldObject;
723 905
 			 $ibf = ibase_field_info($this->_queryID,$fieldOffset);
724
-			 switch (ADODB_ASSOC_CASE) {
906
+			 switch (ADODB_ASSOC_CASE)
907
+			 {
725 908
 			 case 2: // the default
726 909
 			 	$fld->name = ($ibf['alias']);
727
-				 if (empty($fld->name)) $fld->name = ($ibf['name']);
910
+				 if (empty($fld->name))
911
+				 {
912
+				 	$fld->name = ($ibf['name']);
913
+				 }
728 914
 				 break;
729 915
 			 case 0: 
730 916
 				 $fld->name = strtoupper($ibf['alias']);
731
-				 if (empty($fld->name)) $fld->name = strtoupper($ibf['name']);
917
+				 if (empty($fld->name))
918
+				 {
919
+				 	$fld->name = strtoupper($ibf['name']);
920
+				 }
732 921
 				 break;
733 922
 			 case 1: 
734 923
 			 	$fld->name = strtolower($ibf['alias']);
735
-				 if (empty($fld->name)) $fld->name = strtolower($ibf['name']);
924
+				 if (empty($fld->name))
925
+				 {
926
+				 	$fld->name = strtolower($ibf['name']);
927
+				 }
736 928
 				 break;
737 929
 			 }
738 930
 			 
@@ -752,7 +944,8 @@  discard block
 block discarded – undo
752 944
 		$this->_numOfFields = @ibase_num_fields($this->_queryID);
753 945
 
754 946
 		// cache types for blob decode check
755
-		for ($i=0, $max = $this->_numOfFields; $i < $max; $i++) { 
947
+		for ($i=0, $max = $this->_numOfFields; $i < $max; $i++)
948
+		{
756 949
 			$f1 = $this->FetchField($i); 
757 950
 			$this->_cacheType[] = $f1->type;
758 951
 		}				
@@ -763,10 +956,11 @@  discard block
 block discarded – undo
763 956
 		return false;
764 957
 	}
765 958
 	
766
-	function _fetch() 
959
+	function _fetch()
767 960
 	{
768 961
 		$f = @ibase_fetch_row($this->_queryID); 
769
-		if ($f === false) {
962
+		if ($f === false)
963
+		{
770 964
 			$this->fields = false;
771 965
 			return false;
772 966
 		}
@@ -777,17 +971,27 @@  discard block
 block discarded – undo
777 971
 		//$ADODB_ANSI_PADDING_OFF=1;
778 972
 		$rtrim = !empty($ADODB_ANSI_PADDING_OFF);
779 973
 		
780
-		for ($i=0, $max = $this->_numOfFields; $i < $max; $i++) { 
781
-			if ($this->_cacheType[$i]=="BLOB") {
782
-				if (isset($f[$i])) { 
974
+		for ($i=0, $max = $this->_numOfFields; $i < $max; $i++)
975
+		{
976
+			if ($this->_cacheType[$i]=="BLOB")
977
+			{
978
+				if (isset($f[$i]))
979
+				{
783 980
 					$f[$i] = $this->connection->_BlobDecode($f[$i]); 
784
-				} else { 
981
+				}
982
+				else
983
+				{
785 984
 					$f[$i] = null; 
786 985
 				} 
787
-			} else { 
788
-				if (!isset($f[$i])) { 
986
+			}
987
+			else
988
+			{
989
+				if (!isset($f[$i]))
990
+				{
789 991
 					$f[$i] = null; 
790
-				} else if ($rtrim && is_string($f[$i])) {
992
+				}
993
+				else if ($rtrim && is_string($f[$i]))
994
+				{
791 995
 					$f[$i] = rtrim($f[$i]);
792 996
 				}
793 997
 			} 
@@ -795,9 +999,12 @@  discard block
 block discarded – undo
795 999
 		// OPN stuff end 
796 1000
 		
797 1001
 		$this->fields = $f;
798
-		if ($this->fetchMode == ADODB_FETCH_ASSOC) {
1002
+		if ($this->fetchMode == ADODB_FETCH_ASSOC)
1003
+		{
799 1004
 			$this->fields = &$this->GetRowAssoc(ADODB_ASSOC_CASE);
800
-		} else if ($this->fetchMode == ADODB_FETCH_BOTH) {
1005
+		}
1006
+		else if ($this->fetchMode == ADODB_FETCH_BOTH)
1007
+		{
801 1008
 			$this->fields =& array_merge($this->fields,$this->GetRowAssoc(ADODB_ASSOC_CASE));
802 1009
 		}
803 1010
 		return true;
@@ -806,10 +1013,15 @@  discard block
 block discarded – undo
806 1013
 	/* Use associative array to get fields array */
807 1014
 	function Fields($colname)
808 1015
 	{
809
-		if ($this->fetchMode & ADODB_FETCH_ASSOC) return $this->fields[$colname];
810
-		if (!$this->bind) {
1016
+		if ($this->fetchMode & ADODB_FETCH_ASSOC)
1017
+		{
1018
+			return $this->fields[$colname];
1019
+		}
1020
+		if (!$this->bind)
1021
+		{
811 1022
 			$this->bind = array();
812
-			for ($i=0; $i < $this->_numOfFields; $i++) {
1023
+			for ($i=0; $i < $this->_numOfFields; $i++)
1024
+			{
813 1025
 				$o = $this->FetchField($i);
814 1026
 				$this->bind[strtoupper($o->name)] = $i;
815 1027
 			}
@@ -820,26 +1032,31 @@  discard block
 block discarded – undo
820 1032
 	}
821 1033
 	
822 1034
 
823
-	function _close() 
1035
+	function _close()
824 1036
 	{
825 1037
 			return @ibase_free_result($this->_queryID);
826 1038
 	}
827 1039
 
828 1040
 	function MetaType($t,$len=-1,$fieldobj=false)
829 1041
 	{
830
-		if (is_object($t)) {
1042
+		if (is_object($t))
1043
+		{
831 1044
 			$fieldobj = $t;
832 1045
 			$t = $fieldobj->type;
833 1046
 			$len = $fieldobj->max_length;
834 1047
 		}
835
-		switch (strtoupper($t)) {
1048
+		switch (strtoupper($t))
1049
+		{
836 1050
 		case 'CHAR':
837 1051
 			return 'C';
838 1052
 			
839 1053
 		case 'TEXT':
840 1054
 		case 'VARCHAR':
841 1055
 		case 'VARYING':
842
-		if ($len <= $this->blobSize) return 'C';
1056
+		if ($len <= $this->blobSize)
1057
+		{
1058
+			return 'C';
1059
+		}
843 1060
 			return 'X';
844 1061
 		case 'BLOB':
845 1062
 			return 'B';
Please login to merge, or discard this patch.
Upper-Lower-Casing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 	function RowLock($tables,$where,$col)
246 246
 	{
247 247
 		if ($this->autoCommit) $this->BeginTrans();
248
-		$this->Execute("UPDATE $table SET $col=$col WHERE $where "); // is this correct - jlim?
248
+		$this->Execute("update $table SET $col=$col WHERE $where "); // is this correct - jlim?
249 249
 		return 1;
250 250
 	}
251 251
 	
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
 		$blob_id_str = ibase_blob_close($blob_id); 
585 585
 		
586 586
 		fclose($fd); 
587
-		return $this->Execute("UPDATE $table SET $column=(?) WHERE $where",array($blob_id_str)) != false; 
587
+		return $this->Execute("update $table SET $column=(?) WHERE $where",array($blob_id_str)) != false; 
588 588
 	} 
589 589
 	
590 590
 	/*
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
 	
626 626
 	$blob_id_str = ibase_blob_close($blob_id); 
627 627
 	
628
-	return $this->Execute("UPDATE $table SET $column=(?) WHERE $where",array($blob_id_str)) != false; 
628
+	return $this->Execute("update $table SET $column=(?) WHERE $where",array($blob_id_str)) != false; 
629 629
 	
630 630
 	} 
631 631
 	
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
 		$blob_id = ibase_blob_create($this->_connectionID);
636 636
 		ibase_blob_add($blob_id, $val);
637 637
 		$blob_id_str = ibase_blob_close($blob_id);
638
-		return $this->Execute("UPDATE $table SET $column=(?) WHERE $where",array($blob_id_str)) != false;
638
+		return $this->Execute("update $table SET $column=(?) WHERE $where",array($blob_id_str)) != false;
639 639
 	}
640 640
 	
641 641
 	// Format date column in sql string given an input format that understands Y M D
Please login to merge, or discard this patch.
phpgwapi/inc/adodb/drivers/adodb-mssql.inc.php 6 patches
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -524,6 +524,9 @@  discard block
 block discarded – undo
524 524
 		return array($sql,$this->qstr($sql2),$max);
525 525
 	}
526 526
 	
527
+	/**
528
+	 * @param string $sql
529
+	 */
527 530
 	function PrepareSP($sql)
528 531
 	{
529 532
 		if (!$this->_has_mssql_init) {
@@ -577,6 +580,11 @@  discard block
 block discarded – undo
577 580
 		
578 581
 		See mssql_bind documentation at php.net.
579 582
 	*/
583
+
584
+	/**
585
+	 * @param integer $var
586
+	 * @param string $name
587
+	 */
580 588
 	function Parameter(&$stmt, &$var, $name, $isOutput=false, $maxLen=4000, $type=false)
581 589
 	{
582 590
 		if (!$this->_has_mssql_init) {
Please login to merge, or discard this patch.
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -327,29 +327,29 @@  discard block
 block discarded – undo
327 327
 
328 328
 		global $ADODB_FETCH_MODE;
329 329
 		$save = $ADODB_FETCH_MODE;
330
-        $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
331
-        if ($this->fetchMode !== FALSE) {
332
-        	$savem = $this->SetFetchMode(FALSE);
333
-        }
330
+		$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
331
+		if ($this->fetchMode !== FALSE) {
332
+			$savem = $this->SetFetchMode(FALSE);
333
+		}
334 334
         
335
-        $rs = $this->Execute($sql);
336
-        if (isset($savem)) {
337
-        	$this->SetFetchMode($savem);
338
-        }
339
-        $ADODB_FETCH_MODE = $save;
335
+		$rs = $this->Execute($sql);
336
+		if (isset($savem)) {
337
+			$this->SetFetchMode($savem);
338
+		}
339
+		$ADODB_FETCH_MODE = $save;
340 340
 
341
-        if (!is_object($rs)) {
342
-        	return FALSE;
343
-        }
341
+		if (!is_object($rs)) {
342
+			return FALSE;
343
+		}
344 344
 
345 345
 		$indexes = array();
346 346
 		while ($row = $rs->FetchRow()) {
347 347
 			if (!$primary && $row[5]) continue;
348 348
 			
349
-            $indexes[$row[0]]['unique'] = $row[6];
350
-            $indexes[$row[0]]['columns'][] = $row[1];
351
-    	}
352
-        return $indexes;
349
+			$indexes[$row[0]]['unique'] = $row[6];
350
+			$indexes[$row[0]]['columns'][] = $row[1];
351
+		}
352
+		return $indexes;
353 353
 	}
354 354
 	
355 355
 	function MetaForeignKeys($table, $owner=false, $upper=false)
@@ -536,28 +536,28 @@  discard block
 block discarded – undo
536 536
 	}
537 537
 	
538 538
 	// returns concatenated string
539
-    // MSSQL requires integers to be cast as strings
540
-    // automatically cast every datatype to VARCHAR(255)
541
-    // @author David Rogers (introspectshun)
542
-    function Concat()
543
-    {
544
-            $s = "";
545
-            $arr = func_get_args();
546
-
547
-            // Split single record on commas, if possible
548
-            if (sizeof($arr) == 1) {
549
-                foreach ($arr as $arg) {
550
-                    $args = explode(',', $arg);
551
-                }
552
-                $arr = $args;
553
-            }
554
-
555
-            array_walk($arr, create_function('&$v', '$v = "CAST(" . $v . " AS VARCHAR(255))";'));
556
-            $s = implode('+',$arr);
557
-            if (sizeof($arr) > 0) return "$s";
539
+	// MSSQL requires integers to be cast as strings
540
+	// automatically cast every datatype to VARCHAR(255)
541
+	// @author David Rogers (introspectshun)
542
+	function Concat()
543
+	{
544
+			$s = "";
545
+			$arr = func_get_args();
546
+
547
+			// Split single record on commas, if possible
548
+			if (sizeof($arr) == 1) {
549
+				foreach ($arr as $arg) {
550
+					$args = explode(',', $arg);
551
+				}
552
+				$arr = $args;
553
+			}
554
+
555
+			array_walk($arr, create_function('&$v', '$v = "CAST(" . $v . " AS VARCHAR(255))";'));
556
+			$s = implode('+',$arr);
557
+			if (sizeof($arr) > 0) return "$s";
558 558
             
559 559
 			return '';
560
-    }
560
+	}
561 561
 	
562 562
 	/* 
563 563
 	Usage:
Please login to merge, or discard this patch.
Switch Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -219,50 +219,50 @@  discard block
 block discarded – undo
219 219
 			if ($s) $s .= '+';
220 220
 			$ch = $fmt[$i];
221 221
 			switch($ch) {
222
-			case 'Y':
223
-			case 'y':
224
-				$s .= "datename(yyyy,$col)";
225
-				break;
226
-			case 'M':
227
-				$s .= "convert(char(3),$col,0)";
228
-				break;
229
-			case 'm':
230
-				$s .= "replace(str(month($col),2),' ','0')";
231
-				break;
232
-			case 'Q':
233
-			case 'q':
234
-				$s .= "datename(quarter,$col)";
235
-				break;
236
-			case 'D':
237
-			case 'd':
238
-				$s .= "replace(str(day($col),2),' ','0')";
239
-				break;
240
-			case 'h':
241
-				$s .= "substring(convert(char(14),$col,0),13,2)";
242
-				break;
222
+				case 'Y':
223
+				case 'y':
224
+					$s .= "datename(yyyy,$col)";
225
+					break;
226
+				case 'M':
227
+					$s .= "convert(char(3),$col,0)";
228
+					break;
229
+				case 'm':
230
+					$s .= "replace(str(month($col),2),' ','0')";
231
+					break;
232
+				case 'Q':
233
+				case 'q':
234
+					$s .= "datename(quarter,$col)";
235
+					break;
236
+				case 'D':
237
+				case 'd':
238
+					$s .= "replace(str(day($col),2),' ','0')";
239
+					break;
240
+				case 'h':
241
+					$s .= "substring(convert(char(14),$col,0),13,2)";
242
+					break;
243 243
 			
244
-			case 'H':
245
-				$s .= "replace(str(datepart(hh,$col),2),' ','0')";
246
-				break;
244
+				case 'H':
245
+					$s .= "replace(str(datepart(hh,$col),2),' ','0')";
246
+					break;
247 247
 				
248
-			case 'i':
249
-				$s .= "replace(str(datepart(mi,$col),2),' ','0')";
250
-				break;
251
-			case 's':
252
-				$s .= "replace(str(datepart(ss,$col),2),' ','0')";
253
-				break;
254
-			case 'a':
255
-			case 'A':
256
-				$s .= "substring(convert(char(19),$col,0),18,2)";
257
-				break;
248
+				case 'i':
249
+					$s .= "replace(str(datepart(mi,$col),2),' ','0')";
250
+					break;
251
+				case 's':
252
+					$s .= "replace(str(datepart(ss,$col),2),' ','0')";
253
+					break;
254
+				case 'a':
255
+				case 'A':
256
+					$s .= "substring(convert(char(19),$col,0),18,2)";
257
+					break;
258 258
 				
259
-			default:
260
-				if ($ch == '\\') {
261
-					$i++;
262
-					$ch = substr($fmt,$i,1);
263
-				}
264
-				$s .= $this->qstr($ch);
265
-				break;
259
+				default:
260
+					if ($ch == '\\') {
261
+						$i++;
262
+						$ch = substr($fmt,$i,1);
263
+					}
264
+					$s .= $this->qstr($ch);
265
+					break;
266 266
 			}
267 267
 		}
268 268
 		return $s;
@@ -588,11 +588,11 @@  discard block
 block discarded – undo
588 588
 			
589 589
 		if ($type === false) 
590 590
 			switch(gettype($var)) {
591
-			default:
592
-			case 'string': $type = SQLCHAR; break;
593
-			case 'double': $type = SQLFLT8; break;
594
-			case 'integer': $type = SQLINT4; break;
595
-			case 'boolean': $type = SQLINT1; break; # SQLBIT not supported in 4.1.0
591
+				default:
592
+				case 'string': $type = SQLCHAR; break;
593
+				case 'double': $type = SQLFLT8; break;
594
+				case 'integer': $type = SQLINT4; break;
595
+				case 'boolean': $type = SQLINT1; break; # SQLBIT not supported in 4.1.0
596 596
 			}
597 597
 		
598 598
 		if  ($this->debug) {
@@ -978,14 +978,14 @@  discard block
 block discarded – undo
978 978
 		if ($themth <= 0) return false;
979 979
 		
980 980
 		switch (strtoupper($rr[6])) {
981
-		case 'P':
982
-			if ($rr[4]<12) $rr[4] += 12;
983
-			break;
984
-		case 'A':
985
-			if ($rr[4]==12) $rr[4] = 0;
986
-			break;
987
-		default:
988
-			break;
981
+			case 'P':
982
+				if ($rr[4]<12) $rr[4] += 12;
983
+				break;
984
+			case 'A':
985
+				if ($rr[4]==12) $rr[4] = 0;
986
+				break;
987
+			default:
988
+				break;
989 989
 		}
990 990
 		// h-m-s-MM-DD-YY
991 991
 		return  mktime($rr[4],$rr[5],0,$themth,$theday,$rr[3]);
Please login to merge, or discard this patch.
Spacing   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -39,15 +39,15 @@  discard block
 block discarded – undo
39 39
 // has datetime converstion to YYYY-MM-DD format, and also mssql_fetch_assoc
40 40
 if (ADODB_PHPVER >= 0x4300) {
41 41
 // docs say 4.2.0, but testing shows only since 4.3.0 does it work!
42
-	ini_set('mssql.datetimeconvert',0); 
42
+	ini_set('mssql.datetimeconvert', 0); 
43 43
 } else {
44
-global $ADODB_mssql_mths;		// array, months must be upper-case
44
+global $ADODB_mssql_mths; // array, months must be upper-case
45 45
 
46 46
 
47 47
 	$ADODB_mssql_date_order = 'mdy'; 
48 48
 	$ADODB_mssql_mths = array(
49
-		'JAN'=>1,'FEB'=>2,'MAR'=>3,'APR'=>4,'MAY'=>5,'JUN'=>6,
50
-		'JUL'=>7,'AUG'=>8,'SEP'=>9,'OCT'=>10,'NOV'=>11,'DEC'=>12);
49
+		'JAN'=>1, 'FEB'=>2, 'MAR'=>3, 'APR'=>4, 'MAY'=>5, 'JUN'=>6,
50
+		'JUL'=>7, 'AUG'=>8, 'SEP'=>9, 'OCT'=>10, 'NOV'=>11, 'DEC'=>12);
51 51
 }
52 52
 
53 53
 //---------------------------------------------------------------------------
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 global $ADODB_mssql_date_order;
60 60
 	$adate = $conn->GetOne('select getdate()');
61 61
 	if ($adate) {
62
-		$anum = (int) $adate;
62
+		$anum = (int)$adate;
63 63
 		if ($anum > 0) {
64 64
 			if ($anum > 31) {
65 65
 				//ADOConnection::outp( "MSSQL: YYYY-MM-DD date format not supported currently");
@@ -81,13 +81,13 @@  discard block
 block discarded – undo
81 81
 	var $length = 'len';
82 82
 	var $hasAffectedRows = true;
83 83
 	var $metaDatabasesSQL = "select name from sysdatabases where name <> 'master'";
84
-	var $metaTablesSQL="select name,case when type='U' then 'T' else 'V' end from sysobjects where (type='U' or type='V') and (name not in ('sysallocations','syscolumns','syscomments','sysdepends','sysfilegroups','sysfiles','sysfiles1','sysforeignkeys','sysfulltextcatalogs','sysindexes','sysindexkeys','sysmembers','sysobjects','syspermissions','sysprotects','sysreferences','systypes','sysusers','sysalternates','sysconstraints','syssegments','REFERENTIAL_CONSTRAINTS','CHECK_CONSTRAINTS','CONSTRAINT_TABLE_USAGE','CONSTRAINT_COLUMN_USAGE','VIEWS','VIEW_TABLE_USAGE','VIEW_COLUMN_USAGE','SCHEMATA','TABLES','TABLE_CONSTRAINTS','TABLE_PRIVILEGES','COLUMNS','COLUMN_DOMAIN_USAGE','COLUMN_PRIVILEGES','DOMAINS','DOMAIN_CONSTRAINTS','KEY_COLUMN_USAGE','dtproperties'))";
84
+	var $metaTablesSQL = "select name,case when type='U' then 'T' else 'V' end from sysobjects where (type='U' or type='V') and (name not in ('sysallocations','syscolumns','syscomments','sysdepends','sysfilegroups','sysfiles','sysfiles1','sysforeignkeys','sysfulltextcatalogs','sysindexes','sysindexkeys','sysmembers','sysobjects','syspermissions','sysprotects','sysreferences','systypes','sysusers','sysalternates','sysconstraints','syssegments','REFERENTIAL_CONSTRAINTS','CHECK_CONSTRAINTS','CONSTRAINT_TABLE_USAGE','CONSTRAINT_COLUMN_USAGE','VIEWS','VIEW_TABLE_USAGE','VIEW_COLUMN_USAGE','SCHEMATA','TABLES','TABLE_CONSTRAINTS','TABLE_PRIVILEGES','COLUMNS','COLUMN_DOMAIN_USAGE','COLUMN_PRIVILEGES','DOMAINS','DOMAIN_CONSTRAINTS','KEY_COLUMN_USAGE','dtproperties'))";
85 85
 	var $metaColumnsSQL = # xtype==61 is datetime
86 86
 "select c.name,t.name,c.length,
87 87
 	(case when c.xusertype=61 then 0 else c.xprec end),
88 88
 	(case when c.xusertype=61 then 0 else c.xscale end) 
89 89
 	from syscolumns c join systypes t on t.xusertype=c.xusertype join sysobjects o on o.id=c.id where o.name='%s'";
90
-	var $hasTop = 'top';		// support mssql SELECT TOP 10 * FROM TABLE
90
+	var $hasTop = 'top'; // support mssql SELECT TOP 10 * FROM TABLE
91 91
 	var $hasGenID = true;
92 92
 	var $sysDate = 'convert(datetime,convert(char,GetDate(),102),102)';
93 93
 	var $sysTimeStamp = 'GetDate()';
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	
106 106
 	function ADODB_mssql() 
107 107
 	{		
108
-		$this->_has_mssql_init = (strnatcmp(PHP_VERSION,'4.1.0')>=0);
108
+		$this->_has_mssql_init = (strnatcmp(PHP_VERSION, '4.1.0') >= 0);
109 109
 	}
110 110
 
111 111
 	function ServerInfo()
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 			$savem = $this->SetFetchMode(ADODB_FETCH_NUM);
122 122
 		
123 123
 		
124
-		$this->Parameter($stmt,$val,'attribute_id');
124
+		$this->Parameter($stmt, $val, 'attribute_id');
125 125
 		$row = $this->GetRow($stmt);
126 126
 		
127 127
 		//$row = $this->GetRow("execute sp_server_info 2");
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 		return $arr;
137 137
 	}
138 138
 	
139
-	function IfNull( $field, $ifNull ) 
139
+	function IfNull($field, $ifNull) 
140 140
 	{
141 141
 		return " ISNULL($field, $ifNull) "; // if MS SQL Server
142 142
 	}
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 
159 159
 	var $_dropSeqSQL = "drop table %s";
160 160
 	
161
-	function CreateSequence($seq='adodbseq',$start=1)
161
+	function CreateSequence($seq = 'adodbseq', $start = 1)
162 162
 	{
163 163
 		$start -= 1;
164 164
 		$this->Execute("create table $seq (id float(53))");
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 		return true;
172 172
 	}
173 173
 
174
-	function GenID($seq='adodbseq',$start=1)
174
+	function GenID($seq = 'adodbseq', $start = 1)
175 175
 	{
176 176
 		//$this->debug=1;
177 177
 		$this->Execute('BEGIN TRANSACTION adodbseq');
@@ -195,30 +195,30 @@  discard block
 block discarded – undo
195 195
 	}
196 196
 	
197 197
 
198
-	function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0)
198
+	function &SelectLimit($sql, $nrows = -1, $offset = -1, $inputarr = false, $secs2cache = 0)
199 199
 	{
200 200
 		if ($nrows > 0 && $offset <= 0) {
201 201
 			$sql = preg_replace(
202
-				'/(^\s*select\s+(distinctrow|distinct)?)/i','\\1 '.$this->hasTop." $nrows ",$sql);
203
-			$rs =& $this->Execute($sql,$inputarr);
202
+				'/(^\s*select\s+(distinctrow|distinct)?)/i', '\\1 '.$this->hasTop." $nrows ", $sql);
203
+			$rs = & $this->Execute($sql, $inputarr);
204 204
 		} else
205
-			$rs =& ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache);
205
+			$rs = & ADOConnection::SelectLimit($sql, $nrows, $offset, $inputarr, $secs2cache);
206 206
 	
207 207
 		return $rs;
208 208
 	}
209 209
 	
210 210
 	
211 211
 	// Format date column in sql string given an input format that understands Y M D
212
-	function SQLDate($fmt, $col=false)
212
+	function SQLDate($fmt, $col = false)
213 213
 	{	
214 214
 		if (!$col) $col = $this->sysTimeStamp;
215 215
 		$s = '';
216 216
 		
217 217
 		$len = strlen($fmt);
218
-		for ($i=0; $i < $len; $i++) {
218
+		for ($i = 0; $i < $len; $i++) {
219 219
 			if ($s) $s .= '+';
220 220
 			$ch = $fmt[$i];
221
-			switch($ch) {
221
+			switch ($ch) {
222 222
 			case 'Y':
223 223
 			case 'y':
224 224
 				$s .= "datename(yyyy,$col)";
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 			default:
260 260
 				if ($ch == '\\') {
261 261
 					$i++;
262
-					$ch = substr($fmt,$i,1);
262
+					$ch = substr($fmt, $i, 1);
263 263
 				}
264 264
 				$s .= $this->qstr($ch);
265 265
 				break;
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 	   	return true;
278 278
 	}
279 279
 		
280
-	function CommitTrans($ok=true) 
280
+	function CommitTrans($ok = true) 
281 281
 	{ 
282 282
 		if ($this->transOff) return true; 
283 283
 		if (!$ok) return $this->RollbackTrans();
@@ -305,14 +305,14 @@  discard block
 block discarded – undo
305 305
 		
306 306
 		See http://www.swynk.com/friends/achigrik/SQL70Locks.asp
307 307
 	*/
308
-	function RowLock($tables,$where,$flds='top 1 null as ignore') 
308
+	function RowLock($tables, $where, $flds = 'top 1 null as ignore') 
309 309
 	{
310 310
 		if (!$this->transCnt) $this->BeginTrans();
311 311
 		return $this->GetOne("select $flds from $tables with (ROWLOCK,HOLDLOCK) where $where");
312 312
 	}
313 313
 	
314 314
 	
315
-	function &MetaIndexes($table,$primary=false)
315
+	function &MetaIndexes($table, $primary = false)
316 316
 	{
317 317
 		$table = $this->qstr($table);
318 318
 
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
         return $indexes;
353 353
 	}
354 354
 	
355
-	function MetaForeignKeys($table, $owner=false, $upper=false)
355
+	function MetaForeignKeys($table, $owner = false, $upper = false)
356 356
 	{
357 357
 	global $ADODB_FETCH_MODE;
358 358
 	
@@ -369,12 +369,12 @@  discard block
 block discarded – undo
369 369
 where upper(object_name(fkeyid)) = $table
370 370
 order by constraint_name, referenced_table_name, keyno";
371 371
 		
372
-		$constraints =& $this->GetArray($sql);
372
+		$constraints = & $this->GetArray($sql);
373 373
 		
374 374
 		$ADODB_FETCH_MODE = $save;
375 375
 		
376 376
 		$arr = false;
377
-		foreach($constraints as $constr) {
377
+		foreach ($constraints as $constr) {
378 378
 			//print_r($constr);
379 379
 			$arr[$constr[0]][$constr[2]][] = $constr[1].'='.$constr[3]; 
380 380
 		}
@@ -382,8 +382,8 @@  discard block
 block discarded – undo
382 382
 		
383 383
 		$arr2 = false;
384 384
 		
385
-		foreach($arr as $k => $v) {
386
-			foreach($v as $a => $b) {
385
+		foreach ($arr as $k => $v) {
386
+			foreach ($v as $a => $b) {
387 387
 				if ($upper) $a = strtoupper($a);
388 388
 				$arr2[$a] = $b;
389 389
 			}
@@ -394,14 +394,14 @@  discard block
 block discarded – undo
394 394
 	//From: Fernando Moreira <[email protected]>
395 395
 	function MetaDatabases() 
396 396
 	{ 
397
-		if(@mssql_select_db("master")) { 
398
-				 $qry=$this->metaDatabasesSQL; 
399
-				 if($rs=@mssql_query($qry)){ 
400
-						 $tmpAr=$ar=array(); 
401
-						 while($tmpAr=@mssql_fetch_row($rs)) 
402
-								 $ar[]=$tmpAr[0]; 
397
+		if (@mssql_select_db("master")) { 
398
+				 $qry = $this->metaDatabasesSQL; 
399
+				 if ($rs = @mssql_query($qry)) { 
400
+						 $tmpAr = $ar = array(); 
401
+						 while ($tmpAr = @mssql_fetch_row($rs)) 
402
+								 $ar[] = $tmpAr[0]; 
403 403
 						@mssql_select_db($this->databaseName); 
404
-						 if(sizeof($ar)) 
404
+						 if (sizeof($ar)) 
405 405
 								 return($ar); 
406 406
 						 else 
407 407
 								 return(false); 
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
 	global $ADODB_FETCH_MODE;
421 421
 	
422 422
 		$schema = '';
423
-		$this->_findschema($table,$schema);
423
+		$this->_findschema($table, $schema);
424 424
 		if (!$schema) $schema = $this->database;
425 425
 		if ($schema) $schema = "and k.table_catalog like '$schema%'"; 
426 426
 
@@ -434,20 +434,20 @@  discard block
 block discarded – undo
434 434
 		$a = $this->GetCol($sql);
435 435
 		$ADODB_FETCH_MODE = $savem;
436 436
 		
437
-		if ($a && sizeof($a)>0) return $a;
437
+		if ($a && sizeof($a) > 0) return $a;
438 438
 		$false = false;
439 439
 		return $false;	  
440 440
 	}
441 441
 
442 442
 	
443
-	function &MetaTables($ttype=false,$showSchema=false,$mask=false) 
443
+	function &MetaTables($ttype = false, $showSchema = false, $mask = false) 
444 444
 	{
445 445
 		if ($mask) {
446 446
 			$save = $this->metaTablesSQL;
447 447
 			$mask = $this->qstr(($mask));
448 448
 			$this->metaTablesSQL .= " AND name like $mask";
449 449
 		}
450
-		$ret =& ADOConnection::MetaTables($ttype,$showSchema);
450
+		$ret = & ADOConnection::MetaTables($ttype, $showSchema);
451 451
 		
452 452
 		if ($mask) {
453 453
 			$this->metaTablesSQL = $save;
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 	
467 467
 	function ErrorMsg() 
468 468
 	{
469
-		if (empty($this->_errorMsg)){
469
+		if (empty($this->_errorMsg)) {
470 470
 			$this->_errorMsg = mssql_get_last_message();
471 471
 		}
472 472
 		return $this->_errorMsg;
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
 		if (empty($this->_errorMsg)) {
479 479
 			$this->_errorMsg = mssql_get_last_message();
480 480
 		}
481
-		$id = @mssql_query("select @@ERROR",$this->_connectionID);
481
+		$id = @mssql_query("select @@ERROR", $this->_connectionID);
482 482
 		if (!$id) return false;
483 483
 		$arr = mssql_fetch_array($id);
484 484
 		@mssql_free_result($id);
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
 	function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
491 491
 	{
492 492
 		if (!function_exists('mssql_pconnect')) return null;
493
-		$this->_connectionID = mssql_connect($argHostname,$argUsername,$argPassword);
493
+		$this->_connectionID = mssql_connect($argHostname, $argUsername, $argPassword);
494 494
 		if ($this->_connectionID === false) return false;
495 495
 		if ($argDatabasename) return $this->SelectDB($argDatabasename);
496 496
 		return true;	
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 	function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
502 502
 	{
503 503
 		if (!function_exists('mssql_pconnect')) return null;
504
-		$this->_connectionID = mssql_pconnect($argHostname,$argUsername,$argPassword);
504
+		$this->_connectionID = mssql_pconnect($argHostname, $argUsername, $argPassword);
505 505
 		if ($this->_connectionID === false) return false;
506 506
 		
507 507
 		// persistent connections can forget to rollback on crash, so we do it here.
@@ -515,24 +515,24 @@  discard block
 block discarded – undo
515 515
 	
516 516
 	function Prepare($sql)
517 517
 	{
518
-		$sqlarr = explode('?',$sql);
518
+		$sqlarr = explode('?', $sql);
519 519
 		if (sizeof($sqlarr) <= 1) return $sql;
520 520
 		$sql2 = $sqlarr[0];
521 521
 		for ($i = 1, $max = sizeof($sqlarr); $i < $max; $i++) {
522
-			$sql2 .=  '@P'.($i-1) . $sqlarr[$i];
522
+			$sql2 .= '@P'.($i - 1).$sqlarr[$i];
523 523
 		} 
524
-		return array($sql,$this->qstr($sql2),$max);
524
+		return array($sql, $this->qstr($sql2), $max);
525 525
 	}
526 526
 	
527 527
 	function PrepareSP($sql)
528 528
 	{
529 529
 		if (!$this->_has_mssql_init) {
530
-			ADOConnection::outp( "PrepareSP: mssql_init only available since PHP 4.1.0");
530
+			ADOConnection::outp("PrepareSP: mssql_init only available since PHP 4.1.0");
531 531
 			return $sql;
532 532
 		}
533
-		$stmt = mssql_init($sql,$this->_connectionID);
533
+		$stmt = mssql_init($sql, $this->_connectionID);
534 534
 		if (!$stmt)  return $sql;
535
-		return array($sql,$stmt);
535
+		return array($sql, $stmt);
536 536
 	}
537 537
 	
538 538
 	// returns concatenated string
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
             }
554 554
 
555 555
             array_walk($arr, create_function('&$v', '$v = "CAST(" . $v . " AS VARCHAR(255))";'));
556
-            $s = implode('+',$arr);
556
+            $s = implode('+', $arr);
557 557
             if (sizeof($arr) > 0) return "$s";
558 558
             
559 559
 			return '';
@@ -577,17 +577,17 @@  discard block
 block discarded – undo
577 577
 		
578 578
 		See mssql_bind documentation at php.net.
579 579
 	*/
580
-	function Parameter(&$stmt, &$var, $name, $isOutput=false, $maxLen=4000, $type=false)
580
+	function Parameter(&$stmt, &$var, $name, $isOutput = false, $maxLen = 4000, $type = false)
581 581
 	{
582 582
 		if (!$this->_has_mssql_init) {
583
-			ADOConnection::outp( "Parameter: mssql_bind only available since PHP 4.1.0");
583
+			ADOConnection::outp("Parameter: mssql_bind only available since PHP 4.1.0");
584 584
 			return $sql;
585 585
 		}
586 586
 
587 587
 		$isNull = is_null($var); // php 4.0.4 and above...
588 588
 			
589 589
 		if ($type === false) 
590
-			switch(gettype($var)) {
590
+			switch (gettype($var)) {
591 591
 			default:
592 592
 			case 'string': $type = SQLCHAR; break;
593 593
 			case 'double': $type = SQLFLT8; break;
@@ -595,10 +595,10 @@  discard block
 block discarded – undo
595 595
 			case 'boolean': $type = SQLINT1; break; # SQLBIT not supported in 4.1.0
596 596
 			}
597 597
 		
598
-		if  ($this->debug) {
598
+		if ($this->debug) {
599 599
 			$prefix = ($isOutput) ? 'Out' : 'In';
600 600
 			$ztype = (empty($type)) ? 'false' : $type;
601
-			ADOConnection::outp( "{$prefix}Parameter(\$stmt, \$php_var='$var', \$name='$name', \$maxLen=$maxLen, \$type=$ztype);");
601
+			ADOConnection::outp("{$prefix}Parameter(\$stmt, \$php_var='$var', \$name='$name', \$maxLen=$maxLen, \$type=$ztype);");
602 602
 		}
603 603
 		/*
604 604
 			See http://phplens.com/lens/lensforum/msgs.php?id=7231
@@ -625,11 +625,11 @@  discard block
 block discarded – undo
625 625
 		; Valid range 0 - 2147483647. Default = 4096. 
626 626
 		mssql.textsize = 0 ; zero to pass through 
627 627
 	*/
628
-	function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB')
628
+	function UpdateBlob($table, $column, $val, $where, $blobtype = 'BLOB')
629 629
 	{
630 630
 	
631 631
 		if (strtoupper($blobtype) == 'CLOB') {
632
-			$sql = "UPDATE $table SET $column='" . $val . "' WHERE $where";
632
+			$sql = "UPDATE $table SET $column='".$val."' WHERE $where";
633 633
 			return $this->Execute($sql) != false;
634 634
 		}
635 635
 		$sql = "UPDATE $table SET $column=0x".bin2hex($val)." WHERE $where";
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
 	}
638 638
 	
639 639
 	// returns query ID if successful, otherwise false
640
-	function _query($sql,$inputarr)
640
+	function _query($sql, $inputarr)
641 641
 	{
642 642
 		$this->_errorMsg = false;
643 643
 		if (is_array($inputarr)) {
@@ -649,7 +649,7 @@  discard block
 block discarded – undo
649 649
 			$params = '';
650 650
 			$decl = '';
651 651
 			$i = 0;
652
-			foreach($inputarr as $v) {
652
+			foreach ($inputarr as $v) {
653 653
 				if ($decl) {
654 654
 					$decl .= ', ';
655 655
 					$params .= ', ';
@@ -658,14 +658,14 @@  discard block
 block discarded – undo
658 658
 					$len = strlen($v);
659 659
 					if ($len == 0) $len = 1;
660 660
 					
661
-					if ($len > 4000 ) {
661
+					if ($len > 4000) {
662 662
 						// NVARCHAR is max 4000 chars. Let's use NTEXT
663 663
 						$decl .= "@P$i NTEXT";
664 664
 					} else {
665 665
 						$decl .= "@P$i NVARCHAR($len)";
666 666
 					}
667 667
 
668
-					$params .= "@P$i=N". (strncmp($v,"'",1)==0? $v : $this->qstr($v));
668
+					$params .= "@P$i=N".(strncmp($v, "'", 1) == 0 ? $v : $this->qstr($v));
669 669
 				} else if (is_integer($v)) {
670 670
 					$decl .= "@P$i INT";
671 671
 					$params .= "@P$i=".$v;
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
 					$params .= "@P$i=".$v;
675 675
 				} else if (is_bool($v)) {
676 676
 					$decl .= "@P$i INT"; # Used INT just in case BIT in not supported on the user's MSSQL version. It will cast appropriately.
677
-					$params .= "@P$i=".(($v)?'1':'0'); # True == 1 in MSSQL BIT fields and acceptable for storing logical true in an int field
677
+					$params .= "@P$i=".(($v) ? '1' : '0'); # True == 1 in MSSQL BIT fields and acceptable for storing logical true in an int field
678 678
 				} else {
679 679
 					$decl .= "@P$i CHAR"; # Used char because a type is required even when the value is to be NULL.
680 680
 					$params .= "@P$i=NULL";
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
 			$rez = mssql_execute($sql[1]);
691 691
 			
692 692
 		} else {
693
-			$rez = mssql_query($sql,$this->_connectionID);
693
+			$rez = mssql_query($sql, $this->_connectionID);
694 694
 		}
695 695
 		return $rez;
696 696
 	}
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
 	var $hasFetchAssoc; // see http://phplens.com/lens/lensforum/msgs.php?id=6083
728 728
 	// _mths works only in non-localised system
729 729
 	
730
-	function ADORecordset_mssql($id,$mode=false)
730
+	function ADORecordset_mssql($id, $mode = false)
731 731
 	{
732 732
 		// freedts check...
733 733
 		$this->hasFetchAssoc = function_exists('mssql_fetch_assoc');
@@ -737,14 +737,14 @@  discard block
 block discarded – undo
737 737
 			$mode = $ADODB_FETCH_MODE;
738 738
 		}
739 739
 		$this->fetchMode = $mode;
740
-		return $this->ADORecordSet($id,$mode);
740
+		return $this->ADORecordSet($id, $mode);
741 741
 	}
742 742
 	
743 743
 	
744 744
 	function _initrs()
745 745
 	{
746 746
 	GLOBAL $ADODB_COUNTRECS;	
747
-		$this->_numOfRows = ($ADODB_COUNTRECS)? @mssql_num_rows($this->_queryID):-1;
747
+		$this->_numOfRows = ($ADODB_COUNTRECS) ? @mssql_num_rows($this->_queryID) : -1;
748 748
 		$this->_numOfFields = @mssql_num_fields($this->_queryID);
749 749
 	}
750 750
 	
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
 		if ($this->fetchMode != ADODB_FETCH_NUM) return $this->fields[$colname];
768 768
 		if (!$this->bind) {
769 769
 			$this->bind = array();
770
-			for ($i=0; $i < $this->_numOfFields; $i++) {
770
+			for ($i = 0; $i < $this->_numOfFields; $i++) {
771 771
 				$o = $this->FetchField($i);
772 772
 				$this->bind[strtoupper($o->name)] = $i;
773 773
 			}
@@ -806,8 +806,8 @@  discard block
 block discarded – undo
806 806
 		
807 807
 		$this->_currentRow++;
808 808
 		
809
-		if ($this->fetchMode & ADODB_FETCH_ASSOC) {
810
-			if ($this->fetchMode & ADODB_FETCH_NUM) {
809
+		if ($this->fetchMode&ADODB_FETCH_ASSOC) {
810
+			if ($this->fetchMode&ADODB_FETCH_NUM) {
811 811
 				//ADODB_FETCH_BOTH mode
812 812
 				$this->fields = @mssql_fetch_array($this->_queryID);
813 813
 			}
@@ -818,7 +818,7 @@  discard block
 block discarded – undo
818 818
 					$flds = @mssql_fetch_array($this->_queryID);
819 819
 					if (is_array($flds)) {
820 820
 						$fassoc = array();
821
-						foreach($flds as $k => $v) {
821
+						foreach ($flds as $k => $v) {
822 822
 							if (is_numeric($k)) continue;
823 823
 							$fassoc[$k] = $v;
824 824
 						}
@@ -830,11 +830,11 @@  discard block
 block discarded – undo
830 830
 			
831 831
 			if (is_array($this->fields)) {
832 832
 				if (ADODB_ASSOC_CASE == 0) {
833
-					foreach($this->fields as $k=>$v) {
833
+					foreach ($this->fields as $k=>$v) {
834 834
 						$this->fields[strtolower($k)] = $v;
835 835
 					}
836 836
 				} else if (ADODB_ASSOC_CASE == 1) {
837
-					foreach($this->fields as $k=>$v) {
837
+					foreach ($this->fields as $k=>$v) {
838 838
 						$this->fields[strtoupper($k)] = $v;
839 839
 					}
840 840
 				}
@@ -851,10 +851,10 @@  discard block
 block discarded – undo
851 851
 	
852 852
 	// INSERT UPDATE DELETE returns false even if no error occurs in 4.0.4
853 853
 	// also the date format has been changed from YYYY-mm-dd to dd MMM YYYY in 4.0.4. Idiot!
854
-	function _fetch($ignore_fields=false) 
854
+	function _fetch($ignore_fields = false) 
855 855
 	{
856
-		if ($this->fetchMode & ADODB_FETCH_ASSOC) {
857
-			if ($this->fetchMode & ADODB_FETCH_NUM) {
856
+		if ($this->fetchMode&ADODB_FETCH_ASSOC) {
857
+			if ($this->fetchMode&ADODB_FETCH_NUM) {
858 858
 				//ADODB_FETCH_BOTH mode
859 859
 				$this->fields = @mssql_fetch_array($this->_queryID);
860 860
 			} else {
@@ -864,7 +864,7 @@  discard block
 block discarded – undo
864 864
 					$this->fields = @mssql_fetch_array($this->_queryID);
865 865
 					if (@is_array($$this->fields)) {
866 866
 						$fassoc = array();
867
-						foreach($$this->fields as $k => $v) {
867
+						foreach ($$this->fields as $k => $v) {
868 868
 							if (is_integer($k)) continue;
869 869
 							$fassoc[$k] = $v;
870 870
 						}
@@ -875,11 +875,11 @@  discard block
 block discarded – undo
875 875
 			
876 876
 			if (!$this->fields) {
877 877
 			} else if (ADODB_ASSOC_CASE == 0) {
878
-				foreach($this->fields as $k=>$v) {
878
+				foreach ($this->fields as $k=>$v) {
879 879
 					$this->fields[strtolower($k)] = $v;
880 880
 				}
881 881
 			} else if (ADODB_ASSOC_CASE == 1) {
882
-				foreach($this->fields as $k=>$v) {
882
+				foreach ($this->fields as $k=>$v) {
883 883
 					$this->fields[strtoupper($k)] = $v;
884 884
 				}
885 885
 			}
@@ -913,65 +913,65 @@  discard block
 block discarded – undo
913 913
 
914 914
 
915 915
 class ADORecordSet_array_mssql extends ADORecordSet_array {
916
-	function ADORecordSet_array_mssql($id=-1,$mode=false) 
916
+	function ADORecordSet_array_mssql($id = -1, $mode = false) 
917 917
 	{
918
-		$this->ADORecordSet_array($id,$mode);
918
+		$this->ADORecordSet_array($id, $mode);
919 919
 	}
920 920
 	
921 921
 		// mssql uses a default date like Dec 30 2000 12:00AM
922 922
 	function UnixDate($v)
923 923
 	{
924 924
 	
925
-		if (is_numeric(substr($v,0,1)) && ADODB_PHPVER >= 0x4200) return parent::UnixDate($v);
925
+		if (is_numeric(substr($v, 0, 1)) && ADODB_PHPVER >= 0x4200) return parent::UnixDate($v);
926 926
 		
927
-	global $ADODB_mssql_mths,$ADODB_mssql_date_order;
927
+	global $ADODB_mssql_mths, $ADODB_mssql_date_order;
928 928
 	
929 929
 		//Dec 30 2000 12:00AM 
930 930
 		if ($ADODB_mssql_date_order == 'dmy') {
931
-			if (!preg_match( "|^([0-9]{1,2})[-/\. ]+([A-Za-z]{3})[-/\. ]+([0-9]{4})|" ,$v, $rr)) {
931
+			if (!preg_match("|^([0-9]{1,2})[-/\. ]+([A-Za-z]{3})[-/\. ]+([0-9]{4})|", $v, $rr)) {
932 932
 				return parent::UnixDate($v);
933 933
 			}
934 934
 			if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
935 935
 			
936 936
 			$theday = $rr[1];
937
-			$themth =  substr(strtoupper($rr[2]),0,3);
937
+			$themth = substr(strtoupper($rr[2]), 0, 3);
938 938
 		} else {
939
-			if (!preg_match( "|^([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4})|" ,$v, $rr)) {
939
+			if (!preg_match("|^([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4})|", $v, $rr)) {
940 940
 				return parent::UnixDate($v);
941 941
 			}
942 942
 			if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
943 943
 			
944 944
 			$theday = $rr[2];
945
-			$themth = substr(strtoupper($rr[1]),0,3);
945
+			$themth = substr(strtoupper($rr[1]), 0, 3);
946 946
 		}
947 947
 		$themth = $ADODB_mssql_mths[$themth];
948 948
 		if ($themth <= 0) return false;
949 949
 		// h-m-s-MM-DD-YY
950
-		return  mktime(0,0,0,$themth,$theday,$rr[3]);
950
+		return  mktime(0, 0, 0, $themth, $theday, $rr[3]);
951 951
 	}
952 952
 	
953 953
 	function UnixTimeStamp($v)
954 954
 	{
955 955
 	
956
-		if (is_numeric(substr($v,0,1)) && ADODB_PHPVER >= 0x4200) return parent::UnixTimeStamp($v);
956
+		if (is_numeric(substr($v, 0, 1)) && ADODB_PHPVER >= 0x4200) return parent::UnixTimeStamp($v);
957 957
 		
958
-	global $ADODB_mssql_mths,$ADODB_mssql_date_order;
958
+	global $ADODB_mssql_mths, $ADODB_mssql_date_order;
959 959
 	
960 960
 		//Dec 30 2000 12:00AM
961 961
 		 if ($ADODB_mssql_date_order == 'dmy') {
962
-			 if (!preg_match( "|^([0-9]{1,2})[-/\. ]+([A-Za-z]{3})[-/\. ]+([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})|"
962
+			 if (!preg_match("|^([0-9]{1,2})[-/\. ]+([A-Za-z]{3})[-/\. ]+([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})|"
963 963
 			,$v, $rr)) return parent::UnixTimeStamp($v);
964 964
 			if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
965 965
 		
966 966
 			$theday = $rr[1];
967
-			$themth =  substr(strtoupper($rr[2]),0,3);
967
+			$themth = substr(strtoupper($rr[2]), 0, 3);
968 968
 		} else {
969
-			if (!preg_match( "|^([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})|"
969
+			if (!preg_match("|^([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})|"
970 970
 			,$v, $rr)) return parent::UnixTimeStamp($v);
971 971
 			if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
972 972
 		
973 973
 			$theday = $rr[2];
974
-			$themth = substr(strtoupper($rr[1]),0,3);
974
+			$themth = substr(strtoupper($rr[1]), 0, 3);
975 975
 		}
976 976
 		
977 977
 		$themth = $ADODB_mssql_mths[$themth];
@@ -979,16 +979,16 @@  discard block
 block discarded – undo
979 979
 		
980 980
 		switch (strtoupper($rr[6])) {
981 981
 		case 'P':
982
-			if ($rr[4]<12) $rr[4] += 12;
982
+			if ($rr[4] < 12) $rr[4] += 12;
983 983
 			break;
984 984
 		case 'A':
985
-			if ($rr[4]==12) $rr[4] = 0;
985
+			if ($rr[4] == 12) $rr[4] = 0;
986 986
 			break;
987 987
 		default:
988 988
 			break;
989 989
 		}
990 990
 		// h-m-s-MM-DD-YY
991
-		return  mktime($rr[4],$rr[5],0,$themth,$theday,$rr[3]);
991
+		return  mktime($rr[4], $rr[5], 0, $themth, $theday, $rr[3]);
992 992
 	}
993 993
 }
994 994
 
Please login to merge, or discard this patch.
Braces   +479 added lines, -184 removed lines patch added patch discarded remove patch
@@ -15,7 +15,10 @@  discard block
 block discarded – undo
15 15
 */
16 16
 
17 17
 // security - hide paths
18
-if (!defined('ADODB_DIR')) die();
18
+if (!defined('ADODB_DIR'))
19
+{
20
+	die();
21
+}
19 22
 
20 23
 //----------------------------------------------------------------
21 24
 // MSSQL returns dates with the format Oct 13 2002 or 13 Oct 2002
@@ -37,10 +40,13 @@  discard block
 block discarded – undo
37 40
 
38 41
 
39 42
 // has datetime converstion to YYYY-MM-DD format, and also mssql_fetch_assoc
40
-if (ADODB_PHPVER >= 0x4300) {
43
+if (ADODB_PHPVER >= 0x4300)
44
+{
41 45
 // docs say 4.2.0, but testing shows only since 4.3.0 does it work!
42 46
 	ini_set('mssql.datetimeconvert',0); 
43
-} else {
47
+}
48
+else
49
+{
44 50
 global $ADODB_mssql_mths;		// array, months must be upper-case
45 51
 
46 52
 
@@ -58,19 +64,27 @@  discard block
 block discarded – undo
58 64
 {
59 65
 global $ADODB_mssql_date_order;
60 66
 	$adate = $conn->GetOne('select getdate()');
61
-	if ($adate) {
67
+	if ($adate)
68
+	{
62 69
 		$anum = (int) $adate;
63
-		if ($anum > 0) {
64
-			if ($anum > 31) {
70
+		if ($anum > 0)
71
+		{
72
+			if ($anum > 31)
73
+			{
65 74
 				//ADOConnection::outp( "MSSQL: YYYY-MM-DD date format not supported currently");
66
-			} else
67
-				$ADODB_mssql_date_order = 'dmy';
68
-		} else
69
-			$ADODB_mssql_date_order = 'mdy';
75
+			}
76
+			else {
77
+							$ADODB_mssql_date_order = 'dmy';
78
+			}
79
+		}
80
+		else {
81
+					$ADODB_mssql_date_order = 'mdy';
82
+		}
70 83
 	}
71 84
 }
72 85
 
73
-class ADODB_mssql extends ADOConnection {
86
+class ADODB_mssql extends ADOConnection
87
+{
74 88
 	var $databaseType = "mssql";	
75 89
 	var $dataProvider = "mssql";
76 90
 	var $replaceQuote = "''"; // string to use to replace quotes
@@ -103,8 +117,8 @@  discard block
 block discarded – undo
103 117
 	var $uniqueOrderBy = true;
104 118
 	var $_bindInputArray = true;
105 119
 	
106
-	function ADODB_mssql() 
107
-	{		
120
+	function ADODB_mssql()
121
+	{
108 122
 		$this->_has_mssql_init = (strnatcmp(PHP_VERSION,'4.1.0')>=0);
109 123
 	}
110 124
 
@@ -114,11 +128,14 @@  discard block
 block discarded – undo
114 128
 	
115 129
 		$stmt = $this->PrepareSP('sp_server_info');
116 130
 		$val = 2;
117
-		if ($this->fetchMode === false) {
131
+		if ($this->fetchMode === false)
132
+		{
118 133
 			$savem = $ADODB_FETCH_MODE;
119 134
 			$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
120
-		} else 
121
-			$savem = $this->SetFetchMode(ADODB_FETCH_NUM);
135
+		}
136
+		else {
137
+					$savem = $this->SetFetchMode(ADODB_FETCH_NUM);
138
+		}
122 139
 		
123 140
 		
124 141
 		$this->Parameter($stmt,$val,'attribute_id');
@@ -126,17 +143,20 @@  discard block
 block discarded – undo
126 143
 		
127 144
 		//$row = $this->GetRow("execute sp_server_info 2");
128 145
 		
129
-		if ($this->fetchMode === false) {
146
+		if ($this->fetchMode === false)
147
+		{
130 148
 			$ADODB_FETCH_MODE = $savem;
131
-		} else
132
-			$this->SetFetchMode($savem);
149
+		}
150
+		else {
151
+					$this->SetFetchMode($savem);
152
+		}
133 153
 		
134 154
 		$arr['description'] = $row[2];
135 155
 		$arr['version'] = ADOConnection::_findvers($arr['description']);
136 156
 		return $arr;
137 157
 	}
138 158
 	
139
-	function IfNull( $field, $ifNull ) 
159
+	function IfNull( $field, $ifNull )
140 160
 	{
141 161
 		return " ISNULL($field, $ifNull) "; // if MS SQL Server
142 162
 	}
@@ -163,7 +183,8 @@  discard block
 block discarded – undo
163 183
 		$start -= 1;
164 184
 		$this->Execute("create table $seq (id float(53))");
165 185
 		$ok = $this->Execute("insert into $seq with (tablock,holdlock) values($start)");
166
-		if (!$ok) {
186
+		if (!$ok)
187
+		{
167 188
 				$this->Execute('ROLLBACK TRANSACTION adodbseq');
168 189
 				return false;
169 190
 		}
@@ -176,10 +197,12 @@  discard block
 block discarded – undo
176 197
 		//$this->debug=1;
177 198
 		$this->Execute('BEGIN TRANSACTION adodbseq');
178 199
 		$ok = $this->Execute("update $seq with (tablock,holdlock) set id = id + 1");
179
-		if (!$ok) {
200
+		if (!$ok)
201
+		{
180 202
 			$this->Execute("create table $seq (id float(53))");
181 203
 			$ok = $this->Execute("insert into $seq with (tablock,holdlock) values($start)");
182
-			if (!$ok) {
204
+			if (!$ok)
205
+			{
183 206
 				$this->Execute('ROLLBACK TRANSACTION adodbseq');
184 207
 				return false;
185 208
 			}
@@ -197,12 +220,15 @@  discard block
 block discarded – undo
197 220
 
198 221
 	function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0)
199 222
 	{
200
-		if ($nrows > 0 && $offset <= 0) {
223
+		if ($nrows > 0 && $offset <= 0)
224
+		{
201 225
 			$sql = preg_replace(
202 226
 				'/(^\s*select\s+(distinctrow|distinct)?)/i','\\1 '.$this->hasTop." $nrows ",$sql);
203 227
 			$rs =& $this->Execute($sql,$inputarr);
204
-		} else
205
-			$rs =& ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache);
228
+		}
229
+		else {
230
+					$rs =& ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache);
231
+		}
206 232
 	
207 233
 		return $rs;
208 234
 	}
@@ -210,15 +236,23 @@  discard block
 block discarded – undo
210 236
 	
211 237
 	// Format date column in sql string given an input format that understands Y M D
212 238
 	function SQLDate($fmt, $col=false)
213
-	{	
214
-		if (!$col) $col = $this->sysTimeStamp;
239
+	{
240
+		if (!$col)
241
+		{
242
+			$col = $this->sysTimeStamp;
243
+		}
215 244
 		$s = '';
216 245
 		
217 246
 		$len = strlen($fmt);
218
-		for ($i=0; $i < $len; $i++) {
219
-			if ($s) $s .= '+';
247
+		for ($i=0; $i < $len; $i++)
248
+		{
249
+			if ($s)
250
+			{
251
+				$s .= '+';
252
+			}
220 253
 			$ch = $fmt[$i];
221
-			switch($ch) {
254
+			switch($ch)
255
+			{
222 256
 			case 'Y':
223 257
 			case 'y':
224 258
 				$s .= "datename(yyyy,$col)";
@@ -257,7 +291,8 @@  discard block
 block discarded – undo
257 291
 				break;
258 292
 				
259 293
 			default:
260
-				if ($ch == '\\') {
294
+				if ($ch == '\\')
295
+				{
261 296
 					$i++;
262 297
 					$ch = substr($fmt,$i,1);
263 298
 				}
@@ -271,24 +306,42 @@  discard block
 block discarded – undo
271 306
 	
272 307
 	function BeginTrans()
273 308
 	{
274
-		if ($this->transOff) return true; 
309
+		if ($this->transOff)
310
+		{
311
+			return true;
312
+		}
275 313
 		$this->transCnt += 1;
276 314
 	   	$this->Execute('BEGIN TRAN');
277 315
 	   	return true;
278 316
 	}
279 317
 		
280
-	function CommitTrans($ok=true) 
281
-	{ 
282
-		if ($this->transOff) return true; 
283
-		if (!$ok) return $this->RollbackTrans();
284
-		if ($this->transCnt) $this->transCnt -= 1;
318
+	function CommitTrans($ok=true)
319
+	{
320
+		if ($this->transOff)
321
+		{
322
+			return true;
323
+		}
324
+		if (!$ok)
325
+		{
326
+			return $this->RollbackTrans();
327
+		}
328
+		if ($this->transCnt)
329
+		{
330
+			$this->transCnt -= 1;
331
+		}
285 332
 		$this->Execute('COMMIT TRAN');
286 333
 		return true;
287 334
 	}
288 335
 	function RollbackTrans()
289 336
 	{
290
-		if ($this->transOff) return true; 
291
-		if ($this->transCnt) $this->transCnt -= 1;
337
+		if ($this->transOff)
338
+		{
339
+			return true;
340
+		}
341
+		if ($this->transCnt)
342
+		{
343
+			$this->transCnt -= 1;
344
+		}
292 345
 		$this->Execute('ROLLBACK TRAN');
293 346
 		return true;
294 347
 	}
@@ -305,9 +358,12 @@  discard block
 block discarded – undo
305 358
 		
306 359
 		See http://www.swynk.com/friends/achigrik/SQL70Locks.asp
307 360
 	*/
308
-	function RowLock($tables,$where,$flds='top 1 null as ignore') 
361
+	function RowLock($tables,$where,$flds='top 1 null as ignore')
309 362
 	{
310
-		if (!$this->transCnt) $this->BeginTrans();
363
+		if (!$this->transCnt)
364
+		{
365
+			$this->BeginTrans();
366
+		}
311 367
 		return $this->GetOne("select $flds from $tables with (ROWLOCK,HOLDLOCK) where $where");
312 368
 	}
313 369
 	
@@ -328,23 +384,30 @@  discard block
 block discarded – undo
328 384
 		global $ADODB_FETCH_MODE;
329 385
 		$save = $ADODB_FETCH_MODE;
330 386
         $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
331
-        if ($this->fetchMode !== FALSE) {
387
+        if ($this->fetchMode !== FALSE)
388
+        {
332 389
         	$savem = $this->SetFetchMode(FALSE);
333 390
         }
334 391
         
335 392
         $rs = $this->Execute($sql);
336
-        if (isset($savem)) {
393
+        if (isset($savem))
394
+        {
337 395
         	$this->SetFetchMode($savem);
338 396
         }
339 397
         $ADODB_FETCH_MODE = $save;
340 398
 
341
-        if (!is_object($rs)) {
399
+        if (!is_object($rs))
400
+        {
342 401
         	return FALSE;
343 402
         }
344 403
 
345 404
 		$indexes = array();
346
-		while ($row = $rs->FetchRow()) {
347
-			if (!$primary && $row[5]) continue;
405
+		while ($row = $rs->FetchRow())
406
+		{
407
+			if (!$primary && $row[5])
408
+			{
409
+				continue;
410
+			}
348 411
 			
349 412
             $indexes[$row[0]]['unique'] = $row[6];
350 413
             $indexes[$row[0]]['columns'][] = $row[1];
@@ -374,17 +437,26 @@  discard block
 block discarded – undo
374 437
 		$ADODB_FETCH_MODE = $save;
375 438
 		
376 439
 		$arr = false;
377
-		foreach($constraints as $constr) {
440
+		foreach($constraints as $constr)
441
+		{
378 442
 			//print_r($constr);
379 443
 			$arr[$constr[0]][$constr[2]][] = $constr[1].'='.$constr[3]; 
380 444
 		}
381
-		if (!$arr) return false;
445
+		if (!$arr)
446
+		{
447
+			return false;
448
+		}
382 449
 		
383 450
 		$arr2 = false;
384 451
 		
385
-		foreach($arr as $k => $v) {
386
-			foreach($v as $a => $b) {
387
-				if ($upper) $a = strtoupper($a);
452
+		foreach($arr as $k => $v)
453
+		{
454
+			foreach($v as $a => $b)
455
+			{
456
+				if ($upper)
457
+				{
458
+					$a = strtoupper($a);
459
+				}
388 460
 				$arr2[$a] = $b;
389 461
 			}
390 462
 		}
@@ -392,20 +464,29 @@  discard block
 block discarded – undo
392 464
 	}
393 465
 
394 466
 	//From: Fernando Moreira <[email protected]>
395
-	function MetaDatabases() 
396
-	{ 
397
-		if(@mssql_select_db("master")) { 
467
+	function MetaDatabases()
468
+	{
469
+		if(@mssql_select_db("master"))
470
+		{
398 471
 				 $qry=$this->metaDatabasesSQL; 
399
-				 if($rs=@mssql_query($qry)){ 
472
+				 if($rs=@mssql_query($qry))
473
+				 {
400 474
 						 $tmpAr=$ar=array(); 
401
-						 while($tmpAr=@mssql_fetch_row($rs)) 
402
-								 $ar[]=$tmpAr[0]; 
475
+						 while($tmpAr=@mssql_fetch_row($rs))
476
+						 {
477
+						 								 $ar[]=$tmpAr[0];
478
+						 }
403 479
 						@mssql_select_db($this->databaseName); 
404
-						 if(sizeof($ar)) 
405
-								 return($ar); 
406
-						 else 
407
-								 return(false); 
408
-				 } else { 
480
+						 if(sizeof($ar))
481
+						 {
482
+						 								 return($ar);
483
+						 }
484
+						 else {
485
+						 								 return(false);
486
+						 }
487
+				 }
488
+				 else
489
+				 {
409 490
 						 @mssql_select_db($this->databaseName); 
410 491
 						 return(false); 
411 492
 				 } 
@@ -421,8 +502,14 @@  discard block
 block discarded – undo
421 502
 	
422 503
 		$schema = '';
423 504
 		$this->_findschema($table,$schema);
424
-		if (!$schema) $schema = $this->database;
425
-		if ($schema) $schema = "and k.table_catalog like '$schema%'"; 
505
+		if (!$schema)
506
+		{
507
+			$schema = $this->database;
508
+		}
509
+		if ($schema)
510
+		{
511
+			$schema = "and k.table_catalog like '$schema%'";
512
+		}
426 513
 
427 514
 		$sql = "select distinct k.column_name,ordinal_position from information_schema.key_column_usage k,
428 515
 		information_schema.table_constraints tc 
@@ -434,7 +521,10 @@  discard block
 block discarded – undo
434 521
 		$a = $this->GetCol($sql);
435 522
 		$ADODB_FETCH_MODE = $savem;
436 523
 		
437
-		if ($a && sizeof($a)>0) return $a;
524
+		if ($a && sizeof($a)>0)
525
+		{
526
+			return $a;
527
+		}
438 528
 		$false = false;
439 529
 		return $false;	  
440 530
 	}
@@ -442,57 +532,84 @@  discard block
 block discarded – undo
442 532
 	
443 533
 	function &MetaTables($ttype=false,$showSchema=false,$mask=false) 
444 534
 	{
445
-		if ($mask) {
535
+		if ($mask)
536
+		{
446 537
 			$save = $this->metaTablesSQL;
447 538
 			$mask = $this->qstr(($mask));
448 539
 			$this->metaTablesSQL .= " AND name like $mask";
449 540
 		}
450 541
 		$ret =& ADOConnection::MetaTables($ttype,$showSchema);
451 542
 		
452
-		if ($mask) {
543
+		if ($mask)
544
+		{
453 545
 			$this->metaTablesSQL = $save;
454 546
 		}
455 547
 		return $ret;
456 548
 	}
457 549
  
458
-	function SelectDB($dbName) 
550
+	function SelectDB($dbName)
459 551
 	{
460 552
 		$this->databaseName = $dbName;
461
-		if ($this->_connectionID) {
553
+		if ($this->_connectionID)
554
+		{
462 555
 			return @mssql_select_db($dbName);		
463 556
 		}
464
-		else return false;	
557
+		else {
558
+			return false;
559
+		}
465 560
 	}
466 561
 	
467
-	function ErrorMsg() 
562
+	function ErrorMsg()
468 563
 	{
469
-		if (empty($this->_errorMsg)){
564
+		if (empty($this->_errorMsg))
565
+		{
470 566
 			$this->_errorMsg = mssql_get_last_message();
471 567
 		}
472 568
 		return $this->_errorMsg;
473 569
 	}
474 570
 	
475
-	function ErrorNo() 
571
+	function ErrorNo()
476 572
 	{
477
-		if ($this->_logsql && $this->_errorCode !== false) return $this->_errorCode;
478
-		if (empty($this->_errorMsg)) {
573
+		if ($this->_logsql && $this->_errorCode !== false)
574
+		{
575
+			return $this->_errorCode;
576
+		}
577
+		if (empty($this->_errorMsg))
578
+		{
479 579
 			$this->_errorMsg = mssql_get_last_message();
480 580
 		}
481 581
 		$id = @mssql_query("select @@ERROR",$this->_connectionID);
482
-		if (!$id) return false;
582
+		if (!$id)
583
+		{
584
+			return false;
585
+		}
483 586
 		$arr = mssql_fetch_array($id);
484 587
 		@mssql_free_result($id);
485
-		if (is_array($arr)) return $arr[0];
486
-	   else return -1;
588
+		if (is_array($arr))
589
+		{
590
+			return $arr[0];
591
+		}
592
+	   else {
593
+	   	return -1;
594
+	   }
487 595
 	}
488 596
 	
489 597
 	// returns true or false
490 598
 	function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
491 599
 	{
492
-		if (!function_exists('mssql_pconnect')) return null;
600
+		if (!function_exists('mssql_pconnect'))
601
+		{
602
+			return null;
603
+		}
493 604
 		$this->_connectionID = mssql_connect($argHostname,$argUsername,$argPassword);
494
-		if ($this->_connectionID === false) return false;
495
-		if ($argDatabasename) return $this->SelectDB($argDatabasename);
605
+		if ($this->_connectionID === false)
606
+		{
607
+			return false;
608
+		}
609
+		if ($argDatabasename)
610
+		{
611
+			return $this->SelectDB($argDatabasename);
612
+		}
496 613
 		return true;	
497 614
 	}
498 615
 	
@@ -500,25 +617,42 @@  discard block
 block discarded – undo
500 617
 	// returns true or false
501 618
 	function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
502 619
 	{
503
-		if (!function_exists('mssql_pconnect')) return null;
620
+		if (!function_exists('mssql_pconnect'))
621
+		{
622
+			return null;
623
+		}
504 624
 		$this->_connectionID = mssql_pconnect($argHostname,$argUsername,$argPassword);
505
-		if ($this->_connectionID === false) return false;
625
+		if ($this->_connectionID === false)
626
+		{
627
+			return false;
628
+		}
506 629
 		
507 630
 		// persistent connections can forget to rollback on crash, so we do it here.
508
-		if ($this->autoRollback) {
631
+		if ($this->autoRollback)
632
+		{
509 633
 			$cnt = $this->GetOne('select @@TRANCOUNT');
510
-			while (--$cnt >= 0) $this->Execute('ROLLBACK TRAN'); 
634
+			while (--$cnt >= 0)
635
+			{
636
+				$this->Execute('ROLLBACK TRAN');
637
+			}
638
+		}
639
+		if ($argDatabasename)
640
+		{
641
+			return $this->SelectDB($argDatabasename);
511 642
 		}
512
-		if ($argDatabasename) return $this->SelectDB($argDatabasename);
513 643
 		return true;	
514 644
 	}
515 645
 	
516 646
 	function Prepare($sql)
517 647
 	{
518 648
 		$sqlarr = explode('?',$sql);
519
-		if (sizeof($sqlarr) <= 1) return $sql;
649
+		if (sizeof($sqlarr) <= 1)
650
+		{
651
+			return $sql;
652
+		}
520 653
 		$sql2 = $sqlarr[0];
521
-		for ($i = 1, $max = sizeof($sqlarr); $i < $max; $i++) {
654
+		for ($i = 1, $max = sizeof($sqlarr); $i < $max; $i++)
655
+		{
522 656
 			$sql2 .=  '@P'.($i-1) . $sqlarr[$i];
523 657
 		} 
524 658
 		return array($sql,$this->qstr($sql2),$max);
@@ -526,12 +660,16 @@  discard block
 block discarded – undo
526 660
 	
527 661
 	function PrepareSP($sql)
528 662
 	{
529
-		if (!$this->_has_mssql_init) {
663
+		if (!$this->_has_mssql_init)
664
+		{
530 665
 			ADOConnection::outp( "PrepareSP: mssql_init only available since PHP 4.1.0");
531 666
 			return $sql;
532 667
 		}
533 668
 		$stmt = mssql_init($sql,$this->_connectionID);
534
-		if (!$stmt)  return $sql;
669
+		if (!$stmt)
670
+		{
671
+			return $sql;
672
+		}
535 673
 		return array($sql,$stmt);
536 674
 	}
537 675
 	
@@ -545,8 +683,10 @@  discard block
 block discarded – undo
545 683
             $arr = func_get_args();
546 684
 
547 685
             // Split single record on commas, if possible
548
-            if (sizeof($arr) == 1) {
549
-                foreach ($arr as $arg) {
686
+            if (sizeof($arr) == 1)
687
+            {
688
+                foreach ($arr as $arg)
689
+                {
550 690
                     $args = explode(',', $arg);
551 691
                 }
552 692
                 $arr = $args;
@@ -554,7 +694,10 @@  discard block
 block discarded – undo
554 694
 
555 695
             array_walk($arr, create_function('&$v', '$v = "CAST(" . $v . " AS VARCHAR(255))";'));
556 696
             $s = implode('+',$arr);
557
-            if (sizeof($arr) > 0) return "$s";
697
+            if (sizeof($arr) > 0)
698
+            {
699
+            	return "$s";
700
+            }
558 701
             
559 702
 			return '';
560 703
     }
@@ -579,23 +722,28 @@  discard block
 block discarded – undo
579 722
 	*/
580 723
 	function Parameter(&$stmt, &$var, $name, $isOutput=false, $maxLen=4000, $type=false)
581 724
 	{
582
-		if (!$this->_has_mssql_init) {
725
+		if (!$this->_has_mssql_init)
726
+		{
583 727
 			ADOConnection::outp( "Parameter: mssql_bind only available since PHP 4.1.0");
584 728
 			return $sql;
585 729
 		}
586 730
 
587 731
 		$isNull = is_null($var); // php 4.0.4 and above...
588 732
 			
589
-		if ($type === false) 
590
-			switch(gettype($var)) {
733
+		if ($type === false)
734
+		{
735
+					switch(gettype($var)) {
591 736
 			default:
592
-			case 'string': $type = SQLCHAR; break;
737
+			case 'string': $type = SQLCHAR;
738
+		}
739
+		break;
593 740
 			case 'double': $type = SQLFLT8; break;
594 741
 			case 'integer': $type = SQLINT4; break;
595 742
 			case 'boolean': $type = SQLINT1; break; # SQLBIT not supported in 4.1.0
596 743
 			}
597 744
 		
598
-		if  ($this->debug) {
745
+		if  ($this->debug)
746
+		{
599 747
 			$prefix = ($isOutput) ? 'Out' : 'In';
600 748
 			$ztype = (empty($type)) ? 'false' : $type;
601 749
 			ADOConnection::outp( "{$prefix}Parameter(\$stmt, \$php_var='$var', \$name='$name', \$maxLen=$maxLen, \$type=$ztype);");
@@ -609,7 +757,10 @@  discard block
 block discarded – undo
609 757
 			see how it works. - type: one of this new supported PHP constants. 
610 758
 				SQLTEXT, SQLVARCHAR,SQLCHAR, SQLINT1,SQLINT2, SQLINT4, SQLBIT,SQLFLT8 
611 759
 		*/
612
-		if ($name !== 'RETVAL') $name = '@'.$name;
760
+		if ($name !== 'RETVAL')
761
+		{
762
+			$name = '@'.$name;
763
+		}
613 764
 		return mssql_bind($stmt[1], $name, $var, $type, $isOutput, $isNull, $maxLen);
614 765
 	}
615 766
 	
@@ -628,7 +779,8 @@  discard block
 block discarded – undo
628 779
 	function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB')
629 780
 	{
630 781
 	
631
-		if (strtoupper($blobtype) == 'CLOB') {
782
+		if (strtoupper($blobtype) == 'CLOB')
783
+		{
632 784
 			$sql = "UPDATE $table SET $column='" . $val . "' WHERE $where";
633 785
 			return $this->Execute($sql) != false;
634 786
 		}
@@ -640,56 +792,84 @@  discard block
 block discarded – undo
640 792
 	function _query($sql,$inputarr)
641 793
 	{
642 794
 		$this->_errorMsg = false;
643
-		if (is_array($inputarr)) {
795
+		if (is_array($inputarr))
796
+		{
644 797
 			
645 798
 			# bind input params with sp_executesql: 
646 799
 			# see http://www.quest-pipelines.com/newsletter-v3/0402_F.htm
647 800
 			# works only with sql server 7 and newer
648
-			if (!is_array($sql)) $sql = $this->Prepare($sql);
801
+			if (!is_array($sql))
802
+			{
803
+				$sql = $this->Prepare($sql);
804
+			}
649 805
 			$params = '';
650 806
 			$decl = '';
651 807
 			$i = 0;
652
-			foreach($inputarr as $v) {
653
-				if ($decl) {
808
+			foreach($inputarr as $v)
809
+			{
810
+				if ($decl)
811
+				{
654 812
 					$decl .= ', ';
655 813
 					$params .= ', ';
656 814
 				}	
657
-				if (is_string($v)) {
815
+				if (is_string($v))
816
+				{
658 817
 					$len = strlen($v);
659
-					if ($len == 0) $len = 1;
818
+					if ($len == 0)
819
+					{
820
+						$len = 1;
821
+					}
660 822
 					
661
-					if ($len > 4000 ) {
823
+					if ($len > 4000 )
824
+					{
662 825
 						// NVARCHAR is max 4000 chars. Let's use NTEXT
663 826
 						$decl .= "@P$i NTEXT";
664
-					} else {
827
+					}
828
+					else
829
+					{
665 830
 						$decl .= "@P$i NVARCHAR($len)";
666 831
 					}
667 832
 
668 833
 					$params .= "@P$i=N". (strncmp($v,"'",1)==0? $v : $this->qstr($v));
669
-				} else if (is_integer($v)) {
834
+				}
835
+				else if (is_integer($v))
836
+				{
670 837
 					$decl .= "@P$i INT";
671 838
 					$params .= "@P$i=".$v;
672
-				} else if (is_float($v)) {
839
+				}
840
+				else if (is_float($v))
841
+				{
673 842
 					$decl .= "@P$i FLOAT";
674 843
 					$params .= "@P$i=".$v;
675
-				} else if (is_bool($v)) {
844
+				}
845
+				else if (is_bool($v))
846
+				{
676 847
 					$decl .= "@P$i INT"; # Used INT just in case BIT in not supported on the user's MSSQL version. It will cast appropriately.
677 848
 					$params .= "@P$i=".(($v)?'1':'0'); # True == 1 in MSSQL BIT fields and acceptable for storing logical true in an int field
678
-				} else {
849
+				}
850
+				else
851
+				{
679 852
 					$decl .= "@P$i CHAR"; # Used char because a type is required even when the value is to be NULL.
680 853
 					$params .= "@P$i=NULL";
681 854
 					}
682 855
 				$i += 1;
683 856
 			}
684 857
 			$decl = $this->qstr($decl);
685
-			if ($this->debug) ADOConnection::outp("<font size=-1>sp_executesql N{$sql[1]},N$decl,$params</font>");
858
+			if ($this->debug)
859
+			{
860
+				ADOConnection::outp("<font size=-1>sp_executesql N{$sql[1]},N$decl,$params</font>");
861
+			}
686 862
 			$rez = mssql_query("sp_executesql N{$sql[1]},N$decl,$params");
687 863
 			
688
-		} else if (is_array($sql)) {
864
+		}
865
+		else if (is_array($sql))
866
+		{
689 867
 			# PrepareSP()
690 868
 			$rez = mssql_execute($sql[1]);
691 869
 			
692
-		} else {
870
+		}
871
+		else
872
+		{
693 873
 			$rez = mssql_query($sql,$this->_connectionID);
694 874
 		}
695 875
 		return $rez;
@@ -697,8 +877,11 @@  discard block
 block discarded – undo
697 877
 	
698 878
 	// returns true or false
699 879
 	function _close()
700
-	{ 
701
-		if ($this->transCnt) $this->RollbackTrans();
880
+	{
881
+		if ($this->transCnt)
882
+		{
883
+			$this->RollbackTrans();
884
+		}
702 885
 		$rez = @mssql_close($this->_connectionID);
703 886
 		$this->_connectionID = false;
704 887
 		return $rez;
@@ -720,7 +903,8 @@  discard block
 block discarded – undo
720 903
 	 Class Name: Recordset
721 904
 --------------------------------------------------------------------------------------*/
722 905
 
723
-class ADORecordset_mssql extends ADORecordSet {	
906
+class ADORecordset_mssql extends ADORecordSet
907
+{
724 908
 
725 909
 	var $databaseType = "mssql";
726 910
 	var $canSeek = true;
@@ -732,7 +916,8 @@  discard block
 block discarded – undo
732 916
 		// freedts check...
733 917
 		$this->hasFetchAssoc = function_exists('mssql_fetch_assoc');
734 918
 
735
-		if ($mode === false) { 
919
+		if ($mode === false)
920
+		{
736 921
 			global $ADODB_FETCH_MODE;
737 922
 			$mode = $ADODB_FETCH_MODE;
738 923
 		}
@@ -753,7 +938,10 @@  discard block
 block discarded – undo
753 938
 	// get next resultset - requires PHP 4.0.5 or later
754 939
 	function NextRecordSet()
755 940
 	{
756
-		if (!mssql_next_result($this->_queryID)) return false;
941
+		if (!mssql_next_result($this->_queryID))
942
+		{
943
+			return false;
944
+		}
757 945
 		$this->_inited = false;
758 946
 		$this->bind = false;
759 947
 		$this->_currentRow = -1;
@@ -764,10 +952,15 @@  discard block
 block discarded – undo
764 952
 	/* Use associative array to get fields array */
765 953
 	function Fields($colname)
766 954
 	{
767
-		if ($this->fetchMode != ADODB_FETCH_NUM) return $this->fields[$colname];
768
-		if (!$this->bind) {
955
+		if ($this->fetchMode != ADODB_FETCH_NUM)
956
+		{
957
+			return $this->fields[$colname];
958
+		}
959
+		if (!$this->bind)
960
+		{
769 961
 			$this->bind = array();
770
-			for ($i=0; $i < $this->_numOfFields; $i++) {
962
+			for ($i=0; $i < $this->_numOfFields; $i++)
963
+			{
771 964
 				$o = $this->FetchField($i);
772 965
 				$this->bind[strtoupper($o->name)] = $i;
773 966
 			}
@@ -783,66 +976,100 @@  discard block
 block discarded – undo
783 976
 
784 977
 	function &FetchField($fieldOffset = -1) 
785 978
 	{
786
-		if ($fieldOffset != -1) {
979
+		if ($fieldOffset != -1)
980
+		{
787 981
 			$f = @mssql_fetch_field($this->_queryID, $fieldOffset);
788 982
 		}
789
-		else if ($fieldOffset == -1) {	/*	The $fieldOffset argument is not provided thus its -1 	*/
983
+		else if ($fieldOffset == -1)
984
+		{
985
+/*	The $fieldOffset argument is not provided thus its -1 	*/
790 986
 			$f = @mssql_fetch_field($this->_queryID);
791 987
 		}
792 988
 		$false = false;
793
-		if (empty($f)) return $false;
989
+		if (empty($f))
990
+		{
991
+			return $false;
992
+		}
794 993
 		return $f;
795 994
 	}
796 995
 	
797
-	function _seek($row) 
996
+	function _seek($row)
798 997
 	{
799 998
 		return @mssql_data_seek($this->_queryID, $row);
800 999
 	}
801 1000
 
802 1001
 	// speedup
803
-	function MoveNext() 
1002
+	function MoveNext()
804 1003
 	{
805
-		if ($this->EOF) return false;
1004
+		if ($this->EOF)
1005
+		{
1006
+			return false;
1007
+		}
806 1008
 		
807 1009
 		$this->_currentRow++;
808 1010
 		
809
-		if ($this->fetchMode & ADODB_FETCH_ASSOC) {
810
-			if ($this->fetchMode & ADODB_FETCH_NUM) {
1011
+		if ($this->fetchMode & ADODB_FETCH_ASSOC)
1012
+		{
1013
+			if ($this->fetchMode & ADODB_FETCH_NUM)
1014
+			{
811 1015
 				//ADODB_FETCH_BOTH mode
812 1016
 				$this->fields = @mssql_fetch_array($this->_queryID);
813 1017
 			}
814
-			else {
815
-				if ($this->hasFetchAssoc) {// only for PHP 4.2.0 or later
1018
+			else
1019
+			{
1020
+				if ($this->hasFetchAssoc)
1021
+				{
1022
+// only for PHP 4.2.0 or later
816 1023
 					 $this->fields = @mssql_fetch_assoc($this->_queryID);
817
-				} else {
1024
+				}
1025
+				else
1026
+				{
818 1027
 					$flds = @mssql_fetch_array($this->_queryID);
819
-					if (is_array($flds)) {
1028
+					if (is_array($flds))
1029
+					{
820 1030
 						$fassoc = array();
821
-						foreach($flds as $k => $v) {
822
-							if (is_numeric($k)) continue;
1031
+						foreach($flds as $k => $v)
1032
+						{
1033
+							if (is_numeric($k))
1034
+							{
1035
+								continue;
1036
+							}
823 1037
 							$fassoc[$k] = $v;
824 1038
 						}
825 1039
 						$this->fields = $fassoc;
826
-					} else
827
-						$this->fields = false;
1040
+					}
1041
+					else {
1042
+											$this->fields = false;
1043
+					}
828 1044
 				}
829 1045
 			}
830 1046
 			
831
-			if (is_array($this->fields)) {
832
-				if (ADODB_ASSOC_CASE == 0) {
833
-					foreach($this->fields as $k=>$v) {
1047
+			if (is_array($this->fields))
1048
+			{
1049
+				if (ADODB_ASSOC_CASE == 0)
1050
+				{
1051
+					foreach($this->fields as $k=>$v)
1052
+					{
834 1053
 						$this->fields[strtolower($k)] = $v;
835 1054
 					}
836
-				} else if (ADODB_ASSOC_CASE == 1) {
837
-					foreach($this->fields as $k=>$v) {
1055
+				}
1056
+				else if (ADODB_ASSOC_CASE == 1)
1057
+				{
1058
+					foreach($this->fields as $k=>$v)
1059
+					{
838 1060
 						$this->fields[strtoupper($k)] = $v;
839 1061
 					}
840 1062
 				}
841 1063
 			}
842
-		} else {
1064
+		}
1065
+		else
1066
+		{
843 1067
 			$this->fields = @mssql_fetch_row($this->_queryID);
844 1068
 		}
845
-		if ($this->fields) return true;
1069
+		if ($this->fields)
1070
+		{
1071
+			return true;
1072
+		}
846 1073
 		$this->EOF = true;
847 1074
 		
848 1075
 		return false;
@@ -851,21 +1078,34 @@  discard block
 block discarded – undo
851 1078
 	
852 1079
 	// INSERT UPDATE DELETE returns false even if no error occurs in 4.0.4
853 1080
 	// also the date format has been changed from YYYY-mm-dd to dd MMM YYYY in 4.0.4. Idiot!
854
-	function _fetch($ignore_fields=false) 
1081
+	function _fetch($ignore_fields=false)
855 1082
 	{
856
-		if ($this->fetchMode & ADODB_FETCH_ASSOC) {
857
-			if ($this->fetchMode & ADODB_FETCH_NUM) {
1083
+		if ($this->fetchMode & ADODB_FETCH_ASSOC)
1084
+		{
1085
+			if ($this->fetchMode & ADODB_FETCH_NUM)
1086
+			{
858 1087
 				//ADODB_FETCH_BOTH mode
859 1088
 				$this->fields = @mssql_fetch_array($this->_queryID);
860
-			} else {
861
-				if ($this->hasFetchAssoc) // only for PHP 4.2.0 or later
1089
+			}
1090
+			else
1091
+			{
1092
+				if ($this->hasFetchAssoc)
1093
+				{
1094
+					// only for PHP 4.2.0 or later
862 1095
 					$this->fields = @mssql_fetch_assoc($this->_queryID);
863
-				else {
1096
+				}
1097
+				else
1098
+				{
864 1099
 					$this->fields = @mssql_fetch_array($this->_queryID);
865
-					if (@is_array($$this->fields)) {
1100
+					if (@is_array($$this->fields))
1101
+					{
866 1102
 						$fassoc = array();
867
-						foreach($$this->fields as $k => $v) {
868
-							if (is_integer($k)) continue;
1103
+						foreach($$this->fields as $k => $v)
1104
+						{
1105
+							if (is_integer($k))
1106
+							{
1107
+								continue;
1108
+							}
869 1109
 							$fassoc[$k] = $v;
870 1110
 						}
871 1111
 						$this->fields = $fassoc;
@@ -873,17 +1113,26 @@  discard block
 block discarded – undo
873 1113
 				}
874 1114
 			}
875 1115
 			
876
-			if (!$this->fields) {
877
-			} else if (ADODB_ASSOC_CASE == 0) {
878
-				foreach($this->fields as $k=>$v) {
1116
+			if (!$this->fields)
1117
+			{
1118
+			}
1119
+			else if (ADODB_ASSOC_CASE == 0)
1120
+			{
1121
+				foreach($this->fields as $k=>$v)
1122
+				{
879 1123
 					$this->fields[strtolower($k)] = $v;
880 1124
 				}
881
-			} else if (ADODB_ASSOC_CASE == 1) {
882
-				foreach($this->fields as $k=>$v) {
1125
+			}
1126
+			else if (ADODB_ASSOC_CASE == 1)
1127
+			{
1128
+				foreach($this->fields as $k=>$v)
1129
+				{
883 1130
 					$this->fields[strtoupper($k)] = $v;
884 1131
 				}
885 1132
 			}
886
-		} else {
1133
+		}
1134
+		else
1135
+		{
887 1136
 			$this->fields = @mssql_fetch_row($this->_queryID);
888 1137
 		}
889 1138
 		return $this->fields;
@@ -892,7 +1141,7 @@  discard block
 block discarded – undo
892 1141
 	/*	close() only needs to be called if you are worried about using too much memory while your script
893 1142
 		is running. All associated result memory for the specified result identifier will automatically be freed.	*/
894 1143
 
895
-	function _close() 
1144
+	function _close()
896 1145
 	{
897 1146
 		$rez = mssql_free_result($this->_queryID);	
898 1147
 		$this->_queryID = false;
@@ -912,8 +1161,9 @@  discard block
 block discarded – undo
912 1161
 }
913 1162
 
914 1163
 
915
-class ADORecordSet_array_mssql extends ADORecordSet_array {
916
-	function ADORecordSet_array_mssql($id=-1,$mode=false) 
1164
+class ADORecordSet_array_mssql extends ADORecordSet_array
1165
+{
1166
+	function ADORecordSet_array_mssql($id=-1,$mode=false)
917 1167
 	{
918 1168
 		$this->ADORecordSet_array($id,$mode);
919 1169
 	}
@@ -922,30 +1172,47 @@  discard block
 block discarded – undo
922 1172
 	function UnixDate($v)
923 1173
 	{
924 1174
 	
925
-		if (is_numeric(substr($v,0,1)) && ADODB_PHPVER >= 0x4200) return parent::UnixDate($v);
1175
+		if (is_numeric(substr($v,0,1)) && ADODB_PHPVER >= 0x4200)
1176
+		{
1177
+			return parent::UnixDate($v);
1178
+		}
926 1179
 		
927 1180
 	global $ADODB_mssql_mths,$ADODB_mssql_date_order;
928 1181
 	
929 1182
 		//Dec 30 2000 12:00AM 
930
-		if ($ADODB_mssql_date_order == 'dmy') {
931
-			if (!preg_match( "|^([0-9]{1,2})[-/\. ]+([A-Za-z]{3})[-/\. ]+([0-9]{4})|" ,$v, $rr)) {
1183
+		if ($ADODB_mssql_date_order == 'dmy')
1184
+		{
1185
+			if (!preg_match( "|^([0-9]{1,2})[-/\. ]+([A-Za-z]{3})[-/\. ]+([0-9]{4})|" ,$v, $rr))
1186
+			{
932 1187
 				return parent::UnixDate($v);
933 1188
 			}
934
-			if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
1189
+			if ($rr[3] <= TIMESTAMP_FIRST_YEAR)
1190
+			{
1191
+				return 0;
1192
+			}
935 1193
 			
936 1194
 			$theday = $rr[1];
937 1195
 			$themth =  substr(strtoupper($rr[2]),0,3);
938
-		} else {
939
-			if (!preg_match( "|^([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4})|" ,$v, $rr)) {
1196
+		}
1197
+		else
1198
+		{
1199
+			if (!preg_match( "|^([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4})|" ,$v, $rr))
1200
+			{
940 1201
 				return parent::UnixDate($v);
941 1202
 			}
942
-			if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
1203
+			if ($rr[3] <= TIMESTAMP_FIRST_YEAR)
1204
+			{
1205
+				return 0;
1206
+			}
943 1207
 			
944 1208
 			$theday = $rr[2];
945 1209
 			$themth = substr(strtoupper($rr[1]),0,3);
946 1210
 		}
947 1211
 		$themth = $ADODB_mssql_mths[$themth];
948
-		if ($themth <= 0) return false;
1212
+		if ($themth <= 0)
1213
+		{
1214
+			return false;
1215
+		}
949 1216
 		// h-m-s-MM-DD-YY
950 1217
 		return  mktime(0,0,0,$themth,$theday,$rr[3]);
951 1218
 	}
@@ -953,36 +1220,64 @@  discard block
 block discarded – undo
953 1220
 	function UnixTimeStamp($v)
954 1221
 	{
955 1222
 	
956
-		if (is_numeric(substr($v,0,1)) && ADODB_PHPVER >= 0x4200) return parent::UnixTimeStamp($v);
1223
+		if (is_numeric(substr($v,0,1)) && ADODB_PHPVER >= 0x4200)
1224
+		{
1225
+			return parent::UnixTimeStamp($v);
1226
+		}
957 1227
 		
958 1228
 	global $ADODB_mssql_mths,$ADODB_mssql_date_order;
959 1229
 	
960 1230
 		//Dec 30 2000 12:00AM
961
-		 if ($ADODB_mssql_date_order == 'dmy') {
1231
+		 if ($ADODB_mssql_date_order == 'dmy')
1232
+		 {
962 1233
 			 if (!preg_match( "|^([0-9]{1,2})[-/\. ]+([A-Za-z]{3})[-/\. ]+([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})|"
963
-			,$v, $rr)) return parent::UnixTimeStamp($v);
964
-			if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
1234
+			,$v, $rr))
1235
+			 {
1236
+			 	return parent::UnixTimeStamp($v);
1237
+			 }
1238
+			if ($rr[3] <= TIMESTAMP_FIRST_YEAR)
1239
+			{
1240
+				return 0;
1241
+			}
965 1242
 		
966 1243
 			$theday = $rr[1];
967 1244
 			$themth =  substr(strtoupper($rr[2]),0,3);
968
-		} else {
1245
+		}
1246
+		else
1247
+		{
969 1248
 			if (!preg_match( "|^([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})|"
970
-			,$v, $rr)) return parent::UnixTimeStamp($v);
971
-			if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
1249
+			,$v, $rr))
1250
+			{
1251
+				return parent::UnixTimeStamp($v);
1252
+			}
1253
+			if ($rr[3] <= TIMESTAMP_FIRST_YEAR)
1254
+			{
1255
+				return 0;
1256
+			}
972 1257
 		
973 1258
 			$theday = $rr[2];
974 1259
 			$themth = substr(strtoupper($rr[1]),0,3);
975 1260
 		}
976 1261
 		
977 1262
 		$themth = $ADODB_mssql_mths[$themth];
978
-		if ($themth <= 0) return false;
1263
+		if ($themth <= 0)
1264
+		{
1265
+			return false;
1266
+		}
979 1267
 		
980
-		switch (strtoupper($rr[6])) {
1268
+		switch (strtoupper($rr[6]))
1269
+		{
981 1270
 		case 'P':
982
-			if ($rr[4]<12) $rr[4] += 12;
1271
+			if ($rr[4]<12)
1272
+			{
1273
+				$rr[4] += 12;
1274
+			}
983 1275
 			break;
984 1276
 		case 'A':
985
-			if ($rr[4]==12) $rr[4] = 0;
1277
+			if ($rr[4]==12)
1278
+			{
1279
+				$rr[4] = 0;
1280
+			}
986 1281
 			break;
987 1282
 		default:
988 1283
 			break;
Please login to merge, or discard this patch.
Upper-Lower-Casing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -629,10 +629,10 @@  discard block
 block discarded – undo
629 629
 	{
630 630
 	
631 631
 		if (strtoupper($blobtype) == 'CLOB') {
632
-			$sql = "UPDATE $table SET $column='" . $val . "' WHERE $where";
632
+			$sql = "update $table SET $column='" . $val . "' WHERE $where";
633 633
 			return $this->Execute($sql) != false;
634 634
 		}
635
-		$sql = "UPDATE $table SET $column=0x".bin2hex($val)." WHERE $where";
635
+		$sql = "update $table SET $column=0x".bin2hex($val)." WHERE $where";
636 636
 		return $this->Execute($sql) != false;
637 637
 	}
638 638
 	
@@ -743,7 +743,7 @@  discard block
 block discarded – undo
743 743
 	
744 744
 	function _initrs()
745 745
 	{
746
-	GLOBAL $ADODB_COUNTRECS;	
746
+	global $ADODB_COUNTRECS;	
747 747
 		$this->_numOfRows = ($ADODB_COUNTRECS)? @mssql_num_rows($this->_queryID):-1;
748 748
 		$this->_numOfFields = @mssql_num_fields($this->_queryID);
749 749
 	}
Please login to merge, or discard this patch.