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


PHP wpdb::set_prefix方法代码示例

本文整理汇总了PHP中wpdb::set_prefix方法的典型用法代码示例。如果您正苦于以下问题:PHP wpdb::set_prefix方法的具体用法?PHP wpdb::set_prefix怎么用?PHP wpdb::set_prefix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wpdb的用法示例。


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

示例1: staticInitialization

 private static function staticInitialization()
 {
     self::$testConfig = TestConfig::createDefaultConfig();
     self::$wpAutomation = new WpAutomation(self::$testConfig->testSite, self::$testConfig->wpCliVersion);
     $yamlDir = self::$wpAutomation->getPluginsDir() . '/versionpress/.versionpress';
     $schemaFile = $yamlDir . '/schema.yml';
     $shortcodeFile = $yamlDir . '/shortcodes.yml';
     /** @var $wp_db_version */
     require self::$wpAutomation->getAbspath() . '/wp-includes/version.php';
     if (!function_exists('get_shortcode_regex')) {
         require_once self::$wpAutomation->getAbspath() . '/wp-includes/shortcodes.php';
     }
     self::$schemaInfo = new DbSchemaInfo([$schemaFile], self::$testConfig->testSite->dbTablePrefix, $wp_db_version);
     $rawTaxonomies = self::$wpAutomation->runWpCliCommand('taxonomy', 'list', ['format' => 'json', 'fields' => 'name']);
     $taxonomies = array_column(json_decode($rawTaxonomies, true), 'name');
     $dbHost = self::$testConfig->testSite->dbHost;
     $dbUser = self::$testConfig->testSite->dbUser;
     $dbPassword = self::$testConfig->testSite->dbPassword;
     $dbName = self::$testConfig->testSite->dbName;
     $dbPrefix = self::$testConfig->testSite->dbTablePrefix;
     self::$database = new \mysqli($dbHost, $dbUser, $dbPassword, $dbName);
     self::$wpdb = new \wpdb($dbUser, $dbPassword, $dbName, $dbHost);
     self::$wpdb->set_prefix($dbPrefix);
     self::$vp_database = new Database(self::$wpdb);
     $shortcodesInfo = new ShortcodesInfo([$shortcodeFile]);
     self::$vpidRepository = new VpidRepository(self::$vp_database, self::$schemaInfo);
     self::$shortcodesReplacer = new ShortcodesReplacer($shortcodesInfo, self::$vpidRepository);
     $vpdbPath = self::$wpAutomation->getVpdbDir();
     $tableSchemaRepository = new TableSchemaStorage(self::$vp_database, $vpdbPath . '/.schema');
     self::$storageFactory = new StorageFactory($vpdbPath, self::$schemaInfo, self::$vp_database, $taxonomies, null, $tableSchemaRepository);
     require self::$wpAutomation->getPluginsDir() . '/versionpress/.versionpress/hooks.php';
     self::defineGlobalVariables();
 }
开发者ID:versionpress,项目名称:versionpress,代码行数:33,代码来源:DBAsserter.php

示例2: set_prefix

 public function set_prefix($prefix, $set_table_names = true)
 {
     if (function_exists('currheap') && false !== currheap()) {
         $alt_db_prefix = 'tmp_' . currheap() . '_';
         $prefix = $prefix . $alt_db_prefix;
         // wp_tmp_{_alt_heap}_
     }
     // set up the prefix globally and set up all the tables
     parent::set_prefix($prefix, $set_table_names);
     if (function_exists('currheap') && false !== currheap()) {
         // bail out early if wordpress isn't installed
         // check if siteurl is available
         $siteurl = $this->get_var("SELECT option_value FROM {$this->options} WHERE option_name='siteurl'");
         header('X-Siteurl:' . $this->options);
         if (null === $siteurl) {
             // it's not, let's bail out...
             // clear the alt_heap cookie
             setcookie('_alt_heap', '', 0, '/');
             // reload the page
             // Note: wp_redirect isn't set yet, so we do it manually
             $request_uri = $_SERVER['REQUEST_URI'];
             header('Location:' . $request_uri);
             http_response_code(302);
             exit;
         }
     }
 }
开发者ID:anttiviljami,项目名称:wp-safe-updates,代码行数:27,代码来源:db.php

