0
嗨,我有這個錯誤「可捕捉的致命錯誤:類__PHP_Incomplete_Class的對象無法轉換爲字符串在C:\ xampp \ htdocs \ ProjectTA \ dao \ CustomerDao.php在線161" 就是這樣,我不知道要解決這個問題,我檢查了所有的一切是沒什麼問題對象類__PHP_Incomplete_Class無法轉換爲字符串
這是我的客戶DAO
public function getOneCustomer($id) {
try {
$conn = Connection::getConnection();
$query = "select * from Customer c join Company comp on c.Company_IdCompany = comp.IdCompany JOIN City cit ON c.City_Id = cit.IdC WHERE c.IdCustomer = ?";
$stmt = $conn->prepare($query);
$stmt->bindParam(1, $id);
$stmt->execute();
$row = $stmt->fetch();
$customer = new Customer();
$customer->setIdCustomer($row['IdCustomer']);
$customer->setCustomerName($row['CustomerName']);
$customer->setPhoneNumber($row['PhoneNumber']);
$customer->setBankNumber($row['BankNumber']);
$customer->setCAddress($row['AddressC']);
$customer->setCEmail($row['EmailC']);
$customer->setPassword($row['Password']);
$customer->setCustomerStatus($row['CustomerStatus']);
$customer->setPhoto($row['Photo']);
$company = new Company();
$company->setIdCompany($row['IdCompany']);
$company->setCompanyName($row['CompanyName']);
$company->setWebsite($row['Website']);
$company->setPhone($row['Phone']);
$company->setEmail($row['Email']);
$company->setAddress($row['Address']);
$company->setLogo($row['Logo']);
$city = new city();
$city->setIdC($row['IdC']);
$city->setNameC($row['NameC']);
$customer->setCompany_IdCompany($company);
$customer->setCity_Id($city);
} catch (PDOexception $e) {
echo $e->getMessage();
die();
}
$conn = null;
return $customer;
}
,我想在我的客戶視圖中顯示此
<?php
if (isset($_SESSION['IdCustomer'])) {
$dao = new CustomerDao();
$id = $_SESSION['IdCustomer'];
$dataInfo = $dao->getOneCustomer($id);
echo '<div class="col-md-12">
<div id="fh5co-tab-feature-vertical" class="fh5co-tab">
<ul class="resp-tabs-list hor_1">
<li><i class="fh5co-tab-menu-icon ti-ruler-pencil"></i> Company</li>
<li><i class="fh5co-tab-menu-icon ti-paint-bucket"></i> Project & Task</li>
<li><i class="fh5co-tab-menu-icon ti-shopping-cart"></i> Proof of Payment</li>
</ul>
<div class="resp-tabs-container hor_1">
<div>
<div class="row">
<div class="col-md-12">
<h2 class="h3">Company</h2>
</div>
<div class="col-md-6">
<h2>'.$dataInfo->getCustomerName().'</h2> // i want diplay customer name
</div>
</div>
</div>
</div>
</div>
</div>
</div>';
}?>
謝謝