0
我想,因为它永远挂在我尝试用几个职位加载一个页面上我笨的应用程序在我的服务器返回一个500错误调试问题。这个模型结构是否容易出现无限循环?
此错误是间歇性的。 10次中的7次,我的页面加载速度快,CI的分析器显示执行时间< 0.6。
该模型使用这样的结构,其中来自不同的条款将取决于正在取得(即,我的职位,收藏,其它帖子)的请求被插入。没有SQL错误,没有PHP错误。只有在处理显著延迟和一些Apache的错误,如
[Sat May 19 21:27:21 2012] [warn] mod_fcgid: process 21174 graceful kill fail, sending SIGKILL
[Sat May 19 21:27:27 2012] [notice] mod_fcgid: process /var/www/vhosts/example.com/httpdocs/blog/index.php(21174) exit(communication error), get stop signal 9
就是这种SQL模式容易产生无限循环或一些其他类型的可以证明我的服务器要发狂了问题?
class Home_model extends CI_Model {
function __construct()
{
parent::__construct();
}
function count_posts($author_id = NULL, $section = NULL, $user_id = NULL, $origin = NULL)
{
$clause = $this->clause($author_id, $section, $user_id, $origin);
$query = $this->db->query("
SELECT *
$clause
");
return $query->num_rows;
}
function clause($author_id, $section, $user_id, $origin = NULL)
{
if ($section == 'favorites') {
$clause = "FROM post RIGHT JOIN favorites ON post_id_fk = post_id WHERE user_id_fk = $user_id";
} elseif (($section == 'posts') AND ($origin == 'user')) {
$clause = "FROM post WHERE post_author_id = $author_id";
} else {
if ($author_id == NULL) {
$clause = "FROM post";
} else {
$clause = "FROM post WHERE post_author_id = $author_id";
}
}
return $clause;
}
}
它肯定容易受到SQL注入传递 – Galen
无属性都是经得起用户输入 - 循环如何? – pepe