I"m currently learning PHP OOP, and I stuck with conversion of results, that I'm getting from query to database from one of my objects. The print_r result looks like this:
Array ( [0] => Product Object ( [id] => 1 [product_title] => test product [product_description] => Lorem ipsum dolor sit amet, consectetur adipisicing elit. Natus accusamus doloribus repellat, ad eius ex et veniam reiciendis molestiae, illum dolore eaque iusto voluptatibus quia, vitae officiis ut facere quam odio aliquam modi. Quisquam unde error eos, earum ad ex non dolorem assumenda reprehenderit nam repellat, veniam voluptatem quae, architecto? [short_desc] => Lorem ipsum dolor sit amet, consectetur adipisicing elit. Natus accusamus [product_category_id] => 2 [product_price] => 10.2 [product_quantity] => 0 [product_image] => http://placehold.it/350x150 [errors] => Array ( ) [upload_errors_array] => Array ( [0] => There is no error [1] => The uploaded file exceeds the upload_max_filesize [2] => The uploaded file exceedsthe MAX_FILE_SIZE [3] => The uploaded file was only partially uploaded [4] => No file was uploaded [6] => Missing the temporary folder [7] => Failed to write file to disk [8] => A php extension stopped the file upload ) ) )
I've exhausted all my current knowledge to extract the [product_quantity] result from this. When I try to get to it with
echo $result['product_quantity']
I get mistake which says it is Undefined index:
If I try to get inside with
$result->product_quantity;
I get this mistake
Trying to get property of non-object
Which means that I should get inside array, and then get from it object property, but when try:
while ($row = mysqli_fetch_array($result)) {
$row->product_quantity;
}
I get this mistake: mysqli_fetch_array() expects parameter 1 to be mysqli_result
How do I get to this object property, or overall - what I do wrong?(
Sorry, if this question is dumb, but my search on SE, and google don't show any other results so far(((