0

I've got this code:

$res = $this->EE->db->where(array('EventCode' =>$r["eventcode"]))
       ->limit(1)
       ->get('exp_course_events');
$course_date = $res->row('FormalDate');

but when I try to echo $course_date;, all I get is Array

Isn't this how to use the DB class to return a single row and get it's field values?

2 Answers 2

0

That is because that's what you're probably getting!

If you want to see what's going on, do this:

$res = $this->EE->db->where(array('EventCode' =>$r["eventcode"]))
                    ->limit(1)
                    ->get('exp_course_events');

$course_date = $res->row('FormalDate');

var_dump($course_date);

And update your answer with the output of that var_dump command.

0

I had it inside loop for another Query

The reason it was doing this is because it was a foreach from another call like this:

$results = $this->EE->db->get_where('exp_willis_rosters', array('status' => 'I'));
$registered = array();
if($results->num_rows() > 0) {
    foreach($results->result_array() as $row) {
        // get the corresponding event for the user in the roster row
        $res = $this->EE->db->where(array('EventCode' =>$r["eventcode"]))
               ->limit(1)
               ->get('exp_course_events');
        $course_date = $res->row('FormalDate');
    }
}

I moved the code to another place that works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.