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

[eluser]Taff[/eluser]
I like the idea of active record, but it is causing me some trouble. Hopefully someone can tell me why it isn't working as well as a "normal" equivalent.

These are 2 functions out of my model which are nigh on identical:

Code:
function getTrackedAnswers($answer_id){
    
    $this->db->select('sgq_questions_id, sga_value');
    $this->db->where('sga_sgq_id','sgq_id');
    $this->db->where('sga_id','560');
    $this->db->from('search_guide_answers');
    $this->db->from(array('search_guide_questions','search_guide_answers' ));
    $query=$this->db->get();
    $query = $query->row();
    $return $query;
        
    }

Produces in the config profiler:

Quote:SELECT `sgq_questions_id`, `sga_value` FROM (`search_guide_answers`, `search_guide_questions`) WHERE `sga_sgq_id` = 'sgq_id' AND `sga_id` = '560'

but an empty array when I var_dump.

array(0) { }


Code:
function getTrackedAnswersNoAR($answer_id){
        $sql="SELECT sgq_questions_id, sga_value FROM search_guide_questions, search_guide_answers WHERE sga_sgq_id=sgq_id AND sga_id='560'";
        echo $sql;
        $res=mysql_query($sql);
        $row=mysql_fetch_array($res);
        return $row;
    }


The echo SQL produces:
Quote:SELECT sgq_questions_id, sga_value FROM search_guide_questions, search_guide_answers WHERE sga_sgq_id=sgq_id AND sga_id='560'

but gives me the result I would expect if I var_dump it...

array(4) { [0]=> string(4) "1198" ["sgq_questions_id"]=> string(4) "1198" [1]=> string(1) "0" ["sga_value"]=> string(1) "0" }

Can anybody see what I am doing wrong?

Thanks for any assistance.
Taff


Messages In This Thread
Active Record trouble - by El Forum - 08-21-2008, 08:22 AM
Active Record trouble - by El Forum - 08-21-2008, 08:50 AM
Active Record trouble - by El Forum - 08-22-2008, 04:46 AM
Active Record trouble - by El Forum - 11-15-2008, 06:04 PM
Active Record trouble - by El Forum - 11-15-2008, 08:19 PM



Theme © iAndrew 2016 - Forum software by © MyBB