mysql strtolower_GitHub - redfoxli/mysqlstr: a php extension provide string processing of mysql
mysqlstr
Introduction
a php extension provide string processing of mysql
(strtolower && strtoupper base utf8)
把mysql里的字符串處理函數封裝成php擴展,供php使用
目前只提供了utf8下的大寫轉小寫以及小寫轉大寫這兩個功能
Why need this php ext
the result of strtolower(strtoupper) is different between php and mysql
efficiency
寫這個擴展的目的有兩個,一個是php的大小寫轉換函數和mysql的有一些區別,另外一個是性能問題
##Installation
$ /path/to/phpize
$ ./configure --with-php-config=/path/to/php-config
$ make
$ make install
add extension=mysqlstr.so in php.ini
Interface
strtoupper_utf8_ext
strtoupper_utf8_ext - make a utf8 string uppercase
Description
string strtoupper_utf8_ext(string str)
strtolower_utf8_ext
strtolower_utf8_ext - make a utf8 string lowercase
Description
string strtolower_utf8_ext(string str)
Example
case
$str = "High School D×DⅡ ";
$timeMB = microtime(true);
$resMb = mb_strtolower( $str, "UTF-8");
$timeMB = microtime(true) - $timeMB;
$timeSQL = microtime(true);
$resSQL = strtolower_utf8_ext($str);
$timeSQL = microtime(true) - $timeSQL;
echo "mbTime:" . sprintf("%.5f",$timeMB)." \n";
echo "sqlTime:" . sprintf("%.5f",$timeSQL)."\n";
echo "mbRes:" . $resMb . "\n";
echo "sqlRes:" . $resSQL . "\n";
result
mbTime:0.00004
sqlTime:0.00001
mbRes:high school d×dⅡ
sqlRes:high school d×dⅱ
efficiency case
$str = "High School D×DⅡ ";
$timeMB = microtime(true);
for($i=0;$i<30000;$i++)
$resMb = mb_strtolower( $str, "UTF-8");
$timeMB = microtime(true) - $timeMB;
$timeSQL = microtime(true);
for($i=0;$i<30000;$i++)
$resSQL = strtolower_utf8_ext($str);
$timeSQL = microtime(true) - $timeSQL;
echo "mbTime: " . sprintf("%.5f",$timeMB)." \n";
echo "sqlTime: " . sprintf("%.5f",$timeSQL)."\n";
result:
mbTime: 0.18481
sqlTime: 0.01055
More
String processing of mysql base mysql-5.1.74
More related analysis base Chinese is here
總結
以上是生活随笔為你收集整理的mysql strtolower_GitHub - redfoxli/mysqlstr: a php extension provide string processing of mysql的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql数据库2012_SQLServ
- 下一篇: 查看git安装目录_一、Linux和Wi