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


PHP mysqli::mysqli方法代码示例

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


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

示例1: __construct

 /**
  * Creates the Database object and sets the database connection info based on
  * the config file.
  *
  * You can connect to another database on the server listed in the config class by passing its
  * name in the constructor
  *
  * Only supports Mysql databases.
  *
  * @see includes/walleye.config.php
  * @param string $db
  */
 private function __construct($db = null)
 {
     $dbOptions = Walleye::getInstance()->getDbOptions();
     $server = $dbOptions['SERVER'];
     $user = $dbOptions['USER'];
     $password = $dbOptions['PASS'];
     $port = $dbOptions['PORT'];
     if (is_null($db)) {
         $database = $dbOptions['DATABASE'];
     } else {
         $database = $db;
     }
     parent::mysqli($server, $user, $password, $database, $port);
 }
开发者ID:Jmayhak,项目名称:Walleye,代码行数:26,代码来源:walleye.database.php

示例2: __construct

 /**
  * Creates a mysqli instance representing a connection to a database
  *
  * @author Basilio Briceno <bbh@tlalokes.org>
  * @param array $dsn An array with DSN information
  * @return mysqli Returns a mysqli object on success
  */
 public function __construct(array &$dsn)
 {
     $conn = parent::mysqli($dsn['host'], $dsn['username'], $dsn['password'], $dsn['name']);
     if (mysqli_connect_errno($this)) {
         throw new Exception("Failed to connect: " . mysqli_connect_error());
     }
     return $conn;
 }
开发者ID:nmicht,项目名称:tlalokes,代码行数:15,代码来源:classes.php

示例3: mysqli

require_once "../vendor/autoload.php";
use Configuration\Configuration;
error_reporting(0);
echo "\n<!DOCTYPE html>\n<html>\n<head>\n<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />\n<meta name='viewport' content='width=device-width'/>\n<title>Login & Signup Kit Database Installation</title>\n</head>\n\n<body>\n<h1>Login & Signup Kit Database Installation</h1>\n";
if (isset($_GET["install"])) {
    $dbPassword = Configuration::DATABASE_PASSWORD;
    $dbUser = Configuration::DATABASE_USER;
    $dbHost = Configuration::DATABASE_HOST;
    $dbPort = Configuration::DATABASE_PORT;
    $dbDatabase = Configuration::DATABASE_NAME;
    $dbDatabasePrefix = Configuration::DATABASE_PREFIX;
    $completeDatabaseName = $dbDatabasePrefix . $dbDatabase;
    $dbInstall = false;
    $mysqli = new mysqli();
    $mysqli->mysqli($dbHost, $dbUser, $dbPassword, $completeDatabaseName, $dbPort);
    if ($mysqli->connect_error) {
        $cfg_result = "<p>Cant connect to MySQL server. Check MySQL configuration file (DbConnection.php)</p>";
    } else {
        $databaseCreate = "\n        CREATE DATABASE IF NOT EXISTS " . $completeDatabaseName . " DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;\n        ";
        $loginAttempts = "\n\t    CREATE TABLE IF NOT EXISTS login_attempts (\n        user_id int(11) NOT NULL,\n        time varchar(30) NOT NULL,\n        attemp_id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,\n        time_stamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP\n        ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;\n\t    ";
        $membersTable = "\n        CREATE TABLE IF NOT EXISTS members (\n        id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,\n        username varchar(30) NOT NULL,\n        email varchar(50) NOT NULL,\n        password char(128) NOT NULL\n        ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;\n\t    ";
        $password = '$2y$15$BTm77jO53MqbZXHNCHBtsujee0BcaqLPOQTVtILGlDfhOHKEmJmzW';
        $membersData = "\n        INSERT INTO members (username, email, password) VALUES\n        ('test', 'test@test.com','" . $password . "');\n        ";
        $passwordRequest = "\n        CREATE TABLE IF NOT EXISTS password_requests (\n        id_request int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,\n        user_email varchar(50) NOT NULL,\n        time_stamp varchar(100) NOT NULL,\n        token varchar(150) NOT NULL\n        ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\n\n        ";
        echo '<h2>Installer Log:</h2>';
        $stmt = $mysqli->prepare($databaseCreate);
        if ($stmt->execute()) {
            $cfg_result = "<p style='color: green'>New " . $completeDatabaseName . " database created successfully</p>";
        } else {
            $cfg_result = "<p>Error creating " . $completeDatabaseName . " database</p>";
开发者ID:AntonioIrp,项目名称:mi-web,代码行数:30,代码来源:index.php

示例4:

 function __construct()
 {
     parent::mysqli(DBHOST, DBUSERNAME, DBPASSWORD, DBNAME);
 }
开发者ID:Ristee,项目名称:mvc4,代码行数:4,代码来源:database.class.php


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