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; }
Category: ZEND FRAMEWORK
Delete row mysql query example in zend framework
protected $_name = 'tbl_attribute'; public function deleteAttribute($attribute_id) { $this->delete("attribute_id = $attribute_id"); }
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);
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);
Post form data in zend framework
public function forgotPasswordAction() { if($this->getRequest()->isPost()) { $email=$this->_request->getPost('email'); } }
Mysql Like query example in zend framework
public function getFilteredBrokerCustomers($search_text) { $broker_customers = array('cid', 'esid', 'name', 'broker_code'); $broker_new = array('company_name'); $select = $this->select() ->setIntegrityCheck(false) ->from(array('b_c' => 'broker_customer'), $broker_customers); $select->join(array('b' => 'broker_new'), 'b_c.broker_code=b.broker_code', $broker_new); $select->where('b_c.name LIKE ?', $search_text); $select->where('b_c.status = ?', 1); $select->where('b_c.renewal = ?', 1); return $this->fetchAll($select); }
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; } }
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);
}