Query keywords for php Data Access and php Data keywords

Source: Internet
Author: User
Tags learn php programming

Query keywords for php Data Access and php Data keywords

This example shares the php query implementation code for your reference. The details are as follows:

1. A keyword Query

Home page:

<Html> 

Encapsulation class:

<? Phpclass QiChe {public $ localhost = "localhost"; // server public $ uid = "root"; // user name public $ password = ""; // password // SQL Method for executing the query statement: // parameter description: $ SQL indicates the SQL statement to be executed; $ type indicates the type of the SQL statement, and 0 indicates the query, 1 is other (add, delete, modify, and Query); $ db indicates the public function Query of the database to be queried ($ SQL, $ type = "0", $ db = "mydb ") {$ dbconnect = new MySQLi ($ this-> localhost, $ this-> uid, $ this-> password, $ db );! Mysqli_connect_error () or die ("connection failed! "); $ Result = $ dbconnect-> query ($ SQL); if ($ type = 0) {return $ result-> fetch_all ();} else {return $ result ;}}}

Running result:

2. query multiple keywords

Home page:

<Html> 

Running result:

The above is all the content of this article. I hope it will help you learn php programming.

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.