Developers Archive for the 'mysql database development' Category

FROM_UNIXTIME()

FROM_UNIXTIME() Wednesday, March 21st, 2007

FROM_UNIXTIME() functions return values in the connection’s current time zone, which is available as the value of the time_zone system variable.If we use FROM_UNIXTIME() to convert between TIMESTAMP values and Unix time stamp values, the conversion is lossy because the mapping is not one-to-one in both directions.

Syntax:
FROM_UNIXTIME([timestamp])

Example:
select from_unixtime(1174374559);

Advantages Of Prepared Statements

Advantages Of Prepared Statements Monday, March 19th, 2007

Advantages Of Prepared Statements:
A. Security:
1. Prepared statements can help increase security by separating SQL logic from the data being supplied. This separation of logic and data can help prevent a very common type of vulnerability called an SQL injection attack.
2. Normally when you are dealing with an ad hoc query, you need to be very careful when handling the data that you received from the user. This entails using functions that escape all of the necessary trouble characters, such as the single quote, double quote, and backslash characters. This is necessary when dealing with prepared statements. The separation of the data allows MySQL to automatically take into account these characters and they do not need to be escaped using any special function.

B. Performance :

1. The need to only parse the query a single time. When you initially prepare the statement, MySQL will parse the statement to check the syntax and set up the query to be run. Then if you execute the query many times, it will no longer have that overhead. This pre-parsing can lead to a speed increase if you need to run the same query many times, such as when doing many INSERT statements.
2. where performance may increase is through the use of the new binary protocol that prepared statements can use. The traditional protocol in MySQL always converts everything into strings before sending them across the network. This means that the client converts the data into strings, which are often larger than the original data, sends it over the network (or other
transport) to the server, which finally decodes the string into the correct datatype. The binary protocol removes this conversion overhead. All types are sent in a native binary form, which saves the conversion CPU usage, and can also cut down on network usage.

COERCIBILITY

COERCIBILITY Friday, March 16th, 2007

COERCIBILITY

COERCIBILITY(str)

It returns the collation coercibility value of the string argument.

Example:
SELECT COERCIBILITY(’abc’ COLLATE latin1_swedish_ci);
It returns 0

SELECT COERCIBILITY(USER());
It returns 2

SELECT COERCIBILITY(’abc’);
It returns 3

The return values have the following meanings:

Coercibility  Meaning  Example
0  Explicit collation (Value with COLLATE clause)
1  No collation  (Concatenation of strings with different collations)
2  Implicit collation  (Column value)
3  System constant  (USER() return value)
4  Coercible  (Literal string)
5  Ignorable  (NULL or an expression derived from NULL)


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.