I am trying to create a new instance of a class in php but when I create the object and refresh the page everything goes white. I honestly don't know how best to ask this question because the class file is 711 lines long which I don't want to post here. I was looking for a way to upload a file but there doesn't seem to be a way so I am just going to add a small part of the class file. Below is my code.
$customer = new Customer(1);
Class file
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;
}
}
Errors
[11-Mar-2016 15:05:13 UTC] PHP Warning: include(ICCLUDE_DIRclass.customer.php): failed to open stream: No such file or directory in C:\Websites\OSTickets\upload\include\staff\ticket-view.inc.php on line 3
[11-Mar-2016 15:05:13 UTC] PHP Stack trace:
[11-Mar-2016 15:05:13 UTC] PHP 1. {main}() C:\Websites\OSTickets\upload\scp\tickets.php:0
[11-Mar-2016 15:05:13 UTC] PHP 2. require_once() C:\Websites\OSTickets\upload\scp\tickets.php:546
[11-Mar-2016 15:05:13 UTC] PHP Warning: include(): Failed opening 'ICCLUDE_DIRclass.customer.php' for inclusion (include_path='./;C:/Websites/OSTickets/upload/include/;C:/Websites/OSTickets/upload/include/pear/') in C:\Websites\OSTickets\upload\include\staff\ticket-view.inc.php on line 3
[11-Mar-2016 15:05:13 UTC] PHP Stack trace:
[11-Mar-2016 15:05:13 UTC] PHP 1. {main}() C:\Websites\OSTickets\upload\scp\tickets.php:0
[11-Mar-2016 15:05:13 UTC] PHP 2. require_once() C:\Websites\OSTickets\upload\scp\tickets.php:546
[11-Mar-2016 15:05:13 UTC] PHP Fatal error: Class 'Customer' not found in C:\Websites\OSTickets\upload\include\staff\ticket-view.inc.php on line 28
[11-Mar-2016 15:05:13 UTC] PHP Stack trace:
[11-Mar-2016 15:05:13 UTC] PHP 1. {main}() C:\Websites\OSTickets\upload\scp\tickets.php:0
[11-Mar-2016 15:05:13 UTC] PHP 2. require_once() C:\Websites\OSTickets\upload\scp\tickets.php:546
[11-Mar-2016 15:05:13 UTC] PHP Warning: include(ICCLUDE_DIRclass.customer.php): failed to open stream: No such file or directory in C:\Websites\OSTickets\upload\include\staff\ticket-view.inc.php on line 3
[11-Mar-2016 15:05:13 UTC] PHP Stack trace:
[11-Mar-2016 15:05:13 UTC] PHP 1. {main}() C:\Websites\OSTickets\upload\scp\tickets.php:0
[11-Mar-2016 15:05:13 UTC] PHP 2. require_once() C:\Websites\OSTickets\upload\scp\tickets.php:546
[11-Mar-2016 15:05:13 UTC] PHP Warning: include(): Failed opening 'ICCLUDE_DIRclass.customer.php' for inclusion (include_path='./;C:/Websites/OSTickets/upload/include/;C:/Websites/OSTickets/upload/include/pear/') in C:\Websites\OSTickets\upload\include\staff\ticket-view.inc.php on line 3
[11-Mar-2016 15:05:13 UTC] PHP Stack trace:
[11-Mar-2016 15:05:13 UTC] PHP 1. {main}() C:\Websites\OSTickets\upload\scp\tickets.php:0
[11-Mar-2016 15:05:13 UTC] PHP 2. require_once() C:\Websites\OSTickets\upload\scp\tickets.php:546
[11-Mar-2016 15:05:13 UTC] PHP Fatal error: Class 'Customer' not found in C:\Websites\OSTickets\upload\include\staff\ticket-view.inc.php on line 28
[11-Mar-2016 15:05:13 UTC] PHP Stack trace:
[11-Mar-2016 15:05:13 UTC] PHP 1. {main}() C:\Websites\OSTickets\upload\scp\tickets.php:0
[11-Mar-2016 15:05:13 UTC] PHP 2. require_once() C:\Websites\OSTickets\upload\scp\tickets.php:546