loading...

print last query in codeigniter

pakainfocom profile image pakainfo ・1 min read

Codeigniter print last query : Codeigniter provides database class to deal with database. You can use $this->db->last_query(); to print last executed query. This prints the last executed query by codeigniter

print last query in codeigniter

We can get last executed query using last_query() function of db class in codeigniter. It is a very simple to use $this->db->last_query() function to see SQL statements of last executed query in php codeigniter app. You have to simple code that function after your main query that you wanted check

public function getAllMovies()
{
    $query = $this->db->get("tamilrokers");
  
    $data = $this->db->last_query();
   
    print_r($data);
    exit;
}

You may use transaction to check if the query executed successfully or not. After that you can check the $this->db->affected_rows() to see if the admin really updated the user value or not, and return message accordingly.

Also You can learn more way about last query in ci

Posted on by:

pakainfocom profile

pakainfo

@pakainfocom

My name is Angular King. I'm a full-stack developer, entrepreneur and owner of Pakainfo. I live in India and I love to write

Discussion

pic
Editor guide