• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
$this->db->lastquery() not working

I'm dazzled as to what is causing this error. I'm simply writing $this->db->lastquery(), and I don't even get an error - the output is just nothing (""). I tried print_r($this->db->lastquery()) and the output was "1"

Am I missing a helper or something - have I destroyed the beautiful codeigniter framework? Can I ever feel happy after such a hideous crime?

It has to be $this->db->last_query()

It actually was Tongue It's:

return "query: ".$this->db->last_query();

and I only see "query:"

you should show more code then

How I call it is in my model:
function lastquery()
    return "query: ".$this->db->last_query();

then I call my Model by doing
function lastquery_get()
    $dude = $this->Model->lastquery();

in this case I serve it as a REST response hence the response($var,200);
but as I said I only get "query: "

Please let me know what other pieces of code you'd want to see.

show the code before lastquery_get call. Maybe dumb question, but do you execute any queries before you call last_query?

I'm not quite following - everything is in functions. The controller itself is extending Phil Sturgeons RESTController, and I have no constructor. I don't know how comfortable I am dumping the entire controller code, but on the other hand I would appreciate the help, is there some way to post the code discretely Big Grin ?

[quote author="SPeed_FANat1c" date="1293821877"]show the code before lastquery_get call. Maybe dumb question, but do you execute any queries before you call last_query?[/quote]

I don't consider it a dumb question, I've asked myself this, and I'd say that the answer was yes. To my understanding it is supposed to give me the last processed query. I have first made calls to methods that queried the db, and gave me the correct results, and thn tried calling lastquery, but without luck. I may have misunderstood it though, that's always an option, so thank you for asking.

Again, you need to show the code before last_query() was called. It's not clear from your code which query is being called.

There are different, but an update would look like:
function SetMarker($data, $id)
    if($id != 'null')
    {  $this->db->where('id', $id);
       $this->db->update('markers'); }
    { $this->db->insert('markers');
    $data['id'] = $this->db->insert_id();}
    return $data;

I know they work since the job gets done, still lastquery returns nothing. Is there another way with codeigniter or phpmyadmin I can view the entire last query?

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.