Welcome Guest, Not a member yet? Register   Sign In
$this->db->from(), aliases and AR caching
#1

[eluser]Armchair Samurai[/eluser]
This is a pretty bizarre bug involving 1.6.1's active record caching: the following queries should produce the same result:
Code:
// This works (no caching involved though) ...
$this->db->get('foo AS x');
// Produces

// ... so does this...
$this->db->from('foo AS x');
$this->db->get();

//... this one too...
$this->db->start_cache();
$this->db->from('foo x');
$this->db->stop_cache();
$this->db->get();

//... but this throws a hissy fit.
$this->db->start_cache();
$this->db->from('foo AS x');
$this->db->stop_cache();
$this->db->get();

The last AR query will produce the following in MySQL:
Code:
SELECT * FROM (`foo` x, `foo` AS `x`)

For some reason, the combination of using AR caching and from() produces a malformed query. Not exactly an earth-shatting bug, but a bug nonetheless.
#2

[eluser]Derek Allard[/eluser]
Well, this is a bug indeed. Could I trouble you to make a report in the bug tracker for me?
#3

[eluser]Armchair Samurai[/eluser]
Consider it done.
#4

[eluser]Roland B.[/eluser]
Maybe it helps to find the bug:

My select looks like that:
$this->obj->db->select("id,question_name," .
"(CONCAT(question_name,'_quest')) as kb_quest_key," .
"(CONCAT(question_name,'_answ')) as kb_answ_key," .
"product_id");
$this->obj->db->from("qa");

The code sample contains 2 equal parts: '(CONCAT(question_name' and both of them are essential for the statement but the second one gets deleted. The same statement worked in CI 1.5.4 without problems.

But if I slightly modify the statement and omit the () around ONE of the CONCAT functions it works!




Theme © iAndrew 2016 - Forum software by © MyBB