English 中文(简体)
mysqli类不可能包含价格限制,可能吗?
原标题:The mysqli class couldn t possibly contain a price - atrribute or could it?
  • 时间:2011-05-26 09:33:51
  •  标签:
  • php
  • mysqli

这更多的是一个理论问题。我正在尝试为我的在线披萨店网络应用程序构建一个购物车系统,使用luke welling和laura thomson的php和mysql开发书中的一个示例书店。

在下面的代码中,$item变量是一个对象。该对象似乎具有该价格属性。据我所知,您正在将这个对象追溯到mysqli类。由于我使用的是netbeans,因此包含的mysqli.php文件是隐藏的。我在电脑上的任何其他mysqli.php文件中都找不到price属性。

再说一遍,我很确定mysqli类中没有price属性,因为这根本没有意义,但这个属性可能来自哪里?

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;
            }
        }        
    }
问题回答

没有$item->;披萨饭引用从数据库中获取的一行中的一段数据。我假设数据库有一个名为pizza_price的列。因此$item->;披萨饭将包含此处的值。

fetch_object()返回

具有与提取的行相对应的字符串属性的对象,如果结果集中没有更多行,则为NULL。





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签