title: Message: Undefined property: stdClass::$image
body: <p>I'm a beginner in PHP and CodeIgniter framework, I have found out similar problems and tried to fix the error but it still keeps on telling me </p>
  
  <p>Message: Undefined property: stdClass::$image
  Filename: controllers/ItemController.php</p>
  
  <p>Line Number: 137</p>
  
  <p>MODEL</p>
  
  <pre><code>class ItemModel extends CI_Model {
  
      public function itemList () {
  
      return $this-&gt;db-&gt;select("items.*, supplier.name as supplier_name")
                      -&gt;from("items")
                      -&gt;join("supplier", "supplier.id = items.supplier_id", "both")
                      -&gt;get()
                      -&gt;result();
  
      }
  
  
      public function deleteItem($id) {
          $id = $this-&gt;security-&gt;xss_clean($id);
          $this-&gt;db-&gt;trans_start();
          $this-&gt;db-&gt;where('item_id', $id)-&gt;delete('ordering_level');
          $this-&gt;db-&gt;where('item_id', $id)-&gt;delete('prices');
          $this-&gt;db-&gt;where('id', $id)-&gt;delete('items');
  
          if ($this-&gt;db-&gt;trans_status() === FALSE) {
              $this-&gt;db-&gt;trans_rollback();
              return false;
          }
  
          return $this-&gt;db-&gt;trans_commit();
  
      }
  
      public function getDetails($id) {
          $id = $this-&gt;security-&gt;xss_clean($id);
          return $this-&gt;db-&gt;where('id', $id)-&gt;get('items')-&gt;row();
      }
  
      public function item_info($id) {
          $id = $this-&gt;security-&gt;xss_clean($id);
          $sql = $this-&gt;db-&gt;where('id', $id)-&gt;get('items');
          return $sql-&gt;row();
  
      }
  
      public function update_item($id,$name,$category,$description,$price_id, $image, $supplier_id) {
  
         $item = $this-&gt;db-&gt;where('id',$id)-&gt;get('items')-&gt;row();
  
         $data = array(
              'name' =&gt; $name,
              'category_id' =&gt; $category,
              'description' =&gt; $description,
              'supplier_id' =&gt; $supplier_id
              );
          $data = $this-&gt;security-&gt;xss_clean($data);
              if ($image != '')
              $data['image'] = $image;
  
          return $this-&gt;db-&gt;where('id',$id)-&gt;update('items',$data);
      }
  
      public function get_all_item() {
          $items = $this-&gt;db-&gt;select('name')-&gt;get('items');
          return $items-&gt;result_array();
      }
  
      public function total() {
          return $this-&gt;db-&gt;select("SUM(prices.price * ordering_level.quantity) as total")
                      -&gt;from("items")
                      -&gt;join("prices", "prices.item_id = items.id", "both")
                      -&gt;join("ordering_level", "ordering_level.item_id = items.id", "both")
                      -&gt;get()
                      -&gt;row();
      }
  
  }
  </code></pre>
  
  <p>CONTROLLER</p>
  
  <pre><code>class ItemController extends CI_Controller {
  
  
  
          $datasets = array_map(function($item) {
          $itemPrice = $this-&gt;PriceModel-&gt;getPrice($item-&gt;id);
          $itemCapital = $this-&gt;PriceModel-&gt;getCapital($item-&gt;id);
          $stocksRemaining = $this-&gt;OrderingLevelModel-&gt;getQuantity($item-&gt;id)-&gt;quantity ?? 0;
          $itemSupplier = $this-&gt;db-&gt;where('id', $item-&gt;supplier_id)-&gt;get('supplier')-&gt;row()-&gt;name ?? '';
  
      return [
          $this-&gt;disPlayItemImage($item-&gt;image), //line 137
                  $item-&gt;name,
          $this-&gt;categories_model-&gt;getName($item &gt;category_id),
                  '₱' . number_format($itemCapital),
                  '₱' . number_format($itemPrice),
                  $stocksRemaining . ' pcs',
                  $item-&gt;name,
                  $itemSupplier,
                 ];
  
          }, $items);
  
          echo json_encode([
              'draw' =&gt; $this-&gt;input-&gt;post('draw'),
              'recordsTotal' =&gt; count($datasets),
              'recordsFiltered' =&gt; count($datasets),
              'data' =&gt; $datasets
          ]);
      }
  </code></pre>
  
  <p>VIEW</p>
  
  <pre><code>     &lt;div class="panel-heading"&gt;
           Items List
  
       &lt;/div&gt;
  
       &lt;!-- /.panel-heading --&gt;
       &lt;div class="panel-body"&gt;
           &lt;table class="table table-responsive table-hover table-bordered" id="item_tbl"&gt;
             &lt;thead&gt;
              &lt;tr&gt;
                  &lt;th width="8%"&gt;&amp;nbsp;&lt;/th&gt;
                  &lt;th width="20%"&gt;Item Name&lt;/th&gt;
                  &lt;th width="10%"&gt;Category&lt;/th&gt; 
                  &lt;th width="11%"&gt;Capital Per/Item&lt;/th&gt;
                  &lt;th width="11%"&gt;Retail Price&lt;/th&gt;
                  &lt;th width="10%"&gt;Stocks&lt;/th&gt;
                  &lt;th width="10%"&gt;Total&lt;/th&gt;
                  &lt;th width="10%"&gt;Supplier&lt;/th&gt;
                  &lt;th width="10%"&gt;Action&lt;/th&gt;
              &lt;/tr&gt;
          &lt;/thead&gt;
          &lt;tbody&gt;
  
  
          &lt;/tbody&gt;
      &lt;/table&gt;
  &lt;/div&gt;
  </code></pre>