2010-04-28 6 views
1

Codeigniter 프레임 워크에서 PHP를하고 있습니다. 항상 Codeigniter는 기본 영구 연결을 지원합니다. 그 연결을 사용하고 싶지 않습니다. 수동으로 연결해야합니다. Codeigniter에서 가능합니까? 아무도 모른다면 내가 앞으로 나아갈 수 있도록 도와주세요. 나는 약간의 설명도 필요합니다.Codeigniter 매뉴얼 데이터베이스 연결

답변

2

영구 연결을 원하지 않으면 config 파일을 설정하십시오.

$config['hostname'] = "localhost"; 
$config['username'] = "myusername"; 
$config['password'] = "mypassword"; 
$config['database'] = "mydatabase"; 
$config['dbdriver'] = "mysql"; 
$config['dbprefix'] = ""; 

$config['pconnect'] = FALSE; 

$config['db_debug'] = TRUE; 
$config['cache_on'] = FALSE; 
$config['cachedir'] = ""; 
$config['char_set'] = "utf8"; 
$config['dbcollat'] = "utf8_general_ci"; 

$this->load->database($config); 


당신은 당신은/설정/databse.php

값은 특정 environment.For 예에 따라, 사용하는 경우를 응용 프로그램에서 파일을 업데이트해야

+0

** ** pconnect ** 지속적인 연결 –

0

http://codeigniter.com/user_guide/database/connecting.html에서 자세한 내용을보실 수 있습니다 SQLite를 사용하면 사용자 이름이나 암호를 입력 할 필요가 없으며 데이터베이스 이름은 데이터베이스 파일의 경로가됩니다.

xampp 서버를 사용하는 경우 암호 필드를 비워 둡니다.

$active_group ='default'; 
$query_builder = TRUE; 

$db['default'] = array(
    'dsn' => '', 
    'hostname' => 'localhost', 
    'username' => 'root', 
    'password' => '', 
    'database' => 'test', 
    'dbdriver' => 'mysqli', 
    'dbprefix' => '', 
    'pconnect' => FALSE, 
    'db_debug' => (ENVIRONMENT !== 'production'), 
    'cache_on' => FALSE, 
    'cachedir' => '', 
    'char_set' => 'utf8', 
    'dbcollat' => 'utf8_general_ci', 
    'swap_pre' => '', 
    'encrypt' => FALSE, 
    'compress' => FALSE, 
    'stricton' => FALSE, 
    'failover' => array(), 
    'save_queries' => TRUE 
); 
관련 문제