Category: zendframework

zend mysql between query

$aEventsSelect = Engine_Api::_()->getItemTable(‘event’)->select(); if(count($aEventIds) > 0){ $aEventsSelect->where(“event_id IN (?)”, $aEventIds); } if( $filter == “past” ) { $aEventsSelect->where(“endtime <= FROM_UNIXTIME(?)”, time()); } else { $aEventsSelect->where(“endtime > FROM_UNIXTIME(?)”, time()); } if($eventdate != ‘0’) { $whereSql = “‘{$eventdate}’ BETWEEN DATE(starttime) AND DATE(endtime)”; $aEventsSelect->where($whereSql); }

How to change the redirection page after login in socialengine

socialengine is a zendframework based project helps the developers to build their own custom social network website. socialengine following the MVC structure. The login action is in user/controllers/AuthController.php Here we specify the redirection URL return $this->_helper->redirector->gotoRoute(array(“action”  =>  ‘home’) ,  “user_general” ,  true);  change the user router according to your need.

Socialengine/zend simple Update Query

  Update query using Socialengine or zendframework. Engine_Db_Table::getDefaultAdapter()->update(‘engine4_activity_actions’, array(‘like_count’=>sizeof($oLikes)) , array(‘action_id = ?’=>$iId) );

Pass custom error message to zend/socialengine form from controller

$this->view->form = $form = new User_Form_Admin_Universities_Createdomain(); $this->view->university_id = $iId = $this->_getParam(‘id’, null); $form->populate(array(‘university_id’=>$iId)); if($this->getRequest()->isPost() && $form->isValid($this->getRequest()->getPost()) ) { $iExists = $oUniversitydomains->ifExistsDomain(‘domain’, $aData[‘domain’], $aData[‘university_id’]); if($iExists > 0) { $message = ‘Domain Name Already Registered’;              $form->getElement(‘domain’)->addError($message);              return; } }

How to simply create a zend framework project?

I’m writing this tutorial based on LAMP(Linux Apache Mysql PHP)  development environment. You can create sample php zendframework project using terminal. For that type the following command smart@smarttips-System-Product-Name:~$ zf crate project /var/www/testzend If this package is not previously installed then will show this message The program ‘zf’ is currently not installed. You can install it

select query cannot join with another table zend framework

$select = $table->select() ->setIntegrityCheck(false) ->from($tableName) ->joinRight($subtableName, ‘`’.$subtableName.’`.`user_id` = `’.$tableName.’`.`user_id`’,array(‘resource_approved’,’user_approved’)) ->where(‘`’.$subtableName.’`.`resource_id` = ?’, $resource->getIdentity()); Give the following sql statement for avoid  “select query cannot join with another table zend framework”  mysql error. setIntegrityCheck(false)  

usort() function Issue with PHP 5.3

There is an issue existing with usort() function. Problem is purely related to php version, the old syntax is not work  well in php 5.3 Here is the fix for usort() function Issue with PHP 5.3 usort($aResult, function ($elem1, $elem2) { return strcmp($elem1[‘title’], $elem2[‘title’]); }); solution Use a different function. usort($aResult,”mySort“); function mySort($elem1,$elem2){ return strcmp($elem1[‘title’],