PHP interface and database operations

interface:

Using the interface ( interface ), you can specify a class method which must implement , but need not define the specific content of these methods.

The interface is defined by the interface keyword, like the definition of a standard of class, but the definition of all the methods are empty.

All methods defined in the interface must be public , which is characteristic of the interface.

To implement an interface, using implements operator . Class all the methods defined in the interface must be implemented, otherwise it will report a fatal error. Class can implement multiple interfaces, with a comma-separated names of the plurality of interfaces.

Database operations:

Step 1: Connect to the MySQL database server mysql -uroot -root

Step two: Select the database to operate (current database) use db_name

Step 3: Set the character set set names gbk

Step Four: Execute SQL statement: add, delete, change,

增加:INSERT INTO table_name(title,author,addate) VALUES(‘标题’,’admin’,now())

Delete: DELETE FROM table_name WHERE conditional expression

Modify: UPDATE table_name SET title = "new title" WHERE conditional expression

查询:SELECT * FROM table_name WHERE条件 ORDER BY  LIMIT

Link MySQL : three ways

The difference between process-oriented and object-oriented : process-oriented is to analyze the steps needed to resolve them, and then use the function of these steps, step by step to achieve , when used one by one in turn call on it; object-oriented is to be a problem affairs broken down into each object, the purpose of creating an object is not to complete a step, but to Miao Xu a thing in the entire steps to resolve the problem of conduct.

Use PDO: need to switch more database

Query data:

$result = $conn->query($sql);

$ Result-> num_rows; Analyzing data returned

$ Result-> fetch_assoc () to be incorporated into the set associative arrays and cyclic output

Guess you like

Origin www.cnblogs.com/wangzihao147/p/12346763.html
Recommended