Welcome Guest, Not a member yet? Register   Sign In
Active Record Incorrect Results
#1

[eluser]Unknown[/eluser]
Hi,

Here is my codes:
$this->db->_compile_select();
$this->db->select('destination,price_inc_vat,country,network,short_code,flag');
$this->db->where('country', $this->db->escape_str($data['dest']));
$this->db->order_by("network", "asc");
$query = $this->db->get('pricing');
echo $this->db->last_query();

The CI generated SQL is:
SELECT `destination`, `price_inc_vat`, `country`, `network`, `short_code`, `flag` FROM (`pricing`) WHERE `country` = 'Grenada (incl Carriacou)' ORDER BY `network` asc

While I run the exactly same SQL in PHPMyAdmin, it returns 2 matches. But none in CI.

Thanks in advance!
#2

[eluser]Jamie Rumbelow[/eluser]
Hi arthurln,

Are you connected to the correct database, with the correct tables and correct data? Why are you calling _compile_select()?

Jamie
#3

[eluser]Unknown[/eluser]
Hi Jamie,

Thanks for your reply.

I'm pretty sure that I'm using the same database. As I tested the app on my laptop and there is only one db with one table have that structure.

I'm using '_compile_select()' to display the generated SQL. So I can run the exact same SQL with my mysql client.

By the way, I'm using an older release of CI which I downloaded about half a year ago. I'm not sure if this problem has already been fixed after that.




Theme © iAndrew 2016 - Forum software by © MyBB