File name
Commit message
Commit date
File name
Commit message
Commit date
<?php
require_once("DB.php");
class Address
{
private $db;
public function __construct(){
$db = new DB();
$this->db = $db->getDB();
}
public function getListWhere($no) {
try {
$stmt = $this->db->prepare("select * from address where no = ?");
$stmt->execute(array($no));
$result = $stmt->fetchAll();
return $result;
}catch (PDOException $e) {
return $e;
}
}
public function getList(){
try {
$stmt = $this->db->prepare("select * from address LIMIT 0, 5");
$stmt->execute();
$result = $stmt->fetchAll();
return $result;
}catch (Exception $e){
echo $e;
}
}
public function getListPage($limitStart, $onePage){
try {
$sql = "select * from address limit " . $limitStart . ", " . $onePage;
$stmt = $this->db->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll();
return $result;
}catch (Exception $e){
return $e;
}
}
public function addressInsert($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(Exception $e){
echo $e;
return FALSE;
}
}
public function addressUpdate($name, $age, $tel, $area, $birth, $no){
try {
$stmt = $this->db->prepare("update address set name=?, age=?, tel=?, area=?, birth=? where no=?");
$stmt->execute(array($name, $age, $tel, $area, $birth, $no));
return TRUE;
}catch (Exception $e){
echo $e;
return FALSE;
}
}
public function addressDelete($no){
try {
$stmt = $this->db->prepare("delete from address where no=?");
$stmt->execute(array($no));
return TRUE;
}catch (Exception $e){
echo $e;
return FALSE;
}
}
public function getCountList(){
try {
$sql = "select count(*) as count from address";
$stmt = $this->db->prepare($sql);
$stmt->execute();
$result = $stmt->fetch();
return $result;
}catch(Exception $e){
return $e;
}
}
}