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


PHP mysqli::close方法代码示例

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


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

示例1: authenticateWithEmail

 /**
  * (non-PHPdoc)
  * @see IUserLoginMethod::authenticateWithEmail()
  */
 public function authenticateWithEmail($email, $password)
 {
     // connect to a data base
     // Note: If your source application shares the same data base, you can simply use $this->_db, rather than open another connection.
     $mysqli = new mysqli($this->_websoccer->getConfig('db_host'), $this->_websoccer->getConfig('db_user'), $this->_websoccer->getConfig('db_passwort'), $this->_websoccer->getConfig('db_name'));
     // get user from your source table
     $escapedEMail = $mysqli->real_escape_string($email);
     $dbresult = $mysqli->query('SELECT password FROM mydummy_table WHERE email = \'' . $escapedEMail . '\'');
     if (!$dbresult) {
         throw new Exception('Database Query Error: ' . $mysqli->error);
     }
     $myUser = $dbresult->fetch_array();
     $dbresult->free();
     $mysqli->close();
     // could not find user
     if (!$myUser) {
         return FALSE;
     }
     // check is password is correct (in this sample case a simple MD5 hashing is applied).
     if ($myUser['password'] != md5($password)) {
         return FALSE;
     }
     // user is valid user according to custom authentication check. Now test if user already exists in local DB and return its ID.
     $existingUserId = UsersDataService::getUserIdByEmail($this->_websoccer, $this->_db, strtolower($email));
     if ($existingUserId > 0) {
         return $existingUserId;
     }
     // if user does not exist, create a new one. Nick name can be entered by user later.
     return UsersDataService::createLocalUser($this->_websoccer, $this->_db, null, $email);
 }
开发者ID:astroChasqui,项目名称:open-websoccer,代码行数:34,代码来源:DemoUserLoginMethod.class.php

示例2: getMailData

function getMailData()
{
    $mysqli = new mysqli($GLOBALS["servername"], $GLOBALS["server_username"], $GLOBALS["server_password"], $GLOBALS["database"]);
    $stmt = $mysqli->prepare("SELECT comment_id, user_id, text FROM eksam_comment WHERE send_email = ?");
    $stmt->bind_param("s", $_SESSION["user_email"]);
    $stmt->bind_result($comment_id, $id_mail, $text);
    $stmt->execute();
    // tühi massiiv kus hoiame objekte (1 rida andmeid)
    $array = array();
    // tee tsüklit nii mitu korda, kui saad
    // ab'ist ühe rea andmeid
    while ($stmt->fetch()) {
        // loon objekti iga while tsükli kord
        $mail = new StdClass();
        $mail->comment_id = $comment_id;
        $mail->id_mail = $id_mail;
        $mail->text = $text;
        // lisame selle massiivi
        array_push($array, $mail);
        //echo "<pre>";
        //var_dump($array);
        //echo "</pre>";
    }
    $stmt->close();
    $mysqli->close();
    return $array;
}
开发者ID:Max1mov,项目名称:2.kodutoo-II-ruhm,代码行数:27,代码来源:functions.php

示例3: handle_login

function handle_login()
{
    $username = $_POST['username'];
    $password = $_POST['password'];
    require_once 'db.conf';
    $mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
    if ($mysqli->connect_error) {
        $error = 'Error: ' . $mysqli->connect_errno . ' ' . $mysqli->connect_error;
        require "login_form.php";
        exit;
    }
    $username = $mysqli->real_escape_string($username);
    $password = $mysqli->real_escape_string($password);
    $query = "SELECT * FROM users WHERE username = '{$username}' AND password = '{$password}'";
    $mysqliResult = $mysqli->query($query);
    // print_r(mysqli_fetch_all($mysqliResult,MYSQLI_ASSOC));
    if ($mysqliResult) {
        $match = $mysqliResult->num_rows;
        $mysqliResult->close();
        $mysqli->close();
        //print "The match is $match";
        if ($match == 1) {
            $_SESSION['loggedin'] = $username;
            header("Location: home.php");
            exit;
        } else {
            $error = "Incorrect username or password";
            require "login_form.php";
            exit;
        }
    }
}
开发者ID:Jrf5x8,项目名称:tennis,代码行数:32,代码来源:login.php

示例4: modificaCoche

