Latest news
Home » zendframework (page 2)

zendframework

Export large sql table data to csv using php(socialengine)

//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 = array(); $array=array(); // foreach ...

Read More »

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’);

Read More »

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 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);

Read More »

Get baseurl in zendframework

The developers are can use this piece of code anywhere in zendframework  project for get baseurl of currently running project. <?php echo rtrim(Zend_Controller_Front::getInstance()->getBaseUrl(),’/’); ?>

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 »