2014-02-18 2 views
1

이온 인증을 통해 사용자를 인증하는 데 다른 데이터베이스를 사용할 수 있습니까? 사용자 인증 전용 데이터베이스를 만들고 싶습니다. 따라서 트랜잭션 데이터베이스와 분리되어야합니다. 어떻게 그럴 수 있습니까?이온 인증 (Codeigniter) - 다른 데이터베이스 사용 방법

감사합니다.

+0

어떤 데이터베이스를 사용하고 있습니까? – arty

+0

가능한 중복 [Codeigniter - 다중 데이터베이스 연결] (http://stackoverflow.com/questions/8268853/codeigniter-multiple-database-connections) – arty

답변

2

요컨대 ... 네, 인증을 위해 다른 데이터베이스를 사용할 수 있습니다. 기본 구성 외에도 application/config/database.php 파일 (아래와 유사)에서 두 번째 데이터베이스 구성을 작성해야합니다. 그런 다음 데이터베이스를로드 할 때 사용자가 설정 한 것이 두 번째 DB 구성을 사용하도록 ion_auth 모델을 수정해야 할 것 http://ellislab.com/codeigniter/user-guide/database/configuration.html

- 더 참조 참조

$db['default']['hostname'] = "localhost"; 
$db['default']['username'] = "root"; 
$db['default']['password'] = ""; 
$db['default']['database'] = "db_name"; 
$db['default']['dbdriver'] = "mysql"; 

$db['authentication']['hostname'] = "localhost"; 
$db['authentication']['username'] = "root"; 
$db['authentication']['password'] = ""; 
$db['authentication']['database'] = "auth_db_name"; 
$db['authentication']['dbdriver'] = "mysql"; 

.

$auth_db = $this->load->database('authentication', TRUE); 

그런 다음 $auth_db으로 $this->db 대체 모델에 모든 데이터베이스 쿼리를 변경합니다.

따라서 $this->db->select('password, salt')$auth_db->select('password, salt')이됩니다. 추가 참조를 참조하십시오

- 도움 http://ellislab.com/codeigniter/user-guide/database/connecting.html

희망!

2

가장 간단한 방법은 MY_Mark의 말을 확장하는 것입니다.

이 ion_auth_model.php의 생성자에서 그런 다음 새로운 DB의 설정

$db['authentication']['hostname'] = "localhost"; 
$db['authentication']['username'] = "root"; 
$db['authentication']['password'] = ""; 
$db['authentication']['database'] = "auth_db_name"; 
$db['authentication']['dbdriver'] = "mysql"; 

작성이 수행

$this->db = $this->load->database('authentication', TRUE); 

을 그리고 그것은 단지 그 후 작동합니다.