MYSQLi获取对象问题

Why am I getting the error:

Fatal error: Call to undefined method mysqli::fetch_object()

Heres my code:

$mysqli = new mysqli($db_data_hostname, $db_data_username, $db_data_password, $db_data_dbname);
    $query = "SELECT attName, attType, attOptions FROM form_constructor WHERE  device_name='$deviceType';";

    $result = $mysqli->query($query);

    while($row = $mysqli->fetch_object($result)){

        echo $row->attName;
        echo $row->attType;         
        echo $row->attOptions;

    }

You have to use the mysqli result:

while($row = $result->fetch_object()){

        echo $row->attName;
        echo $row->attType;         
        echo $row->attOptions;

    }

Why are you getting the error?

You need to use the variable $result which has $mysqli->query assigned to it. Read about MySQLi Object approach on the manual

Your code, fixed.

$mysqli = new mysqli($db_data_hostname, $db_data_username, $db_data_password, $db_data_dbname);
    $query = "SELECT attName, attType, attOptions FROM form_constructor WHERE  device_name='$deviceType';";

    $result = $mysqli->query($query);

    while($row = $result->fetch_object()){

        echo $row->attName;
        echo $row->attType;         
        echo $row->attOptions;

    }

You should call fetch_object on the stmt result you get from $result. So your while loop would look like:

while($row = $result->fetch_object()) {