<?php
//error_reporting(0);
//ini_set('display_errors', 0);

/********************
MySQLのクラス
　DB：コンストラクタ
  Close：デストラクタ

********************/
class DB
{
	Public $Connect;
	Public $Result;
	Public $DeBug;
	Public $SetCode;
	public $count;

	function __construct() {
		$Server = DBSERVER;
		$User = DBUSER;
		$Pass = DBPASS;
		$DBName=DBNAME;
        $this->mysqli = new mysqli($Server, $User, $Pass, $DBName);
        $this->mysqli->set_charset("utf8");

		$this->DeBug = FALSE;
	}

	function Close(){
        $this->mysqli->close();
	}


	function Query($SqlQuery){
		return $this->mysqli->query($SqlQuery);
	}

	function CountRows($SqlQuery){
		$ret = $this->mysqli->affected_rows;
		return mysqli_num_rows($ret);
	}

	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 Fetch($Result){
		return mysqli_fetch_array($Result);
	}

}

?>