为什么框架变得这么慢啊
本帖最后由 wunayou 于 2012-2-21 12:00 编辑这是模型
<?phpclass MHome extends CI_Model{ function __construct()
{ parent::__construct();
}
function get_category()
{ $query=$this->db->query('select * ,(select count(brand) from product where brand=product_brand.name) as product_count from product_brand;');
return $query->result(); }
}
?>
<?php
class Mbrand extends CI_Model{
function __construct()
{
parent::__construct();
}
var $id;
function get_product($id,$page)
{ $query=$this->db->query("select * from product where brand=(select name from product_brand where id=$id)limit 0,$page");
return $query->result(); }
function get_product_num($id)
{ $query=$this->db->query("select * from product where brand=(select name from product_brand where id=$id)");
return $query->num_rows();
}
}
?>
这是控制器
<?php
class Brand extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->helper('url');
$this->load->database();
$this->load->model('Mhome');
$this->load->model('Mbrand');
$this->load->library('pagination');
}
function watches()
{
$config['base_url']=base_url().'brand/watches/'.$this->uri->segment(3);
$config['total_rows'] = $this->Mbrand->get_product_num($this->uri->segment(3));
$config['uri_segment'] = 4;
$config['per_page'] = 5; // 每页显示数量,为了能有更好的显示效果,我将该数值设置得较小
$config['num_links'] = 3; // 当前连接前后显示页码个数
$this->pagination->initialize($config);
$data['category']=$this->Mhome->get_category();
$data['brand']=$this->Mbrand->get_product($this->uri->segment(3),$config['per_page']);
$this->load->view('header',$data);
$this->load->view('brand');
$this->load->view('footer');
}
}
?>
代码都在这里 为什么打开网页就好像是12M网速变成1M还恐怖
看下哪里慢,这个需要监控下。 Hex 发表于 2012-2-21 15:06 static/image/common/back.gif
看下哪里慢,这个需要监控下。
怎么样监控? 用什么软件? http://codeigniter.org.cn/user_guide/libraries/benchmark.html Hex 发表于 2012-2-21 15:10 static/image/common/back.gif
http://codeigniter.org.cn/user_guide/libraries/benchmark.html
我看了一下 是我控制器慢了用了1.7056 总网站用了1。96mb 是我数据库的原因吗? 还是我电脑的原因? 一般来说慢都是数据库慢。 Hex 发表于 2012-2-21 17:27 static/image/common/back.gif
一般来说慢都是数据库慢。
请问 我的那个分页 那个LAST 不是下一页也在网址后面多加了一零
wunayou 发表于 2012-2-21 17:38 static/image/common/back.gif
请问 我的那个分页 那个LAST 不是下一页也在网址后面多加了一零
分页显示的是偏移量,不是页数。
这是老外的习惯。。。。
页:
[1]