Explorar el Código

Fixes for PHP 5.3

Maurits van der Schee hace 8 años
padre
commit
026f2a12b9
Se han modificado 1 ficheros con 27 adiciones y 7 borrados
  1. 27
    7
      api.php

+ 27
- 7
api.php Ver fichero

@@ -141,12 +141,29 @@ class MySQL implements DatabaseInterface {
141 141
 		return mysqli_query($db,$sql);
142 142
 	}
143 143
 
144
-	public function fetchAssoc($result,$fields=false) {
145
-		return mysqli_fetch_assoc($result);
146
-	}
144
+        protected function convertFloatAndInt($result,&$values, $fields) {
145
+                array_walk($values, function(&$v,$i) use ($result,$fields){
146
+                        $t = $fields[$i]->type;
147
+                        if (is_string($v) && in_array($t,array(1,2,3,4,5,6,8,9))) {
148
+                                $v+=0;
149
+                        }
150
+                });
151
+        }
152
+
153
+        public function fetchAssoc($result,$fields=false) {
154
+                $values = mysqli_fetch_assoc($result);
155
+		if ($values && $fields && !defined('MYSQLI_OPT_INT_AND_FLOAT_NATIVE')) {
156
+                        $this->convertFloatAndInt($result,$values,$fields);
157
+                }
158
+                return $values;
159
+        }
147 160
 
148 161
 	public function fetchRow($result,$fields=false) {
149
-		return mysqli_fetch_row($result);
162
+		$values = mysqli_fetch_row($result);
163
+		if ($values && $fields && !defined('MYSQLI_OPT_INT_AND_FLOAT_NATIVE')) {
164
+                        $this->convertFloatAndInt($result,$values,array_values($fields));
165
+                }
166
+                return $values;
150 167
 	}
151 168
 
152 169
 	public function insertId($result) {
@@ -200,15 +217,18 @@ class MySQL implements DatabaseInterface {
200 217
 	}
201 218
 
202 219
 	public function beginTransaction() {
203
-		return mysqli_begin_transaction($this->db);
220
+		mysqli_query($this->db,'BEGIN');
221
+		//return mysqli_begin_transaction($this->db);
204 222
 	}
205 223
 
206 224
 	public function commitTransaction() {
207
-		return mysqli_commit($this->db);
225
+		mysqli_query($this->db,'COMMIT');
226
+		//return mysqli_commit($this->db);
208 227
 	}
209 228
 
210 229
 	public function rollbackTransaction() {
211
-		return mysqli_rollback($this->db);
230
+		mysqli_query($this->db,'ROLLBACK');
231
+		//return mysqli_rollback($this->db);
212 232
 	}
213 233
 
214 234
 }

Loading…
Cancelar
Guardar