function modificaCoche($coche)
{
    //alert($coche->login);
    global $servidor, $bd, $usuario, $contrasenia;
    try {
        @($db = new mysqli($servidor, $usuario, $contrasenia));
        if (mysqli_connect_errno() != 0) {
            throw new Exception('Error conectando:' . mysqli_connect_error(), mysqli_connect_errno());
        }
        $db->select_db($bd);
        if ($db->errno != 0) {
            throw new Exception('Error seleccionando bd:' . $db->error, $db->errno);
        }
        $consulta = "update coches set marca='" . $coche->marca . "', modelo='" . $coche->modelo . "', color='" . $coche->color . "' where matricula='" . $coche->matricula . "'";
        if ($db->query($consulta) === false) {
            throw new ExcepcionEnTransaccion();
        }
        $db->commit();
        $db->close();
    } catch (ExcepcionEnTransaccion $e) {
        echo 'No se ha podido realizar la modificacion';
        $db->rollback();
        $db->close();
    } catch (Exception $e) {
        echo $e->getMessage();
        if (mysqli_connect_errno() == 0) {
            $db->close();
        }
        exit;
    }
}
开发者ID:rubenet86,项目名称:projecteAutoEscola,代码行数:31,代码来源:cochesModelo.php

示例5: db_connect

function db_connect()
{
    global $MYSQL_HOST;
    global $MYSQL_USER;
    global $MYSQL_PASS;
    $mysqli = new mysqli($MYSQL_HOST, $MYSQL_USER, $MYSQL_PASS);
    if ($mysqli->connect_errno) {
        print "<b>Failed to connect to MySQL: " . $mysqli->connect_error . "</b><br/>\n";
        return FALSE;
    }
    if ($mysqli->select_db("trees") === FALSE) {
        print "<b>select_db() failed</b><br/>\n";
        $mysqli->close();
        return FALSE;
    }
    $result = $mysqli->query("SELECT DATABASE()");
    if ($result !== FALSE) {
        $row = $result->fetch_row();
        if ($row[0] != "trees") {
            print "<b>Unable to select database</b><br/>\n";
            $mysqli->close();
            return FALSE;
        }
    } else {
        print "<b>SELECT DATABASE() failed</b><br/>\n";
        $mysqli->close();
        return FALSE;
    }
    return $mysqli;
}
开发者ID:tmshort,项目名称:trees,代码行数:30,代码来源:mysql.php

示例6: loadData

function loadData($request)
{
    global $hostname_ISANdb;
    global $database_ISANdb;
    global $username_ISANdb;
    global $password_ISANdb;
    $mysqli = new mysqli($hostname_ISANdb, $username_ISANdb, $password_ISANdb, $database_ISANdb);
    if ($mysqli->connect_error) {
        die('Connect Error (' . $mysqli->connect_errno . ') ' . $mysqli->connect_error);
    }
    $mysqli->query("SET NAMES 'UTF8'");
    if ($request == "person") {
        if ($stmt = $mysqli->prepare("SELECT id, firstName, lastName, patrName FROM `{$request}` WHERE 1")) {
            $stmt->execute();
            $stmt->bind_result($id, $fname, $lname, $pname);
            while ($stmt->fetch()) {
                $result .= "<option value=\"{$id}\">{$lname} {$fname} {$pname}</option>";
            }
            $mysqli->close();
            return $result;
        }
    }
    if ($stmt = $mysqli->prepare("SELECT id, name FROM `{$request}` WHERE 1")) {
        $stmt->execute();
        $stmt->bind_result($id, $name);
        $result = "<option value=\"0\">Не выбрано</option>";
        while ($stmt->fetch()) {
            $result .= "<option value=\"{$id}\">{$name}</option>";
        }
        $mysqli->close();
        return $result;
    }
}
开发者ID:9dogs,项目名称:DBManager,代码行数:33,代码来源:ajax.php

示例7: checkUserLoginServe

 public function checkUserLoginServe($input)
 {
     //email, pass
     // dd(444);
     // $this->query = DB::connection('main_store');
     // $pdo = DB::connection('main_store')->getPdo();
     $conn = new mysqli('localhost', 'root', 'root', 'main_store');
     if ($conn->connect_error) {
         dd(5666);
     }
     $email = $input['email'];
     $password = $input['password'];
     $sql = "SELECT id, url, session_id FROM users WHERE email = '{$email}' and password ='{$password}' ";
     $result = $conn->query($sql);
     if ($result->num_rows > 0) {
         $row = $result->fetch_assoc();
         // dd($row['url']);
         //
         $conn->close();
         // dd(11);
         return $row['url'];
         // dd($result->fetch_assoc());
     }
     $conn->close();
     // // dd(123);
     // throw new Prototype\Exceptions\UserLoginException();
     // if (Auth::user()->attempt(Input::only('email', 'password'))){
     //           $userId = Auth::user()->get()->id;
     //           $sessionId = Common::getSessionId(Input::all(), $userId);
     //           //check database
     //           return Common::returnData(200, SUCCESS, $userId, $sessionId);
     //       }
 }
开发者ID:trantung,项目名称:online_market,代码行数:33,代码来源:BaseController.php

示例8: modificaAlumno

