Regular expression
Thứ 2, 1:07 PM Ngày 13/06/2011, số lần xem 528, Lập trình web
Regular Expressions là gì? Regular Expressions (Regex) dịch ra tiếng Việt là Biểu thức chính quy. Khái niệm này nằm trong 1 mớ lý thuyết vô cùng đồ sộ và hầm hố . Nhưng ko nên lo lắng, ta có thể hiểu nôm na Regex là 1 cái mẫu (pattern) dùng để mô tả 1 lớp ký tự nào đó.
..................
Xem chi tiết »
Using INSERT IGNORE with MySQL to prevent duplicate key errors
Thứ 3, 8:24 AM Ngày 03/05/2011, số lần xem 559, Lập trình web
An error will occur when inserting a new record in MySQL if the primary key specified in the insert query already exists. Using the "IGNORE" keyword prevents errors from occuring and other queries are still able to be run.
Why?
Although you shouldn't normally attempt to insert a record without first checking if the primary key you want to use has already been used, there may be times when this is required, such as when multiple developers need to update their own copies of a database, and a particular record may already exist in one or other of the databases.
..................
Xem chi tiết »
parseInt('08') returns 0 with Javascript
Thứ 2, 7:23 AM Ngày 02/05/2011, số lần xem 504, Lập trình web
I came across a rather interesting problem with the Javascript parseInt() function a couple of days ago; if the value is a zero padded string and is '08' or '09' then parseInt() will return 0. This post looks at why 0 is returned and how to solve the problem.
parseInt('08') returns 0
The leading zero in the string tells the Javascript engine that it is an octal number. Because 8 and 9 are not valid numbers in octal, parseInt returns 0. This is expected behaviour because they are not valid octal integers and parseInt returns 0 because the first valid number encountered is a zero.
..................
Xem chi tiết »
10 sql tips to speed up your database
Chủ nhật , 8:48 AM Ngày 01/05/2011, số lần xem 526, Lập trình web
Design your database with caution
This first tip may seems obvious, but the fact is that most database problems come from badly-designed table structure.
For example, I have seen people storing information such as client info and payment info in the same database column. For both the database system and developers who will have to work on it, this is not a good thing.
When creating a database, always put information on various tables, use clear naming standards and make use of primary keys.
Source: http://www.simple-talk.com/sql/database-administration/ten-common-database-design-mistakes/
..................
Xem chi tiết »
Tổng hợp các hàm về date/time trong MySQL
Thứ 4, 3:30 PM Ngày 09/03/2011, số lần xem 1150, Lập trình web
NOW(): ngày hiện tại dạng yyyy-mm-dd h:m:s
ví dụ: SELECT NOW(); //kết quả: 2007-03-28 11:29:33
CURDATE(): ngày hiện tại dạng yyyy-mm-dd
ví dụ: SELECT CURDATE(); //kết quả: 2007-03-28
YEAR(): xác định năm từ 1 ngày cho trước
ví dụ: SELECT YEAR('2007-03-28 11:30:14');//kết quả: 2007
MONTH(): xác định tháng (1-12) từ 1 ngày cho trước
ví dụ: SELECT MONTH('2007-03-28 11:30:11') // kết quả: 3
MONTHNAME(): xác định tháng (January-December) từ 1 ngày cho trước
ví dụ: SELECT MONTH('2007-03-28 11:30:11')//kết quả: March
..................
Xem chi tiết »
Kiểu Datatyle InnoDB và MyISAM trong CSDL MYSQL
Thứ 4, 3:24 PM Ngày 09/03/2011, số lần xem 598, Lập trình web
- InnoDB hỗ trợ relationship (data integrity and foreign key constraints) còn MyISAM thì ko: Đa phần các open source đều không coi trọng việc này nhưng nếu ứng dụng của bạn bắt buộc phải dùng foreign key constraints thì InnoDB là lựa chọn của bạn
- InnoDB hỗ trợ transactions còn MyISAM thì không: Nếu hệ thống của bạn dùng trong các ứng dụng ngân hàng hoặc phải thực hiện việc giao dịch thì chắc chắn là MyISAM sẽ bị loại.
- InnoDB thiên về row-level locking còn MyISAM thiên về table locking: Tức là khi hệ thống của bạn phải thực hiện nhiều các thao tác insert/update thì InnoDB là tốt hơn, còn nếu hệ thống của bạn thực hiện các thao tác select là chủ yếu thì dùng MyISAM là lựu chọn tốt hơn
..................
Xem chi tiết »
56 mẹo để cải thiện tốc độ cho PHP
Thứ 6, 3:26 PM Ngày 07/01/2011, số lần xem 479, Lập trình web
1_ Nếu có thể khai báo hàm tĩnh thì có thể tăng tốc độ lên 4 lần.
2_ Echo thì nhanh hơn Print.
3_ Sử dụng nhiều câu lệnh Echo thay vì Echo 1 chuỗi nối vào nhau.
4_ Đặt giá trị lớn nhất cho vòng lặp for trước, và ko đặt trong vòng lặp for.
5_ Hủy các biến bằng hàm unset() để giải phóng bộ nhớ sau khi sử dụng, đặc biệt là những mảng lớn.
6_ Tránh dùng các định nghĩa kiểu: __get, __set, __autoload.
7_ Tránh dùng hàm require_once().
..................
Xem chi tiết »