Welcome Guest, Not a member yet? Register   Sign In
Problems with Active Record
#11

[eluser]TheFuzzy0ne[/eluser]
That doesn't make sense. I see no occurrences of jpp anywhere in your query. What am I missing?
#12

[eluser]ekarey[/eluser]
Its set as the default table prefix in my config file...can I not use a default prefix?
#13

[eluser]TheFuzzy0ne[/eluser]
Oh, I see! OK, Well looking at the source code, it looks like it won't add the prefix to aliases if you use AS with your aliases.
#14

[eluser]ekarey[/eluser]
Could you give me an example? Sorry to be such a pain!
#15

[eluser]TheFuzzy0ne[/eluser]
Code:
$this->db->from('gamedb AS g'); # Note the 'AS'.

Try that. You may have to do it with each alias in the select statement too, but we'll soon see. Hopefully it should get rid of the error you're currently getting however.
#16

[eluser]ekarey[/eluser]
Tried adding AS to just that section, the select clause and the join clause and none of it resolved the error of it adding the table prefix to the join query Sad
#17

[eluser]TheFuzzy0ne[/eluser]
OK, try passing FALSE as the second parameter for $this->db->from().
#18

[eluser]ekarey[/eluser]
Ok I finally figured it out. The problem was the order of my db statements. I needed to do the from call before the join call because it was using the alias established in the from call. See code below:

Code:
$this->db->select('g.game_id as game_id, g.title as game_title, g.platform_id as platform_id, p.name as platform', FALSE);

$this->db->from('gamedb AS g'); # Moved this before the Join Statement

$this->db->join('gameplatforms p', 'p.platform_id = g.platform_id');

But thanks very much for working through this with me!
#19

[eluser]TheFuzzy0ne[/eluser]
No problem. That's very strange, as all the AR class does is build a query string, it doesn't care about aliases or anything like that, it lets the database worry about that. Anyhow, glad you got it sorted.
#20

[eluser]jacobc[/eluser]
Interesting... That may be an issue that needs to be addressed...

AR protects the identifiers... so it does keep track of the aliases... but obviously it doesn't know about the alias until the from function is called... And doesn't go back and update the query when the from function is called with an alias...




Theme © iAndrew 2016 - Forum software by © MyBB