【问题标题】:Object of class __PHP_Incomplete_Class could not be converted to string__PHP_Incomplete_Class 类的对象无法转换为字符串
【发布时间】:2017-03-02 17:27:22
【问题描述】:

嗨,我有这个错误"Catchable fatal error: Object of class __PHP_Incomplete_Class could not be converted to string in C:\xampp\htdocs\ProjectTA\dao\CustomerDao.php on line 161" 像这样,我不知道如何解决这个问题我检查了所有,一切都很好

这是我的客户 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>';
}?>

谢谢

【问题讨论】:

    标签: php dao


    【解决方案1】:

    所以,我有解决这个问题的办法。在客户登录会话中验证数据登录时我错了

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-12-31
      • 2014-02-21
      • 1970-01-01
      • 1970-01-01
      • 2022-01-05
      • 2015-07-27
      • 2012-04-29
      相关资源
      最近更新 更多