Example #1
0
 /**
  * Get the MySqli connection
  * @return mysqli
  */
 public static function getConnection()
 {
     if (self::$instance == NULL) {
         self::$instance = new DBCnf();
     }
     return self::$instance->conn;
 }
 /**
  * Storing new user
  * returns user details
  */
 public function storeUser($name, $email, $regid)
 {
     $con = DBCnf::getConnection();
     $sql = "insert into gcm_users set name=" . "'" . $name . "',email=" . "'" . $email . "',gcm_regid=" . "'" . $regid . "',created_at=NOW()";
     $result = mysqli_query($con, $sql);
     if ($result) {
         $id = mysqli_insert_id($con);
         // last inserted id
         $result = mysqli_query($con, "SELECT * FROM gcm_users WHERE id = {$id}") or die(mysql_error());
         if (mysqli_num_rows($result) > 0) {
             return mysqli_fetch_array($result);
         } else {
             return false;
         }
     } else {
         return false;
     }
 }