summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
authoradmin <devnull@localhost>2006-10-01 05:38:04 +0200
committeradmin <devnull@localhost>2006-10-01 05:38:04 +0200
commitb2a9ceccdb85050cb494e6d0a98b0a49495d29bb (patch)
tree16307166046e516304e5d38a072b6e8534657927 /system
parent0e42554740e2256eb9bf33bfb2f91788a99a1348 (diff)
Diffstat (limited to 'system')
-rw-r--r--system/codeigniter/Common.php6
-rw-r--r--system/database/DB_driver.php45
-rw-r--r--system/database/DB_utility.php29
-rw-r--r--system/database/drivers/mssql/mssql_driver.php13
-rw-r--r--system/database/drivers/mssql/mssql_utility.php13
-rw-r--r--system/database/drivers/mysql/mysql_driver.php13
-rw-r--r--system/database/drivers/mysql/mysql_utility.php16
-rw-r--r--system/database/drivers/mysqli/mysqli_driver.php13
-rw-r--r--system/database/drivers/mysqli/mysqli_utility.php13
-rw-r--r--system/database/drivers/oci8/oci8_driver.php13
-rw-r--r--system/database/drivers/oci8/oci8_utility.php13
-rw-r--r--system/database/drivers/odbc/odbc_driver.php18
-rw-r--r--system/database/drivers/odbc/odbc_utility.php18
-rw-r--r--system/database/drivers/postgre/postgre_driver.php13
-rw-r--r--system/database/drivers/postgre/postgre_utility.php13
-rw-r--r--system/database/drivers/sqlite/sqlite_driver.php22
-rw-r--r--system/database/drivers/sqlite/sqlite_utility.php22
17 files changed, 152 insertions, 141 deletions
diff --git a/system/codeigniter/Common.php b/system/codeigniter/Common.php
index 124ad9a38..d2342de42 100644
--- a/system/codeigniter/Common.php
+++ b/system/codeigniter/Common.php
@@ -72,7 +72,7 @@ function &_load_class($class, $instantiate = TRUE)
// identically named file in the application/libraries folder. 
// We need to determine, however, if the class being requested is
// a sub-class of an existing library or an independent instance
- // since each needs to be handled slightly differently. 
+ // since each needs to be handled slightly different. 
// To do this we'll open the requested class and read the top portion
// of it. If the class extends a base class we will load the base first.
// If it doesn't extend the base we'll only load the requested class.
@@ -84,12 +84,12 @@ function &_load_class($class, $instantiate = TRUE)
// replaced on-the-fly with nothing required for the user to do
// except write the declaration.  Fortunately PHP is ridiculously fast
// at file reading operations so I'm not able to discern a performance
- // hit based on my benchmarks, assuming a reasonable number of core
+ // hit based on my benchmarks, assuming only a small number of core
// files are being extended, which will usually be the case.
$fp = fopen(APPPATH.'libraries/'.$class.EXT, "rb");
- if (preg_match("/MY_".$class."\s+extends\s+CI_".$class."/", fread($fp, '6000')))
+ if (preg_match("/MY_".$class."\s+extends\s+CI_".$class."/i", fread($fp, '6000')))
{
require(BASEPATH.'libraries/'.$class.EXT);
require(APPPATH.'libraries/'.$class.EXT);
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index 5102cc74c..81af466ef 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -555,37 +555,6 @@ class CI_DB_driver {
// --------------------------------------------------------------------
- // --------------------------------------------------------------------
-
- /**
- * List databases
- *
- * @access public
- * @return bool
- */
- function list_databases()
- {
- // Is there a cached result?
- if (isset($this->cache['db_names']))
- {
- return $this->cache['db_names'];
- }
-
- $query = $this->query($this->_list_database());
- $dbs = array();
- if ($query->num_rows() > 0)
- {
- foreach ($query->result_array() as $row)
- {
- $dbs[] = current($row);
- }
- }
-
- return $this->cache['db_names'] =& $dbs;
- }
-
- // --------------------------------------------------------------------
-
/**
* Returns an array of table names
*
@@ -694,6 +663,20 @@ class CI_DB_driver {
return $this->cache['field_names'][$table] =& $retval;
}
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Determine if a particular field exists
+ * @access public
+ * @param string
+ * @param string
+ * @return boolean
+ */
+ function field_exists($field_name, $table_name)
+ {
+ return ( ! in_array($field_name, $this->list_fields($table_name))) ? FALSE : TRUE;
+ }
// --------------------------------------------------------------------
diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php
index dc56d6524..e568bce02 100644
--- a/system/database/DB_utility.php
+++ b/system/database/DB_utility.php
@@ -87,6 +87,35 @@ class CI_DB_utility {
// --------------------------------------------------------------------
/**
+ * List databases
+ *
+ * @access public
+ * @return bool
+ */
+ function list_databases()
+ {
+ // Is there a cached result?
+ if (isset($this->cache['db_names']))
+ {
+ return $this->cache['db_names'];
+ }
+
+ $query = $this->db->query($this->_list_database());
+ $dbs = array();
+ if ($query->num_rows() > 0)
+ {
+ foreach ($query->result_array() as $row)
+ {
+ $dbs[] = current($row);
+ }
+ }
+
+ return $this->cache['db_names'] =& $dbs;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Optimize Table
*
* @access public
diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php
index 8b82ee314..cb2f48dc3 100644
--- a/system/database/drivers/mssql/mssql_driver.php
+++ b/system/database/drivers/mssql/mssql_driver.php
@@ -258,19 +258,6 @@ class CI_DB_mssql_driver extends CI_DB {
$row = $query->row();
return $row->numrows;
}
-
- // --------------------------------------------------------------------
-
- /**
- * List databases
- *
- * @access private
- * @return bool
- */
- function _list_databases()
- {
- return "EXEC sp_helpdb"; // Can also be: EXEC sp_databases
- }
// --------------------------------------------------------------------
diff --git a/system/database/drivers/mssql/mssql_utility.php b/system/database/drivers/mssql/mssql_utility.php
index ad13167cd..388dbe1c2 100644
--- a/system/database/drivers/mssql/mssql_utility.php
+++ b/system/database/drivers/mssql/mssql_utility.php
@@ -67,6 +67,19 @@ class CI_DB_mssql_utility extends CI_DB_utility {
// --------------------------------------------------------------------
/**
+ * List databases
+ *
+ * @access private
+ * @return bool
+ */
+ function _list_databases()
+ {
+ return "EXEC sp_helpdb"; // Can also be: EXEC sp_databases
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Optimize table query
*
* Generates a platform-specific query so that a table can be optimized
diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php
index ecab648d4..253627cd9 100644
--- a/system/database/drivers/mysql/mysql_driver.php
+++ b/system/database/drivers/mysql/mysql_driver.php
@@ -296,19 +296,6 @@ class CI_DB_mysql_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * List databases
- *
- * @access private
- * @return bool
- */
- function _list_databases()
- {
- return "SHOW DATABASES";
- }
-
- // --------------------------------------------------------------------
-
- /**
* List table query
*
* Generates a platform-specific query string so that the table names can be fetched
diff --git a/system/database/drivers/mysql/mysql_utility.php b/system/database/drivers/mysql/mysql_utility.php
index a81c915f6..b387ace9e 100644
--- a/system/database/drivers/mysql/mysql_utility.php
+++ b/system/database/drivers/mysql/mysql_utility.php
@@ -53,6 +53,19 @@ class CI_DB_mysql_utility extends CI_DB_utility {
// --------------------------------------------------------------------
/**
+ * List databases
+ *
+ * @access private
+ * @return bool
+ */
+ function _list_databases()
+ {
+ return "SHOW DATABASES";
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Drop Table
*
* @access private
@@ -101,7 +114,7 @@ class CI_DB_mysql_utility extends CI_DB_utility {
* MySQL Export
*
* @access private
- * @param array Any preferences
+ * @param array Preferences
* @return mixed
*/
function _backup($params = array())
@@ -217,7 +230,6 @@ class CI_DB_mysql_utility extends CI_DB_utility {
// Build the INSERT string
$output .= 'INSERT INTO '.$table.' ('.$field_str.') VALUES ('.$val_str.');'.$newline;
-
}
$output .= $newline.$newline;
diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php
index a2c380355..4fd9f3aaa 100644
--- a/system/database/drivers/mysqli/mysqli_driver.php
+++ b/system/database/drivers/mysqli/mysqli_driver.php
@@ -288,19 +288,6 @@ class CI_DB_mysqli_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * List databases
- *
- * @access private
- * @return bool
- */
- function _list_databases()
- {
- return "SHOW DATABASES";
- }
-
- // --------------------------------------------------------------------
-
- /**
* List table query
*
* Generates a platform-specific query string so that the table names can be fetched
diff --git a/system/database/drivers/mysqli/mysqli_utility.php b/system/database/drivers/mysqli/mysqli_utility.php
index f5b98b11f..a40441d20 100644
--- a/system/database/drivers/mysqli/mysqli_utility.php
+++ b/system/database/drivers/mysqli/mysqli_utility.php
@@ -62,6 +62,19 @@ class CI_DB_mysqli_utility extends CI_DB_utility {
{
return "DROP TABLE IF EXISTS ".$this->db->_escape_table($name);
}
+
+ // --------------------------------------------------------------------
+
+ /**
+ * List databases
+ *
+ * @access private
+ * @return bool
+ */
+ function _list_databases()
+ {
+ return "SHOW DATABASES";
+ }
// --------------------------------------------------------------------
diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php
index b43b4c41f..e83c640bd 100644
--- a/system/database/drivers/oci8/oci8_driver.php
+++ b/system/database/drivers/oci8/oci8_driver.php
@@ -399,19 +399,6 @@ class CI_DB_oci8_driver extends CI_DB {
return $row->NUMROWS;
}
- // --------------------------------------------------------------------
-
- /**
- * List databases
- *
- * @access private
- * @return bool
- */
- function _list_databases()
- {
- return FALSE;
- }
-
// --------------------------------------------------------------------
/**
diff --git a/system/database/drivers/oci8/oci8_utility.php b/system/database/drivers/oci8/oci8_utility.php
index b6503de63..b1d539ad6 100644
--- a/system/database/drivers/oci8/oci8_utility.php
+++ b/system/database/drivers/oci8/oci8_utility.php
@@ -54,6 +54,19 @@ class CI_DB_oci8_utility extends CI_DB_utility {
// --------------------------------------------------------------------
/**
+ * List databases
+ *
+ * @access private
+ * @return bool
+ */
+ function _list_databases()
+ {
+ return FALSE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Drop Table
*
* @access private
diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php
index 0f002cc1b..4bd6e1106 100644
--- a/system/database/drivers/odbc/odbc_driver.php
+++ b/system/database/drivers/odbc/odbc_driver.php
@@ -263,24 +263,6 @@ class CI_DB_odbc_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * List databases
- *
- * @access private
- * @return bool
- */
- function _list_databases()
- {
- // Not sure if ODBC lets you list all databases...
- if ($this->db_debug)
- {
- return $this->display_error('db_unsuported_feature');
- }
- return FALSE;
- }
-
- // --------------------------------------------------------------------
-
- /**
* Show table query
*
* Generates a platform-specific query string so that the table names can be fetched
diff --git a/system/database/drivers/odbc/odbc_utility.php b/system/database/drivers/odbc/odbc_utility.php
index 6d0fb79f1..5a0e365ef 100644
--- a/system/database/drivers/odbc/odbc_utility.php
+++ b/system/database/drivers/odbc/odbc_utility.php
@@ -66,6 +66,24 @@ class CI_DB_odbc_utility extends CI_DB_utility {
// --------------------------------------------------------------------
/**
+ * List databases
+ *
+ * @access private
+ * @return bool
+ */
+ function _list_databases()
+ {
+ // Not sure if ODBC lets you list all databases...
+ if ($this->db->db_debug)
+ {
+ return $this->db->display_error('db_unsuported_feature');
+ }
+ return FALSE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Drop Table
*
* @access private
diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
index f14395638..340d65046 100644
--- a/system/database/drivers/postgre/postgre_driver.php
+++ b/system/database/drivers/postgre/postgre_driver.php
@@ -290,19 +290,6 @@ class CI_DB_postgre_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * List databases
- *
- * @access private
- * @return bool
- */
- function _list_databases()
- {
- return "SELECT datname FROM pg_database";
- }
-
- // --------------------------------------------------------------------
-
- /**
* Show table query
*
* Generates a platform-specific query string so that the table names can be fetched
diff --git a/system/database/drivers/postgre/postgre_utility.php b/system/database/drivers/postgre/postgre_utility.php
index 46c98cc7d..038aa26cd 100644
--- a/system/database/drivers/postgre/postgre_utility.php
+++ b/system/database/drivers/postgre/postgre_utility.php
@@ -54,6 +54,19 @@ class CI_DB_postgre_utility extends CI_DB_utility {
// --------------------------------------------------------------------
/**
+ * List databases
+ *
+ * @access private
+ * @return bool
+ */
+ function _list_databases()
+ {
+ return "SELECT datname FROM pg_database";
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Drop Table
*
* @access private
diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php
index f57c4b8c8..9da50b676 100644
--- a/system/database/drivers/sqlite/sqlite_driver.php
+++ b/system/database/drivers/sqlite/sqlite_driver.php
@@ -282,28 +282,6 @@ class CI_DB_sqlite_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * List databases
- *
- * I don't believe you can do a database listing with SQLite
- * since each database is its own file. I suppose we could
- * try reading a directory looking for SQLite files, but
- * that doesn't seem like a terribly good idea
- *
- * @access private
- * @return bool
- */
- function _list_databases()
- {
- if ($this->db_debug)
- {
- return $this->display_error('db_unsuported_feature');
- }
- return array();
- }
-
- // --------------------------------------------------------------------
-
- /**
* List table query
*
* Generates a platform-specific query string so that the table names can be fetched
diff --git a/system/database/drivers/sqlite/sqlite_utility.php b/system/database/drivers/sqlite/sqlite_utility.php
index 801660d94..19b06bd6d 100644
--- a/system/database/drivers/sqlite/sqlite_utility.php
+++ b/system/database/drivers/sqlite/sqlite_utility.php
@@ -64,6 +64,28 @@ class CI_DB_sqlite_utility extends CI_DB_utility {
// --------------------------------------------------------------------
/**
+ * List databases
+ *
+ * I don't believe you can do a database listing with SQLite
+ * since each database is its own file. I suppose we could
+ * try reading a directory looking for SQLite files, but
+ * that doesn't seem like a terribly good idea
+ *
+ * @access private
+ * @return bool
+ */
+ function _list_databases()
+ {
+ if ($this->db_debug)
+ {
+ return $this->display_error('db_unsuported_feature');
+ }
+ return array();
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Drop Table
*
* Unsupported feature in SQLite