调用未定义的方法CI_DB_pdo_result :: rows() - pgsql

时间:2018-06-18 20:08:56

标签: php postgresql

我的问题

  

遇到未被捕获的异常    输入:错误

     

消息:调用未定义的方法CI_DB_pdo_result::rows()

     

文件名:C:\ xampp \ htdocs \ CI \ application \ controllers \ Auth.php

     

行号:39

     

回溯:

     

文件:C:\ xampp \ htdocs \ CI \ index.php
  线:315
  功能:require_once

我的代码在下面给出

<?php
class Auth extends  CI_controller
{
    public function logout()
    {
        unset($_SESSION);

        session_destroy();
        redirect("auth/login","refresh");
    }

    public function login()
    {
        $this->form_validation->set_rules('username', 'Username', 'required'); 
        $this->form_validation->set_rules('password', 'Password', 'required|min_length[5]');

        if($this->form_validation->run()==TRUE)        
        {
            $username = $_POST['username'];
            $password = $_POST['password'];

           // check user in database
           $this->db->select('*');
           $this->db->from('users');
           $this->db->where(array(
               'username'=>$username,'password'=>$password));
           $query= $this->db->get();
           return $user=$query->rows(users);
           return $user;

           //if user exists

          if($user->email)
          {
              //temporary message 
              $this->session->set_flashdata("success", "you are logged in");

              //set session varriables

              $_SESSION['user_logged']=TRUE;
              $_SESSION['username']=$user->username;

              //redirect to profile page
              redirect("user/profile","refresh");
          }
          else
          {    
              $this->session->set_flashdata("error", "no such account exist");
              redirect("auth/login", "refresh");
          }
     }
     //load the view
     $this->load->view('login');
 }

 public function register()
 {
     if(isset($_POST['register']))
     { 
         $this->form_validation->set_rules('username','Username','required');
         $this->form_validation->set_rules('email','Email','required');

         $this->form_validation->set_rules('password', 'Password', 'required|min_length[5]');

         //if form validation true
         if($this->form_validation->run()==TRUE)
         {    
             echo 'form validated';

             //add user in database
             $data= array(
             'username'=>$_POST['username'],
             'email'=>$_POST['email'],
             'password'=>md5($_POST['password']),
             'gender'=>$_POST['gender'], 
            );

             $this->db->insert('users',$data);
             $this->session->set_flashdata("success","your account has been registered login now");
             redirect("auth/register","refresh");
         }
     }

     //load the view
     $this->load->view('register');
     }      
 }

?>

0 个答案:

没有答案