Thinkphp 开启字段缓存后,生成字段缓存文件bug修改

论坛 期权论坛     
选择匿名的用户   2021-6-2 16:56   288   0
<p><span style="white-space:pre"></span><strong><span style="font-size:18px">遇到问题描述如下:</span></strong><span style="white-space:pre"></span></p>
<p><span style="white-space:pre"></span><span style="font-size:14px">项目中用到两数据库 ,一个基础数据库,基础数据库hq_gynzsxjy中有个站内信息表 hq_sf_message ;  一个微圈数据库hq_gynzsxjy_sxq(简化微信好友圈功能),微圈数据库有同样有个 消息表hq_sxq_message;</span></p>
<p><span style="font-size:14px">       项目为采用了分组,Model目录大致如下</span></p>
<p><span style="font-size:14px"><span style="white-space:pre"></span>Model </span></p>
<p><span style="font-size:14px">                      Base</span></p>
<p><span style="font-size:14px"><span style="white-space:pre"></span>MessageModel.class.php,对应hq_sf_message表</span></p>
<p><span style="font-size:14px"><span style="white-space:pre"></span>     Sxq</span></p>
<p><span style="font-size:14px"><span style="white-space:pre">MessageModel.class.php对应hq_s</span>xq<span style="white-space:pre">_message表</span></span></p>
<p><span style="font-size:14px"><span style="white-space:pre"></span>项目关闭debug模式,开启数据字段缓存</span></p>
<p><span style="font-size:14px"><span style="white-space:pre"></span><strong>Runtime\Data\_fields</strong>下只生成文件hq_gynzsxjy.message.php,未生成hq_qynzsxjy_sxq.message.php文件</span></p>
<p><span style="font-size:14px"><span style="white-space:pre"></span>两个表结构并不一致的,导致已生成缓存后,另一个信息表的相关操作有误(所取字段不同);</span></p>
<p><span style="white-space:pre"></span></p>
<p><span style="white-space:pre"></span><strong><span style="font-size:18px">查询tp框架后解决办法:</span></strong></p>
<p><span style="font-size:18px"><strong>    </strong></span><span style="font-size:14px"> thinkphp的核心文件Model.class.php中</span></p>
<p></p>
<pre style="font-family:&#39;Source Code Pro&#39;; font-size:12pt; background-color:rgb(43,43,43)"><span style="color:rgb(98,151,85); background-color:rgb(35,37,37)"><em>/**
</em></span><span style="color:rgb(98,151,85); background-color:rgb(35,37,37)"><em> * </em></span><span style="color:rgb(98,151,85); font-family:宋体; background-color:rgb(35,37,37)"><em>自动检测数据表信息
</em></span><span style="color:rgb(98,151,85); font-family:宋体; background-color:rgb(35,37,37)"><em> </em></span><span style="color:rgb(98,151,85); background-color:rgb(35,37,37)"><em>* </em></span><span style="color:rgb(98,151,85); background-color:rgb(35,37,37)"><strong><em>&#64;access </em></strong></span><span style="color:rgb(98,151,85); background-color:rgb(35,37,37)"><em>protected
</em></span><span style="color:rgb(98,151,85); background-color:rgb(35,37,37)"><em> * </em></span><span style="color:rgb(98,151,85); background-color:rgb(35,37,37)"><strong><em>&#64;return </em></strong></span><span style="color:rgb(98,151,85); background-color:rgb(35,37,37)"><em>void
</em></span><span style="color:rgb(98,151,85); background-color:rgb(35,37,37)"><em> */
</em></span><span style="color:rgb(204,120,50); background-color:rgb(35,37,37)"><strong>protected function </strong></span><span style="color:rgb(255,198,109); background-color:rgb(35,37,37)">_checkTableInfo</span><span style="color:rgb(169,183,198); background-color:rgb(35,37,37)">() {
</span><span style="color:rgb(169,183,198); background-color:rgb(35,37,37)">    </span><span style="color:rgb(128,128,128); background-color:rgb(35,37,37)">// </span><span style="color:rgb(128,128,128); font-family:宋体; background-color:rgb(35,37,37)">如果不是</span><span style="color:rgb(128,128,128); background-color:rgb(35,37,37)">Model</span><span style="color:rgb(128,128,128); font-family:宋体; background-color:rgb(35,37,37)">类 自动记录数据表信息
</span><span style="color:rgb(128,128,128); font-family:宋体; background-color:rgb(35,37,37)">    </span><span style="color:rgb(128,128,128); background-color:rgb(35,37,37)">// </span><span style="color:rgb(128,128,128); font-family:宋体; background-color:rgb(35,37,37)">只在第一次执行记录
</span><span style="color:rgb(128,128,128); font-family:宋体; background-color:rgb(35,37,37)">    </span><span style="color:rgb(204,120,50); background-color:rgb(35,37,37)"><strong>if</strong></span><span style="color:rgb(169,183,198); background-color:rgb(35,37,37)">(</span><span style="color:rgb(204,120,50); background-color:rgb(35,37,37)"><strong>empty</strong></span><span style="color:rgb(169,183,198); background-color:rgb(35,37,37)">(</span><span style="color:rgb(152,118,170); background-color:rgb(35,37,37)">$this</span><span style="color:rgb(169,183,198); background-color:rgb(35,37,37)">-&gt;</span><span style="color:rgb(152,118,170); background-color:rgb(35,37,37)">fields</span><span style="color:rgb(169,183,198); background-color:rgb(35,37,37)">)) {
</span><span style="color:rgb(169,183,198); background-color:rgb(35,37,37)">        </span><span style="color:rgb(128,128,128); background-color:rgb(35,37,37)">// </span><span style="color:rgb(128,128,128); font-family:宋体; background-color:rgb(35,37,37)">如果数据表字段没有定义则自动获取
</span><span style="color:rgb(128,128,128); font-family:宋体; background
分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP