#1 改变命运2023
我想在控制器下调用其它方法,来避免重复使用。应该怎么办?比如function s_select2(){
$tpl=$this->spArgs("tpl","default");
$products=spClass("products");
$images=spClass("s_images");
$condition=array('c2name'=>$this->spArgs("c2name"));
$this->results=$products->spPager($this->spArgs('page', 1), 5)->findAll($condition);// 这里使用了spPager,同时用spArgs接受到传入的page参数
$this->images=$images->findAll();
$this->pager = $products->spPager()->getPager();// 这里获取分页数据并发送到smarty模板内
$this->display("{$tpl}/product.html");
$this->display("{$tpl}/pro_left.html");
}
function s_select3(){
$tpl=$this->spArgs("tpl","default");
$products=spClass("products");
$images=spClass("s_images");
$condition=$this->spArgs("name");
$sql ="SELECT * FROM products WHERE name like '%".$condition."%'";
$this->results=$products->spPager($this->spArgs('page', 1), 5)->findSql($sql);// 这里使用了spPager,同时用spArgs接受到传入的page参数
$this->images=$images->findAll();
$this->pager = $products->spPager()->getPager();// 这里获取分页数据并发送到smarty模板内
$this->display("{$tpl}/product.html");
$this->display("{$tpl}/pro_left.html");
}
我想在s_select2中调用s_select3中的方法,这样我就不用重复写方法了。
2012-05-06 17:09:58