Skip to content
This repository
Browse code

Moving shared method from DboMysqli and DboMysql up to DboMysqlBase. …

…Fixes #358
  • Loading branch information...
commit 64dffb76632d316a50e178c4be69d48f5f3abf00 1 parent 51d0805
Mark Story authored November 24, 2009
94  cake/libs/model/datasources/dbo/dbo_mysql.php
@@ -363,6 +363,53 @@ function insertMulti($table, $fields, $values) {
363 363
 		$values = implode(', ', $values);
364 364
 		$this->query("INSERT INTO {$table} ({$fields}) VALUES {$values}");
365 365
 	}
  366
+/**
  367
+ * Converts database-layer column types to basic types
  368
+ *
  369
+ * @param string $real Real database-layer column type (i.e. "varchar(255)")
  370
+ * @return string Abstract column type (i.e. "string")
  371
+ */
  372
+	function column($real) {
  373
+		if (is_array($real)) {
  374
+			$col = $real['name'];
  375
+			if (isset($real['limit'])) {
  376
+				$col .= '('.$real['limit'].')';
  377
+			}
  378
+			return $col;
  379
+		}
  380
+
  381
+		$col = str_replace(')', '', $real);
  382
+		$limit = $this->length($real);
  383
+		if (strpos($col, '(') !== false) {
  384
+			list($col, $vals) = explode('(', $col);
  385
+		}
  386
+
  387
+		if (in_array($col, array('date', 'time', 'datetime', 'timestamp'))) {
  388
+			return $col;
  389
+		}
  390
+		if (($col == 'tinyint' && $limit == 1) || $col == 'boolean') {
  391
+			return 'boolean';
  392
+		}
  393
+		if (strpos($col, 'int') !== false) {
  394
+			return 'integer';
  395
+		}
  396
+		if (strpos($col, 'char') !== false || $col == 'tinytext') {
  397
+			return 'string';
  398
+		}
  399
+		if (strpos($col, 'text') !== false) {
  400
+			return 'text';
  401
+		}
  402
+		if (strpos($col, 'blob') !== false || $col == 'binary') {
  403
+			return 'binary';
  404
+		}
  405
+		if (strpos($col, 'float') !== false || strpos($col, 'double') !== false || strpos($col, 'decimal') !== false) {
  406
+			return 'float';
  407
+		}
  408
+		if (strpos($col, 'enum') !== false) {
  409
+			return "enum($vals)";
  410
+		}
  411
+		return 'text';
  412
+	}
366 413
 }
367 414
 
368 415
 /**
@@ -570,53 +617,6 @@ function lastInsertId($source = null) {
570 617
 		return null;
571 618
 	}
572 619
 /**
573  
- * Converts database-layer column types to basic types
574  
- *
575  
- * @param string $real Real database-layer column type (i.e. "varchar(255)")
576  
- * @return string Abstract column type (i.e. "string")
577  
- */
578  
-	function column($real) {
579  
-		if (is_array($real)) {
580  
-			$col = $real['name'];
581  
-			if (isset($real['limit'])) {
582  
-				$col .= '('.$real['limit'].')';
583  
-			}
584  
-			return $col;
585  
-		}
586  
-
587  
-		$col = str_replace(')', '', $real);
588  
-		$limit = $this->length($real);
589  
-		if (strpos($col, '(') !== false) {
590  
-			list($col, $vals) = explode('(', $col);
591  
-		}
592  
-
593  
-		if (in_array($col, array('date', 'time', 'datetime', 'timestamp'))) {
594  
-			return $col;
595  
-		}
596  
-		if (($col == 'tinyint' && $limit == 1) || $col == 'boolean') {
597  
-			return 'boolean';
598  
-		}
599  
-		if (strpos($col, 'int') !== false) {
600  
-			return 'integer';
601  
-		}
602  
-		if (strpos($col, 'char') !== false || $col == 'tinytext') {
603  
-			return 'string';
604  
-		}
605  
-		if (strpos($col, 'text') !== false) {
606  
-			return 'text';
607  
-		}
608  
-		if (strpos($col, 'blob') !== false || $col == 'binary') {
609  
-			return 'binary';
610  
-		}
611  
-		if (strpos($col, 'float') !== false || strpos($col, 'double') !== false || strpos($col, 'decimal') !== false) {
612  
-			return 'float';
613  
-		}
614  
-		if (strpos($col, 'enum') !== false) {
615  
-			return "enum($vals)";
616  
-		}
617  
-		return 'text';
618  
-	}
619  
-/**
620 620
  * Enter description here...
621 621
  *
622 622
  * @param unknown_type $results
47  cake/libs/model/datasources/dbo/dbo_mysqli.php
@@ -252,53 +252,6 @@ function lastInsertId($source = null) {
252 252
 		return null;
253 253
 	}
254 254
 /**
255  
- * Converts database-layer column types to basic types
256  
- *
257  
- * @param string $real Real database-layer column type (i.e. "varchar(255)")
258  
- * @return string Abstract column type (i.e. "string")
259  
- */
260  
-	function column($real) {
261  
-		if (is_array($real)) {
262  
-			$col = $real['name'];
263  
-			if (isset($real['limit'])) {
264  
-				$col .= '('.$real['limit'].')';
265  
-			}
266  
-			return $col;
267  
-		}
268  
-
269  
-		$col = str_replace(')', '', $real);
270  
-		$limit = $this->length($real);
271  
-		if (strpos($col, '(') !== false) {
272  
-			list($col, $vals) = explode('(', $col);
273  
-		}
274  
-
275  
-		if (in_array($col, array('date', 'time', 'datetime', 'timestamp'))) {
276  
-			return $col;
277  
-		}
278  
-		if (($col == 'tinyint' && $limit == 1) || $col == 'boolean') {
279  
-			return 'boolean';
280  
-		}
281  
-		if (strpos($col, 'int') !== false) {
282  
-			return 'integer';
283  
-		}
284  
-		if (strpos($col, 'char') !== false || $col == 'tinytext') {
285  
-			return 'string';
286  
-		}
287  
-		if (strpos($col, 'text') !== false) {
288  
-			return 'text';
289  
-		}
290  
-		if (strpos($col, 'blob') !== false || $col == 'binary') {
291  
-			return 'binary';
292  
-		}
293  
-		if (strpos($col, 'float') !== false || strpos($col, 'double') !== false || strpos($col, 'decimal') !== false) {
294  
-			return 'float';
295  
-		}
296  
-		if (strpos($col, 'enum') !== false) {
297  
-			return "enum($vals)";
298  
-		}
299  
-		return 'text';
300  
-	}
301  
-/**
302 255
  * Enter description here...
303 256
  *
304 257
  * @param unknown_type $results

0 notes on commit 64dffb7

Please sign in to comment.
Something went wrong with that request. Please try again.