データベースクラス


  dbMs.php (SQLServer 用)



  
<?
# **********************************************************
# データベースクラス
# **********************************************************
class DB {
 
	var $Connect;
	var $Result;
 
# **********************************************************
# コンストラクタ
# **********************************************************
	function DB( $Server='127.0.0.1', $DbName='lightbox', $User='sa', $Password='' ) {
		if ( !extension_loaded( "mssql" ) ) {
			dl("php_mssql.dll");
		}
		$this->Connect = mssql_connect( $Server, $User, $Password );
		mssql_select_db( $DbName, $this->Connect );
	}
 
# **********************************************************
# 接続解除
# **********************************************************
	function Close( ) {
		mssql_close( $this->Connect );
	}
 
# **********************************************************
# クエリー
# **********************************************************
	function Query( $SqlQuery ) {
		$ret = mssql_query( $SqlQuery,$this->Connect );
		return $ret;
	}
 
# **********************************************************
# フェッチ
# **********************************************************
	function Fetch( $Result ) {
		return mssql_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 = mssql_query( $SqlExec,$this->Connect );
		return $ret;
	}
 
# **********************************************************
# バージョン文字列取得
# **********************************************************
	function Version( ) {
		$Field = $this->QueryEx( "sp_server_info @attribute_id = 2" );
		return $Field["attribute_value"];
	}
 
}
?>
  










  infoboard   管理者用   
このエントリーをはてなブックマークに追加





フリーフォントWEBサービス
SQLの窓WEBサービス

SQLの窓フリーソフト

素材

一般WEBツールリンク

SQLの窓

フリーソフト

JSライブラリ