データベースクラス


  dbPs.php (PostgreSQL用)



  
<?
# **********************************************************
# データベースクラス
# **********************************************************
class DB {
 
	var $Connect;
	var $Result;
 
# **********************************************************
# コンストラクタ
# **********************************************************
	function DB(
		$Server='localhost',
		$DbName='lightbox',
		$User='lightbox',
		$Password='' ) {
		if ( !extension_loaded( "pgsql" ) ) {
			dl("php_pgsql.dll");
		}
		$this->Connect = pg_connect(
			"host=$Server" .
			" port=5432" .
			" dbname=$DbName" .
			" user=$User" .
			" password=$Password"
		);
		$this->QueryEx( "SET CLIENT_ENCODING TO 'SJIS'" );
	}
 
# **********************************************************
# 接続解除
# **********************************************************
	function Close( ) {
		pg_close( $this->Connect );
	}
 
# **********************************************************
# クエリー
# **********************************************************
	function Query( $SqlQuery ) {
		$ret = pg_query( $this->Connect, $SqlQuery );
		return $ret;
	}
 
# **********************************************************
# フェッチ
# **********************************************************
	function Fetch( $Result ) {
		return pg_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 = pg_query( $this->Connect, $SqlExec );
		return $ret;
	}
 
# **********************************************************
# バージョン文字列取得
# **********************************************************
	function Version( ) {
		$Field = $this->QueryEx( "SHOW SERVER_VERSION" );
		return $Field["server_version"];
	}
 
}
?>
  










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





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

SQLの窓フリーソフト

素材

一般WEBツールリンク

SQLの窓

フリーソフト

JSライブラリ