Welcome Guest, Not a member yet? Register   Sign In
CI1.61 ActiveRecord quotes nested SELECTs in FROM part
#1

[eluser]Thoer[/eluser]
I upgraded a site from 1.5.4 to 1.6.1 and ActiveRecord class seems to choke on 'from's when I use nested SELECT calls. Different sql keywords get quoted. (I use mysql in case it's important)
#2

[eluser]Seppo[/eluser]
To avoid this behaviour pass a second argument with FALSE, for example
Code:
$this->db->select('MAX(num)', false);
#3

[eluser]Thoer[/eluser]
Thanks, but unfortunately, it's in the FROM clause.

Code:
$this->from('(SELECT some_cols FROM some_table WHERE criteria_is_met) AS altname');
#4

[eluser]Derek Allard[/eluser]
Thoer, could you post your full AR statement?
#5

[eluser]Thoer[/eluser]
[quote author="Derek Allard" date="1203287773"]Thoer, could you post your full AR statement?[/quote]

Check your private messages.
#6

[eluser]Derek Allard[/eluser]
<whine>OHhhhhh..</whine> Wink

By sending it to my private messages you put me and me alone on the hook for helping you through this... I was really just hoping to take a quick look. I'll endeavour to take a look when I find some free time.
#7

[eluser]xwero[/eluser]
[quote author="Thoer" date="1203283744"]Thanks, but unfortunately, it's in the FROM clause.

Code:
$this->from('(SELECT some_cols FROM some_table WHERE criteria_is_met) AS altname');
[/quote]
isn't from to define the tables? So shouldn't the subquery be in the select method?
#8

[eluser]Thoer[/eluser]
@Derek: I really believe I shared all the info needed and I don't want everybody to look at the original. As you can see from my PM, I've "solved" the problem using the $this->db->query() method, I just wanted you guys to know that it worked in 1.5.4 and doesn't in 1.6.1. Wink

@xwero: It depends on what you want to do. In this case I need it in the from part. Smile
#9

[eluser]Derek Jones[/eluser]
Subqueries are something we have planned for the future for Active Record, but seeing ways that developers are commonly using them in real world apps is beneficial, which is one of the reason Derek asked you to post the query. I'm sure you have a good reason for keeping it "secret", but you must understand how difficult this makes it for us to develop solutions that accommodate the widest range of implementations, and prevents us from getting valuable feedback from the talented members of the community. And besides, you needn't show your exact query with field and table names, reduced anonymous samples are often better when demonstrating a bug or feature request.
#10

[eluser]xwero[/eluser]
@Thoer : could you explain why you want to put a subquery in the from method.

@Derek Jones : Are subqueries one of the reasons mysql versions lower than 4.1 aren't supported anymore? Is 4.1 support the stepping stone for moving to version 5?




Theme © iAndrew 2016 - Forum software by © MyBB