创建类

时间:2016-03-11 14:54:10

标签: php class

我正在尝试在php中创建一个类的新实例但是当我创建对象并刷新页面时,一切都变白了。老实说,我不知道如何最好地提出这个问题,因为课程文件长711行,我不想在这里发帖。我一直在寻找一种上传文件的方法,但似乎没有办法,所以我只想添加一小部分类文件。以下是我的代码。

$customer = new Customer(1);

班级档案

class Customer extends VerySimpleModel
implements TemplateVariable {
      static $meta = array(
        'table' => CUST_TABLE,
        'pk' => array('cust_id'),
        'joins' => array(
            'location' => array(
                'constraint' => array('cust_id' => 'loc.cust_id'),
            ),
            'service' => array(
                'constraint' => array('service_level' => 'service.id'),
            ),
        ),
    );

    var $id; var $name; var $contact; var $fname; var $lname; var $isactive; 
    var $contact_phone; var $phone_number; var $fax_number; var $locations; 
    var $domain; var $service_level; var $row; var $address; var $_location = null;

    function __onload() {
        $time = null;
        if (isset($this->passwdreset) && $this->passwdreset)
            $time=strtotime($this->passwdreset);
        elseif (isset($this->added) && $this->added)
        $time=strtotime($this->added);

        if ($time)
            $this->passwd_change = time()-$time; //XXX: check timezone issues.
    }

    function __toString() {
        return (string) $this->getName();
    }

    function asVar() {
        return $this->__toString();
    }

    public static function getCustomer( $id ) {
        $instance = new self();
        $instance->loadByID( $id );
        return $instance;
    }

    public static function withRow( array $row ) {
        $instance = new self();
        $instance->fill( $row );
        return $instance;
    }

    protected function loadByID( $id ) {
        $row = $this->getInfoById( $id );
        $this->fill( $row );
    }

    protected function fill( array $row ) {
        $this->row=$row;
        $this->id=$row["cust_id"];
        $this->cust_name=$row["cust_name"];
        $this->domain=$row["domain"];
        $this->isactive=$row["isactive"];
        $this->service_level=$row["service_level"];
    }

    static function getVarScope() {
        return array(
            'name' => array('class' => 'Customer', 'desc' => __('Customer')),
            'contact' => 'Primary contact',
            'phone' => 'Phone number',
            'address' => 'Address',
            'isactive' => 'Active',
            'serviceLevel' => 'Service Level'
        );
    } 

    function getId() {
        if ($this->id) {
            return $this->id;
        }
        return $this->cust_id;
    }

    function getInfoById($id) {
        $sql='SELECT * FROM '.CUST_TABLE.' WHERE cust_id='.db_input($id);

        if(($res=db_query($sql)) && db_num_rows($res))
            return db_fetch_array($res);

        return null;
    }

    function getInfo() {
        return $this->row;
    }

    static function create($vars=false, &$errors=array()) {
        $cust = parent::create($vars);
        $cust->created = SqlFunction::NOW();

        return $cust;
    }

    static function __create($vars, &$errors) {
        $cust = self::create();
        $cust->update($vars, $errors);

        return isset($cust->id) ? $cust : null;
    }
}

错误

  

[2016年3月11日15:05:13 UTC] PHP警告:   include(ICCLUDE_DIRclass.customer.php):无法打开流:没有这样的   文件或目录   C:\ Websites \ OSTickets \ upload \ include \ staff \ ticket-view.inc.php就行了   3

     

[2016年3月11日15:05:13 UTC] PHP Stack跟踪:

     

[2016年3月11日15:05:13 UTC] PHP 1. {main}()   C:\网站\ OSTickets \上传\ SCP \ tickets.php:0

     

[2016年3月11日15:05:13 UTC] PHP 2. require_once()   C:\网站\ OSTickets \上传\ SCP \ tickets.php:546

     

[2016年3月11日15:05:13 UTC] PHP警告:include():打开失败   ' ICCLUDE_DIRclass.customer.php'包括在内   (包含路径=' ./; C:/网站/ OSTickets /上传/包含/; C:/网站/ OSTickets /上传/包含/梨/')   在C:\ Websites \ OSTickets \ upload \ include \ staff \ ticket-view.inc.php上   第3行

     

[2016年3月11日15:05:13 UTC] PHP Stack跟踪:

     

[2016年3月11日15:05:13 UTC] PHP 1. {main}()   C:\网站\ OSTickets \上传\ SCP \ tickets.php:0

     

[2016年3月11日15:05:13 UTC] PHP 2. require_once()   C:\网站\ OSTickets \上传\ SCP \ tickets.php:546

     

[2016年3月11日15:05:13 UTC] PHP致命错误:班级'客户'不   在发现   C:\ Websites \ OSTickets \ upload \ include \ staff \ ticket-view.inc.php就行了   28

     

[2016年3月11日15:05:13 UTC] PHP Stack跟踪:

     

[2016年3月11日15:05:13 UTC] PHP 1. {main}()   C:\网站\ OSTickets \上传\ SCP \ tickets.php:0

     

[2016年3月11日15:05:13 UTC] PHP 2. require_once()   C:\网站\ OSTickets \上传\ SCP \ tickets.php:546

     

[2016年3月11日15:05:13 UTC] PHP警告:   include(ICCLUDE_DIRclass.customer.php):无法打开流:没有这样的   文件或目录   C:\ Websites \ OSTickets \ upload \ include \ staff \ ticket-view.inc.php就行了   3

     

[2016年3月11日15:05:13 UTC] PHP Stack跟踪:

     

[2016年3月11日15:05:13 UTC] PHP 1. {main}()   C:\网站\ OSTickets \上传\ SCP \ tickets.php:0

     

[2016年3月11日15:05:13 UTC] PHP 2. require_once()   C:\网站\ OSTickets \上传\ SCP \ tickets.php:546

     

[2016年3月11日15:05:13 UTC] PHP警告:include():打开失败   ' ICCLUDE_DIRclass.customer.php'包括在内   (包含路径=' ./; C:/网站/ OSTickets /上传/包含/; C:/网站/ OSTickets /上传/包含/梨/')   在C:\ Websites \ OSTickets \ upload \ include \ staff \ ticket-view.inc.php上   第3行

     

[2016年3月11日15:05:13 UTC] PHP Stack跟踪:

     

[2016年3月11日15:05:13 UTC] PHP 1. {main}()   C:\网站\ OSTickets \上传\ SCP \ tickets.php:0

     

[2016年3月11日15:05:13 UTC] PHP 2. require_once()   C:\网站\ OSTickets \上传\ SCP \ tickets.php:546

     

[2016年3月11日15:05:13 UTC] PHP致命错误:班级'客户'不   在发现   C:\ Websites \ OSTickets \ upload \ include \ staff \ ticket-view.inc.php就行了   28

     

[2016年3月11日15:05:13 UTC] PHP Stack跟踪:

     

[2016年3月11日15:05:13 UTC] PHP 1. {main}()   C:\网站\ OSTickets \上传\ SCP \ tickets.php:0

     

[2016年3月11日15:05:13 UTC] PHP 2. require_once()   C:\网站\ OSTickets \上传\ SCP \ tickets.php:546

1 个答案:

答案 0 :(得分:0)

抱歉,我显然犯了一个愚蠢的错误。顶部的包含拼写错误。有趣的是,我复制并粘贴了那部分,所以我不知道它是如何拼写错误的。