converted to unix-style eol
[www-register-wizard.git] / database / DB.php
index 2b3ff3d..ca0cfc2 100644 (file)
-<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');\r
-/**\r
- * CodeIgniter\r
- *\r
- * An open source application development framework for PHP 4.3.2 or newer\r
- *\r
- * @package            CodeIgniter\r
- * @author             ExpressionEngine Dev Team\r
- * @copyright  Copyright (c) 2008, EllisLab, Inc.\r
- * @license            http://codeigniter.com/user_guide/license.html\r
- * @link               http://codeigniter.com\r
- * @since              Version 1.0\r
- * @filesource\r
- */\r
-\r
-// ------------------------------------------------------------------------\r
-\r
-/**\r
- * Initialize the database\r
- *\r
- * @category   Database\r
- * @author             ExpressionEngine Dev Team\r
- * @link               http://codeigniter.com/user_guide/database/\r
- */\r
-function &DB($params = '', $active_record_override = FALSE)\r
-{\r
-       // Load the DB config file if a DSN string wasn't passed\r
-       if (is_string($params) AND strpos($params, '://') === FALSE)\r
-       {\r
-               include(APPPATH.'config/database'.EXT);\r
-               \r
-               if ( ! isset($db) OR count($db) == 0)\r
-               {\r
-                       show_error('No database connection settings were found in the database config file.');\r
-               }\r
-               \r
-               if ($params != '')\r
-               {\r
-                       $active_group = $params;\r
-               }\r
-               \r
-               if ( ! isset($active_group) OR ! isset($db[$active_group]))\r
-               {\r
-                       show_error('You have specified an invalid database connection group.');\r
-               }\r
-               \r
-               $params = $db[$active_group];\r
-       }\r
-       elseif (is_string($params))\r
-       {\r
-               \r
-               /* parse the URL from the DSN string\r
-               *  Database settings can be passed as discreet\r
-               *  parameters or as a data source name in the first\r
-               *  parameter. DSNs must have this prototype:\r
-               *  $dsn = 'driver://username:password@hostname/database';\r
-               */\r
-       \r
-               if (($dns = @parse_url($params)) === FALSE)\r
-               {\r
-                       show_error('Invalid DB Connection String');\r
-               }\r
-               \r
-               $params = array(\r
-                                                       'dbdriver'      => $dns['scheme'],\r
-                                                       'hostname'      => (isset($dns['host'])) ? rawurldecode($dns['host']) : '',\r
-                                                       'username'      => (isset($dns['user'])) ? rawurldecode($dns['user']) : '',\r
-                                                       'password'      => (isset($dns['pass'])) ? rawurldecode($dns['pass']) : '',\r
-                                                       'database'      => (isset($dns['path'])) ? rawurldecode(substr($dns['path'], 1)) : ''\r
-                                               );\r
-               \r
-               // were additional config items set?\r
-               if (isset($dns['query']))\r
-               {\r
-                       parse_str($dns['query'], $extra);\r
-\r
-                       foreach($extra as $key => $val)\r
-                       {\r
-                               // booleans please\r
-                               if (strtoupper($val) == "TRUE")\r
-                               {\r
-                                       $val = TRUE;\r
-                               }\r
-                               elseif (strtoupper($val) == "FALSE")\r
-                               {\r
-                                       $val = FALSE;\r
-                               }\r
-\r
-                               $params[$key] = $val;\r
-                       }\r
-               }\r
-       }\r
-       \r
-       // No DB specified yet?  Beat them senseless...\r
-       if ( ! isset($params['dbdriver']) OR $params['dbdriver'] == '')\r
-       {\r
-               show_error('You have not selected a database type to connect to.');\r
-       }\r
-\r
-       // Load the DB classes.  Note: Since the active record class is optional\r
-       // we need to dynamically create a class that extends proper parent class\r
-       // based on whether we're using the active record class or not.\r
-       // Kudos to Paul for discovering this clever use of eval()\r
-       \r
-       if ($active_record_override == TRUE)\r
-       {\r
-               $active_record = TRUE;\r
-       }\r
-       \r
-       require_once(BASEPATH.'database/DB_driver'.EXT);\r
-\r
-       if ( ! isset($active_record) OR $active_record == TRUE)\r
-       {\r
-               require_once(BASEPATH.'database/DB_active_rec'.EXT);\r
-               \r
-               if ( ! class_exists('CI_DB'))\r
-               {\r
-                       eval('class CI_DB extends CI_DB_active_record { }');\r
-               }\r
-       }\r
-       else\r
-       {\r
-               if ( ! class_exists('CI_DB'))\r
-               {\r
-                       eval('class CI_DB extends CI_DB_driver { }');\r
-               }\r
-       }\r
-                       \r
-       require_once(BASEPATH.'database/drivers/'.$params['dbdriver'].'/'.$params['dbdriver'].'_driver'.EXT);\r
-\r
-       // Instantiate the DB adapter\r
-       $driver = 'CI_DB_'.$params['dbdriver'].'_driver';\r
-       $DB =& new $driver($params);\r
-       \r
-       if ($DB->autoinit == TRUE)\r
-       {\r
-               $DB->initialize();\r
-       }\r
-       \r
-       return $DB;\r
-}      \r
-\r
-\r
-\r
-/* End of file DB.php */\r
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Initialize the database
+ *
+ * @category   Database
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/database/
+ */
+function &DB($params = '', $active_record_override = FALSE)
+{
+       // Load the DB config file if a DSN string wasn't passed
+       if (is_string($params) AND strpos($params, '://') === FALSE)
+       {
+               include(APPPATH.'config/database'.EXT);
+               
+               if ( ! isset($db) OR count($db) == 0)
+               {
+                       show_error('No database connection settings were found in the database config file.');
+               }
+               
+               if ($params != '')
+               {
+                       $active_group = $params;
+               }
+               
+               if ( ! isset($active_group) OR ! isset($db[$active_group]))
+               {
+                       show_error('You have specified an invalid database connection group.');
+               }
+               
+               $params = $db[$active_group];
+       }
+       elseif (is_string($params))
+       {
+               
+               /* parse the URL from the DSN string
+               *  Database settings can be passed as discreet
+               *  parameters or as a data source name in the first
+               *  parameter. DSNs must have this prototype:
+               *  $dsn = 'driver://username:password@hostname/database';
+               */
+       
+               if (($dns = @parse_url($params)) === FALSE)
+               {
+                       show_error('Invalid DB Connection String');
+               }
+               
+               $params = array(
+                                                       'dbdriver'      => $dns['scheme'],
+                                                       'hostname'      => (isset($dns['host'])) ? rawurldecode($dns['host']) : '',
+                                                       'username'      => (isset($dns['user'])) ? rawurldecode($dns['user']) : '',
+                                                       'password'      => (isset($dns['pass'])) ? rawurldecode($dns['pass']) : '',
+                                                       'database'      => (isset($dns['path'])) ? rawurldecode(substr($dns['path'], 1)) : ''
+                                               );
+               
+               // were additional config items set?
+               if (isset($dns['query']))
+               {
+                       parse_str($dns['query'], $extra);
+
+                       foreach($extra as $key => $val)
+                       {
+                               // booleans please
+                               if (strtoupper($val) == "TRUE")
+                               {
+                                       $val = TRUE;
+                               }
+                               elseif (strtoupper($val) == "FALSE")
+                               {
+                                       $val = FALSE;
+                               }
+
+                               $params[$key] = $val;
+                       }
+               }
+       }
+       
+       // No DB specified yet?  Beat them senseless...
+       if ( ! isset($params['dbdriver']) OR $params['dbdriver'] == '')
+       {
+               show_error('You have not selected a database type to connect to.');
+       }
+
+       // Load the DB classes.  Note: Since the active record class is optional
+       // we need to dynamically create a class that extends proper parent class
+       // based on whether we're using the active record class or not.
+       // Kudos to Paul for discovering this clever use of eval()
+       
+       if ($active_record_override == TRUE)
+       {
+               $active_record = TRUE;
+       }
+       
+       require_once(BASEPATH.'database/DB_driver'.EXT);
+
+       if ( ! isset($active_record) OR $active_record == TRUE)
+       {
+               require_once(BASEPATH.'database/DB_active_rec'.EXT);
+               
+               if ( ! class_exists('CI_DB'))
+               {
+                       eval('class CI_DB extends CI_DB_active_record { }');
+               }
+       }
+       else
+       {
+               if ( ! class_exists('CI_DB'))
+               {
+                       eval('class CI_DB extends CI_DB_driver { }');
+               }
+       }
+                       
+       require_once(BASEPATH.'database/drivers/'.$params['dbdriver'].'/'.$params['dbdriver'].'_driver'.EXT);
+
+       // Instantiate the DB adapter
+       $driver = 'CI_DB_'.$params['dbdriver'].'_driver';
+       $DB =& new $driver($params);
+       
+       if ($DB->autoinit == TRUE)
+       {
+               $DB->initialize();
+       }
+       
+       return $DB;
+}      
+
+
+
+/* End of file DB.php */
 /* Location: ./system/database/DB.php */
\ No newline at end of file