ようこそ! このブログは、PHPとMysqlを使って作成したオリジナルプログラムを、QHMに読み込んで表示させています。

BaseDB.class.php

FrontPage

BaseDB.class.phpのソースコード

<?php
require_once "config.php";
// DBアクセスの基本クラス
class BaseDB 
{
// メンバ変数
	public $errors;  	// エラー数
	public $errorm;  	// エラーメッセージ
	
	private $db;      // mysql_connect関数の結果
	
// コンストラクタ
	function __construct(){
		$this->errors = 0;
// MySQLを開く
	if(!$this->db = @mysql_connect (HOSTNAME,USERNAME,PASSWORD))
	{
		$this->errorm = "MySQLに接続できません。";
			$this->errors++;
			return null;
	}
		
// DBを選択
	if(!mysql_select_db(USERNAME,$this->db))
	{
         $this->errorm = "データベースが存在しません。";
			$this->errors++;
			return null;
	}
		
//MySQL4.1への対応
		mysql_query("SET NAMES UJIS");
		
		return $this->db;
	}

// デスクトラクタ
	function __desctruct(){
		mysql_close( $this->db );
	}
	
	function mysql_fetch_all($result) {
	    $all = array();
	    while ( $rec = mysql_fetch_assoc($result)) {
	    	$all[] = $rec;
	    }
	    return $all;
	}
  	
} //クラス終了
?>

powered by Quick Homepage Maker 4.25
based on PukiWiki 1.4.7 License is GPL. QHM

最新の更新 RSS  Valid XHTML 1.0 Transitional