Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?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;
- }
- }
- }
Add Comment
Please, Sign In to add comment