Welcome Guest, Not a member yet? Register   Sign In
Fatal error: Call to undefined method CI_DB_mysql_driver::row()?
#1

[eluser]anna16[/eluser]
guys i have this error below,

Code:
Fatal error: Call to undefined method CI_DB_mysql_driver::row()

here is the codes again,
Code:
<?php
class Membership extends Model
{

  function __construct()
  {
    parent::Model();
    $this->load->database();
  }

    function add_record($data)
    {
        $this->db->insert('user', $data);
        return;
    }
  
  function check_email()
  {
    $query = $this->db->select('email')->where('email', $this->input->post('email'));
    return $query->row();
    #return $query->result();
  }

  function check_username()
  {
    $query = $this->db->select('username')->where('username', $this->input->post('username'));
        return $query->result();
  }



}
//end of membership_model


I'm lost thanks in advanced.
#2

[eluser]TaylorOtwell[/eluser]
It doesn't look like you're calling the "get()" method in your "check_email()" function, so the query you are defining is never actually executing.

Try this:

Code:
$query = $this->db->select('email')->where('email', $this->input->post('email'))->get();
#3

[eluser]anna16[/eluser]
thanks for the hint

i guess i got it,
Code:
function check_email()
  {
    $query = $this->db
      ->select('email')
      ->from('user')
      ->where('email', $this->input->post('email'));
      
    return $query;
  }
#4

[eluser]TaylorOtwell[/eluser]
That still doesn't actually execute the query does it?
#5

[eluser]anna16[/eluser]
yeah,

why is it not accepting this codes below,

function check_email()
{
$query = $this->db
->select('email')
->from('user')
->where('email', $this->input->post('email'));

return $query->result();
}

it says,
Code:
Fatal error: Call to undefined method CI_DB_mysql_driver::result()
thanks in advanced.
#6

[eluser]dudeami0[/eluser]
The problem is you never actually execute the query. It's like setting up the string "SELECT `email` FROM `users` WHERE `email` = ?" but never sending it to the DB. The get() function executes the query, so you need:

Code:
function check_email() {
   $query = $this->db
      ->select('email')
      ->where('email', $this->input->post('email'))
      ->get('user');
  
   return $query->result();
}
#7

[eluser]anna16[/eluser]
@dudeami0

Thank you very much, you are a <b>BIG</b> help.
It is working now.

My question is why is 'from' doesn't work?

Thanks in advanced.
#8

[eluser]dudeami0[/eluser]
The from function does work, but it just adds the "from" to the query. So you could do

Code:
function check_email() {
   $query = $this->db
      ->select('email')
      ->from('user')
      ->where('email', $this->input->post('email'))
      ->get();
  
   return $query->result();
}

And it would work. Select(), from(), and where() are all used to build the query. get(), insert(), and update() execute queries based on what you gave it with select, from, and where before calling them.
#9

[eluser]InsiteFX[/eluser]
Hi anna,

This is all in the CodeIgniter User Guide Active Record.

Active Record Class

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB