public function indexAction() { $busca = $this->_request->getParam('id'); $ingredienteModel = new Application_Model_Ingrediente(); $nome_ingrediente = $ingredienteModel->fetchAll($ingredienteModel->select()->from($ingredienteModel->info(Zend_Db_Table_Abstract::NAME))->columns(array('nome_ingrediente'))->where('id_ingrediente like :busca')->bind(array('busca' => '%' . $busca . '%'))); $this->view->nome_ingrediente = $nome_ingrediente[0]['nome_ingrediente']; $relacionamentosModel = new Application_Model_Relacionamentos(); $this->view->relacionamento = $relacionamentosModel->fetchAll($relacionamentosModel->select()->where('excluido = 0')->where('id_ingrediente = ?', $busca)->order('id_ingrediente_idx DESC')); }
public function removerAction() { $id = $this->_request->getParam('id'); $confirma = $this->_request->getParam('confirma'); if (isset($confirma)) { if ($confirma == 1) { $ingredienteModel = new Application_Model_Ingrediente(); $ingredienteModel->update(array('excluido' => '1'), 'id_ingrediente = ' . $id); $relacionamentosModel = new Application_Model_Relacionamentos(); $relacionamentosModel->update(array('excluido' => '1'), 'id_ingrediente = ' . $id); return $this->_helper->redirector('index'); } else { return $this->_helper->redirector('index'); } } else { $this->view->id = $this->_request->getParam('id'); $ingredienteModel = new Application_Model_Ingrediente(); $nome_ingrediente = $ingredienteModel->fetchAll($ingredienteModel->select()->from($ingredienteModel->info(Zend_Db_Table_Abstract::NAME))->columns(array('nome_ingrediente'))->where('id_ingrediente = ?', $id)); $this->view->ingrediente = $nome_ingrediente; } }