Created
October 15, 2012 15:47
-
-
Save tony1223/3893198 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | |
class UserModel extends CI_Model { | |
function __construct() | |
{ | |
parent::__construct(); | |
} | |
function insert($account,$password){ | |
$this->db->insert("user", | |
Array( | |
"account" => $account, | |
"password" => $password | |
)); | |
} | |
function checkUserExist($account){ | |
$this->db->select("COUNT(*) AS users"); | |
$this->db->from("user"); | |
$this->db->where("account", $account); | |
$query = $this->db->get(); | |
return $query->row()->users > 0 ; | |
} | |
public function getUser($account,$password){ | |
$this->db->select("*"); | |
$query = $this->db->get_where("user",Array("account" => $account, "password" => $password )); | |
if ($query->num_rows() > 0){ //如果數量大於0 | |
return $query->row(); //回傳第一筆 | |
}else{ | |
return null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment