当前位置: 首页>>代码示例>>PHP>>正文


PHP dead_db函数代码示例

本文整理汇总了PHP中dead_db函数的典型用法代码示例。如果您正苦于以下问题:PHP dead_db函数的具体用法?PHP dead_db怎么用?PHP dead_db使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了dead_db函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: insert

 public static function insert($keysValues)
 {
     global $wpdb;
     $table = $wpdb->prefix . 'data_pengajian_kota';
     $wpdb->insert($table, (array) $keysValues);
     if (!empty($wpdb->error)) {
         dead_db();
         var_dump($wpdb->last_query);
     }
 }
开发者ID:jeins,项目名称:Forkom,代码行数:10,代码来源:Connection.php

示例2: wp_set_wpdb_vars

/**
 * Sets the database table prefix and the format specifiers for database table columns.
 *
 * Columns not listed here default to %s.
 *
 * @see wpdb::$field_types Since 2.8.0
 * @see wpdb::prepare()
 * @see wpdb::insert()
 * @see wpdb::update()
 * @see wpdb::set_prefix()
 *
 * @access private
 * @since 3.0.0
 */
function wp_set_wpdb_vars()
{
    global $wpdb, $table_prefix;
    if (!empty($wpdb->error)) {
        dead_db();
    }
    $wpdb->field_types = array('post_author' => '%d', 'post_parent' => '%d', 'menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'term_taxonomy_id' => '%d', 'parent' => '%d', 'count' => '%d', 'object_id' => '%d', 'term_order' => '%d', 'ID' => '%d', 'commment_ID' => '%d', 'comment_post_ID' => '%d', 'comment_parent' => '%d', 'user_id' => '%d', 'link_id' => '%d', 'link_owner' => '%d', 'link_rating' => '%d', 'option_id' => '%d', 'blog_id' => '%d', 'meta_id' => '%d', 'post_id' => '%d', 'user_status' => '%d', 'umeta_id' => '%d', 'comment_karma' => '%d', 'comment_count' => '%d', 'active' => '%d', 'cat_id' => '%d', 'deleted' => '%d', 'lang_id' => '%d', 'mature' => '%d', 'public' => '%d', 'site_id' => '%d', 'spam' => '%d');
    $prefix = $wpdb->set_prefix($table_prefix);
    if (is_wp_error($prefix)) {
        wp_die('<strong>错误</strong>:在 <code>wp-config.php</code> 配置文件中的 <code>$table_prefix</code> 只能包含数字、字母和下划线。');
    }
}
开发者ID:laiello,项目名称:qinhan,代码行数:26,代码来源:load.php

示例3: check_connection

 /**
  * Check that the connection to the database is still up. If not, try to reconnect.
  *
  * If this function is unable to reconnect, it will forcibly die, or if after the
  * the template_redirect hook has been fired, return false instead.
  *
  * If $allow_bail is false, the lack of database connection will need
  * to be handled manually.
  *
  * @since 3.9.0
  *
  * @param bool $allow_bail Optional. Allows the function to bail. Default true.
  * @return bool|void True if the connection is up.
  */
 public function check_connection($allow_bail = true)
 {
     if ($this->use_mysqli) {
         if (@mysqli_ping($this->dbh)) {
             return true;
         }
     } else {
         if (@mysql_ping($this->dbh)) {
             return true;
         }
     }
     $error_reporting = false;
     // Disable warnings, as we don't want to see a multitude of "unable to connect" messages
     if (WP_DEBUG) {
         $error_reporting = error_reporting();
         error_reporting($error_reporting & ~E_WARNING);
     }
     for ($tries = 1; $tries <= $this->reconnect_retries; $tries++) {
         // On the last try, re-enable warnings. We want to see a single instance of the
         // "unable to connect" message on the bail() screen, if it appears.
         if ($this->reconnect_retries === $tries && WP_DEBUG) {
             error_reporting($error_reporting);
         }
         if ($this->db_connect(false)) {
             if ($error_reporting) {
                 error_reporting($error_reporting);
             }
             return true;
         }
         sleep(1);
     }
     // If template_redirect has already happened, it's too late for wp_die()/dead_db().
     // Let's just return and hope for the best.
     if (did_action('template_redirect')) {
         return false;
     }
     if (!$allow_bail) {
         return false;
     }
     // We weren't able to reconnect, so we better bail.
     $this->bail(sprintf("\n<h1>Error reconnecting to the database</h1>\n<p>This means that we lost contact with the database server at <code>%s</code>. This could mean your host's database server is down.</p>\n<ul>\n\t<li>Are you sure that the database server is running?</li>\n\t<li>Are you sure that the database server is not under particularly heavy load?</li>\n</ul>\n<p>If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the <a href='https://wordpress.org/support/'>WordPress Support Forums</a>.</p>\n", htmlspecialchars($this->dbhost, ENT_QUOTES)), 'db_connect_fail');
     // Call dead_db() if bail didn't die, because this database is no more. It has ceased to be (at least temporarily).
     dead_db();
 }
开发者ID:renanvicente,项目名称:codedeploytest,代码行数:58,代码来源:wp-db.php

示例4: require

		define('WP_LANG_DIR', ABSPATH . WPINC . '/languages'); // no leading slash, no trailing slash, full path, not relative to ABSPATH
		if (!defined('LANGDIR')) {
			// Old relative path maintained for backwards compatibility
			define('LANGDIR', WPINC . '/languages');
		}
	}
}

