CodeIgniter"MySQL已经消失" [英] CodeIgniter 'MySQL has Gone Away'

查看:69
本文介绍了CodeIgniter"MySQL已经消失"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有很多关于MySQL的服务器已消失"错误的主题,但是这似乎是随机发生的,并且是在不利条件下发生的.

I know there are many topics about MySQL's "Server has gone away" error, but this one seems to be happening randomly and in a non-favorable condition.

我正在使用CodeIgniter 3.0.在我所做的研究中,我发现使用此框架其他有此问题的人,但是问题从未解决.他/她说这是CodeIgniter的错,因为该数据库在其他应用程序上没有问题.

I'm using CodeIgniter 3.0. In the research I did, I found someone else with this problem using this framework but that issue was never solved. He/she stated that it was CodeIgniter's fault because the database had no problems with other applications.

人们说这个问题通常是由于超时引起的,但是我认为可能不会出现超时的情况,因为该期间的数据量很少.实际上,我尝试从中获取信息的表的行数不超过5行.我只是在做SELECT * FROM table WHERE id = x,所以我真的不认为该数量的数据存在性能问题.

People say this issue is usually because of a timeout, but I don't think there could be a timeout where the amount of data is minimal. In fact, the tables where I'm trying to pick up information from have no more than 5 rows. I'm just doing a SELECT * FROM table WHERE id = x so I don't really think that there's a performance issue with that amount of data.

我用于查询的代码如下:

My code for the query goes as follows:

public function getArticleByRef($ref)
            {
                $this->db->reconnect();
                $article = array();
                $mods = array();
                $run = array();
                $supplier=array();
                $query = ($this->db->get_where('PABE_articles',array('Reference' => $ref),1));
                $article = $query->result_array();

                if(!$article)
                    return array('article' => null,'mods' => $mods,'run' => $run,'supplier'=>$supplier);
                $id = $article[0]['id'];
                $query = $this->db->get_where('PABE_mods',array('idarticle'=>$id));
                $mods = $query->result_array();
                $query = $this->db->select('*')
                    ->from('PABE_run')
                    ->where('idarticle', $id)
                    ->order_by('Color asc,Number asc')
                    ->get();
                $run = $query->result_array();
                $query = $this->db->get_where('PABE_supplieres',array('Reference' => $article[0]['Referencesupplier']));
                $supplier=  $query->result_array();
                return array('article' => $article,'mods' => $mods,'run' => $run,'supplier'=>$supplier);
            }

如您所见,我做了四个查询.再说一次,在这些表中没有一个有超过5行.

As you can see, I do four queries. Then again, in none of these tables there's more than 5 rows.

表的列数是:

Articles: 27
Supplier: 2
Run: 3
Mods: 4

这个问题是完全随机的,因此如果不解决它,我将无法完成此应用程序.相当奇怪的是,即使报告了此问题,也可以毫无问题地加载数据库中的所有数据.

The problem is totally random, so I can't complete this application without fixing it. Something that's pretty weird is that, even though this problem gets reported, all data from the database gets loaded with no problems.

一切都在我的PC上运行-Localhost.

Everything's running on my PC - Localhost.

推荐答案

可能是您的mysql未配置为支持持久连接.尝试在重新连接行中添加注释或编辑my.ini并启用持久连接.

Could be that your mysql is not configured to support persistent connections. Try commenting the reconnect line or edit my.ini and enable persistent connections.

致谢

这篇关于CodeIgniter"MySQL已经消失"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