File name
Commit message
Commit date
File name
Commit message
Commit date
<?php
require_once("DB.php");
class Address
{
private $db;
// address 인스턴스를 생성하면 자동으로 DB 연결
public function __construct() {
$db = new DB();
$this->db = $db->getDB();
}
public function getList() {
try {
$stmt = $this->db->prepare("select * from address");
$stmt->execute();
$result = $stmt->fetchAll();
return $result;
}catch (PDOException $e) {
return $e;
}
}
public function insertTest($name, $age, $tel, $area, $birth) {
try {
$stmt = $this->db->prepare("insert into address values(NULL, ?, ?, ?, ?, ?)");
$stmt->execute(array($name, $age, $tel, $area, $birth));
return true;
}catch (PDOException $e) {
echo $e;
return false;
}
}
public function updateTest($no, $name, $age, $tel, $area, $birth) {
try {
$stmt = $this->db->prepare("update address set name=?, age=?, tel=?, area=?, birth=? where no=?");
$stmt->execute(array($no));
return true;
}catch (PDOException $e) {
echo $e;
return false;
}
}
public function deleteTest($no) {
try {
$stmt = $this->db->prepare("delete from address where no=?");
$stmt->execute(array($no));
return true;
}catch (PDOException $e){
echo $e;
return false;
}
}
}