Pagination in zend framework

public function indexAction() { $data = $this->_em->getRepository('Application_Model_User') ->findBy(array('isDelete' => 0, 'roleId' => 2)); /* Pagination */ $page = $this->_getParam('page', 1); $paginator = Zend_Paginator::factory($data); $paginator->setItemCountPerPage(8); $paginator->setCurrentPageNumber($page); $paginator->setPageRange(1); $this->view->homeData = $paginator; }

Share This:


Delete row mysql query example in zend framework

protected $_name = 'tbl_attribute'; public function deleteAttribute($attribute_id) { $this->delete("attribute_id = $attribute_id"); }

Share This:


Update mysql query example in zend framework

protected $_name = 'tbl_attribute'; $data = array( 'attribute_name' => $attribute_name,'attribute_set' => $attribute_set, 'attribute_status' => $attribute_status); $this->update($data, 'attribute_id = '. (int)$attribute_id);

Share This:


Insert mysql query example in zend framework

protected $_name = 'tbl_attribute'; $data = array( 'attribute_name' => $attribute_name,'attribute_set' => $attribute_set, 'attribute_status' => $attribute_status); $this->insert($data);

Share This:


Post form data in zend framework

public function forgotPasswordAction() { if($this->getRequest()->isPost()) { $email=$this->_request->getPost('email'); } }

Share This:


Fetch row in zend framework

public function getDetail($id) { $customer = array('cid', 'esid', 'name', 'broker_code'); $broker_new = array('sid', 'company_name', 'broker_name','phone_number'); $select = $this->select() ->setIntegrityCheck(false) ->from(array('c' => 'customer'),$customer); $select->join(array('b' => 'broker_new'), 'b.broker_code=c.broker_code', $broker_new); $select->where('c.cid =?',$id); $row = $this->fetchRow($select); if($row){ return $row; }else{ return false; } }

Share This:


Join in zend framework

public function getFilteredCustomers($search_text) {
$customers = array('cid', 'esid', 'name', 'broker_code');
$broker_new = array('company_name');
$select = $this->select()
->setIntegrityCheck(false)
->from(array('c' => 'customer'), $customers);
$select->join(array('b' => 'broker_new'), 'c.broker_code=b.broker_code', $broker_new);
$select->where('c.name LIKE ?', $search_text.'%');
$select->where('c.status = ?', 1);
return $this->fetchAll($select);
}

Share This: