Welcome Guest, Not a member yet? Register   Sign In
$this->db->lastquery() not working
#1

[eluser]D-dawg[/eluser]
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?
#2

[eluser]WanWizard[/eluser]
It has to be $this->db->last_query()
#3

[eluser]D-dawg[/eluser]
It actually was Tongue It's:

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

and I only see "query:"
#4

[eluser]SPeed_FANat1c[/eluser]
you should show more code then
#5

[eluser]D-dawg[/eluser]
Sure
How I call it is in my model:
Code:
function lastquery()
  {
    return "query: ".$this->db->last_query();
  }

then I call my Model by doing
Code:
function lastquery_get()
  {
    $this->load->model('Model');
    $dude = $this->Model->lastquery();
    $this->response($dude,200);
  }

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.
#6

[eluser]SPeed_FANat1c[/eluser]
show the code before lastquery_get call. Maybe dumb question, but do you execute any queries before you call last_query?
#7

[eluser]D-dawg[/eluser]
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 ?
#8

[eluser]D-dawg[/eluser]
[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.
#9

[eluser]Atharva[/eluser]
Again, you need to show the code before last_query() was called. It's not clear from your code which query is being called.
#10

[eluser]D-dawg[/eluser]
There are different, but an update would look like:
Code:
function SetMarker($data, $id)
  {
    $this->db->set($data);
    if($id != 'null')
    {  $this->db->where('id', $id);
       $this->db->update('markers'); }
    else
    { $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?




Theme © iAndrew 2016 - Forum software by © MyBB