alaa Posted February 8, 2009 Share Posted February 8, 2009 please iwant db.php file iwant ask question can iprogramming engine game by mysql and php only without otherthings pear and some thing like this Quote Link to comment Share on other sites More sharing options...
a_bertrand Posted February 9, 2009 Share Posted February 9, 2009 Re: please iwant db.php file You can build all the code yourself without using pre-existing packages. Now, personally, I would not avoid other packages by principle, you should still check if there isn't something which does what you want as it may spare you a lot of work. Only problem is that most of those packages are under the GNU license or similar, which means you may have some troubles for commercial re-distribution, check carefully the license which comes with packages you may use. Quote Link to comment Share on other sites More sharing options...
alaa Posted February 9, 2009 Author Share Posted February 9, 2009 Re: please iwant db.php file thank you man iwant db.php file please Quote Link to comment Share on other sites More sharing options...
Dave Posted February 10, 2009 Share Posted February 10, 2009 Re: please iwant db.php file Can i ask? Is your space bar a bit dodgy :P Quote Link to comment Share on other sites More sharing options...
a_bertrand Posted February 11, 2009 Share Posted February 11, 2009 Re: please iwant db.php file That's the class I wrote which reflects more or less ADOdb syntax but yet is much faster as it has less functions. Don't know if this is what you was looking for. <?PHP Class database { var $conn; var $nbquer; var $storeQuery; var $storeID; function database($host,$username,$password,$dbname) { $this->nbquer=0; $this->conn = mysql_connect($host, $username, $password) //$this->conn = mysql_pconnect($host, $username, $password) or die("Could not connect : " . mysql_error()); mysql_select_db($dbname,$this->conn) or die("Could not select database"); } function startStore($id) { $this->storeQuery=true; $this->storeID=$id; $file=fopen("cache/queries_$id.txt","w"); fclose($file); } function close() { mysql_close($this->conn);} function execute($query) { if($this->storeQuery) {$file=fopen("cache/queries_".($this->storeID).".txt","a"); fwrite($file,"$query-*@*-"); fclose($file);} $this->nbquer++; $res=new resultset(); return $res->exec($query,$this->conn); } function getid() { return mysql_insert_id(); } function SelectLimit($query,$nb,$start) { $res=new resultset(); return $res->exec($query." LIMIT $start,$nb",$this->conn); } function updateclob($table,$field,$data,$where) { $query="UPDATE $table SET $field=".$this->qstr($data)." WHERE $where"; return mysql_query($query,$this->conn); } function qstr($str) { return "'".mysql_real_escape_string($str)."'"; } } class resultset { var $result; var $fields; var $EOF; function resultset() {$this->EOF=true;$this->result=null;} function exec($query,$conn) { $this->EOF=false; $this->result = mysql_query($query,$conn); if($this->result === FALSE) { $this->result=null;$this->EOF=true; return false; } if($this->result === TRUE) { $this->result=null;$this->EOF=true; return true; } $this->fields=mysql_fetch_row($this->result); if($this->fields === FALSE) { $this->EOF=true; $this->fields=array(); } return $this; } function close() { if($this->result != null) @mysql_free_result($this->result); } function movenext() { $this->fields=mysql_fetch_row($this->result); if($this->fields === FALSE) { $this->fields=array(); $this->EOF=true; } } function fieldcount() { return mysql_num_fields($this->result); } function fetchfield($col) { return mysql_fetch_field($this->result, $col); } } $db=new database("localhost", "your_user", "you_pass", "your_db"); ?> Quote Link to comment Share on other sites More sharing options...
~Spooky~ Posted April 9, 2009 Share Posted April 9, 2009 Re: please iwant db.php file the db.php seems to be missing from the engine. Thanks for posting Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.