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


PHP Helpers::dbConnect方法代码示例

本文整理汇总了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();
 }
开发者ID:korrio,项目名称:LASTVMAPI,代码行数:10,代码来源:PostsController.php

示例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;
             }
         }
     }
 }
开发者ID:korrio,项目名称:wouchat-api,代码行数:45,代码来源:Helpers.php

示例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));
 }
开发者ID:korrio,项目名称:wouchat-api,代码行数:24,代码来源:UserController.php


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