Here is my query , I want to write it in zend framework inside model.
SHOW COLUMNS FROM employee WHERE Field = 'status'
You can always use $this->getAdapter()->query($yourQuery) to execute an arbitrary query on the current database.
Your function would thus look something like this:
public function getByField($fieldName){
$yourQuery=$this->getAdapter()->quoteInto("SHOW COLUMNS FROM employee WHERE Field = '?'",$fieldname);
$query=$this->getAdapter()->query($yourQuery);
return $this->getAdapter()->fetchAll($query);
}
This should do it quite nicely.
getDbTable(), do a getAdapter(). I don't know what getDbTable() is, but i assume that it returns a Zend_Db_Table_Abstract object. What you want is a ` Zend_Db_Adapter_Abstract` object. Try it EXACTLY as I wrote it.Zend_Db_Table_Abstract ? If so, this should work. If not, your best chance is to save the database connection from initialization. In any case, you should either try using getAdapter() on your database object, or skip it, and do $this->fetchAll(). function getstatusColumn()
{
$fieldname = 'status';
$select = $this->getDbTable()->getAdapter()->quoteInto("SHOW COLUMNS FROM employee WHERE Field = ?",$fieldname);
$select = $this->getDbTable()->getAdapter()->fetchAll($select);
foreach($select as $result)
{
$r = $result['Type'];
$enum = substr($r, 6, -2);
$values = explode("','", $enum);
}
return $values;
}
This is what I did to get souliton for my question . This I used to display the values in the drop down list.