require (ABSPATH . WPINC . '/compat.php');
require (ABSPATH . WPINC . '/functions.php');
require (ABSPATH . WPINC . '/classes.php');

require_wp_db();

if ( !empty($wpdb->error) )
	dead_db();

/**
 * Format specifiers for DB columns. Columns not listed here default to %s.
 * @since 2.8.0
 * @see wpdb:$field_types
 * @see wpdb:prepare()
 * @see wpdb:insert()
 * @see wpdb:update()
 */
$wpdb->field_types = array( 'post_author' => '%d', 'post_parent' => '%d', 'menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'term_taxonomy_id' => '%d',
	'parent' => '%d', 'count' => '%d','object_id' => '%d', 'term_order' => '%d', 'ID' => '%d', 'commment_ID' => '%d', 'comment_post_ID' => '%d', 'comment_parent' => '%d',
	'user_id' => '%d', 'link_id' => '%d', 'link_owner' => '%d', 'link_rating' => '%d', 'option_id' => '%d', 'blog_id' => '%d', 'meta_id' => '%d', 'post_id' => '%d',
	'user_status' => '%d', 'umeta_id' => '%d', 'comment_karma' => '%d', 'comment_count' => '%d');

$prefix = $wpdb->set_prefix($table_prefix);
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:31,代码来源:wp-settings.php

示例5: is_blog_installed

/**
 * Test whether blog is already installed.
 *
 * The cache will be checked first. If you have a cache plugin, which saves the
 * cache values, then this will work. If you use the default WordPress cache,
 * and the database goes away, then you might have problems.
 *
 * Checks for the option siteurl for whether WordPress is installed.
 *
 * @since 2.1.0
 * @uses $wpdb
 *
 * @return bool Whether blog is already installed.
 */
function is_blog_installed()
{
    global $wpdb;
    // Check cache first. If options table goes away and we have true cached, oh well.
    if (wp_cache_get('is_blog_installed')) {
        return true;
    }
    $suppress = $wpdb->suppress_errors();
    if (!defined('WP_INSTALLING')) {
        $alloptions = wp_load_alloptions();
    }
    // If siteurl is not set to autoload, check it specifically
    if (!isset($alloptions['siteurl'])) {
        $installed = $wpdb->get_var("SELECT option_value FROM {$wpdb->options} WHERE option_name = 'siteurl'");
    } else {
        $installed = $alloptions['siteurl'];
    }
    $wpdb->suppress_errors($suppress);
    $installed = !empty($installed);
    wp_cache_set('is_blog_installed', $installed);
    if ($installed) {
        return true;
    }
    $suppress = $wpdb->suppress_errors();
    $tables = $wpdb->get_col('SHOW TABLES');
    $wpdb->suppress_errors($suppress);
    $wp_tables = $wpdb->tables();
    // Loop over the WP tables.  If none exist, then scratch install is allowed.
    // If one or more exist, suggest table repair since we got here because the options
    // table could not be accessed.
    foreach ($wp_tables as $table) {
        // If one of the WP tables exist, then we are in an insane state.
        if (in_array($table, $tables)) {
            // The existence of custom user tables shouldn't suggest an insane state or prevent a clean install.
            if (defined('CUSTOM_USER_TABLE') && CUSTOM_USER_TABLE == $table) {
                continue;
            }
            if (defined('CUSTOM_USER_META_TABLE') && CUSTOM_USER_META_TABLE == $table) {
                continue;
            }
            // If visiting repair.php, return true and let it take over.
            if (defined('WP_REPAIRING')) {
                return true;
            }
            // Die with a DB error.
            $wpdb->error = sprintf('Uma ou mais tabelas do banco de dados não estão disponíveis. O banco de dados pode precisar <a href="%s">reparo</a>.', 'maint/repair.php?referrer=is_blog_installed');
            dead_db();
        }
    }
    wp_cache_set('is_blog_installed', false);
    return false;
}
开发者ID:Ogwang,项目名称:sainp,代码行数:66,代码来源:functions.php

