diff --git a/ThinkPHP/Library/Think/Controller.class.php b/ThinkPHP/Library/Think/Controller.class.php index 16823fd223649523520ec84bd738bf95d1642265..d89b54424856f85d7558b130f8d125245077a368 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'); diff --git a/ThinkPHP/Library/Think/Controller/RestController.class.php b/ThinkPHP/Library/Think/Controller/RestController.class.php index 3d02c3ba149dae8b5cb52ff30902d5a8f013da24..7ef2d71bf4a505c9b5566dc99a9c510a86294e38 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(); diff --git a/ThinkPHP/Library/Think/Db.class.php b/ThinkPHP/Library/Think/Db.class.php index 9c49bbdb32d4cbf634a14a781fa31aa880de402e..2c30f411d197faf7960f60ce82413abbc09db509 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 +} diff --git a/ThinkPHP/Library/Think/Db/Driver/Pdo.class.php b/ThinkPHP/Library/Think/Db/Driver/Pdo.class.php index c7d450189ea2dc13b9ecb72b7cd8dbe28d795abe..c239e91d8034c8734b06fe26f80aa2c4f743dfaf 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; + } + } +}