class class_MySQL{
var $cl_Conn;
var $cl_HostName = "";
var $cl_UserID = "";
var $cl_Password = "";
var $cl_DbName = "";
var $cl_Rows = 0;
//
//コンストラクタ
//
function class_MySQL(){
$file_name = "/home/client/k3310000/my_sql.ini";
if(!file_exists($file_name)){
die("my_sql.ini file not found.");
}else{
$fp = fopen($file_name, "r");
if(!$fp){
die("my_sql.ini can't open.");
}else{
$this->cl_HostName = trim(fgets($fp));
$this->cl_UserID = trim(fgets($fp));
$this->cl_Password = trim(fgets($fp));
$this->cl_DbName = trim(fgets($fp));
}
fclose($fp);
}
// echo "$this->cl_HostName
";
// echo "$this->cl_UserID
";
// echo "$this->cl_Password
";
// echo "$this->cl_DbName
";
//接続
$this->cl_Conn = mysql_connect($this->cl_HostName, $this->cl_UserID, $this->cl_Password);
if(!$this->cl_Conn){
die("DB connect error.");
}
//データベース選択
if(!mysql_select_db($this->cl_DbName, $this->cl_Conn)){
die("DB select error.");
}
}
//クエリ処理
function sql_query($sql_str){
$this->cl_Rows = mysql_query($sql_str, $this->cl_Conn);
if(!$this->cl_Rows){
die("DB error
{$sql_str}
" .mysql_errno().":
".mysql_errno());
}
return $this->cl_Rows;
}
//DATA FETCH
function sql_fetch(){
return mysql_fetch_array($this->cl_Rows);
}
}
?>