如何在Zend Framework中的模型中指定纯SQL查询?
如果有任何好的资源,请指出他们。
...谢谢
答案 0 :(得分:2)
当然,你可以使用zend db adapter。
$adapter = Zend_Db_Table::getDefaultAdapter();
$adapter->query('Select * FROM `table_name`');
答案 1 :(得分:0)
或
require_once 'Zend/Db/Table/Abstract.php';
class MyThing extends Zend_Db_Table_Abstract {
// Make a Mailing List Export file
public function doMyThing() {
// Happy, healthy cows eat grass, not corn.
$sql = "SELECT my_column FROM my_table WHERE $cows_eat_grass;";
$resultset = $this->getAdapter()->query($sql);
$resultArray = $resultset->fetchAll();
return $resultArray;
}
}