Codeigniter/PHP - Problem sending Model Data to View

Asked

Viewed 99 times

0

Good night,

I am using Codeigniter 3.1.10. I have a problem sending a specific data from the Model database to the Controller:

var_dump($data) returns me only the array I passed that would be the email,

i need to return the accessed data from the column database checkkey

How can I do that?

var_dump($test); does not return anything...

Model:

public function reenvioSenha($dados) {

            $this->db->select("email,verifica_key");
            $this->db->from("usuarios");
            $this->db->where_in("email",$dados);

            $query = $this->db->get();

            if($query->num_rows() > 0) {
              foreach ($query->result() as $key => $value) {
                  $teste = $value->verifica_key;
              }

              return $teste;

            } else {
                return false;
            }
        }

Controller:

     public function reenviar_senha() {
     $dados = array (
        'email' => $this->input->post('email')
    );
     if($this->Usuarios_model->reenvioSenha($dados) == true) {

                var_dump($dados);
                var_dump($teste);
                exit;
       }
  }

1 answer

1

You can try this way.

controller

public function reenviar_senha()
{
    $email = $this->input->post('email');

    $this->load->model('usuario_model','usuario');
    $retorno = $this->usuario->reenviar_senha($email);
    //header('Content-Type: application/json');
    //echo json_encode($retorno); //retorna em json
    print_r ($retorno);
}

model

public function reenviar_senha($email)
{       
    $this->db->select('*');
    //$this->db->select('email, verifica_key'); //caso queira consultar apenas os campos email e verifica_key
    $this->db->from('usuario');
    $this->db->where('email', $email);
    $query = $this->db->get();
    $item = $query->result();

    return $item;
}

Browser other questions tagged

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