Created
December 23, 2010 02:25
-
-
Save koshiaaaaan/752467 to your computer and use it in GitHub Desktop.
複数コネクションを持つ場合。こんな感じかなぁ・・・
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class DB{ | |
var $db_encoding="UTF-8"; | |
var $script_encoding="UTF-8"; | |
var $db=null; | |
#--------------------------- | |
# constructer | |
#--------------------------- | |
function DB($db=DBNAME,$user=USER,$pass=PASS,$host=HOST){ | |
# CONNECT MySQL | |
if (!($mysql=mysql_connect($host,$user,$pass,true))) { | |
die("ERROR: HOST CONNECT FAILED"); | |
} | |
$this->db = $mysql ; | |
# CONNECT DB | |
if (!(mysql_select_db($db,$this->db))) { | |
die("ERROR: DB CONNECT FAILED"); | |
} | |
} | |
#--------------------------- | |
# class method | |
#--------------------------- | |
function exe($stmt){ | |
# Execute SQL | |
if (!($data = mysql_query($stmt,$this->db))) { | |
echo mysql_error($this->db)."\n"; | |
var_dump($stmt); | |
return false; | |
} | |
$result = Array(); | |
while($tmp = @mysql_fetch_assoc($data)){ | |
array_push($result,$tmp); | |
} | |
if( !empty ( $result ) ){ | |
return $result; | |
}else{ | |
return TRUE; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment