Welcome Guest, Not a member yet? Register   Sign In
newbie problem assigning result of query to a field.
#1

[eluser]buckboru[/eluser]
I’m trying to populate a field on a new record with the results of a Select_max query.
I’m getting the proper result from the query, but i’m doing something dumb in my set_fields function.
Via debug i can see the result of query gets the correct value, but i’m not getting $fields[‘TAPEID’] loaded.

Probably a super simple problem, but i’m not sure how to resolve it at the moment.

Thanks.
Code:
function _set_fields(){
        $fields['LABEL'] = 'TAPELABEL';
        $fields['TAPEID'] = $this->Tape_model->getMaxTape();
        $fields['SYSTEM'] = 'SYSTEM';
        $fields['LOCATION'] = 'LOCATION';
        $fields['STATUS'] = 'STATUS';
        $fields['NOTES'] = 'NOTES';
Code:
function getMaxTape()
    {
        $this->db->select_max('TAPEID');
        $query = $this->db->get('tstmis.tapeinv');
        return $query->result();
        
    }
#2

[eluser]Maglok[/eluser]
You are returning a set of results. You can't assign that to a field?

If you expect 1 row to come out try selecting one row, like $query->row(). Depends a bit on what you want it to display.

Quote:Result(): This function returns the query result as an array of objects, or an empty array on failure.
#3

[eluser]buckboru[/eluser]
OK, i changed to $query->row();

I still am not getting $fields['TAPEID'] = $this->Tape_model->getMaxTape(); to populate

When i look at debug after this statement, $fields['TAPEID'] shows Object of Confusedtdclass




Theme © iAndrew 2016 - Forum software by © MyBB