$this->db->select()->from(array('T1'=>'TBL_1'),array('table1_id'))
->join(array('T2'=>'TBL_2'),
'T1.site_id = T2.site_id',
array('GROUP_CONCAT( T2.name) as site_name'))
->where('T1.table1_id = ?',mysql_escape_string($tableId))
How to set view file in the controller
We can use the same view file for different actions by using the view render helper.
If we want to use the same view file for Add and Edit pages, Create a view file for Add and use the below code in the Edit action function
$this->_helper->viewRenderer->setRender('add');
If we want to use the same view file for Add and Edit pages, Create a view file for Add and use the below code in the Edit action function
$this->_helper->viewRenderer->setRender('add');
How to change the default Index controller in Zend Framework
Add the following code in the bootstrap init function
$frontController = $this->getResource('FrontController');
$frontController->setDefaultControllerName('controllerName');
$frontController = $this->getResource('FrontController');
$frontController->setDefaultControllerName('controllerName');
How to get last Insert Id in Zend Framework
If we want to get the last insert id in the Model we can use the command like this
$this->getAdapter()->lastInsertId();
Or we if we have the object of the db adapater, we can use the below code.
$db = Zend_Db_Table_Abstract::getDefaultAdapter();
$db->lastInsertId()
$this->getAdapter()->lastInsertId();
Or we if we have the object of the db adapater, we can use the below code.
$db = Zend_Db_Table_Abstract::getDefaultAdapter();
$db->lastInsertId()
How to get the config variables from application.ini in Controller
You can use the below code in the controller and it will return an array of config variables.
$config = $this->getInvokeArg(‘bootstrap’)->getOptions();
$config = $this->getInvokeArg(‘bootstrap’)->getOptions();
Zend Form button with onclick attribute
$form = new Zend_Form();
$form->addElement('button', 'add', array(
'Label' => 'Add Person',
'order' => '2',
'attribs' => array('onclick'=>'addMemberToSharedCalendar(this)')
));
$form->addElement('button', 'add', array(
'Label' => 'Add Person',
'order' => '2',
'attribs' => array('onclick'=>'addMemberToSharedCalendar(this)')
));
How to Set and Get Session values in Zend Framework
//To set the session
Initialize the session name space
$this->nameSpace = new Zend_Session_Namespace('HN');
$this->nameSpace->userId = 'userId';
//To get the session value
Initialize the session name space
$this->nameSpace = new Zend_Session_Namespace('HN');
$userId = $this->nameSpace->userId;
Initialize the session name space
$this->nameSpace = new Zend_Session_Namespace('HN');
$this->nameSpace->userId = 'userId';
//To get the session value
Initialize the session name space
$this->nameSpace = new Zend_Session_Namespace('HN');
$userId = $this->nameSpace->userId;
Subscribe to:
Posts (Atom)