how to get raw query in codeigniter

Today, We want to share with you get last query in codeigniter.In this post we will show you print last query in core php, hear for select query in codeigniter controller we will give you demo and example for implement.In this post, we will learn about last query in ci with an example.

codeigniter print query before executing

In this post we will give you information about PHP Codeigniter get last executed query example. Hear we will give you detail about PHP Codeigniter get last executed query exampleAnd how to use it also give you demo for it if it is necessary.

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

PHP Codeigniter get last executed query example

Controller Code:

 * Get All Data from this method.
 * @return Response

public function index()

    $data['data'] = $this->db->get("items")->result();
    $executedQuery = $this->db->last_query();


public function test_db(){    
	$query = $this->db->get("items");      
	$str = $this->db->last_query();       
	echo "<pre>";    print_r($str);    

How To Get Last Query In PHP Codeigniter?

public function product()
    $query = $this->db->get("product");
    $str = $this->db->last_query();
    echo "<pre>";


SELECT * FROM `product`

I hope you get an idea about how to get raw query in codeigniter.
I would like to have feedback on my 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.

Read Also:  print last query in codeigniter Example

Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  Woocommerce Featured Image URL and Gallery images in Wordpress
  2. Read Also:  PHP Laravel carbon convert String To Date
  3. Read Also:  codeigniter print last query - PHP Examples
  4. Read Also:  Update Query In Codeigniter Example Tutorial
  5. Read Also:  Laravel 6 Inner Join Query Example - MySQL
  6. Read Also:  How to Get Last Executed Query in Codeigniter?
  7. Read Also:  last query ci - codeigniter last query Example
  8. Read Also:  Laravel 6.2 Create Custom Helper Tutorial with Example
  9. Read Also:  PHP Time Ago Function Converting Timestamp
  10. Read Also:  ci last query | last query ci | get last query codeigniter Example