code example Sharing for PHP surface Image object Operation database

Source: Internet
Author: User
Tags php class
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:


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.