summaryrefslogtreecommitdiffstats
path: root/system/database/drivers/mysql/mysql_utility.php
diff options
context:
space:
mode:
authorPascal Kriete <pascal.kriete@ellislab.com>2010-11-04 22:59:52 +0100
committerPascal Kriete <pascal.kriete@ellislab.com>2010-11-04 22:59:52 +0100
commite917f9be8b05c81357c1c2c9730d5060685d644d (patch)
treeb6a7d5ce8ba57b69ba61454f77829b04f2ce5974 /system/database/drivers/mysql/mysql_utility.php
parent5b2d2da5ae2e97043c6bef53e565d30e50196e2b (diff)
parente1f6e9ddff788f6a154f5f35dc117d14aeb0c484 (diff)
Automated merge with http://hg.ellislab.com/CodeIgniter2
Diffstat (limited to 'system/database/drivers/mysql/mysql_utility.php')
-rw-r--r--system/database/drivers/mysql/mysql_utility.php46
1 files changed, 23 insertions, 23 deletions
diff --git a/system/database/drivers/mysql/mysql_utility.php b/system/database/drivers/mysql/mysql_utility.php
index c4a970cfd..3b574c6f4 100644
--- a/system/database/drivers/mysql/mysql_utility.php
+++ b/system/database/drivers/mysql/mysql_utility.php
@@ -84,7 +84,7 @@ class CI_DB_mysql_utility extends CI_DB_utility {
// Extract the prefs for simplicity
extract($params);
-
+
// Build the output
$output = '';
foreach ((array)$tables as $table)
@@ -97,31 +97,31 @@ class CI_DB_mysql_utility extends CI_DB_utility {
// Get the table schema
$query = $this->db->query("SHOW CREATE TABLE `".$this->db->database.'`.'.$table);
-
+
// No result means the table name was invalid
if ($query === FALSE)
{
continue;
}
-
+
// Write out the table schema
$output .= '#'.$newline.'# TABLE STRUCTURE FOR: '.$table.$newline.'#'.$newline.$newline;
- if ($add_drop == TRUE)
- {
+ if ($add_drop == TRUE)
+ {
$output .= 'DROP TABLE IF EXISTS '.$table.';'.$newline.$newline;
}
-
+
$i = 0;
$result = $query->result_array();
foreach ($result[0] as $val)
{
if ($i++ % 2)
- {
+ {
$output .= $val.';'.$newline.$newline;
}
}
-
+
// If inserts are not needed we're done...
if ($add_insert == FALSE)
{
@@ -130,16 +130,16 @@ class CI_DB_mysql_utility extends CI_DB_utility {
// Grab all the data from the current table
$query = $this->db->query("SELECT * FROM $table");
-
+
if ($query->num_rows() == 0)
{
continue;
}
-
+
// Fetch the field names and determine if the field is an
// integer type. We use this info to decide whether to
// surround the data with quotes or not
-
+
$i = 0;
$field_str = '';
$is_int = array();
@@ -148,24 +148,24 @@ class CI_DB_mysql_utility extends CI_DB_utility {
// Most versions of MySQL store timestamp as a string
$is_int[$i] = (in_array(
strtolower(mysql_field_type($query->result_id, $i)),
- array('tinyint', 'smallint', 'mediumint', 'int', 'bigint'), //, 'timestamp'),
+ array('tinyint', 'smallint', 'mediumint', 'int', 'bigint'), //, 'timestamp'),
TRUE)
) ? TRUE : FALSE;
-
+
// Create a string of field names
$field_str .= '`'.$field->name.'`, ';
$i++;
}
-
+
// Trim off the end comma
$field_str = preg_replace( "/, $/" , "" , $field_str);
-
-
+
+
// Build the insert string
foreach ($query->result_array() as $row)
{
$val_str = '';
-
+
$i = 0;
foreach ($row as $v)
{
@@ -184,21 +184,21 @@ class CI_DB_mysql_utility extends CI_DB_utility {
else
{
$val_str .= $v;
- }
- }
-
+ }
+ }
+
// Append a comma
$val_str .= ', ';
$i++;
}
-
+
// Remove the comma at the end of the string
$val_str = preg_replace( "/, $/" , "" , $val_str);
-
+
// Build the INSERT string
$output .= 'INSERT INTO '.$table.' ('.$field_str.') VALUES ('.$val_str.');'.$newline;
}
-
+
$output .= $newline.$newline;
}