|
<?
# **********************************************************
# データベースクラス
# **********************************************************
class DB {
var $Connect;
var $Result;
# **********************************************************
# コンストラクタ
# **********************************************************
function DB( $Dsn='MDB', $User='', $Pass='' ) {
$this->Connect = odbc_connect( $Dsn, $User, $Pass );
}
# **********************************************************
# 接続解除
# **********************************************************
function Close( ) {
odbc_close( $this->Connect );
}
# **********************************************************
# クエリー
# **********************************************************
function Query( $SqlQuery ) {
$ret = odbc_exec( $this->Connect, $SqlQuery );
return $ret;
}
# **********************************************************
# フェッチ
# **********************************************************
function Fetch( $Result ) {
$FetchArray = odbc_fetch_array( $Result );
if ( is_array( $FetchArray ) ) {
$Cnt = 0;
foreach( $FetchArray as $Value ) {
$FetchArray[$Cnt] = $Value;
$Cnt++;
}
return $FetchArray;
}
else {
return FALSE;
}
}
# **********************************************************
# クエリーとフェッチ
# **********************************************************
function QueryEx( $SqlQuery='' ) {
if ( $SqlQuery != '' ) {
$this->Result = $this->Query( $SqlQuery );
if ( !$this->Result ) {
return FALSE;
}
return $this->Fetch ( $this->Result );
}
else {
return $this->Fetch ( $this->Result );
}
}
# **********************************************************
# 実行
# **********************************************************
function Execute( $SqlExec ) {
$ret = odbc_exec( $this->Connect, $SqlExec );
return $ret;
}
# **********************************************************
# エラーメッセージ取得
# **********************************************************
function GetError() {
return odbc_errormsg( $this->Connect );
}
}
?>
| |