示例3: wpdb

 function __construct($parent)
 {
     global $cache_db, $wpdb, $table_prefix;
     $this->advance_cache_tpl = plugin_dir_path(dirname(__FILE__)) . 'advanced_cache_tpl/advanced-cache.tpl';
     $this->regex_include_tpl = plugin_dir_path(dirname(__FILE__)) . 'advanced_cache_tpl/regex_include.tpl';
     $this->parent = $parent;
     if (defined('CACHE_DB_NAME') && defined('CACHE_DB_USER') && defined('CACHE_DB_PASSWORD') && defined('CACHE_DB_HOST')) {
         $cache_db = new wpdb(CACHE_DB_USER, CACHE_DB_PASSWORD, CACHE_DB_NAME, CACHE_DB_HOST);
         $cache_db->set_prefix($table_prefix);
     } else {
         $cache_db = $wpdb;
     }
     if (is_admin()) {
         add_action('admin_menu', array($this, 'add_setting_menu'));
         add_action('load-wp-sitemanager_page_wp-sitemanager-cache', array($this, 'update_cache_setting'));
         //		add_action( 'theme_switcher/device_updated'                , array( $this, 'clear_all_cache' ) );
         add_action('theme_switcher/device_updated', array($this, 'generate_advanced_cache_file'));
         //		add_action( 'theme_switcher/device_group_updated'          , array( $this, 'clear_all_cache' ) );
         add_action('theme_switcher/device_group_updated', array($this, 'generate_advanced_cache_file'));
         add_action('transition_post_status', array($this, 'post_publish_clear_cache'), 10, 3);
         //		add_action( 'delete_term'                                  , array( $this, 'clear_all_cache' ) );
         //		add_action( 'edited_term'                                  , array( $this, 'clear_all_cache' ) );
         //		add_action( 'deleted_user'                                 , array( $this, 'clear_all_cache' ) );
         //		add_action( 'profile_update'                               , array( $this, 'clear_all_cache' ) );
     } else {
         add_action('init', array($this, 'buffer_start'));
         //		add_action( 'template_redirect'                            , array( $this, 'check_vars' ) );
     }
     add_action('init', array($this, 'check_installed'));
     //	add_action( 'transition_comment_status'                        , array( $this, 'transition_comment_status' ), 10, 3 );
     //	add_action( 'comment_post'                                     , array( $this, 'new_comment' ), 10, 2 );
 }
开发者ID:nobu222,项目名称:Wordpress1DayTraning,代码行数:32,代码来源:site-cache.php

示例4: createConnection

 /**
  * Creates a connection and returns it
  * @return Instance of WPDB
  */
 private function createConnection()
 {
     if (!empty($this->connectionConfig)) {
         //TO DO: Use the provided connection config
         $connectionConfig = $this->connectionConfig;
         $password = $this->decryptString($connectionConfig['password']);
         $newWpdb = new wpdb($connectionConfig['user'], $password, $connectionConfig['name'], $connectionConfig['hostname']);
         $newWpdb->set_prefix($connectionConfig['base_prefix']);
         return $newWpdb;
     } else {
         global $wpdb;
         return $wpdb;
     }
 }
开发者ID:fia3876,项目名称:iqmas-portal,代码行数:18,代码来源:MySQLDBConnector.php

示例5: prepare_deleteOrphanedMenuItems

 public function prepare_deleteOrphanedMenuItems()
 {
     $dbHost = self::$testConfig->testSite->dbHost;
     $dbUser = self::$testConfig->testSite->dbUser;
     $dbPassword = self::$testConfig->testSite->dbPassword;
     $dbName = self::$testConfig->testSite->dbName;
     $wpdb = new \wpdb($dbUser, $dbPassword, $dbName, $dbHost);
     $wpdb->set_prefix(self::$testConfig->testSite->dbTablePrefix);
     $deleteOrphanedFilesSeconds = Reverter::DELETE_ORPHANED_POSTS_SECONDS;
     $database = new Database($wpdb);
     $database->query($wpdb->prepare("UPDATE {$database->postmeta} SET meta_value = meta_value - {$deleteOrphanedFilesSeconds} " . "WHERE meta_key='_menu_item_orphaned' ORDER BY meta_id DESC LIMIT 1", []));
     $pluginsDir = self::$wpAutomation->getPluginsDir();
     $updateConfigArgs = ['VERSIONPRESS_GUI', 'html', 'require' => $pluginsDir . '/versionpress/src/Cli/vp-internal.php'];
     self::$wpAutomation->runWpCliCommand('vp-internal', 'update-config', $updateConfigArgs);
 }
开发者ID:versionpress,项目名称:versionpress,代码行数:15,代码来源:MenusSeleniumWorker.php

示例6: wpdb

<?php

//store global post object to retrieve at end
global $post;
$post_bu = $post;
// db vars defined in wp-config
// create a new wpdb object with external db connection
$gcmaz_wpdb = new wpdb(DB_USER_SRCH, DB_PASSWORD_SRCH, DB_NAME_SRCH, DB_HOST_SRCH);
//set table names prefix
$gcmaz_wpdb->set_prefix(DB_SRCH_PREFIX);
//show errors
//echo ("<h1>SHOW DB ERRORS ON</h1>");
//$wpdb->show_errors();
//$gcmaz_wpdb->show_errors();
/*********************************
 *  INITIALIZE VARS
 ********************************/
