From 6a2b8496387c02c805690ff44cdd57d6db5dd243 Mon Sep 17 00:00:00 2001 From: zhuyajie Date: Mon, 26 May 2014 12:24:51 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=94=B9=E8=BF=9B:=E6=B7=BB=E5=8A=A0insert?= =?UTF-8?q?All=E6=96=B9=E6=B3=95,=E6=94=AF=E6=8C=81mysql=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Library/Think/Db/Driver/Pdo.class.php | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/ThinkPHP/Library/Think/Db/Driver/Pdo.class.php b/ThinkPHP/Library/Think/Db/Driver/Pdo.class.php index c7d4501..c239e91 100644 --- a/ThinkPHP/Library/Think/Db/Driver/Pdo.class.php +++ b/ThinkPHP/Library/Think/Db/Driver/Pdo.class.php @@ -491,4 +491,35 @@ class Pdo extends Db{ return $vo?$vo[0]["currval"]:0; } } -} \ No newline at end of file + + /** + * 插入记录 + * @access public + * @param mixed $datas 数据 + * @param array $options 参数表达式 + * @param boolean $replace 是否replace + * @return false | integer + */ + public function insertAll($datas,$options=array(),$replace=false) { + if ( $this->dbType=='MYSQL' ) { + if(!is_array($datas[0])) return false; + $fields = array_keys($datas[0]); + array_walk($fields, array($this, 'parseKey')); + $values = array(); + foreach ($datas as $data){ + $value = array(); + foreach ($data as $key=>$val){ + $val = $this->parseValue($val); + if(is_scalar($val)) { // 过滤非标量数据 + $value[] = $val; + } + } + $values[] = '('.implode(',', $value).')'; + } + $sql = ($replace?'REPLACE':'INSERT').' INTO '.$this->parseTable($options['table']).' ('.implode(',', $fields).') VALUES '.implode(',',$values); + return $this->execute($sql); + }else{ + return false; + } + } +} -- Gitee From eef7247b470f634d676b0b430ddb61a565179292 Mon Sep 17 00:00:00 2001 From: zhuyajie Date: Mon, 26 May 2014 12:37:13 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=94=B9=E8=BF=9B:RestController=20?= =?UTF-8?q?=E6=9E=84=E9=80=A0=E6=96=B9=E6=B3=95=E8=AE=BE=E7=BD=AE=20SHOW?= =?UTF-8?q?=5FPAGE=5FTRACE=20=E4=B8=BAfalse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ThinkPHP/Library/Think/Controller/RestController.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/ThinkPHP/Library/Think/Controller/RestController.class.php b/ThinkPHP/Library/Think/Controller/RestController.class.php index 3d02c3b..7ef2d71 100644 --- a/ThinkPHP/Library/Think/Controller/RestController.class.php +++ b/ThinkPHP/Library/Think/Controller/RestController.class.php @@ -38,6 +38,7 @@ class RestController extends Controller { * @access public */ public function __construct() { + C('SHOW_PAGE_TRACE',false);//显示trace工具条会引起header发送,强制设为false // 资源类型检测 if(''==__EXT__) { // 自动检测资源类型 $this->_type = $this->getAcceptType(); -- Gitee From b6c7f3680fa467bcb6cc2f6c199108c2122246e8 Mon Sep 17 00:00:00 2001 From: zhuyajie Date: Mon, 26 May 2014 12:39:44 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=94=B9=E8=BF=9B:=20Db=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E8=BF=9E=E6=8E=A5=E6=97=B6=E7=9A=84=5FlintID=E8=B5=8B?= =?UTF-8?q?=E5=80=BC=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ThinkPHP/Library/Think/Db.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ThinkPHP/Library/Think/Db.class.php b/ThinkPHP/Library/Think/Db.class.php index 9c49bbd..2c30f41 100644 --- a/ThinkPHP/Library/Think/Db.class.php +++ b/ThinkPHP/Library/Think/Db.class.php @@ -163,7 +163,7 @@ class Db { $this->_linkID = $this->multiConnect($master); else // 默认单数据库 - if ( !$this->connected ) $this->_linkID = $this->connect(); + if ( !$this->connected ||!$this->_linkID ) $this->_linkID = $this->connect(); } /** @@ -897,4 +897,4 @@ class Db { // 关闭数据库 由驱动类定义 public function close(){} -} \ No newline at end of file +} -- Gitee From 09fe614a6c23b0a3618f51e36dc165f077a53424 Mon Sep 17 00:00:00 2001 From: zhuyajie Date: Mon, 26 May 2014 12:42:07 +0800 Subject: [PATCH 4/4] =?UTF-8?q?dispatchJump=E4=B8=AD=E6=88=90=E5=8A=9F?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC=E5=AE=8C=E6=88=90=E5=90=8E=E6=9C=AAexit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ThinkPHP/Library/Think/Controller.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ThinkPHP/Library/Think/Controller.class.php b/ThinkPHP/Library/Think/Controller.class.php index 16823fd..d89b544 100644 --- a/ThinkPHP/Library/Think/Controller.class.php +++ b/ThinkPHP/Library/Think/Controller.class.php @@ -281,6 +281,7 @@ abstract class Controller { // 默认操作成功自动返回操作前页面 if(!isset($this->jumpUrl)) $this->assign("jumpUrl",$_SERVER["HTTP_REFERER"]); $this->display(C('TMPL_ACTION_SUCCESS')); + exit ; }else{ $this->assign('error',$message);// 提示信息 //发生错误时候默认停留3秒 @@ -303,4 +304,4 @@ abstract class Controller { } } // 设置控制器别名 便于升级 -class_alias('Think\Controller','Think\Action'); \ No newline at end of file +class_alias('Think\Controller','Think\Action'); -- Gitee