You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.4 KiB
PHP
59 lines
1.4 KiB
PHP
<?php
|
|
|
|
class Customer extends CI_Model
|
|
{
|
|
public $customerid;
|
|
public $lastname;
|
|
public $firstname;
|
|
public $dob;
|
|
public $contactinfo;
|
|
public $emailadd;
|
|
public $address;
|
|
public $editdate;
|
|
public $creationdate;
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
|
|
$this->load->database();
|
|
}
|
|
|
|
|
|
public function getCustomerByLimit($from, $to)
|
|
{
|
|
return $this->db->get("customer", $from, $to);
|
|
}
|
|
|
|
public function getAllCustomerOrderBy($col, $order)
|
|
{
|
|
return $this->db->order_by($col, $order)->get("customer");
|
|
}
|
|
|
|
public function getCustomerByLastnameFirstname($name)
|
|
{
|
|
return $this->db->like("CONCAT(lastname, ', ', firstname)", $name)->get("customer");
|
|
}
|
|
|
|
|
|
public function addNewCustomer()
|
|
{
|
|
$data = array(
|
|
"lastname" => $this->lastname,
|
|
"firstname" => $this->firstname,
|
|
"dob" => $this->dob,
|
|
"contactinfo" => $this->contactinfo,
|
|
"emailadd" => $this->emailadd,
|
|
"address" => $this->address
|
|
);
|
|
|
|
$this->db->set($data);
|
|
$this->db->set("editdate", "NOW()", FALSE);
|
|
$success = $this->db->set("creationdate", "NOW()", FALSE)->insert("customer");
|
|
|
|
if($success)
|
|
return array("success"=>$success, "data" => $this->db->insert_id());
|
|
else
|
|
return array("success"=>$success, "data" => $this->db->error());
|
|
}
|
|
} |