示例6: ms_not_installed

/**
 * Displays a failure message.
 *
 * Used when a blog's tables do not exist. Checks for a missing $wpdb->site table as well.
 *
 * @access private
 * @since 3.0.0
 * @since 4.4.0 The `$domain` and `$path` parameters were added.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param string $domain The requested domain for the error to reference.
 * @param string $path   The requested path for the error to reference.
 */
function ms_not_installed($domain, $path)
{
    global $wpdb;
    if (!is_admin()) {
        dead_db();
    }
    wp_load_translations_early();
    $title = __('Error establishing a database connection');
    $msg = '<h1>' . $title . '</h1>';
    $msg .= '<p>' . __('If your site does not display, please contact the owner of this network.') . '';
    $msg .= ' ' . __('If you are the owner of this network please check that MySQL is running properly and all tables are error free.') . '</p>';
    $query = $wpdb->prepare("SHOW TABLES LIKE %s", $wpdb->esc_like($wpdb->site));
    if (!$wpdb->get_var($query)) {
        $msg .= '<p>' . sprintf(__('<strong>Database tables are missing.</strong> This means that MySQL is not running, WordPress was not installed properly, or someone deleted %s. You really should look at your database now.'), '<code>' . $wpdb->site . '</code>') . '</p>';
    } else {
        $msg .= '<p>' . sprintf(__('<strong>Could not find site %1$s.</strong> Searched for table %2$s in database %3$s. Is that right?'), '<code>' . rtrim($domain . $path, '/') . '</code>', '<code>' . $wpdb->blogs . '</code>', '<code>' . DB_NAME . '</code>') . '</p>';
    }
    $msg .= '<p><strong>' . __('What do I do now?') . '</strong> ';
    /* translators: %s: Codex URL */
    $msg .= sprintf(__('Read the <a href="%s" target="_blank">bug report</a> page. Some of the guidelines there may help you figure out what went wrong.'), __('https://codex.wordpress.org/Debugging_a_WordPress_Network'));
    $msg .= ' ' . __('If you&#8217;re still stuck with this message, then check that your database contains the following tables:') . '</p><ul>';
    foreach ($wpdb->tables('global') as $t => $table) {
        if ('sitecategories' == $t) {
            continue;
        }
        $msg .= '<li>' . $table . '</li>';
    }
    $msg .= '</ul>';
    wp_die($msg, $title, array('response' => 500));
}
开发者ID:pbearne,项目名称:contrib2core,代码行数:44,代码来源:ms-load.php

示例7: wp_set_wpdb_vars

/**
 * Sets the database table prefix and the format specifiers for database table columns.
 *
 * Columns not listed here default to %s.
 *
 * @see wpdb::$field_types Since 2.8.0
 * @see wpdb::prepare()
 * @see wpdb::insert()
 * @see wpdb::update()
 * @see wpdb::set_prefix()
 *
 * @access private
 * @since 3.0.0
 */
