|
1. What is the difference between get and post submission methods in a form?
A: Get is a request sent through the HTTP protocol to receive the request through URL parameter transmission, while post is an object data, and a large amount of information can be submitted through the form.
2. What is the difference between session and cookie?
A: Session: stores the globally unique variables for user access, which are stored in the session_dir directory specified by PHP on the server.
COOKIE: it is used to store a consecutive challenge surface. It is stored on the client, and the cookie is stored in the temp directory of user win.
You can set the length of time through time.
3. What are the transactions in the database?
A: transaction is a group of sequential database operations as a unit. If all operations in the group are successful, the transaction is considered successful. Even if only one operation fails, the transaction fails. If all operations are completed, the transaction is committed, and the modifications are applied to all other database processes. If an operation fails, the transaction will be rolled back and all operations affected by the transaction will be canceled.
4. Can I separate HTML and PHP templates?
Answer: smarty, dwoo, tinybutstrong, template lite, savant, phemplate, and xtemplate
5. How to optimize the MYSQL database?
A:
1. select the most suitable field attribute, minimize the length of the defined field, and set the field not null as much as possible, such as 'province, gender'. It is best to set it to enum.
2. Use join instead of subquery:
A. Delete no order Customer: delete from customerinfo where customerid not in (select customerid from orderinfo)
B. Extract all customers without orders: select from customerinfo where customerid not in (select customerid from orderinfo)
C. Speed up B optimization: SELECT FROM customerinfo LEFT JOIN orderid customerinfo. customerid = orderinfo. customerid
WHERE orderinfo. customerid IS NULL
3. Use UNION instead of creating a temporary table manually
A. Create a temporary table: SELECT name FROM 'nametest 'union select username FROM 'nametest2'
4. Transaction processing:
A. ensure data integrity. For example, if both the ADD and modify operations are performed, both operations fail.
Mysql_query ("BEGIN ");
Mysql_query ("insert into mermerinfo (name) VALUES ('$ name1 ')";
Mysql_query ("SELECT * FROM 'orderinfo' where customerid =". $ id ");
Mysql_query ("COMMIT ");
5. Lock the table and optimize transaction processing:
A. We use a SELECT statement to retrieve the initial data. Through some calculations, we use the UPDATE statement to UPDATE the new value to the table.
The lock table statement containing the WRITE keyword can ensure that before the unlock tables command is executed,
There will be no other access to insert, update, or delete inventory
Mysql_query ("lock table customerinfo READ, orderinfo WRITE ");
Mysql_query ("SELECT customerid FROM 'mermerinfo' where id =". $ id );
Mysql_query ("UPDATE 'orderinfo' SET ordertitle = '$ title' where mermerid =". $ id );
Mysql_query ("unlock tables ");
6. Use foreign keys to optimize table locking
A. Map customerid in customerinfo to customerid in orderinfo,
Any record without a valid mermerid will not be written to orderinfo
Create table customerinfo
(
Customerid int not null,
Primary key (customerid)
) TYPE = INNODB;
Create table orderinfo
(
Orderid int not null,
Customerid int not null,
Primary key (customerid, orderid ),
Foreign key (customerid) REFERENCES customerinfo
(Customerid) ON DELETE CASCADE
) TYPE = INNODB;
Note: 'On delete cascade 'ensures that order is also deleted when a record in the customerinfo table is deleted.
All records of the user in the Table. Note that the transaction security type should be defined as INNODB using the foreign key;
7. Create an index:
A. format:
(Common Index)->
CREATE: create index <INDEX Name> ON tablename (INDEX field)
Modify: alter table tablename add index [INDEX name] (INDEX field)
Create table specified INDEX: create table tablename ([...], INDEX [INDEX name] (INDEX field ))
(Unique index)->
CREATE: create unique <index Name> ON tablename (index field)
Modify: alter table tablename add unique [index name] (index field)
Create table specified index: create table tablename ([...], UNIQUE [index name] (index field ))
(Primary Key)->
It is a unique index. Generally, a table is created in the format:
Creata table tablename ([...], primary key [index field])
8. Optimize Query statements
A. It is best to compare the same fields and minimize the number of function operations on the created index fields.
Example 1:
SELECT * FROM order where year (orderDate) <2008; (slow)
SELECT * FROM order WHERE orderDate <"2008-01-01"; (FAST)
Example 2:
SELECT * FROM order WHERE addtime/7 <24; (slow)
SELECT * FROM order WHERE addtime <24*7; (FAST)
Example 3:
SELECT * FROM order WHERE title like "% good % ";
SELECT * FROM order WHERE title> = "good" and name <"good ";
6. What is the function for MYSQL to obtain the current time ?, The format function is (2 points) A: now (), dateformat () |