1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| <?php
require_once './DBConnect.php';
//require_once './Customers.php';
class Customers extends DBConnect {
protected $customer_id;
protected $first_name;
protected $last_name;
protected $email;
protected $active;
public function __construct() {
parent::connect();
}
public function setFirstName($first_name) {
$this->first_name = $first_name;
}
public function setLastName($last_name) {
$this->last_name = $last_name;
}
public function setEmail($email) {
$this->email = $email;
}
public function setStatus($status) {
$this->last_name = $status;
}
public function getAll() {
$sth = $this->DBH->prepare('SELECT customer_id,first_name,last_name,email,active FROM customers');
$sth->execute();
$data = $sth->fetchAll();
return $data;
}
public function get($customer_id) {
$sth = $this->DBH->prepare('SELECT customer_id,first_name,last_name,email,active FROM customers WHERE customer_id = ?');
$sth->execute(array($customer_id));
$data = $sth->fetchAll();
return $data;
}
public function insert() {
$sth = $this->DBH->prepare('INSERT INTO customers ( first_name,last_name,email,active) VALUES (?,?,?,?)');
$sth->execute(array($this->first_name, $this->last_name, $this->email, $this->active));
}
public function update() {
$sth = $this->DBH->prepare('UPDATE customers SET first_name = ?,last_name = ?,email = ?,active = ? WHERE customer_id = ?');
$sth->execute(array($this->first_name, $this->last_name, $this->email, $this->active, $this->customer_id));
}
public function delete() {
$sth = $this->DBH->prepare('DELETE FROM customers WHERE customer_id = ?');
$sth->execute(array($this->customer_id));
}
}
?> |
Partager