Welcome Guest, Not a member yet? Register   Sign In
How can I get stdClass Object instead of an array
#4

[eluser]pickupman[/eluser]
Code:
$this->db->select('auction.*, items.name'); //all columns in auction table and name from items table
$this->db->join('items','items.id = auction.items_id');
$query = $this->db->get('auction');

//Make sure we have something to work with
if($query->num_rows() > 0){
            
            $new_array = array();
            
            $i = 0; // Preset for multi-demi arrays
            $result = $query->result(); //little speed boost
            foreach($result as $row)
            {
                // Set new variables into new array
                $new_array[$i]= (object)array('id' => $row->id,
                     'min_bid' => $row->min_bid,
                     'name'    => $row->name);
                
                ++$i; // slightly faster syntax
            }
     return $new_array; // return multi-demi array
   }
return FALSE; //no results found


Messages In This Thread
How can I get stdClass Object instead of an array - by El Forum - 05-14-2010, 06:21 PM
How can I get stdClass Object instead of an array - by El Forum - 05-14-2010, 06:45 PM
How can I get stdClass Object instead of an array - by El Forum - 05-14-2010, 07:03 PM
How can I get stdClass Object instead of an array - by El Forum - 05-14-2010, 08:22 PM



Theme © iAndrew 2016 - Forum software by © MyBB