Beispiel #1
0
function driver_db_query($query)
{
    global $db_conn;
    static $reconnect_attempts = 0;
    $result = mysql_query($query, $db_conn);
    if (empty($result)) {
        // Lost connection, try to reconnect (max - 3 times)
        if ((mysql_errno($db_conn) == 2013 || mysql_errno($db_conn) == 2006) && $reconnect_attempts < 3) {
            $db_conn = db_initiate(Registry::get('config.db_host'), Registry::get('config.db_user'), Registry::get('config.db_password'), Registry::get('config.db_name'));
            $reconnect_attempts++;
            $result = driver_db_query($query);
            // Assume that the table is broken
            // Try to repair
        } elseif (preg_match("/'(\\S+)\\.(MYI|MYD)/", mysql_error($db_conn), $matches)) {
            $result = mysql_query("REPAIR TABLE {$matches['1']}", $db_conn);
        }
    }
    return $result;
}
Beispiel #2
0
}
// Check if software is installed
if ($config['db_host'] == '%DB_HOST%') {
    die(PRODUCT_NAME . ' is <b>not installed</b>. Please click here to start the installation process: <a href="install/">[install]</a>');
}
// Load core functions
$fn_list = array('fn.database.php', 'fn.users.php', 'fn.catalog.php', 'fn.cms.php', 'fn.cart.php', 'fn.locations.php', 'fn.common.php', 'fn.fs.php', 'fn.images.php', 'fn.init.php', 'fn.control.php', 'fn.search.php', 'fn.promotions.php', 'fn.log.php', 'fn.companies.php', 'fn.addons.php');
$fn_list[] = 'fn.' . strtolower(PRODUCT_EDITION) . '.php';
foreach ($fn_list as $file) {
    require $config['dir']['functions'] . $file;
}
Registry::set('class_loader', $classLoader);
Registry::set('config', $config);
unset($config);
// Connect to database
if (!db_initiate(Registry::get('config.db_host'), Registry::get('config.db_user'), Registry::get('config.db_password'), Registry::get('config.db_name'))) {
    throw new DatabaseException('Cannot connect to the database server');
}
register_shutdown_function(array('\\Tygh\\Registry', 'save'));
fn_init_stack(array('fn_init_unmanaged_addons'));
if (defined('API')) {
    fn_init_stack(array('fn_init_api'));
}
fn_init_stack(array('fn_init_storage'), array('fn_init_ua'));
if (fn_allowed_for('ULTIMATE')) {
    fn_init_stack(array('fn_init_store_params_by_host', &$_REQUEST));
}
fn_init_stack(array(array('\\Tygh\\Session', 'init'), &$_REQUEST), array('fn_init_ajax'), array('fn_init_company_id', &$_REQUEST), array('fn_check_cache', $_REQUEST), array('fn_init_settings'), array('fn_init_addons'), array('fn_get_route', &$_REQUEST), array('fn_simple_ultimate', &$_REQUEST));
if (!Registry::get('config.tweaks.disable_localizations') && !fn_allowed_for('ULTIMATE:FREE')) {
    fn_init_stack(array('fn_init_localization', &$_REQUEST));
}
Beispiel #3
0
 public static function initiateImportedDB($store_data)
 {
     $db_conn = db_initiate($store_data['db_host'], $store_data['db_user'], $store_data['db_password'], $store_data['db_name'], array('dbc_name' => General::CONNECTION_NAME, 'table_prefix' => $store_data['table_prefix']));
     return $db_conn;
 }