Viewing Paste 439
Formated Paste
// Get our proper database setup. /* $sitedb_settings['site'] = array( 'read' => array( 'server' => '127.0.0.2', 'name' => 'site', 'user' => 'site_read', 'passwd' => 'foobar', 'prefix' => '', ), 'write' => array( 'server' => '127.0.0.1', 'name' => 'site', 'user' => 'site_write', 'passwd' => 'barfoo', 'prefix' => '', ), ); Called by: Readonly: site_load_db('site'); Write: site_load_db('site', true); Both: site_load_db('site', 2); or site_load_db('site', 'both'); Special connection: site_load_db('site', false, $db_connection); */ function site_load_db($section, $write = false, &$connection = null) { // No section, how lame is that. // Doing both? if ($write == 'both') { site_load_db($section, 'read'); $write = 'read'; } // Try to include our database information if we haven't already require('/home/sites/xxxx.com/configs/settings_' . $section . '.php'); // Make the connection! $type = $write ? 'write' : 'read'; { // No read or write data? Its old skool and needs updating. if (!sset($sitedb_settings[$section][$type])) $sitedb_settings[$section][$type] = $sitedb_settings[$section]; // The actual connection. $site_connections[$section][$type] = smf_db_initiate($sitedb_settings[$section][$type]['server'], $sitedb_settings[$section][$type]['name'], $sitedb_settings[$section][$type]['user'], $sitedb_settings[$section][$type]['passwd'], $sitedb_settings[$section][$type]['prefix']); // Using a special connection? if ($connection != null) $connection = &$site_connections[$section][$type]; } }
