致命错误:第183行的... \ model.php中超过30秒的最大执行时间 [英] Fatal error: Maximum execution time of 30 seconds exceeded in ...\model.php on line 183

查看:63
本文介绍了致命错误:第183行的... \ model.php中超过30秒的最大执行时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在本地计算机上.我仅在insert | create | delete之后第一次加载页面时才收到该错误.然后它加载非常快.再一次,如果我修改数据库,则在访问页面时第一次(有时是第二次)时出现该错误. 我不明白

I'm on local machine. I only get that error when loading the page the first time after an insert|create|delete. Then it loads very fast. Then again if I modify the database, the first time(sometimes the second time) when accessing the page i get that error. I don't get it.

为什么在修改数据库后仅在第一次访问该网站时才会出现该错误?

$sth = $this->dbh->prepare("SELECT g.t_tree_c_parent AS gp ,h.t_tree_c_parent AS hp
                FROM t_tree a INNER JOIN (t_data b, t_data c, t_tree d, t_data e, t_data f, t_tree g, t_tree h, t_tree i) 
                ON a.t_tree_c_child=b.t_data_c_space
                AND b.t_data_c_object=c.t_data_c_object
                AND c.t_data_c_space=d.t_tree_c_child
                AND d.t_tree_c_parent=e.t_data_c_object
                AND e.t_data_c_space=f.t_data_c_object
                AND f.t_data_c_space=g.t_tree_c_child
                AND g.t_tree_c_parent=h.t_tree_c_child
                AND e.t_data_c_space=i.t_tree_c_child
                AND i.t_tree_c_parent=?
                WHERE a.t_tree_c_child=?");
$sth->execute(array($this->glob['children'], $child)); //  <- LINE:183

我将拆分该查询以进行测试.但是我问也许我遗漏了一些东西.

I will split that query to test out. But I'm asking maybe I'm missing something.

@ jcho360询问的更新:

UPDATE asked by @jcho360:

CREATE TABLE `t_data` (
`t_data_c_space` VARCHAR(50) NOT NULL DEFAULT '0.00000000000',
`t_data_c_object` VARCHAR(50) NULL DEFAULT NULL,
`t_data_c_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`t_data_c_space`)
 )
COLLATE='utf8_general_ci'
ENGINE=InnoDB;

CREATE TABLE `t_tree` (
`t_tree_c_parent` VARCHAR(50) NOT NULL,
`t_tree_c_child` VARCHAR(50) NOT NULL,
`t_tree_c_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB;

在HeidiSQL中为孩子(在项目中此查询在递归函数中):

In HeidiSQL for a child(in project this query is in a recursive function):

在进行db小更新后第一次<2.137秒,然后0.000秒

2.137 sec the first time after a small update in db then 0.000 sec

我开始认为这是由Leandro Barreto推荐的mysql缓存.

I start to think that is the mysql caching, sugested by Leandro Barreto.

推荐答案

我会在这里给您一个疯狂的猜测:数据库缓存.

I will give you a wild guess here: Database caching.

第一次执行该页面时,查询未缓存在数据库中,因此它花费的时间更长,从而使PHP的时间限制到期.

On the first time you execute the page, the query is not cached in the database, so, it takes longer, thus, expiring PHP's time limit.

有时候,查询要快得多.

On the other times, the query is much faster.

您可以如前所述拆分查询,也可以尝试增加脚本的时间限制:

You can either split the query, as you mentioned, or you could try increasing the time limit on the script:

set_time_limit(0); //No time limit
set_time_limit(60); //60 seconds

可以肯定的是,您可以使用来清理数据库缓存并始终使用它,因此您将始终在干净的缓存上运行页面.

To be sure, you could use this to clean database cache and use it always sou you will always run the page on clean cache.

这篇关于致命错误:第183行的... \ model.php中超过30秒的最大执行时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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