本文整理汇总了PHP中Helpers::dbConnect方法的典型用法代码示例。如果您正苦于以下问题:PHP Helpers::dbConnect方法的具体用法?PHP Helpers::dbConnect怎么用?PHP Helpers::dbConnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Helpers
的用法示例。
在下文中一共展示了Helpers::dbConnect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
$token = Request::header('X-Auth-Token');
$this->user = json_decode(AuthToken::validate($token));
$this->api_token = Input::get('api_token');
$this->page = Input::get('page');
$this->per_page = Input::get('per_page');
$this->type = Input::get('type');
$this->dbConnect = Helpers::dbConnect();
}
示例2: SK_registerUser
public static function SK_registerUser($data = 0)
{
$dbConnect = Helpers::dbConnect();
//$dbConnect = mysqli_connect($sql_host, $sql_user, $sql_pass, $sql_name,$sql_port);
mysqli_set_charset($dbConnect, "utf8");
// Check connection
if (mysqli_connect_errno($dbConnect)) {
exit(mysqli_connect_error());
}
if (!is_array($data)) {
return false;
}
if (!empty($data['name']) && !empty($data['username']) && !empty($data['email']) && !empty($data['password']) && !empty($data['gender'])) {
$name = $data['name'];
$username = $data['username'];
$email = $data['email'];
$password = trim($data['password']);
$md5_password = md5($password);
$gender = $data['gender'];
//echo SK_validateUsername($username) . " " . is_numeric($username) . " " . !SK_validateEmail($email) . " " . !preg_match('/(male|female)/', $gender);
if (!Helpers::SK_validateUsername($username)) {
return false;
}
if (is_numeric($username)) {
return false;
}
if (!Helpers::SK_validateEmail($email)) {
return false;
}
if (!preg_match('/(male|female)/', $gender)) {
return false;
}
$query_one = "INSERT INTO accounts (active,cover_id,email,email_verification_key,name,password,time,type,username) VALUES (1,0,'{$email}','" . md5(Helpers::SK_generateKey()) . "','{$name}','{$md5_password}'," . time() . ",'user','{$username}')";
$sql_query_one = mysqli_query($dbConnect, $query_one);
if ($sql_query_one) {
$user_id = mysqli_insert_id($dbConnect);
$query_two = "INSERT INTO users (id,gender) VALUES ({$user_id},'{$gender}')";
$sql_query_two = mysqli_query($dbConnect, $query_two);
if ($sql_query_two) {
//$get = SK_getUser($user_id, true);
//return $get;
}
}
}
}
示例3: changePassword
public function changePassword()
{
$params = Input::all();
$old_password = md5(Helpers::SK_secureEncode($params['old_password']));
$new_password = md5(Helpers::SK_secureEncode($params['new_password']));
//$hash = md5($password);
$userId = (int) $this->user->id;
$dbConnect = Helpers::dbConnect();
if ($old_password && $old_password != $new_password) {
$find = mysqli_query($dbConnect, "SELECT password from accounts WHERE id = {$userId} AND password = '{$old_password}'");
$sql_numrows = mysqli_num_rows($find);
if ($sql_numrows == 1) {
//$sql_fetch = mysqli_fetch_assoc($sql_query);
$res = mysqli_query($dbConnect, "UPDATE accounts SET password = '{$new_password}' WHERE id = {$userId}");
if ($res) {
return Response::json(array('status' => '1', 'message' => 'Success, your password is changed', 'user_id' => $userId));
} else {
return Response::json(array('status' => '0', 'message' => 'Failed', 'user_id' => $userId));
}
}
return Response::json(array('status' => '0', 'message' => 'Failed, more than 1 user found', 'user_id' => $userId));
}
return Response::json(array('status' => '0', 'message' => 'Failed, new password should not be same as old password', 'user_id' => $userId));
}