//function to download all users deatails to csv public function downloadcsvAction() { ob_end_clean(); set_time_limit(0); ini_set(‘memory_limit’, ‘2024M’); $this->_helper->viewRenderer->setNoRender(true); $this->_helper->layout->disableLayout(); $query=Engine_Db_Table::getDefaultAdapter()->select() ->from(‘engine4_users’,array(‘user_id’,’email’,’displayname’,’level_id’,’enabled’,’approved’,’intro_page’,’creation_date’)) ->where(‘user_id <> ?’, 1) ->where(‘user_id not in (?)’, array(‘685′,’870′,’948′,’965′,’1031′,’1249′,’1279′,’1283’)) ->where(‘user_id <> ?’, 6); $aResult= $query->query()->fetchAll(); $fileName = “users_”.time().’.csv’; header(‘Content-Type: application/csv’); header(‘Content-Disposition: attachement; filename=”‘.$fileName.’”‘); $f = fopen(‘php://output’, ‘w’) or show_error(“Can’t open php://output”); $n = 0; $line…
Category: zendframework
zendframework tips and tutorials, zendframework source codes, zendframework sql queries
session in socialengine
socialengine basically using zendframework for development. Zendframework methods can see all through the socialengine code. Session is an important functionality in programming. For achieving the session in socialengine use the following code $session = new Zend_Session_Namespace(‘invite’); $session->invite_code = $this->_getParam(‘code’); $session->invite_email = $this->_getParam(’email’);
call view helper in api or plugin of socialengine
View property is not available in plugin .So call view property using zend and use this for get view helper $view = Zend_Registry::get(‘Zend_View’); $job_status = $view->getJobStatus(‘id’);
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.’); } }
zend framework group by select in socialengine
$viewer = Engine_Api::_()->user()->getViewer(); $iCurUser = $viewer->getIdentity(); $oSelect = $this->getAdapter()->select() ->from(‘engine4_job_usersapplied’, array(‘job_id’, ‘COUNT(job_id) as applied_count’)) ->group(‘job_id’) ->where(‘job_user = ?’, $iCurUser); $result = $this->getAdapter()->fetchAll($oSelect);