setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); } catch(PDOException $e){ echo "連接失敗 : " . $e->getMessage(); } return $db; } } ?>