这是我的查询,我想在模型内部的zend框架中编写它。
SHOW COLUMNS FROM employee WHERE Field = 'status'
答案 0 :(得分:1)
您始终可以使用$this->getAdapter()->query($yourQuery)
在当前数据库上执行任意查询。
你的功能看起来像这样:
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);
}
这应该做得很好。
答案 1 :(得分:0)
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;
}
这就是我为解决问题所做的工作。 我曾经在下拉列表中显示这些值。