function wp_set_wpdb_vars() {
	global $wpdb, $table_prefix;
	if ( !empty( $wpdb->error ) )
		dead_db();

	$wpdb->field_types = array( 'post_author' => '%d', 'post_parent' => '%d', 'menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'term_taxonomy_id' => '%d',
		'parent' => '%d', 'count' => '%d','object_id' => '%d', 'term_order' => '%d', 'ID' => '%d', 'commment_ID' => '%d', 'comment_post_ID' => '%d', 'comment_parent' => '%d',
		'user_id' => '%d', 'link_id' => '%d', 'link_owner' => '%d', 'link_rating' => '%d', 'option_id' => '%d', 'blog_id' => '%d', 'meta_id' => '%d', 'post_id' => '%d',
		'user_status' => '%d', 'umeta_id' => '%d', 'comment_karma' => '%d', 'comment_count' => '%d',
		// multisite:
		'active' => '%d', 'cat_id' => '%d', 'deleted' => '%d', 'lang_id' => '%d', 'mature' => '%d', 'public' => '%d', 'site_id' => '%d', 'spam' => '%d',
	);

	$prefix = $wpdb->set_prefix( $table_prefix );

	if ( is_wp_error( $prefix ) )
		wp_die( /*WP_I18N_BAD_PREFIX*/'<strong>ERROR</strong>: <code>$table_prefix</code> in <code>wp-config.php</code> can only contain numbers, letters, and underscores.'/*/WP_I18N_BAD_PREFIX*/ );
}
开发者ID:realfluid,项目名称:umbaugh,代码行数:32,代码来源:load.php

示例8: nxt_set_nxtdb_vars

/**
 * Sets the database table prefix and the format specifiers for database table columns.
 *
 * Columns not listed here default to %s.
 *
 * @see nxtdb::$field_types Since 2.8.0
 * @see nxtdb::prepare()
 * @see nxtdb::insert()
 * @see nxtdb::update()
 * @see nxtdb::set_prefix()
 *
 * @access private
 * @since 3.0.0
 */
