• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CodeIngiter Query: 0 results. Pasting same query into query tool: 1 result. Uh... what?

Strange issue going on here. I've got one query thats giving me 0 results in CodeIgniter, and 1 result in pgAdmin (postgresql).

Here's the php:
function pageinfo($page, $subpage){
        $arrReturn = array();
        echo $this->db->last_query();
        return $arrReturn;

The first query works fine. Second query returns no results.

The query being returned from the last_query() echo:

SELECT * FROM "tblcategory" WHERE "urlkeyword" = 'test1' AND "parentid" = '0baaf830-68bb-11dd-ad8b-0800200c9a66'

Pasting this exact query into pgadmin, it gives me a result. How is this possible...? Maybe I am simply doing something wrong here?

Also, I should mention, replacing the double ->where on the second query with only one where using an array did not fix it.

Hmm, it seems you can't set array elements to the object in the manner I was trying. Or rather, they were setting, but the second items query was empty. I don't know if this is a restriction of the way code igniter is built or something to do with php itself (I'm very new to PHP). When I changed it to the following, it works fine.

function pageinfo($page, $subpage){
        $arrReturn = array();
        $where=array('parentid' => $arrReturn['page']['id'], 'urlkeyword' => $subpage);
        return $arrReturn;

[eluser]Eric Cope[/eluser]
I have issues with arrays of objects or arrays of mixed types. Glad to see you found a work around.
On a side note, isn't it fun to talk to yourself on a forum?

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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