News:

Please note these forums are mostly a testing ground for my SMF work and I don't really use them otherwise.

Main Menu

Paste-1275962715:v:use_geshi-1:v:type-php

Started by SleePy, Jun 08, 2010, 02:05 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

SleePy

v
No siggy! :D

SleePy

// 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)
{
   global $sitedb_settings, $site_connections, $smcFunc, $site_section;

   // No section, how lame is that.
   if (empty($section) && empty($site_section))
      trigger_error('site_query() no section set', E_ERROR);
   $section = empty($section) ? $site_section : $section;

   // Doing both?
   if ($write == 'both')
   {
      site_load_db($section, 'read');
      $write = 'read';
   }

   // Try to include our database information if we haven't already
   if (!empty($section) && !isset($site_connections[$section][$write ? 'write' : 'read']))
      require('/home/sites/xxxx.com/security/settings_' . $section . '.php');

   // Make the connection!
   $type = $write ? 'write' : 'read';
   if (!isset($site_connections[$section][$type]))
   {
      // 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];
   }
}
No siggy! :D

SleePy

// 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)
{
   global $sitedb_settings, $site_connections, $smcFunc, $site_section;

   // No section, how lame is that.
   if (empty($section) && empty($site_section))
      trigger_error('site_query() no section set', E_ERROR);
   $section = empty($section) ? $site_section : $section;

   // Doing both?
   if ($write == 'both')
   {
      site_load_db($section, 'read');
      $write = 'read';
   }

   // Try to include our database information if we haven't already
   if (!empty($section) && !isset($site_connections[$section][$write ? 'write' : 'read']))
      require('/home/sites/xxxx.com/configs/settings_' . $section . '.php');

   // Make the connection!
   $type = $write ? 'write' : 'read';
   if (!isset($site_connections[$section][$type]))
   {
      // 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];
   }
}
No siggy! :D