class내에서 php4와 php5에서 호환가능한 __construct 함수(include변수사용가능)
//class내에서 php4와 php5에서 호환가능한 __construct 함수만들기(include변수사용가능)
include_once '외부의DB관련설정파일.php';
global $db_host,$db_user,$db_pass,$db_name;
$db_host = 외부변수;
$db_user = 외부변수;
$db_pass = 외부변수;
$db_name = 외부변수;
class GPLmysql extends GPLmessage{
var $db_host,$db_user,$db_pass,$db_name,$db_conn;
function GPLmysql_connect($db_host='',$db_user='',$db_pass='',$db_name=''){
$argcv = func_get_args();
call_user_func_array(array(&$this, '__construct'),$argcv); //호출하는 __construct생성자함수명을 동일하게 하는것이 php4에서 사용가능하게하는 핵심
}
function __construct($db_host='',$db_user='',$db_pass='',$db_name='') {
global $db_host,$db_user,$db_pass,$db_name;
$this->db_host = $db_host;
$this->db_user = $db_user;
$this->db_pass = $db_pass;
$this->db_name = $db_name;
$this->db_conn = @mysql_connect($this->db_host,$this->db_user,$this->db_pass) or die("데이타 베이스에 접속이 불가능합니다.");
@mysql_query("set names utf8");//한글깨져서 추가
@mysql_select_db( $this->db_name, $this->db_conn);
}
.... 생략
}