php - codeigniter misses the value of the id field from sql query -


when execute query, codeigniter replaces value of id field category.id

id | category_id | manufacturer_id | title  1  |    4        |    12           |  symfony 2  |    4        |    16           | pioneer 3  |    4        |     93          | razer 4  |    4        |    2            | python   $item_id = 3;    $this->db->select("*")             ->from("items")             ->join("category", "category.id=items.category_id")             ->where("items.id", $item_id);   var_dump($this->db->get->result_object()); 

what returns is

 stdclass::__set_state(array(  'id' => '4',  'category_id' => '4',  'manufacturer_id' => '1',  'title' => 'floral swing dress',  'image_file_name' => 'c62e854fe16c8cc60e508a423f9a14da.jpg',  'price' => '84',  'type' => 'evening_dress',  'parent_id' => '2',   )), 

the value of id being replaced value of category_id . id should 3, 4.

when execute query in phpmyadmin correct results.

you may try this:

$this->db->select("items.*, category.id cat_id, category.otherfieldname")         ->from("items")         ->join("category", "category.id=items.category_id")         ->where("items.id", $item_id); 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -