The mysqli class couldn't possibly contain a 'price' - atrribute or could it?
This is more of a theoretical question. I'm trying to build a shopping cart system for my online pizzashop webapp using an example bookstore out of php and mysql development book by luke welling and laura thomson.
in the code below, there is the $item variable that is an object. That object appears to have that price attribute. As far as I can judge you're tracing th开发者_开发技巧is object back to the mysqli class. Since I'm using netbeans, the contained mysqli.php file is hidden. and I can't find the price attribute in any other mysqli.php file on my computer.
Then again, I'm pretty sure there is no price attribute in the mysqli class because it would make no sense at all, but then where COULD the attribute possibly come from?
if (is_array($bestelling))
{
$conn = connect2db();
foreach ($bestelling as $isbn => $key)
{
$query = "SELECT pizza_price FROM pizzas WHERE Pizza_id = $pizzaId";
$result = $conn->query($query);
if ($result)
{
$item = $result->fetch_object();
$item_price = $item->price;
}
}
}
No $item->pizza_price;
refers to a piece of data in a row that you get from the database. I'm going to assume the database has a column named pizza_price
. So $item->pizza_price;
will contain values from here.
fetch_object()
returns
an object with string properties that corresponds to the fetched row or NULL if there are no more rows in resultset.
精彩评论