How to Execute a straight SQL query without the hassle of a model.
#application/controlers/MyController.php
I assume the Database is setup in the config file, Application.ini.
$dbAdapter = Zend_Db_Table::getDefaultAdapter();
$sql ='SELECT * FROM users WHERE id > 23';
$statement = $dbAdapter->query($sql);
$row = $statement->fetch();
if ($arr['id'] == 45)
$this->view->response = 'yes';
else
$this->view->response = 'no';
If you have not setup the adapter you can use:
$db = new Zend_Db_Adapter_Pdo_Mysql(array(
'host' => '127.0.0.1',
'username' => 'webuser',
'password' => 'xxxxxxxx',
'dbname' => 'test'
));