Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8845459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:44:45+00:00 2026-06-14T11:44:45+00:00

I am using codeigniter for my project and couldn’t find what’s wrong with my

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T11:44:46+00:00Added an answer on June 14, 2026 at 11:44 am

    You should look at this

    if you are limiting your results to 1 as in your get_where instruction then return

    $q->row_array() // for array
    

    And

    $q->result_array() // for object
    

    And in Controller do this

    $products = $this->products_model->getProductsQuantity($id);
    $quantity = $products->quantity; // Object notation
    

    And

    $quantity = $products['quantity']; // Array notation
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using this library for Facebook graph API access within my codeigniter project: http://www.haughin.com/code/facebook/
Using codeigniter and oci8 for a project. $this->db->insert_id(); would would perfect for getting the
I'm using codeigniter for this project. I have a search form and search form
I'm using codeigniter for a project. The URL is segmented like this: example.com/admin/events example.com/admin/events/add
Hi I am using codeigniter for this project I have a button element as
I'm using this example in my Codeigniter project and want to know how I
I noticed this small bit of code above a controller on a demo codeigniter
I am using Codeigniter for a project and i usually call a series of
I'm using codeigniter framework and I'm getting this error when I've submitted my form:
I am using codeigniter for my project and the file upload is taking a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.