Codeigniter not registered

Asked

Viewed 73 times

0

I’m trying to enter some data in the database but I can’t. Some problem in the array that Codeigniter returns.

Follow the Controller that the form calls:

    function cadastrar()
{
    $this->load->helper('array');

    $dados = array();
    $dados2 = array();

    $dados2 = $this->input->post(NULL, TRUE);

    $this->load->model('Entidade_model', '', TRUE);

    if($this->Entidade_model->cadastrar($dados2))
    {
            $dados['tp_msg'] = 'success';
            $dados['msg'] = '<strong>Warning!</strong> Entidade inserida com sucesso!';
    }
    else{
            $dados['tp_msg'] = 'danger';
            $dados['msg'] = '<strong>Warning!</strong> Erro ao inserir entidade.';
    }

    $this->load->view('alert', $dados);
}

Follow the Model Controler sends the data:

    function cadastrar(array $data)
{
    return $this->db->insert('entidade', $data);
}

And he didn’t register.

  • And what would be this problem in the array?

  • it would be interesting to know the return too

1 answer

1

Next up, man. First, I advise you to read the Codeigniter user guide, especially this one part! Second, when I created my registration I followed the rule that is in this tab, so I filled the array only in the model and using the associative array this way:

$data = array( 'title' => $this->input->post('title') );

Browser other questions tagged

You are not signed in. Login or sign up in order to post.