批量插入数据insert into select示例

 

//增加
                        $addSql =" insert into hxqc_auth_group_limits(group_id,company_id)";
                        foreach ($add_data as $val) {
                            $addSql .=" select '$k','$val' union all";
                        }
                        if(strrpos($addSql, 'union all', -1)===strlen($addSql)-9){
                            $addSql = rtrim($addSql,'union all');
                            $insertAffect = M()->execute($addSql);
                            if($insertAffect === false) {
                                $this->rollback();
                                return 1;
                            }
                        }

 

posted @ 2017-03-06 10:01  Nullnullisnull  阅读(1601)  评论(0编辑  收藏  举报