當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DataBase::getConnection方法代碼示例

本文整理匯總了PHP中DataBase::getConnection方法的典型用法代碼示例。如果您正苦於以下問題:PHP DataBase::getConnection方法的具體用法?PHP DataBase::getConnection怎麽用?PHP DataBase::getConnection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DataBase的用法示例。


在下文中一共展示了DataBase::getConnection方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __construct

 function __construct()
 {
     $this->db = DataBase::getConnection();
 }
開發者ID:EmmanuelSW,項目名稱:MeetupPHP,代碼行數:4,代碼來源:wine.php

示例2: User

 * This file should be removed once this is done.
 */
require_once 'app/config/SecurityConfig.php';
require_once 'app/helperClasses/database/DataBase.php';
require_once 'app/helperClasses/database/DataBaseException.php';
require_once 'app/models/user/User.php';
require_once 'app/helperClasses/random/Random.php';
// Generate password salt
$passwordSalt = Random::getGuid();
// Create new user
$user = new User();
$user->userId = 0;
$user->email = 'admin@stippers.be';
$user->firstName = 'admin';
$user->lastName = 'admin';
$user->street = 'Stippers street';
$user->houseNumber = '1';
$user->city = 'Stippers city';
$user->postalCode = '0000';
$user->country = 'Belgium';
$user->dateOfBirth = '23/03/1993';
$user->isAdmin = true;
$user->phone = '';
$user->passwordHash = hash_pbkdf2('sha256', 'Passw0rd', $passwordSalt, SecurityConfig::N_PASSWORD_HASH_ITERATIONS);
// Insert user in data base
$conn = DataBase::getConnection();
$commString = 'INSERT INTO stippers_users (user_id, email, first_name, last_name, password_hash, password_salt, phone, date_of_birth, street, house_number, city, postal_code, country) ' . 'VALUES (?, ?, ?, ?, ?, ?, ?, STR_TO_DATE(?, "%d/%m/%Y"), ?, ?, ?, ?, ?)';
$stmt = $conn->prepare($commString);
$stmt->bind_param('issssssssssss', $user->userId, $user->email, $user->firstName, $user->lastName, $user->passwordHash, $passwordSalt, $user->phone, $user->dateOfBirth, $user->street, $user->houseNumber, $user->city, $user->postalCode, $user->country);
$stmt->execute();
$conn->close();
開發者ID:JHDeStip,項目名稱:Stippers,代碼行數:31,代碼來源:createAdmin.php


注:本文中的DataBase::getConnection方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。