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


PHP MySQLi::select_db方法代码示例

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


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

示例1: setUp

 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->addToContainer('link', function ($c) {
         $db_host = $this->getTestMySqlConnectionParam('host', 'localhost');
         $db_port = $this->getTestMySqlConnectionParam('port', 3306);
         $db_user = $this->getTestMySqlConnectionParam('user', 'root');
         $db_pass = $this->getTestMySqlConnectionParam('pass', '');
         $db_name = $this->getTestMySqlConnectionParam('database', $this->getTestMySqlDatabaseName($c['app_name']));
         $link = new \MySQLi("{$db_host}:{$db_port}", $db_user, $db_pass);
         if ($link->connect_error) {
             throw new RuntimeException('Failed to connect to database. MySQL said: ' . $link->connect_error);
         }
         if (!$link->select_db($db_name)) {
             throw new RuntimeException('Failed to select database');
         }
         return $link;
     });
     $this->addToContainer('connection', function ($c) {
         $connection = new MysqliConnection($c['link']);
         $connection->execute('SET foreign_key_checks = 0;');
         foreach ($connection->getTableNames() as $table_name) {
             $connection->dropTable($table_name);
         }
         $connection->execute('SET foreign_key_checks = 1;');
         return $connection;
     });
 }
开发者ID:activecollab,项目名称:bootstrap,代码行数:31,代码来源:DatabaseTestCase.php

示例2: selectDatabase

 public function selectDatabase($name)
 {
     if ($this->dbConn->select_db($name)) {
         $this->databaseName = $name;
         return true;
     } else {
         return false;
     }
 }
开发者ID:nicocin,项目名称:silverstripe-framework,代码行数:9,代码来源:MySQLiConnector.php

示例3: requireDatabaseOrCreatePermissions

 /**
  * Ensure that the database connection is able to use an existing database,
  * or be able to create one if it doesn't exist.
  *
  * @param array $databaseConfig Associative array of db configuration, e.g. "server", "username" etc
  * @return array Result - e.g. array('success' => true, 'alreadyExists' => 'true')
  */
 public function requireDatabaseOrCreatePermissions($databaseConfig)
 {
     $success = false;
     $alreadyExists = false;
     $conn = new MySQLi($databaseConfig['server'], $databaseConfig['username'], $databaseConfig['password']);
     if ($conn && $conn->select_db($databaseConfig['database'])) {
         $success = true;
         $alreadyExists = true;
     } else {
         if ($conn && $conn->query('CREATE DATABASE testing123')) {
             $conn->query('DROP DATABASE testing123');
             $success = true;
             $alreadyExists = false;
         }
     }
     return array('success' => $success, 'alreadyExists' => $alreadyExists);
 }
开发者ID:nzjoel,项目名称:sapphire,代码行数:24,代码来源:MySQLDatabaseConfigurationHelper.php

示例4: init

 private function init()
 {
     $handle = new MySQLi();
     $handle->init();
     $handle->options(MYSQLI_OPT_CONNECT_TIMEOUT, 5);
     if (@$handle->real_connect(_DBMS_HOST, _DBMS_LOGIN, _DBMS_PASS, _DBMS_DB) === FALSE) {
         throw new DatabaseException($handle->connect_error);
     }
     if (!$handle->select_db(_DBMS_DB)) {
         throw new DatabaseException('Can\'t connect to Database !');
     }
     return $handle;
 }
开发者ID:Korko,项目名称:RiskOnline,代码行数:13,代码来源:MySQL_DBMS.php

示例5: MySQLi

<?php

session_start();
date_default_timezone_set('Asia/Kolkata');
$host = "localhost";
$user = "root";
$pwd = "root";
$db = "adminp";
$url = "http://localhost/TH/index.php";
$con = new MySQLi($host, $user, $pwd);
$con->select_db($db);
$id = session_id();
$tm = time();
session_destroy();
$query = "update user_details set th_session_end='" . $tm . "' where th_session_id='" . $id . "'";
$con->query($query);
header("Location: " . $url);
die;
exit;
开发者ID:ronakjain2012,项目名称:TH,代码行数:19,代码来源:signout.php

示例6: select_db

 public function select_db($dbname = '')
 {
     if (!parent::select_db($this->cfg['database'])) {
         throw new Poodle_SQL_Exception($this->error, $this->errno, Poodle_SQL_Exception::NO_DATABASE);
     }
     //		if (POODLE_SETUP) parent::query("ALTER DATABASE `{$this->cfg['database']}` CHARACTER SET {$this->cfg['charset']} COLLATE {$this->cfg['charset']}_bin");
 }
开发者ID:cbsistem,项目名称:nexos,代码行数:7,代码来源:mysqli.php

示例7:

 function __construct()
 {
     parent::__construct('*', '*', '*');
     parent::select_db('zs1jas_1');
     parent::query("SET NAMES utf8");
 }
开发者ID:b4naser,项目名称:social_website,代码行数:6,代码来源:database.class.php

示例8: strpos

 *  
 *  Changelog:
 *   8/21/2014 - Added comment header
 */
/**  **  **  **  **  **  **  **  **  **
 *   SETUP CONNECTION PARAMETERS
 */
$mode = strpos($_SERVER['SERVER_NAME'], 'in.genio.us') !== false ? "production" : "testing";
switch ($mode) {
    case 'production':
        // PRODUCTION SERVER VARIABLES
        define("HN", "mysql.in.genio.us");
        define("UN", "ingenious_db_un");
        define("PW", "QoA9ImefL0hu7Z");
        define("DB", "aimsysdb");
        break;
    case 'testing':
        // TESTING SERVER VARIABLES
        define("HN", "10.0.100.250");
        define("UN", "aimsys_db_un");
        define("PW", "P@ssw0rd");
        define("DB", "aimsysdb");
        break;
}
/**  **  **  **  **  **  **  **  **  **
 *   ESTABLISH DB CONNECTION
 */
global $dbc;
$dbc = new MySQLi(HN, UN, PW);
$dbc->select_db(DB);
开发者ID:Gimcrack,项目名称:aimsys,代码行数:30,代码来源:db.php

示例9: add_user

function add_user($Uname, $Upass, $Urole)
{
    try {
        $host = "localhost";
        $user = "root";
        $pwd = "root";
        $db = "adminp";
        $con = new MySQLi($host, $user, $pwd);
        $con->select_db($db);
        $Uname1 = $Uname;
        $Uname = hash('md5', $Uname);
        $Upass = hash('md5', $Upass);
        $query = "insert into admin_users (u_name,u_pwd,u_role) values('" . $Uname . "','" . $Upass . "','" . $Urole . "')";
        if ($con->query($query)) {
            ?>
<div class="alert alert-success fade in" style="text-align:left;"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Success !</strong>Admin User is Added. USER :<?php 
            echo $Uname1;
            ?>
</div>
<?php 
        } else {
            ?>
<div class="alert alert-danger fade in" style="text-align:left;"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Unsuccess !</strong>User already EXISTS</div>
<?php 
        }
    } catch (Exception $ex) {
        print "{$ex}";
    }
    $con->close();
}
开发者ID:ronakjain2012,项目名称:TH,代码行数:30,代码来源:dashboard.php


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