Check-in Project summary

Source: Internet
Author: User

I. Overall introduction: http://m.fang.com/public/qd/

Two. Problems encountered:

(1) Data problems:

1. Establishment of the database (engine, encoding type)

A. Each library will have its own default engine and code, in the library and the table can also specify the library, table, field encoding format

B. In MySQL database, if using "UTF8" encoding format, varchar (12) can store 12 Chinese, which are stored in characters;

If the "Latin" is used, varchar (12) can store 4 Chinese, which is the byte storage unit

C. Storage Engine: http://www.ha97.com/4197.html

InnoDB MyISAM

Composition: Data files and log files, definitions of the. frm table. MyD to save specific data. Myi Storage Index

. frm files for data storage

Transactional: Supports transactional and foreign key emphasis on read performance, does not support transactions

Read the exact number of rows in the table: count (*) to scan the full table count (*) to read the table's rows directly without using where

Lock: Row lock (if a SQL statement is executed that does not confirm the table lock

The scan range will lock the entire table, such as using like)

Spatial structure: B+tree B Tree

Summary: Build an index on the appropriate field, and take the appropriate length when building the index; The combined index follows the leftmost prefix matching principle

2. How the table should be built (with what type, how long, whether the index is built, the engine of the table, the encoding type of the table)

The above is one of the tables that I used, the problems that existed

A. In my application qd_id This field does not need to use the self-increment, also did not need to use so big length;

B. Specify the appropriate length according to the specific application varchar () (this place should be carefully coded in your format)

C.sex This type of field identified with 0 and the use of the enum format to store the better;

D. It is best not to use NULL to "(NULL);

E. Time type with int better, convenient program processing and comparison

f.user_agent field length is not enough, roughly in varchar (200) More appropriate

(2) Procedural questions:

    1. Front-end validation: validating input characters with regular matches
    2. Ajax request limit (can bypass JS to send requests directly, with authentication code or limit the number of requests with IP)
    3. Back-end data Filtering (Mysql_real_escape_string (), Addslashes () strip_tags (), Htmlspecialchars ()) can view http://www.111cn.net/phper/ Phpanqn/58589.htm
    4. Code optimization (JS optimization, PHP optimization, page effect optimization)

(3) post-viewing issues (how to print check-in information into a readable form)

Before the output, add

Header ("Content-type:application/vnd.ms-excel");
Header ("Content-disposition:attachment;filename=dahuiqiandao_data.xls");

These two sentences can convert the output data to an Excel type

If I get a $result array, the code is as follows

Header ("Content-type:application/vnd.ms-excel");

Header ("Content-disposition:attachment;filename=dahuiqiandao_data.xls");
echo "Name". " \ t ";
echo "Phone". " \ t ";
echo "\ n";
if (Is_array ($result) && count ($result) >0) {
foreach ($result as $k = = $v) {
echo $v [' user_name ']. " \ t ";
echo $v [' User_tel ']. " \ t ";
echo "\ n";
}
echo "\ t cutoff". Date (' y-m-d h:i:s ', Time ()). " There are already ". Count ($result)." Man \ t ";
}

You can export the fields in the $result to the appropriate Excel

Three. Summary

Practice out of the truth, self-made and their own advance to think of the results generally inconsistent, more hands-on, technology is practiced out, a certain knowledge reserves is the premise

Check-in Project summary

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.