I am using codeigniter for my project and couldn't find what's wrong with my code. This is my controller code
$products = $this->products_model->getProductsQuantity($id);
$q = $warehouse_product->quantity;
object notation is working but getting error: Trying to get property of non-object
$q = $warehouse_product['quantity'];
array notation not working and getting php error: Fatal error: Cannot use object of type stdClass as array in products\controllers\products.php on line xx
Here is my model function
public function getProductsQuantity($product_id)
{
$q = $this->db->get_where('products', array('product_id' => $product_id), 1);
if( $q->num_rows() > 0 )
{
return $q->row();
}
return FALSE;
}
Please help me to fins where is the problem in my code.