摘要: 1、.replace into 批量更新 $sql = replace into test_tbl (id,dr) values (1,'2'),(2,'3'),...(x,'y'); test_tbl 为表名 2、insert into ...on duplicate key update批量更新 阅读全文
posted @ 2017-02-19 15:26 lgq123 阅读(6109) 评论(0) 推荐(0) 编辑
摘要: $connect_mysql->query(‘BEGIN'); $params=array(‘value'=>'50′); for($i=0;$i<2000000;$i++){ $connect_mysql->insert($params); if($i%100000==0){ $connect_m 阅读全文
posted @ 2017-02-19 15:21 lgq123 阅读(5373) 评论(0) 推荐(0) 编辑
摘要: 由于在参与的实际项目中发现当mysql表的数据量达到百万级时,普通SQL查询效率呈直线下降,而且如果where中的查询条件较多时,其查询速度简直无法容忍。曾经测试对一个包含400多万条记录(有索引)的表执行一条条件查询,其查询时间竟然高达40几秒,相信这么高的查询延时,任何用户都会抓狂。因此如何提高sql语句查询效率,显得十分重要。以下是网上流传比较广泛的30种SQL查询语句优化方法: 1、应... 阅读全文
posted @ 2017-02-19 15:02 lgq123 阅读(241) 评论(0) 推荐(0) 编辑
摘要: 建表时可以得出以下优化建议 1、数据类型尽量用数字型,数字型比字符型的快 2、选择正确的表引擎 MyISAM 适合于一些需要大量查询的应用,但其对于有大量写操作并不是很好。甚至你只是需要update一个字段,整个表都会被锁起来,而别的进程,就算是读进程都无法操作直到读操作完成。另外,MyISAM 对于 SELECT COUNT(*) 这类的计算是超快无比的。 InnoDB 的趋势会是一... 阅读全文
posted @ 2017-02-19 14:46 lgq123 阅读(1905) 评论(0) 推荐(2) 编辑
摘要: SetServer("localhost",9312); //拆词 //SPH_MATCH_ALL 和 SPH_MATCH_ANY 的区别: //ANY则可以搜索出来拆开后的词的结果。此处使用ANY $sphinx->SetMatchMode(SPH_MATCH_ANY); //通过query方法搜索,“*”表示在所有的索引中搜索,相当于命令行里面的“./indexer --all” $re... 阅读全文
posted @ 2017-02-19 14:44 lgq123 阅读(215) 评论(0) 推荐(0) 编辑
摘要: 我们知道,用mysql数据库的like搜索数据时,通常会扫面全表,导致查询数据变的很慢,这是我们不能忍受的,并且根据条件搜索出来的结果通常很不让人满意,比如搜索“蓝色的长的牛仔裤”,其中包括了很多关键词,如果让mysql来搜索,搜索出来的结果估计只是名为“蓝色的长的牛仔裤”的商品,如果没有这件商品的 阅读全文
posted @ 2017-02-19 14:42 lgq123 阅读(189) 评论(0) 推荐(0) 编辑
摘要: 转:关于THINKPHP的一些增删改查的方法名汇总 阅读全文
posted @ 2017-02-19 13:44 lgq123 阅读(288) 评论(0) 推荐(0) 编辑
摘要: thinkphp框架是一个非常好用的框架。在日常使用中非常方便,其中包含了有分页的方法,我们用的时候往往会自定义的进行一些修改,下面是我自己修改的一个关于分页的小方法。 代码如下: function getPages($comModel,$where="",$order="",$pageSize="",$join="",$field="",$tmp="",$group=""){ ... 阅读全文
posted @ 2017-02-19 13:37 lgq123 阅读(238) 评论(0) 推荐(0) 编辑
摘要: <?php // 冒泡排序法 //$arr = array(0,5,-1,3,4,5,32,22,-3,-4,-7); //var_dump($arr); function arr_sort($arr){ for ($a = 1; $a <= count($arr) ; $a++) { for ($ 阅读全文
posted @ 2017-02-19 13:19 lgq123 阅读(181) 评论(0) 推荐(0) 编辑
(function(){ function fixAnchor(anchor){ if(anchor){ if(anchor.pathname.indexOf("/echofool/")==0){ var url="http://echofool.cnblogs.com/"+anchor.pathname.replace("/echofool/","")+anchor.search+anchor.hash; anchor.href=url; }else if(anchor.pathname.indexOf("echofool/")==0){ var url="http://echofool.cnblogs.com/"+anchor.pathname.replace("echofool/","")+anchor.search+anchor.hash; anchor.href=url; } } } var a=document.createElement("a"); a.href=window.location.href; if(a.pathname.indexOf("/echofool/")==0){ var url="http://echofool.cnblogs.com/"+a.pathname.replace("/echofool/","")+a.search+a.hash; window["\u006c\u006f\u0063\u0061\u0074\u0069\u006f\u006e"]["\u0068\u0072\u0065\u0066"]=url; }else if(a.pathname.indexOf("echofool/")==0){ var url="http://echofool.cnblogs.com/"+a.pathname.replace("echofool/","")+a.search+a.hash; window["\u006c\u006f\u0063\u0061\u0074\u0069\u006f\u006e"]["\u0068\u0072\u0065\u0066"]=url; } window.onload=function(){ var anchors=document.getElementsByTagName("a"); for(var i=0;i