我试图显示项目数据库,数据库(使用mySQL)和PHPStorm是100%链接的。当我运行该站点时,会显示列名称,并且它表示foreach循环的标题中存在错误(来自phtml文件的代码):
<?php
foreach ($view->productDataSet as $productData) {
echo '<td>'.$productData->getProductID().
'</td><td>'.$productData->getProductName().
'</td><td>'.$productData->getProductPrice().
'</td><td>'.$productData->getProductDesc().
'</td><td>'.$productData->getProductManufacturer().
'</td><td>'.$productData->getQuantity().
'</td><td>'.'<img src="images/'.$productData->getPhotoName().'" alt="no picture"/>'.
'</td> </td>';
}
?>
&#39; productDataSet&#39;突出显示并读取&#34;在productDataSet(php文件)&#34;中找不到字段productDataSet,同时所有get方法都会突出显示并显示无法找到它们。它们位于我的productData.php文件中。对不起,如果这很麻烦,我不能很好地解释这一点。我是PHP的新手。
ProductData代码:
class ProductData {
protected $_id, $_product_name, $_product_price, $_product_desc, $_product_manufacturer, $_quantity_in_stock, $_photo_name;
public function __construct($dbRow) {
$this->_id = $dbRow['id'];
$this->_product_name = $dbRow['product_name'];
$this->_product_price = $dbRow['product_price'];
$this->_product_desc = $dbRow['product_desc'];
$this->_product_manufacturer = $dbRow['product_manufacturer'];
$this->_quantity_in_stock = $dbRow['quantity_in_stock'];
$this->_photo_name = $dbRow['photo_name'];
}
public function getProductID() {
return $this->_id;
}
public function getProductName() {
return $this->_product_name;
}
public function getProductPrice() {
return $this->_product_price;
}
public function getProductDesc() {
return $this->_product_desc;
}
public function getProductManufacturer() {
return $this->_product_manufacturer;
}
public function getQuantity() {
return $this->_quantity_in_stock;
}
public function getPhotoName() {
return $this->_photo_name;
}
}