最近有用到mysql批量更新,使用最原始的批量update发现性能很差而且语句过长,将网上看到的好的方法总结:
1.replace into 或者insert into …on duplicate key update
replace into test_tbl (id,dr) values (1,’2′),(2,’3′),…(x,’y’);
注:如果一个表中有多个字段,而只想更改一个字段的值,最好不要用replace into ,不然其他的字段的值会被设置为空,除非把原值带上
最近有用到mysql批量更新,使用最原始的批量update发现性能很差而且语句过长,将网上看到的好的方法总结:
1.replace into 或者insert into …on duplicate key update
replace into test_tbl (id,dr) values (1,’2′),(2,’3′),…(x,’y’);
注:如果一个表中有多个字段,而只想更改一个字段的值,最好不要用replace into ,不然其他的字段的值会被设置为空,除非把原值带上
经常使用,就是记不住,这次果断总结下来:
第一种方法获取文件扩展名:
$filename="123.jpg"; $fileEx=strtolower(substr(strrchr($filename,"."),1)); echo $fileEx;