File name
Commit message
Commit date
File name
Commit message
Commit date
<?php
class DB
{
private $user = "root";
private $password = "1234";
private $option = array(PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION);
private $db;
public function __construct(){
try {
$this->db = new PDO("mysql:host=localhost;dbname=study", $this->user, $this->password, $this->option);
$this->db->exec("set names UTF8");
}catch (PDOException $e){
echo "<h2>Database Connection FAIL!!</h2>";
echo "Because : " . $e . "<hr>";
}
}
public function getDB() {
return $this->db;
}
// public function selectTest() {
// try {
// $stmt = $this->db->prepare("select * from address");
// $stmt->execute();
// $result = $stmt->fetchAll();
// return $result;
// } catch (PDOException $e){
// return $e;
// }
// }
//
// public function insertTest(){
// try {
// $stmt = $this->db->prepare("insert into address values(null, ?, ?, ?, ?, ?)");
// $stmt->execute(array("홍길동", 25, '010-5635-5959', '울산', '1789-05-04'));
// return TRUE;
// }catch(Exception $e){
// echo $e;
// return FALSE;
// }
// }
//
// public function updateTest(){
// try {
// $stmt = $this->db->prepare("update address set name=? where name=?");
// $stmt->execute(array('태연', '홍길동'));
// return TRUE;
// }catch (Exception $e){
// echo $e;
// return FALSE;
// }
// }
//
// public function deleteTest(){
// try {
// $stmt = $this->db->prepare("delete from address where name=?");
// $stmt->execute(array('태연'));
// return TRUE;
// }catch (Exception $e){
// echo $e;
// return FALSE;
// }
// }
}