function modificaAlumno($alumno)
{
    global $servidor, $bd, $usuario, $contrasenia;
    try {
        @($db = new mysqli($servidor, $usuario, $contrasenia));
        if (mysqli_connect_errno() != 0) {
            throw new Exception('Error conectando:' . mysqli_connect_error(), mysqli_connect_errno());
        }
        $db->select_db($bd);
        if ($db->errno != 0) {
            throw new Exception('Error seleccionando bd:' . $db->error, $db->errno);
        }
        $consulta = "update alumnos set password='" . $alumno->password . "', nombre='" . $alumno->nombre . "', apellido='" . $alumno->apellido . "', dni='" . $alumno->dni . "', email='" . $alumno->email . "', telefono=" . $alumno->telefono . ", sexo='" . $alumno->sexo . "' where login='" . $alumno->login . "'";
        if ($db->query($consulta) === false) {
            throw new ExcepcionEnTransaccion();
        }
        $db->commit();
        $db->close();
    } catch (ExcepcionEnTransaccion $e) {
        echo 'No se ha podido realizar la modificacion';
        $db->rollback();
        $db->close();
    } catch (Exception $e) {
        echo $e->getMessage();
        if (mysqli_connect_errno() == 0) {
            $db->close();
        }
        exit;
    }
}
开发者ID:rubenet86,项目名称:projecteAutoEscola,代码行数:30,代码来源:alumnosModelo.php

示例9: auth

function auth($username, $password)
{
    // Create connection
    $mysqli = new mysqli($servername, $user, $passwd, $database);
    // Check connection
    if ($mysqli->connect_error) {
        die("Connection failed: " . $mysqli->connect_error);
    }
    if ($stmt = $mysqli->prepare("SELECT COUNT(*), wa_nickname, wa_number, wa_key FROM config where username = ? and password = ?;")) {
        $stmt->bind_param("ss", $username, $password);
        $stmt->execute();
        $stmt->bind_result($userCount, $wa_nickname, $wa_number, $wa_key);
        $stmt->fetch();
        if ($userCount == 1) {
            $_SESSION['wa_nickname'] = $wa_nickname;
            $_SESSION['wa_number'] = $wa_number;
            $_SESSION['wa_key'] = $wa_key;
            $stmt->close();
            $mysqli->close();
            return true;
        } else {
            $stmt->close();
            $mysqli->close();
            return false;
        }
    }
    return false;
}
开发者ID:KreMat,项目名称:whatsapp-broadcaster,代码行数:28,代码来源:auth.php

示例10: Find

 public function Find()
 {
     $myDBConnector = new DBConnector();
     $dbARY = $myDBConnector->infos();
     $myQuery = "SELECT MAX(usedID) FROM usedIDs";
     $connection = new mysqli($dbARY[0], $dbARY[1], $dbARY[2], $dbARY[3]);
     if ($connection->connect_error) {
         return -1;
     }
     /* database'e girdik */
     $result = $connection->query($myQuery);
     if ($result->num_rows != 0) {
         $curResult = $result->fetch_assoc();
         $newResult = $curResult["MAX(usedID)"];
         $newResult = (int) $newResult;
         $newResult = $newResult + 1;
     } else {
         $newResult = 1;
     }
     if ($connection->query("INSERT INTO usedIDs(usedID) VALUES (" . $newResult . ")") === TRUE) {
         $connection->close();
         return $newResult;
     }
     $connection->close();
     return -1;
 }
开发者ID:oguzeroglu,项目名称:serinhikaye.com,代码行数:26,代码来源:EmptyIDFinder.class.php

示例11: closeConnection

 public function closeConnection()
 {
     if ($this->isConnected()) {
         $this->connected = false;
         $this->mysqli->close();
     }
 }
开发者ID:charger88,项目名称:orange.database,代码行数:7,代码来源:MySQL.php

示例12: closeConn

 /**
  * Closes the current DB connection
  */
 public function closeConn()
 {
     if (!isset($this->_conn)) {
         return;
     }
     $this->_conn->close();
 }
开发者ID:gromtoskamp,项目名称:nom,代码行数:10,代码来源:Conn.php

示例13: Uninit

 public function Uninit()
 {
     if ($this->connection) {
         $this->connection->close();
         $this->connection = null;
     }
 }
开发者ID:Hozuki,项目名称:newbie-reg,代码行数:7,代码来源:DB.php

示例14: close

 public function close()
 {
     if ($this->connection !== NULL) {
         //            mysql_close($this->connection);
         $this->connection->close();
         $this->connection = NULL;
     }
 }
开发者ID:stefda,项目名称:pocketsail,代码行数:8,代码来源:CL_MySQL.back.php

示例15: __destruct

 /**
  * Connection destructor
  */
 public function __destruct()
 {
     if (isset($this->mysqli) && !$this->mysqli->connect_error) {
         $threadId = $this->mysqli->thread_id;
         $this->mysqli->kill($threadId);
         $this->mysqli->close();
     }
 }
开发者ID:justin-robinson,项目名称:scoop,代码行数:11,代码来源:connection.php


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