db.php For MySQL

  MySQL をターゲットとしたクラス



  
<?
# **********************************************************
# データベースクラス
# **********************************************************
class DB {
 
	var $Connect;
	var $Result;
 
	var $Debug;
 
# **********************************************************
# コンストラクタ
# **********************************************************
	function DB( $Server='localhost', $DbName='lightbox', $User='root', $Password='' ) {
		$this->Connect = mysql_connect( $Server, $User, $Password );
		mysql_select_db( $DbName, $this->Connect );
		$this->Debug = FALSE;
	}
 
# **********************************************************
# 接続解除
# **********************************************************
	function Close( ) {
		mysql_close( $this->Connect );
	}
 
# **********************************************************
# クエリー
# **********************************************************
	function Query( $SqlQuery ) {
		$ret = mysql_query( $SqlQuery,$this->Connect );
		if ( $this->Debug ) {
			if ( mysql_errno() != 0 ) {
				print "<B>" . mysql_error() . "</B><BR>";
			}
		}
		return $ret;
	}
 
# **********************************************************
# フェッチ
# **********************************************************
	function Fetch( $Result ) {
		return mysql_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 = mysql_query( $SqlExec,$this->Connect );
		if ( $this->Debug ) {
			if ( mysql_errno() != 0 ) {
				print "<B>" . mysql_error() . "</B><BR>";
			}
		}
		return $ret;
	}
 
# **********************************************************
# バージョン文字列取得
# **********************************************************
	function Version( ) {
		$Field = $this->QueryEx( "show variables like 'version'" );
		return $Field[1];
	}
 
}
?>
  














   SQLの窓    create:2004/04/24  update:2018/02/08   管理者用(要ログイン)





フリーフォントツール

SQLの窓ツール

SQLの窓フリーソフト

写真素材

一般ツールリンク

SQLの窓

フリーソフト