|
<?
# **********************************************************
# データベースクラス
# **********************************************************
class DB {
var $Connect;
var $Result;
# **********************************************************
# コンストラクタ
# **********************************************************
function DB( $Dsn='MDB' ) {
$this->Connect = odbc_connect( $Dsn, '', '' );
}
# **********************************************************
# 接続解除
# **********************************************************
function Close( ) {
odbc_close( $this->Connect );
}
# **********************************************************
# クエリー
# **********************************************************
function Query( $SqlQuery ) {
$ret = odbc_exec( $this->Connect, $SqlQuery );
return $ret;
}
# **********************************************************
# フェッチ
# **********************************************************
function Fetch( $Result ) {
return odbc_fetch_array( $Result );
}
# **********************************************************
# クエリーとフェッチ
# **********************************************************
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 );
}
}
?>
| |