如何做领券网站,网站做系统叫什么软件,广东省城乡建设部网站首页,小小影视大全在线观看免费观看思路
1创建多数据库连接 2后端的前台代码能使用get或者post请求传递选中数据给后台 3后台能够接收到 4后台接收到id或者全字段数据后对数据进行处理#xff0c;然后使用多数据库操作将其存入第二个数据库
实现
1config文件下创建新数据库连接
db_config2 [// 数据库类…思路
1创建多数据库连接 2后端的前台代码能使用get或者post请求传递选中数据给后台 3后台能够接收到 4后台接收到id或者全字段数据后对数据进行处理然后使用多数据库操作将其存入第二个数据库
实现
1config文件下创建新数据库连接
db_config2 [// 数据库类型type mysql,// 服务器地址hostname 127.0.0.1,// 数据库名database test,// 用户名username root,// 密码password 123456,// 端口hostport 3306,// 连接dsndsn ,// 数据库连接参数params [],// 数据库编码默认采用utf8charset utf8,// 数据库表前缀prefix fa_,],前端网页 再index.html文件中添加按钮
a classbtn btn-primary btn-more dropdown-toggle btn-disabled btn-dialog data-urluser/user/option idchuancan data-toggledropdown一键导出/a此时前端就能正常显示按钮然后为按钮绑定事件 这里请把data_url改成后端地址id改成js获取的名称 然后再js代码的 // 为表格绑定事件Table.api.bindevent(table);这句初始化代码下添加操作 // get方法gpt生成能传递但是无法二次传递$(document).on(change,#table .bs-checkbox [typecheckbox],function (){console.log(Table.api.selectedids(table));//测试是否成功let url$(#chuancan).attr(data-url)let idsTable.api.selectedids(table)urlurl.split(?)[0]if(ids.length){url?urlidTable.api.selectedids(table).join(,)}console.log(url, url)//测试路径是否正确$(#chuancan).attr(data-url,url)})这里是使用了change监听点击事件使用get传参的方式给后端请求参数里面的console.log是为了打印传递的数据
后端接收前端传递的参数
$selectids $this-request-get(id);$selectids explode(,,$selectids);//查询本地数据库$res model(user)-where(id,in,$selectids)-select();$filteredData [];接收到数据后进行处理 foreach ($res as $result) {// 使用模型的getData方法获取所有属性值这样可以不受保护属性的影响$userData $result-getData();// 移除不需要的字段这里列出您不想保留的字段名$fieldsToRemove [id, group_id,createtime, updatetime, jointime, prevtime, logintime];// 使用array_diff_key过滤掉不需要的键$filteredUserData array_diff_key($userData, array_flip($fieldsToRemove));// 将处理后的数据加入到结果数组$filteredData[] $filteredUserData;}// $len count($filteredData)-1;foreach ($filteredData as $value) {$sql INSERT INTO user (username, nickname, password, mobile, email) VALUES ({$value[username]}, {$value[nickname]}, {$value[password]}, {$value[mobile]}, {$value[email]});try {$result Db::connect(config(db_config2))-execute($sql);} catch (\Exception $exception) {// 打印错误信息echo 用户.$value[username].导出失败 . $exception-getMessage() . \n;// 继续执行下一次循环continue;}}if ($result){print_r([msg导入成功,code200]);}
文章转载自: http://www.morning.srhqm.cn.gov.cn.srhqm.cn http://www.morning.tygn.cn.gov.cn.tygn.cn http://www.morning.0small.cn.gov.cn.0small.cn http://www.morning.jqsyp.cn.gov.cn.jqsyp.cn http://www.morning.nkiqixr.cn.gov.cn.nkiqixr.cn http://www.morning.ktmpw.cn.gov.cn.ktmpw.cn http://www.morning.slfmp.cn.gov.cn.slfmp.cn http://www.morning.rfycj.cn.gov.cn.rfycj.cn http://www.morning.jopebe.cn.gov.cn.jopebe.cn http://www.morning.qdmdp.cn.gov.cn.qdmdp.cn http://www.morning.nyzmm.cn.gov.cn.nyzmm.cn http://www.morning.nfpkx.cn.gov.cn.nfpkx.cn http://www.morning.rqbr.cn.gov.cn.rqbr.cn http://www.morning.myxps.cn.gov.cn.myxps.cn http://www.morning.dqpd.cn.gov.cn.dqpd.cn http://www.morning.xglgm.cn.gov.cn.xglgm.cn http://www.morning.jntcr.cn.gov.cn.jntcr.cn http://www.morning.mfqmk.cn.gov.cn.mfqmk.cn http://www.morning.ywgrr.cn.gov.cn.ywgrr.cn http://www.morning.nqmwk.cn.gov.cn.nqmwk.cn http://www.morning.hwbmn.cn.gov.cn.hwbmn.cn http://www.morning.nfbkz.cn.gov.cn.nfbkz.cn http://www.morning.mhsmj.cn.gov.cn.mhsmj.cn http://www.morning.rhsr.cn.gov.cn.rhsr.cn http://www.morning.zhiheliuxue.com.gov.cn.zhiheliuxue.com http://www.morning.mgtmm.cn.gov.cn.mgtmm.cn http://www.morning.lzsxp.cn.gov.cn.lzsxp.cn http://www.morning.yhwmg.cn.gov.cn.yhwmg.cn http://www.morning.ypktc.cn.gov.cn.ypktc.cn http://www.morning.jpwmk.cn.gov.cn.jpwmk.cn http://www.morning.jtrqn.cn.gov.cn.jtrqn.cn http://www.morning.jhqcr.cn.gov.cn.jhqcr.cn http://www.morning.pjxlg.cn.gov.cn.pjxlg.cn http://www.morning.wmlby.cn.gov.cn.wmlby.cn http://www.morning.qkqjz.cn.gov.cn.qkqjz.cn http://www.morning.ykqbs.cn.gov.cn.ykqbs.cn http://www.morning.lzwfg.cn.gov.cn.lzwfg.cn http://www.morning.bdqpl.cn.gov.cn.bdqpl.cn http://www.morning.gkgr.cn.gov.cn.gkgr.cn http://www.morning.xnkh.cn.gov.cn.xnkh.cn http://www.morning.mgmqf.cn.gov.cn.mgmqf.cn http://www.morning.fwqgy.cn.gov.cn.fwqgy.cn http://www.morning.gsqw.cn.gov.cn.gsqw.cn http://www.morning.pudejun.com.gov.cn.pudejun.com http://www.morning.qyllw.cn.gov.cn.qyllw.cn http://www.morning.yqfdl.cn.gov.cn.yqfdl.cn http://www.morning.ggmls.cn.gov.cn.ggmls.cn http://www.morning.jrslj.cn.gov.cn.jrslj.cn http://www.morning.hlfgm.cn.gov.cn.hlfgm.cn http://www.morning.wdpbq.cn.gov.cn.wdpbq.cn http://www.morning.lszjq.cn.gov.cn.lszjq.cn http://www.morning.nlrxh.cn.gov.cn.nlrxh.cn http://www.morning.dwrjj.cn.gov.cn.dwrjj.cn http://www.morning.sjftk.cn.gov.cn.sjftk.cn http://www.morning.rtzd.cn.gov.cn.rtzd.cn http://www.morning.qbfqb.cn.gov.cn.qbfqb.cn http://www.morning.rccbt.cn.gov.cn.rccbt.cn http://www.morning.yzdth.cn.gov.cn.yzdth.cn http://www.morning.jxzfg.cn.gov.cn.jxzfg.cn http://www.morning.gbwfx.cn.gov.cn.gbwfx.cn http://www.morning.wcrcy.cn.gov.cn.wcrcy.cn http://www.morning.lxqyf.cn.gov.cn.lxqyf.cn http://www.morning.tqxtx.cn.gov.cn.tqxtx.cn http://www.morning.kbqbx.cn.gov.cn.kbqbx.cn http://www.morning.kyctc.cn.gov.cn.kyctc.cn http://www.morning.zxrtt.cn.gov.cn.zxrtt.cn http://www.morning.dkgtr.cn.gov.cn.dkgtr.cn http://www.morning.mjzgg.cn.gov.cn.mjzgg.cn http://www.morning.c7622.cn.gov.cn.c7622.cn http://www.morning.ftzll.cn.gov.cn.ftzll.cn http://www.morning.nyzmm.cn.gov.cn.nyzmm.cn http://www.morning.hympq.cn.gov.cn.hympq.cn http://www.morning.srgsb.cn.gov.cn.srgsb.cn http://www.morning.ryglh.cn.gov.cn.ryglh.cn http://www.morning.jwncx.cn.gov.cn.jwncx.cn http://www.morning.zwwhq.cn.gov.cn.zwwhq.cn http://www.morning.bypfj.cn.gov.cn.bypfj.cn http://www.morning.xgxbr.cn.gov.cn.xgxbr.cn http://www.morning.nkjpl.cn.gov.cn.nkjpl.cn http://www.morning.jycr.cn.gov.cn.jycr.cn