Foros del Web » Programando para Internet » PHP » Zend »

Problema al Insertar en la DB con Zend

Estas en el tema de Problema al Insertar en la DB con Zend en el foro de Zend en Foros del Web. Hola tengo un problema al inserta en la DB me da el siguiente error Cita: Fatal error: Call to undefined function insertar() in C:\xampp\htdocs\Game\application\modules\default\c ontrollers\IndexController.php ...
  #1 (permalink)  
Antiguo 29/08/2012, 13:20
Avatar de lekuack  
Fecha de Ingreso: agosto-2012
Ubicación: Cabrero
Mensajes: 35
Antigüedad: 11 años, 8 meses
Puntos: 0
Problema al Insertar en la DB con Zend

Hola tengo un problema al inserta en la DB me da el siguiente error

Cita:
Fatal error: Call to undefined function insertar() in C:\xampp\htdocs\Game\application\modules\default\c ontrollers\IndexController.php on line 29

El modelo es el siguiente

Código PHP:
<?php

class Default_Model_DbTable_Usuario extends Zend_Db_Table_Abstract
{

    protected 
$_name 'usuario';
    
    public function 
get($id)
    {
        
$id = (int) $id;
        
$row $this->fetchRow('id = ' $id);
        if (!
$row)
        {
            throw new 
Exception("Could not find row $id");
        }
        return 
$row->toArray();
    }
    
    public function 
insertar($usuario$clave$email$registro)
    {
        
$data = array('usuario' => $usuario'email' => $email,
            
'clave' => $clave'registro' => $registro);
        
$this->insert($data);        
    }
}
y en el controlador tengo lo siguiente

Código PHP:
<?php

class Default_IndexController extends Zend_Controller_Action
{

    public function 
init()
    {
        
$this->view->title ":: Mi web ::";
        
$this->view->headTitle($this->view->title);
        
$this->initView();
        
$this->view->baseUrl "/Game/public";
        
$cont $this->getRequest()->getControllerName();
        
$this->view->controller $cont;
    }

    public function 
indexAction()
    {
       
$form = new Default_Form_Registro();
       
$this->view->form $form;
       if (
$this->getRequest()->isPost()){
           
$formData $this->getRequest()->getPost();
           if (
$form->isValid($formData)){
                
$usuario $form->getValue('usuario');
                
$email $form->getValue('email');
                
$clave $form->getValue('clave');
                
$registro "2012-08-29";
                
$usuarios = new Default_Model_DbTable_Usuario();
                
$usuarios insertar($usuario$clave$email$registro);
                
$this->_helper->redirector('index');
           }
           else
           {
                
$form->populate($formData);
           }
       }
    }
}
  #2 (permalink)  
Antiguo 29/08/2012, 13:23
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Respuesta: Problema al Insertar en la DB con Zend

Para llamar a un método de un objeto debes de usar -> no =, es decir:
Código PHP:
Ver original
  1. // mal
  2. $usuarios = insertar($usuario, $clave, $email, $registro);
  3. // bien
  4. $usuarios->insertar($usuario, $clave, $email, $registro);

Saludos.
  #3 (permalink)  
Antiguo 29/08/2012, 13:42
Avatar de lekuack  
Fecha de Ingreso: agosto-2012
Ubicación: Cabrero
Mensajes: 35
Antigüedad: 11 años, 8 meses
Puntos: 0
Respuesta: Problema al Insertar en la DB con Zend

Muchas gracias =D
estuve horas buscando el error

Etiquetas: Ninguno
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 15:21.