last query in ci | get last query codeigniter Example

Today, We want to share with you last query in ci.In this post we will show you codeigniter last insert id, hear for Printing the query executed last by codeigniter framework using active record class we will give you demo and example for implement.In this post, we will learn about Join Query In Codeigniter Example Tutorial with an example.

Read Also:  get last query codeigniter | last query in ci Example

How to print SQL statement in codeigniter model?

codeigniter last query
codeigniter last query

How To Get Last Query In PHP Codeigniter?

Example 1:

public function product()
{
    $this->db->select('*'); 
    $query = $this->db->get("product");
    $str = $this->db->last_query();
    echo "<pre>";
    print_r($str);
}

Get the last executed Query in Codeigniter

Example 2:

$lastquery = $this->db->last_query();
echo $lastquery;

This will print the query in the format

/// SELECT * FROM products....


I hope you get an idea about get last query codeigniter 4.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.