本文整理汇总了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();
}
示例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();