function is_username_available($username)
{
$this->db->select('1', FALSE);
$this->db->where('LOWER(username)=', strtolower($username));
$query = $this->db->get($this->table_name);
return $query->num_rows() == 0;
}
(위에 select('1', FALSE) 부분에서 에러가 나는거 같아요)$this->table_name 이 값이 제대로 나오는지 찍어보시고
3, 4번 라인 주석처리하고 해보시면 답이 나올거 같네요.
혹시 모르니까 4번 라인에 세번째 파라미터 FALSE도 넣어서 해보시구요
$this->load->database();로 DB가 정상적으로 로딩 되어 있는지 확인해 보세요.
$this->load->database(); 넣어서 해봐니Call to a member function database() on a non-object
function __construct()
{
parent::__construct();
$ci =& get_instance();
$this->table_name = $ci->config->item('db_table_prefix', 'tank_auth').$this->table_name;
$this->profile_table_name = $ci->config->item('db_table_prefix', 'tank_auth').$this->profile_table_name;
}
function __construct()
{
parent::__construct();
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
$this->load->library('security');
$this->load->library('tank_auth');
$this->lang->load('tank_auth');
}auth 컨트롤러
class Summary extends CI_Controller {
....
}
class Auth extends CI_Controller{
Auth 컨트롤러 그대로 사용하고 있으니깐요.$this->tank_auth->is_username_available();이 부분이 아래처럼 되어 있더군요.
function is_username_available($username)
{
return ((strlen($username) > 0) AND $this->ci->users->is_username_available($username));
}
function create_user($username, $email, $password, $email_activation)
{
if ((strlen($username) > 0) AND !$this->ci->users->is_username_available($username)) {
$this->error = array('username' => 'auth_username_in_use');
} elseif (!$this->ci->users->is_email_available($email)) {
$this->error = array('email' => 'auth_email_in_use');
} else {
// Hash password using phpass
$hasher = new PasswordHash(
$this->ci->config->item('phpass_hash_strength', 'tank_auth'),
$this->ci->config->item('phpass_hash_portable', 'tank_auth'));
$hashed_password = $hasher->HashPassword($password);
$data = array(
'username' => $username,
'password' => $hashed_password,
'email' => $email,
'last_ip' => $this->ci->input->ip_address(),
);
if ($email_activation) {
$data['new_email_key'] = md5(rand().microtime());
}
if (!is_null($res = $this->ci->users->create_user($data, !$email_activation))) {
$data['user_id'] = $res['user_id'];
$data['password'] = $password;
unset($data['last_ip']);
return $data;
}
}
return NULL;
}
보니깐 위에 처럼 되어 있네요.application/config/autoload.php 에서 아래 설정 추가하면 해결됩니다.
$autoload['libraries'] = array("database");
$this->db->select('1', FALSE); <- 이 부분은 필드나 테이블명을 백틱(`)으로 감싸지 말라는 것인데 1만 준다면 필요가 없을 것 같습니다.
$this->db->select('1');로 해보세요