Php Codes
Algorithms
Arrays
Authentication
Calendar
Code Snippets
Programs
Content Manage
Contest Related
Cookies
Credit Cards
DBase Related
Databases
Date Time
Directories
E-Mail
Errors
File
File System
Forms
Handling
Graphics
HTML and PHP
Informix
Ingres
InterBase
LDAP
Look and Feel
Miscellaneous
MySQL
Other
PHP Classes
Searching
Navigation
Statistics
Strings
User Manage
Php > Database Related sample source codes
MySQL MSSQL abstraction Layer
MySQL MSSQL abstraction Layer instance = $instance; } // get username function setuser($user){ $this->user = $user; } // get password function setpass($pass){ $this->pass = $pass; } // get database name function dbname($dbname){ $this->dbname = $dbname; } // Use persistent connections? // Only call this if you want persistent connections function persist(){ $this->persist = 1; } } $file = join("", array("DB_", $dbtype, ".php")); require($file); ?> persist){ $this->conn = mysql_pconnect($this->instance, $this->user, $this->pass); } else { $this->conn = mysql_connect($this->instance, $this->user, $this->pass); } mysql_select_db($this->dbname, $this->conn); return($this->conn); } // close function close(){ if($this->persist) { $ret = 1; } else { $ret = mysql_close($this->conn); } return($ret); } // query function query($query){ $this->result = mysql_query($query); return($this->result); } // numrows function numrows(){ $this->numrows = mysql_num_rows($this->result); return($this->numrows); } // affected rows function affrows(){ $this->affrows = mysql_affected_rows($this->result); return($this->affrows); } // seek function seek($row){ $seek = mysql_data_seek($this->result, $row); return($seek); } // fetch object function fobject(){ $object = mysql_fetch_object($this->result); return($object); } // fetch array function farray(){ $array = mysql_fetch_array($this->result); return($array); } // free function free(){ $free = mysql_free_result($this->result); return($free); } } ?> /* example usage setinst("dbserver"); $db->setuser("dbusername"); $db->setpass("dbpassword"); $db->dbname("dbname"); $db->persist(); $conn = $db->connect(); $db->query("SELECT id,narf FROM foo WHERE id > 4"); while($r = $db->fobject()){ echo "$r->id: $r->narf
\n"; } ?> */
Privacy Policy
|
Link to Us
|
Links