当前位置: 首页>>代码示例>>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;未经允许,请勿转载。