// since 2 queries, possible total number is 2x this
$rows_to_return = 100;
// DEFINE OUR RESULTS PER PAGE FOR PAGINATION
$results_per_page = 12;
// STATION RELATED VARS
$station_name = "103.7 The Eagle";
$pages_to_ignore_gcmaz = array(1882, 1881, 1880, 1879, 1878, 1877, 1846, 1845, 15);
$pages_to_ignore_local = array(50);
/************************************
 * GET SEARCH TERMS AND PREPARE SQL STATEMENT
 *  I.  create an array of search terms
 *  II. define and remove stop words
 *  III. compose sql statement of search terms
 *  IV. call the search function or return no results
开发者ID:smark73,项目名称:eagle,代码行数:31,代码来源:search.php

示例7: someWpTablesExist

 /**
  * Checks if some tables with the given prefix exist in the database
  *
  * @param string $dbUser
  * @param string $dbPassword
  * @param string $dbName
  * @param string $dbHost
  * @param string $dbPrefix
  * @return bool
  */
 private function someWpTablesExist($dbUser, $dbPassword, $dbName, $dbHost, $dbPrefix)
 {
     $wpdb = new \wpdb($dbUser, $dbPassword, $dbName, $dbHost);
     $wpdb->set_prefix($dbPrefix);
     $tables = $wpdb->get_col("SHOW TABLES LIKE '{$dbPrefix}_%'");
     $wpTables = array_intersect($tables, $wpdb->tables());
     return count($wpTables) > 0;
 }
开发者ID:wp-cpm,项目名称:versionpress,代码行数:18,代码来源:vp.php

示例8: fix_multisite_domains

 /**
  * In multisite mode WordPress uses site domain to work out which blog to show. Domains are stored in the database.
  * However, domains will be different for different SitePush versions of a site, so this won't work unless
  * we make sure the database has the right domains for the right sites.
  *
  * This method makes sure the database has the correct domains in place.
  *
  * @requires domain map file (path set in options)
  */
 private function fix_multisite_domains()
 {
     $sitepush_domain_map = parse_ini_file($this->options->domain_map_conf, TRUE);
     if ($this->dry_run) {
         $this->add_result("Fixing destination domains for multisite (not done because this is a dry run)", 2);
         return FALSE;
     } else {
         $this->add_result("Fixing destination domains for multisite", 2);
     }
     //create a new WPDB object for the database we are pushing to
     $db_dest = $this->options->get_db_params_for_site($this->dest);
     $dest_host = empty($db_dest['host']) ? DB_HOST : $db_dest['host'];
     $spdb = new wpdb($db_dest['user'], $db_dest['pw'], $db_dest['name'], $dest_host);
     //set up $spdb properties
     global $table_prefix;
     $spdb->set_prefix($table_prefix);
     $sitepush_replace_urls = $sitepush_domain_map[$this->dest];
     $sitepush_replace_urls = array_unique($sitepush_replace_urls);
     //remove any duplicates
     unset($sitepush_domain_map[$this->dest]);
     $sitepush_search_sites = array_keys($sitepush_domain_map);
     $blogs = $spdb->get_results("SELECT blog_id FROM {$spdb->blogs}", ARRAY_A);
     //cycle through each domain for this site
     foreach ($sitepush_replace_urls as $site_id => $sitepush_replace_url) {
         //cycle through each sitepush site
         foreach ($sitepush_search_sites as $sitepush_search_site) {
             $sitepush_search_url = empty($sitepush_domain_map[$sitepush_search_site][$site_id]) ? '' : $sitepush_domain_map[$sitepush_search_site][$site_id];
             if (!$sitepush_search_url) {
                 continue;
             }
             //domain wasn't specified for that site
             //update domain in wp_site
             $spdb->query($spdb->prepare("UPDATE {$spdb->site} SET domain = %s WHERE domain = %s", array($sitepush_replace_url, $sitepush_search_url)));
             //update domain in wp_sitemeta
             $spdb->query($spdb->prepare("UPDATE {$spdb->sitemeta} SET meta_value = REPLACE(meta_value, %s, %s) WHERE meta_key = 'siteurl'", array($sitepush_search_url, $sitepush_replace_url)));
             //update domain in wp_blogs
             $spdb->query($spdb->prepare("UPDATE {$spdb->blogs} SET domain = %s WHERE domain = %s", array($sitepush_replace_url, $sitepush_search_url)));
             //update domain in main wp_options
             $spdb->query($spdb->prepare("UPDATE {$spdb->base_prefix}options SET option_value = REPLACE(option_value, %s, %s) WHERE option_name = 'siteurl' OR option_name = 'home' OR option_name = 'fileupload_url' ", array($sitepush_search_url, $sitepush_replace_url)));
             //update domain in wp_options for each site
             foreach ($blogs as $blog_id) {
                 $spdb->query($spdb->prepare("UPDATE {$spdb->base_prefix}{$blog_id['blog_id']}_options SET option_value = REPLACE(option_value, %s, %s) WHERE option_name = 'siteurl' OR option_name = 'home' OR option_name = 'fileupload_url' ", array($sitepush_search_url, $sitepush_replace_url)));
             }
         }
     }
 }
开发者ID:iPublicis,项目名称:sitepush,代码行数:55,代码来源:class-sitepush-core.php


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