PHP Surface Image Object Database operation class, constructs a database operation class, encapsulates all database operation, can extend facilitates the use of the background management program, retrieve the database record number, returns the database table field number and the table field name set, finally does not forget to close the data path connection.
The first step is to download the PHP Surface Object database Operation class Library that we need to use in this lesson: http://www.php.cn/xiazai/leiku/546
The second step, after the download, find the PHP class files we need, unzip to our local directory, create a new PHP file!
After the third step, we will call this class in the new PHP file, and instantiate the class:
<?phpinclude_once "sql.php";//Import class file//Use directly require the file, then instantiate: $SqlDB = new MySQLdb ("localhost", "root", "root", "ABCD $sql = "SELECT * from t_table WHERE 1"; $result = $SqlDB->query ($sql);//Query $rs = $SqlDB->getrows ($result);//get record set $ num = $SqlDB->getrowsnum ($result);//Get Record count//... The rest of the operation is the loop value, for ($i =0; $i < $num; $i + +) {echo "Sid:". $rs [$i] [SID]). " <br> "; echo" AA: ". ($rs [$i] ["AA"]). " <br> "; echo" BBC: ". ($rs [$i] [BBC]]. " <br> ";}
Run this file and get the results as shown: