summaryrefslogtreecommitdiffstats
path: root/system/database/DB_forge.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/DB_forge.php
parent5b2d2da5ae2e97043c6bef53e565d30e50196e2b (diff)
parente1f6e9ddff788f6a154f5f35dc117d14aeb0c484 (diff)
Automated merge with http://hg.ellislab.com/CodeIgniter2
Diffstat (limited to 'system/database/DB_forge.php')
-rw-r--r--system/database/DB_forge.php72
1 files changed, 36 insertions, 36 deletions
diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php
index 8be65e0d6..74aed8610 100644
--- a/system/database/DB_forge.php
+++ b/system/database/DB_forge.php
@@ -24,9 +24,9 @@
*/
class CI_DB_forge {
- var $fields = array();
+ var $fields = array();
var $keys = array();
- var $primary_keys = array();
+ var $primary_keys = array();
var $db_char_set = '';
/**
@@ -34,7 +34,7 @@ class CI_DB_forge {
*
* Grabs the CI super object instance so we can access it.
*
- */
+ */
function CI_DB_forge()
{
// Assign the main database object to $this->db
@@ -55,12 +55,12 @@ class CI_DB_forge {
function create_database($db_name)
{
$sql = $this->_create_database($db_name);
-
+
if (is_bool($sql))
{
return $sql;
}
-
+
return $this->db->query($sql);
}
@@ -76,12 +76,12 @@ class CI_DB_forge {
function drop_database($db_name)
{
$sql = $this->_drop_database($db_name);
-
+
if (is_bool($sql))
{
return $sql;
}
-
+
return $this->db->query($sql);
}
@@ -103,15 +103,15 @@ class CI_DB_forge {
{
$this->add_key($one, $primary);
}
-
+
return;
}
-
+
if ($key == '')
{
show_error('Key information is required for that operation.');
}
-
+
if ($primary === TRUE)
{
$this->primary_keys[] = $key;
@@ -137,7 +137,7 @@ class CI_DB_forge {
{
show_error('Field information is required.');
}
-
+
if (is_string($field))
{
if ($field == 'id')
@@ -157,16 +157,16 @@ class CI_DB_forge {
{
show_error('Field information is required for that operation.');
}
-
+
$this->fields[] = $field;
}
}
-
+
if (is_array($field))
{
$this->fields = array_merge($this->fields, $field);
}
-
+
}
// --------------------------------------------------------------------
@@ -179,19 +179,19 @@ class CI_DB_forge {
* @return bool
*/
function create_table($table = '', $if_not_exists = FALSE)
- {
+ {
if ($table == '')
{
show_error('A table name is required for that operation.');
}
-
+
if (count($this->fields) == 0)
- {
+ {
show_error('Field information is required.');
}
$sql = $this->_create_table($this->db->dbprefix.$table, $this->fields, $this->primary_keys, $this->keys, $if_not_exists);
-
+
$this->_reset();
return $this->db->query($sql);
}
@@ -208,12 +208,12 @@ class CI_DB_forge {
function drop_table($table_name)
{
$sql = $this->_drop_table($this->db->dbprefix.$table_name);
-
+
if (is_bool($sql))
{
return $sql;
}
-
+
return $this->db->query($sql);
}
@@ -233,7 +233,7 @@ class CI_DB_forge {
{
show_error('A table name is required for that operation.');
}
-
+
$sql = $this->_rename_table($table_name, $new_table_name);
return $this->db->query($sql);
}
@@ -259,25 +259,25 @@ class CI_DB_forge {
// add field info into field array, but we can only do one at a time
// so we cycle through
- foreach ($field as $k => $v)
- {
- $this->add_field(array($k => $field[$k]));
+ foreach ($field as $k => $v)
+ {
+ $this->add_field(array($k => $field[$k]));
if (count($this->fields) == 0)
- {
+ {
show_error('Field information is required.');
}
-
+
$sql = $this->_alter_table('ADD', $this->db->dbprefix.$table, $this->fields, $after_field);
$this->_reset();
-
+
if ($this->db->query($sql) === FALSE)
{
return FALSE;
}
}
-
+
return TRUE;
}
@@ -294,7 +294,7 @@ class CI_DB_forge {
*/
function drop_column($table = '', $column_name = '')
{
-
+
if ($table == '')
{
show_error('A table name is required for that operation.');
@@ -306,7 +306,7 @@ class CI_DB_forge {
}
$sql = $this->_alter_table('DROP', $this->db->dbprefix.$table, $column_name);
-
+
return $this->db->query($sql);
}
@@ -336,20 +336,20 @@ class CI_DB_forge {
$this->add_field(array($k => $field[$k]));
if (count($this->fields) == 0)
- {
+ {
show_error('Field information is required.');
}
-
+
$sql = $this->_alter_table('CHANGE', $this->db->dbprefix.$table, $this->fields);
$this->_reset();
-
+
if ($this->db->query($sql) === FALSE)
{
return FALSE;
}
}
-
+
return TRUE;
}
@@ -365,9 +365,9 @@ class CI_DB_forge {
*/
function _reset()
{
- $this->fields = array();
+ $this->fields = array();
$this->keys = array();
- $this->primary_keys = array();
+ $this->primary_keys = array();
}
}