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


PHP Utils\run_mysql_command函数代码示例

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


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

示例1: config

 /**
  * Generate a wp-config.php file.
  *
  * ## OPTIONS
  *
  * --dbname=<dbname>
  * : Set the database name.
  *
  * --dbuser=<dbuser>
  * : Set the database user.
  *
  * [--dbpass=<dbpass>]
  * : Set the database user password.
  *
  * [--dbhost=<dbhost>]
  * : Set the database host. Default: 'localhost'
  *
  * [--dbprefix=<dbprefix>]
  * : Set the database table prefix. Default: 'wp_'
  *
  * [--dbcharset=<dbcharset>]
  * : Set the database charset. Default: 'utf8'
  *
  * [--dbcollate=<dbcollate>]
  * : Set the database collation. Default: ''
  *
  * [--locale=<locale>]
  * : Set the WPLANG constant. Defaults to $wp_local_package variable.
  *
  * [--extra-php]
  * : If set, the command copies additional PHP code into wp-config.php from STDIN.
  *
  * [--skip-salts]
  * : If set, keys and salts won't be generated, but should instead be passed via `--extra-php`.
  *
  * [--skip-check]
  * : If set, the database connection is not checked.
  *
  * ## EXAMPLES
  *
  *     # Standard wp-config.php file
  *     wp core config --dbname=testing --dbuser=wp --dbpass=securepswd --locale=ro_RO
  *
  *     # Enable WP_DEBUG and WP_DEBUG_LOG
  *     wp core config --dbname=testing --dbuser=wp --dbpass=securepswd --extra-php <<PHP
  *     define( 'WP_DEBUG', true );
  *     define( 'WP_DEBUG_LOG', true );
  *     PHP
  */
 public function config($_, $assoc_args)
 {
     if (Utils\locate_wp_config()) {
         WP_CLI::error("The 'wp-config.php' file already exists.");
     }
     $defaults = array('dbhost' => 'localhost', 'dbpass' => '', 'dbprefix' => 'wp_', 'dbcharset' => 'utf8', 'dbcollate' => '', 'locale' => self::get_initial_locale());
     $assoc_args = array_merge($defaults, $assoc_args);
     if (preg_match('|[^a-z0-9_]|i', $assoc_args['dbprefix'])) {
         WP_CLI::error('--dbprefix can only contain numbers, letters, and underscores.');
     }
     // Check DB connection
     if (!isset($assoc_args['skip-check'])) {
         Utils\run_mysql_command('mysql --no-defaults', array('execute' => ';', 'host' => $assoc_args['dbhost'], 'user' => $assoc_args['dbuser'], 'pass' => $assoc_args['dbpass']));
     }
     if (isset($assoc_args['extra-php']) && $assoc_args['extra-php'] === true) {
         $assoc_args['extra-php'] = file_get_contents('php://stdin');
     }
     // TODO: adapt more resilient code from wp-admin/setup-config.php
     if (!isset($assoc_args['skip-salts'])) {
         $assoc_args['keys-and-salts'] = self::_read('https://api.wordpress.org/secret-key/1.1/salt/');
     }
     $out = Utils\mustache_render('wp-config.mustache', $assoc_args);
     $bytes_written = file_put_contents(ABSPATH . 'wp-config.php', $out);
     if (!$bytes_written) {
         WP_CLI::error('Could not create new wp-config.php file.');
     } else {
         WP_CLI::success('Generated wp-config.php file.');
     }
 }
开发者ID:wturrell,项目名称:wp-cli,代码行数:78,代码来源:core.php

示例2: run_sql

 private static function run_sql($sql)
 {
     Utils\run_mysql_command('mysql --no-defaults', array('execute' => $sql, 'host' => 'localhost', 'user' => self::$db_settings['dbuser'], 'pass' => self::$db_settings['dbpass']));
 }
开发者ID:stevegrunwell,项目名称:revision-strike,代码行数:4,代码来源:FeatureContext.php

示例3: run

 private static function run($cmd, $assoc_args = array(), $descriptors = null)
 {
     $required = array('host' => DB_HOST, 'user' => DB_USER, 'pass' => DB_PASSWORD);
     if (defined('DB_CHARSET') && constant('DB_CHARSET')) {
         $required['default-character-set'] = constant('DB_CHARSET');
     }
     $final_args = array_merge($assoc_args, $required);
     Utils\run_mysql_command($cmd, $final_args, $descriptors);
 }
开发者ID:wp-cli,项目名称:wp-cli,代码行数:9,代码来源:db.php

示例4: run

 private static function run($cmd, $assoc_args = array(), $descriptors = null)
 {
     $final_args = array_merge($assoc_args, array('host' => DB_HOST, 'user' => DB_USER, 'pass' => DB_PASSWORD, 'default-character-set' => DB_CHARSET));
     Utils\run_mysql_command($cmd, $final_args, $descriptors);
 }
开发者ID:nb,项目名称:wp-cli,代码行数:5,代码来源:db.php


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