MySQL has powerful user-defined functions, as shown below. I wrote a MySQL function to determine whether the video address can be played on the mobile phone.
MySQL has powerful user-defined functions, as shown below. I wrote a MySQL function to determine whether the video address can be played on the mobile phone.
The Code is as follows:
Delimiter |
Drop function if exists IS_MOBILE |
Create function IS_MOBILE (x VARCHAR (255) returns tinyint (1)
BEGIN
DECLARE result TINYINT (1) DEFAULT 0;
SET x = LCASE (x );
If right (x, 4) = '.mp4 'THEN
SET result = 1;
Elseif left (x, 9) = '[ctvideo]' THEN
SET result = 1;
End if;
RETURN result;
END;
Delimiter;
Note:
This method has application scenarios. I used to make a tag in the creation of the sphinx index, for example:
SELECT IS_MOBILE ('HTTP: // www.jb51.net/demo/test.mp4') AS m
If the front-end is used in large quantities, the MySQL pressure will be increased. It is recommended that the script program be used.
I personally only have a temporary solution, which will be completed by upgrading the system later.