Latest news
Home » Tag Archives: zend framewrok

Tag Archives: zend framewrok

Pass custom error messages to form in socialengine / zend framework

if( !$form->isValid($this->getRequest()->getPost()) ) { return; } // Process $values = $form->getValues(); if( ($CouponCode = $form->getElement(‘coupon_code’)) && isset($values[‘coupon_code’])) { $iCouponExist = $table->checkCouponExist($values[‘coupon_code’]); if($iCouponExist == 1) { return $CouponCode->addError(‘This Coupon Code is not available, please use another one.’); } }

Read More »

Zend framework select Query with order Random

Use order(‘RAND()’)  in zendframework select query for fetching records in random. $usersTable = Engine_Api::_()->getItemTable(‘user’); $select = $usersTable->select() ->where(‘enabled = ?’, 1) ->where(‘approved = ?’, 1)   ->order(‘RAND()’) ->limit(5);

Read More »

File download zend framework php script

File download zend framework php script <?php $imagePath = getcwd().’/public/images/smartips_log.png’; header(‘Content-Type: image/jpeg’); header(‘Content-Disposition: attachment; filename=smartips_log.png’); readfile($imagePath); ?>

Read More »

php zend framework email validation

zend framework email validation $value=array(‘smarttips@smarttips.in,test@gmail.com’); // Validate emails $validate = new Zend_Validate_EmailAddress(); $emails = array_unique(array_filter(array_map(‘trim’, preg_split(“/[s,]+/”, $value)))); if( empty($emails) ) { return false; } foreach( $emails as $email ) { if( !$validate->isValid($email) ) { return false; } }

Read More »

php zend Pagination

Zend pagination Zend pagination is a default option available in zend framework. Only needs to use it .The codes are apply in  controller and view class Admin_PollsocietiesController extends Core_Controller_Action { public function listsocreqAction() { $oSocReqs   = new Model_Societysignup(); $aSocReqs   = $oSocReqs->getPendingRequests(); unset($oSocReqs); //for pagination $climit  = 20; $page1 = $this->_getParam(‘page’,1); $paginator = Zend_Paginator::factory($aSocReqs); $paginator->setItemCountPerPage($climit); $paginator->setCurrentPageNumber($page1); $this->view->paginator=$paginator; $this->view->assign(‘aSocs’, $paginator); } } ...

Read More »