How i can use a sql-query code that i already have on Zend-Framework using Model and Controller?
I'm tried of many ways and i can't solve this.
This is a example of "common sql-query code" to test: "SELECT id_arquivos_retorno FROM sa_arquivos_retorno LIMIT 100"
*My original code it's a big query and it's terrible transform to a zend-select()
This is my Model:
class PedidosInscricoesModel extends Zend_Db_Table_Abstract{
protected $_name = 'sa_arquivos_retorno';
public function getPedidosInscricoes(array $params) {
$this->_db = Zend_Registry::get('db2');
$session = new Zend_Session_Namespace('autenticacao');
$query = $this->query("SELECT id_arquivos_retorno FROM sa_arquivos_retorno LIMIT 100");
$retorno = $this->fetchAll($query)->toArray();
return $retorno;
}}
And That's my Controller:
public function indexAction()
{
$PedidosInscricoesModel = new PedidosInscricoesModel();
$this->view->id_arquivos_retorno = $_REQUEST['id_arquivos_retorno'];
$params = $this->_request->getParams();
$data = $PedidosInscricoesModel->getPedidosInscricoes($params);
$this->view->data = $retorno;
}
My index view:
<?php
foreach($this->data as $dados) {
?>
<tr>
<td><?php echo $dados["id_arquivos_retorno"]; ?></td>
</tr>
<?php
}
?>
-Sorry for bad english guys