function _startup() { $db = return_db(); $db = $db['default']; $link = mysql_connect($db['hostname'], $db['username'], $db['password']) or die('Could not connect: ' . mysql_error()); // Create the database if it does not exist $sql = 'CREATE DATABASE IF NOT EXISTS ' . $db['database']; mysql_query($sql, $link) or die('Could not create database: ' . mysql_error()); mysql_close($link); }
function drop_fks() { $db = return_db(); $db = $db['default']; $link = mysql_connect($db['hostname'], $db['username'], $db['password']) or die('Could not connect: ' . mysql_error()); $test = $db['database']; mysql_select_db($db['database'], $link) or die('Could select database: ' . mysql_error()); $result = mysql_query("SELECT DISTINCT table_name, constraint_name FROM information_schema.key_column_usage" . " WHERE constraint_schema = '$db[database]' AND referenced_table_name IS NOT NULL"); while($row = mysql_fetch_assoc($result)) { mysql_query("ALTER TABLE `$row[table_name]` DROP FOREIGN KEY `$row[constraint_name]`", $link) or die('Could not drop fks: ' . mysql_error()); } mysql_free_result($result); mysql_close($link); }
| ['swap_pre'] A default table prefix that should be swapped with the dbprefix | ['autoinit'] Whether or not to automatically initialize the database. | ['stricton'] TRUE/FALSE - forces 'Strict Mode' connections | - good for ensuring strict SQL while developing | | The $active_group variable lets you choose which connection group to | make active. By default there is only one group (the 'default' group). | | The $active_record variables lets you determine whether or not to load | the active record class */ $active_group = 'default'; $active_record = TRUE; $db = return_db(); $db['default']['dbdriver'] = 'mysql'; $db['default']['dbprefix'] = ''; $db['default']['pconnect'] = TRUE; $db['default']['db_debug'] = TRUE; $db['default']['cache_on'] = FALSE; $db['default']['cachedir'] = ''; $db['default']['char_set'] = 'utf8'; $db['default']['dbcollat'] = 'utf8_general_ci'; $db['default']['swap_pre'] = ''; $db['default']['autoinit'] = TRUE; $db['default']['stricton'] = FALSE; /* End of file database.php */ /* Location: ./app/config/database.php */