Lionel-Messi
19-05-2010, 11:43
Chào cả nhà, nhờ cả nhà giúp em
Trong model em có như sau
function getDulieu()
{
$db=&JFactory::getDBO();
$search = JRequest::getVar('search');
if ($search)
{
$where[] = "d.ten_dv LIKE '%$search%'";
}
$where[]= " d.id>1 ";
$filter = JRequest::getVar('filter',0);
if($filter)
{
$dvids=$this->getchildid($filter);
$dvids[]=$filter;
$dvids = '('.implode(',',$dvids).')';
$where[]='d.id in '.$dvids;
}
$where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' );
$query='select count(*) from #__donvi as d '.$where;
$db->SetQuery($query);
$total = $db->loadresult();
jimport('joomla.html.pagination');
$pagination = new JPagination( $total, $limitstart, $limit );
$query = 'select d.id,d.ma_dv,d.ten_dv,dd.ten_dv as tendvql,d.diachi,d.type,d.dienthoai,d.email,d.truc thuoc
from #__donvi as d left join #__donvi as dd on dd.id=d.parentid '
.$where;
;
$db->SetQuery($query);
$donvis=$db->loadObjectList();
return $donvis;
}
Ở trên em có 1 biến là $pagination
Sang View em muốn lấy biến $pagination mang giá trị như trong Model thì làm sao ạ
Em chỉ biết lấy theo hàm như dưới, còn lấy theo biến thì em chưa rõ lắm
$model = $this->getModel();
$donvis = $model->getDulieu();
Thank các bác nhiều!
Trong model em có như sau
function getDulieu()
{
$db=&JFactory::getDBO();
$search = JRequest::getVar('search');
if ($search)
{
$where[] = "d.ten_dv LIKE '%$search%'";
}
$where[]= " d.id>1 ";
$filter = JRequest::getVar('filter',0);
if($filter)
{
$dvids=$this->getchildid($filter);
$dvids[]=$filter;
$dvids = '('.implode(',',$dvids).')';
$where[]='d.id in '.$dvids;
}
$where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' );
$query='select count(*) from #__donvi as d '.$where;
$db->SetQuery($query);
$total = $db->loadresult();
jimport('joomla.html.pagination');
$pagination = new JPagination( $total, $limitstart, $limit );
$query = 'select d.id,d.ma_dv,d.ten_dv,dd.ten_dv as tendvql,d.diachi,d.type,d.dienthoai,d.email,d.truc thuoc
from #__donvi as d left join #__donvi as dd on dd.id=d.parentid '
.$where;
;
$db->SetQuery($query);
$donvis=$db->loadObjectList();
return $donvis;
}
Ở trên em có 1 biến là $pagination
Sang View em muốn lấy biến $pagination mang giá trị như trong Model thì làm sao ạ
Em chỉ biết lấy theo hàm như dưới, còn lấy theo biến thì em chưa rõ lắm
$model = $this->getModel();
$donvis = $model->getDulieu();
Thank các bác nhiều!