How to use Zend Framework Database functions for other application

- Include Zend library using set_include_path or .htaccess
- include 'Zend/Db/Table.php';
- $db = Zend_Db::factory('Pdo_Mysql', array(
'host' => 'localhost',
'username' => 'userName',
'password' => 'password',
'dbname' => 'dbName',
));

How to redirect with parameters in Zend Framework

$this->_helper->_redirector('action','controller','module',array('param1'=>'value1'));

How to get the table column names using Database functions

$result = $this->db->query($sql_query);
$result->setFetchMode(Zend_Db::FETCH_NUM);
$metaData = $this->db->describeTable('tableName');
$columnNames = array_keys($metaData);

Zend Framework : Difference ways to redirect from controller

Zend Framework 1.8 Web Application Development

1. $this->_helper->redirector('index','profile');
2. $url = $this->_helper->url('index','profile','',array('smsg'=>'moved'));
$this->_helper->redirector->goToUrl($url);
3. $this->_forward('index','profile');
PHP Zend Studio 5 - Instructor-based Video Training

Perform action with out view page in Zend Framework

$this->_helper->viewRenderer->setNoRender()

OR

$this->getHelper('viewRenderer')->setNoRender()

How to add OR condition in select query

$selectQry = $this->db->select()->where('fieldname = ?','value')
->orWhere('fieldname = ?','value);

Zend Framework select query with limit and order clause

$selectQry = $this->db->select()->from(array('MedA'=>TBL_NAME),array('answer_id','didTake','dateRecorded'))
->join(array('Med'=>TBL_NAME),
'Med.medication_id = MedA.medication_id',
array('nick_name'))
->where('MedA.is_deleted = ?',0)
->where('MedA.medication_id = ?',$medId)
->where('MedA.time_slot_id = ?',$timeSlotId)
->where('MedA.user_id = ?',$idValue)
->order('MedA.dateRecorded DESC');

if(!empty($limit))
$selectQry->limit($offset,$limit)