function nxt_set_nxtdb_vars()
{
    global $nxtdb, $table_prefix;
    if (!empty($nxtdb->error)) {
        dead_db();
    }
    $nxtdb->field_types = array('post_author' => '%d', 'post_parent' => '%d', 'menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'term_taxonomy_id' => '%d', 'parent' => '%d', 'count' => '%d', 'object_id' => '%d', 'term_order' => '%d', 'ID' => '%d', 'commment_ID' => '%d', 'comment_post_ID' => '%d', 'comment_parent' => '%d', 'user_id' => '%d', 'link_id' => '%d', 'link_owner' => '%d', 'link_rating' => '%d', 'option_id' => '%d', 'blog_id' => '%d', 'meta_id' => '%d', 'post_id' => '%d', 'user_status' => '%d', 'umeta_id' => '%d', 'comment_karma' => '%d', 'comment_count' => '%d', 'active' => '%d', 'cat_id' => '%d', 'deleted' => '%d', 'lang_id' => '%d', 'mature' => '%d', 'public' => '%d', 'site_id' => '%d', 'spam' => '%d');
    $prefix = $nxtdb->set_prefix($table_prefix);
    if (is_nxt_error($prefix)) {
        nxt_die('<strong>ERROR</strong>: <code>$table_prefix</code> in <code>nxt-config.php</code> can only contain numbers, letters, and underscores.');
    }
}
开发者ID:nxtclass,项目名称:NXTClass,代码行数:26,代码来源:load.php

示例9: check_connection

 /**
  * Check that the connection to the database is still up. If not, try
  * to reconnect
  *
  * If this function is unable to reconnect, it will forcibly die, or if after the
  * the template_redirect hook has been fired, return false instead
  *
  * If $allow_bail is false, the lack of database connection will need
  * to be handled manually
  *
  * @param bool $allow_bail Optional. Allows the function to bail. Default true.
  *
  * @return bool|void True if the connection is up.
  */
 public function check_connection($allow_bail = true, $dbh_or_table = false)
 {
     $dbh = $this->get_db_object($dbh_or_table);
     if ($this->dbh_type_check($dbh)) {
         if (true === $this->use_mysqli) {
             if (mysqli_ping($dbh)) {
                 return true;
             }
         } else {
             if (mysql_ping($dbh)) {
                 return true;
             }
         }
     }
     if (false === $allow_bail) {
         return false;
     }
     $error_reporting = false;
     // Disable warnings, as we don't want to see a multitude of "unable to connect" messages
     if (WP_DEBUG) {
         $error_reporting = error_reporting();
         error_reporting($error_reporting & ~E_WARNING);
     }
     for ($tries = 1; $tries <= $this->reconnect_retries; $tries++) {
         // On the last try, re-enable warnings. We want to see a single instance of the
         // "unable to connect" message on the bail() screen, if it appears.
         if ($this->reconnect_retries === $tries && WP_DEBUG) {
             error_reporting($error_reporting);
         }
         if ($this->db_connect(false)) {
             if ($error_reporting) {
                 error_reporting($error_reporting);
             }
             return true;
         }
         sleep(1);
     }
     // If template_redirect has already happened, it's too late for wp_die()/dead_db().
     // Let's just return and hope for the best.
     if (did_action('template_redirect')) {
         return false;
     }
     wp_load_translations_early();
     $message = '<h1>' . __('Error reconnecting to the database', 'ludicrousdb') . "</h1>\n";
     $message .= '<p>' . sprintf(__('This means that we lost contact with the database server at %s. This could mean your host&#8217;s database server is down.', 'ludicrousdb'), '<code>' . htmlspecialchars($this->dbhost, ENT_QUOTES) . '</code>') . "</p>\n";
     $message .= "<ul>\n";
     $message .= '<li>' . __('Are you sure that the database server is running?', 'ludicrousdb') . "</li>\n";
     $message .= '<li>' . __('Are you sure that the database server is not under particularly heavy load?', 'ludicrousdb') . "</li>\n";
     $message .= "</ul>\n";
     $message .= '<p>' . sprintf(__('If you&#8217;re unsure what these terms mean you should probably contact your host. If you still need help you can always visit the <a href="%s">WordPress Support Forums</a>.', 'ludicrousdb'), __('https://wordpress.org/support/', 'ludicrousdb')) . "</p>\n";
     // We weren't able to reconnect, so we better bail.
     $this->bail($message, 'db_connect_fail');
     // Call dead_db() if bail didn't die, because this database is no more. It has ceased to be (at least temporarily).
     dead_db();
 }
开发者ID:stuttter,项目名称:ludicrousdb,代码行数:69,代码来源:class-ludicrousdb.php

示例10: hq_set_hqdb_vars

/**
 * Set the database table prefix and the format specifiers for database
 * table columns.
 *
 * Columns not listed here default to `%s`.
 *
 * @since 0.0.1
 * @access private
 *
 * @global hqdb   $hqdb         The HiveQueen database class.
 * @global string $table_prefix The database table prefix.
 */
function hq_set_hqdb_vars()
{
    global $hqdb, $table_prefix;
    if (!empty($hqdb->error)) {
        dead_db();
    }
    //TODO: Redefine db
    /*
    $hqdb->field_types = array( 'post_author' => '%d', 'post_parent' => '%d', 'menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'term_taxonomy_id' => '%d',
            'parent' => '%d', 'count' => '%d','object_id' => '%d', 'term_order' => '%d', 'ID' => '%d', 'comment_ID' => '%d', 'comment_post_ID' => '%d', 'comment_parent' => '%d',
            'user_id' => '%d', 'link_id' => '%d', 'link_owner' => '%d', 'link_rating' => '%d', 'option_id' => '%d', 'blog_id' => '%d', 'meta_id' => '%d', 'post_id' => '%d',
            'user_status' => '%d', 'umeta_id' => '%d', 'comment_karma' => '%d', 'comment_count' => '%d',
            // multisite:
            'active' => '%d', 'cat_id' => '%d', 'deleted' => '%d', 'lang_id' => '%d', 'mature' => '%d', 'public' => '%d', 'site_id' => '%d', 'spam' => '%d',
    );
    */
    $hqdb->field_types = array('menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'parent' => '%d', 'count' => '%d', 'object_id' => '%d', 'term_order' => '%d', 'ID' => '%d', 'user_id' => '%d', 'option_id' => '%d', 'user_status' => '%d');
    $prefix = $hqdb->set_prefix($table_prefix);
    if (is_hq_error($prefix)) {
        hq_load_translations_early();
        hq_die(__('<strong>ERROR</strong>: <code>$table_prefix</code> in <code>hq-config.php</code> can only contain numbers, letters, and underscores.'));
    }
}
开发者ID:gcorral,项目名称:hivequeen,代码行数:35,代码来源:load.php

示例11: is_blog_installed

/**
 * Test whether blog is already installed.
 *
 * The cache will be checked first. If you have a cache plugin, which saves
 * the cache values, then this will work. If you use the default WordPress
 * cache, and the database goes away, then you might have problems.
 *
 * Checks for the 'siteurl' option for whether WordPress is installed.
 *
 * @since 2.1.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @return bool Whether the blog is already installed.
 */
function is_blog_installed()
{
    global $wpdb;
    /*
     * Check cache first. If options table goes away and we have true
     * cached, oh well.
     */
    if (wp_cache_get('is_blog_installed')) {
        return true;
    }
    $suppress = $wpdb->suppress_errors();
    if (!defined('WP_INSTALLING')) {
        $alloptions = wp_load_alloptions();
    }
    // If siteurl is not set to autoload, check it specifically
    if (!isset($alloptions['siteurl'])) {
        $installed = $wpdb->get_var("SELECT option_value FROM {$wpdb->options} WHERE option_name = 'siteurl'");
    } else {
        $installed = $alloptions['siteurl'];
    }
    $wpdb->suppress_errors($suppress);
    $installed = !empty($installed);
    wp_cache_set('is_blog_installed', $installed);
    if ($installed) {
        return true;
    }
    // If visiting repair.php, return true and let it take over.
    if (defined('WP_REPAIRING')) {
        return true;
    }
    $suppress = $wpdb->suppress_errors();
    /*
     * Loop over the WP tables. If none exist, then scratch install is allowed.
     * If one or more exist, suggest table repair since we got here because the
     * options table could not be accessed.
     */
    $wp_tables = $wpdb->tables();
    foreach ($wp_tables as $table) {
        // The existence of custom user tables shouldn't suggest an insane state or prevent a clean install.
        if (defined('CUSTOM_USER_TABLE') && CUSTOM_USER_TABLE == $table) {
            continue;
        }
        if (defined('CUSTOM_USER_META_TABLE') && CUSTOM_USER_META_TABLE == $table) {
            continue;
        }
        if (!$wpdb->get_results("DESCRIBE {$table};")) {
            continue;
        }
        // One or more tables exist. We are insane.
        wp_load_translations_early();
        // Die with a DB error.
        $wpdb->error = sprintf(__('One or more database tables are unavailable. The database may need to be <a href="%s">repaired</a>.'), 'maint/repair.php?referrer=is_blog_installed');
        dead_db();
    }
    $wpdb->suppress_errors($suppress);
    wp_cache_set('is_blog_installed', false);
    return false;
}
开发者ID:hpilevar,项目名称:WordPress,代码行数:73,代码来源:functions.php

示例12: is_blog_installed

/**
 * Test whether blog is already installed.
 *
 * The cache will be checked first. If you have a cache plugin, which saves the
 * cache values, then this will work. If you use the default WordPress cache,
 * and the database goes away, then you might have problems.
 *
 * Checks for the option siteurl for whether WordPress is installed.
 *
 * @since 2.1.0
 * @uses $wpdb
 *
 * @return bool Whether blog is already installed.
 */
function is_blog_installed()
{
    global $wpdb;
    // Check cache first. If options table goes away and we have true cached, oh well.
    if (wp_cache_get('is_blog_installed')) {
        return true;
    }
    $suppress = $wpdb->suppress_errors();
    $alloptions = wp_load_alloptions();
    // If siteurl is not set to autoload, check it specifically
    if (!isset($alloptions['siteurl'])) {
        $installed = $wpdb->get_var("SELECT option_value FROM {$wpdb->options} WHERE option_name = 'siteurl'");
    } else {
        $installed = $alloptions['siteurl'];
    }
    $wpdb->suppress_errors($suppress);
    $installed = !empty($installed);
    wp_cache_set('is_blog_installed', $installed);
    if ($installed) {
        return true;
    }
    $suppress = $wpdb->suppress_errors();
    $tables = $wpdb->get_col('SHOW TABLES');
    $wpdb->suppress_errors($suppress);
    // Loop over the WP tables.  If none exist, then scratch install is allowed.
    // If one or more exist, suggest table repair since we got here because the options
    // table could not be accessed.
    foreach ($wpdb->tables as $table) {
        // If one of the WP tables exist, then we are in an insane state.
        if (in_array($wpdb->prefix . $table, $tables)) {
            // If visiting repair.php, return true and let it take over.
            if (defined('WP_REPAIRING')) {
                return true;
            }
            // Die with a DB error.
            $wpdb->error = __('One or more database tables are unavailable.  The database may need to be <a href="maint/repair.php?referrer=is_blog_installed">repaired</a>.');
            dead_db();
        }
    }
    wp_cache_set('is_blog_installed', false);
    return false;
}
开发者ID:bluedanbob,项目名称:wordpress,代码行数:56,代码来源:functions.php

示例13: wp_set_wpdb_vars

/**
 * Set the database table prefix and the format specifiers for database
 * table columns.
 *
 * Columns not listed here default to `%s`.
 *
 * @since 3.0.0
 * @access private
 *
 * @global wpdb   $wpdb         The WordPress database class.
 * @global string $table_prefix The database table prefix.
 */
function wp_set_wpdb_vars()
{
    global $wpdb, $table_prefix;
    if (!empty($wpdb->error)) {
        dead_db();
    }
    $wpdb->field_types = array('post_author' => '%d', 'post_parent' => '%d', 'menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'term_taxonomy_id' => '%d', 'parent' => '%d', 'count' => '%d', 'object_id' => '%d', 'term_order' => '%d', 'ID' => '%d', 'comment_ID' => '%d', 'comment_post_ID' => '%d', 'comment_parent' => '%d', 'user_id' => '%d', 'link_id' => '%d', 'link_owner' => '%d', 'link_rating' => '%d', 'option_id' => '%d', 'blog_id' => '%d', 'meta_id' => '%d', 'post_id' => '%d', 'user_status' => '%d', 'umeta_id' => '%d', 'comment_karma' => '%d', 'comment_count' => '%d', 'active' => '%d', 'cat_id' => '%d', 'deleted' => '%d', 'lang_id' => '%d', 'mature' => '%d', 'public' => '%d', 'site_id' => '%d', 'spam' => '%d');
    $prefix = $wpdb->set_prefix($table_prefix);
    if (is_wp_error($prefix)) {
        wp_load_translations_early();
        wp_die(sprintf(__('<strong>ERROR</strong>: %1$s in %2$s can only contain numbers, letters, and underscores.'), '<code>$table_prefix</code>', '<code>wp-config.php</code>'));
    }
}
开发者ID:hughnet,项目名称:WordPress,代码行数:25,代码来源:load.php

示例14: is_blog_installed

/**
 * Test whether blog is already installed.
 *
 * The cache will be checked first. If you have a cache plugin, which saves the
 * cache values, then this will work. If you use the default WordPress cache,
 * and the database goes away, then you might have problems.
 *
 * Checks for the option siteurl for whether WordPress is installed.
 *
 * @since 2.1.0
 * @uses $wpdb
 *
 * @return bool Whether blog is already installed.
 */
function is_blog_installed() {
	global $wpdb;

	// Check cache first. If options table goes away and we have true cached, oh well.
	if ( wp_cache_get( 'is_blog_installed' ) )
		return true;

	$suppress = $wpdb->suppress_errors();
	if ( ! defined( 'WP_INSTALLING' ) ) {
		$alloptions = wp_load_alloptions();
	}
	// If siteurl is not set to autoload, check it specifically
	if ( !isset( $alloptions['siteurl'] ) )
		$installed = $wpdb->get_var( "SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'" );
	else
		$installed = $alloptions['siteurl'];
	$wpdb->suppress_errors( $suppress );

	$installed = !empty( $installed );
	wp_cache_set( 'is_blog_installed', $installed );

	if ( $installed )
		return true;

	$suppress = $wpdb->suppress_errors();
	$tables = $wpdb->get_col('SHOW TABLES');
	$wpdb->suppress_errors( $suppress );

	$wp_tables = $wpdb->tables();
	// Loop over the WP tables.  If none exist, then scratch install is allowed.
	// If one or more exist, suggest table repair since we got here because the options
	// table could not be accessed.
	foreach ( $wp_tables as $table ) {
		// If one of the WP tables exist, then we are in an insane state.
		if ( in_array( $table, $tables ) ) {
			// The existence of custom user tables shouldn't suggest an insane state or prevent a clean install.
			if ( defined( 'CUSTOM_USER_TABLE' ) && CUSTOM_USER_TABLE == $table )
				continue;
			if ( defined( 'CUSTOM_USER_META_TABLE' ) && CUSTOM_USER_META_TABLE == $table )
				continue;

			// If visiting repair.php, return true and let it take over.
			if ( defined('WP_REPAIRING') )
				return true;
			// Die with a DB error.
			$wpdb->error = sprintf( /*WP_I18N_NO_TABLES*/'Mindestens eine Datenbanktabelle ist nicht erreichbar. Die Datenbank sollte vielleicht <a href="%s">repariert</a> werden.'/*/WP_I18N_NO_TABLES*/, 'maint/repair.php?referrer=is_blog_installed' );
			dead_db();
		}
	}

	wp_cache_set( 'is_blog_installed', false );

	return false;
}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:68,代码来源:functions.php


注:本文中的dead_db函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。