Loading...

PDO連接Mysql方式 MVC上應用

Temperature: 0 °C

ChungChung
author_tools


PDO連接Mysql方式 MVC上應用
將連結資料庫的方式加入model

function connect()
{
$dbhost=DB_SERVER;
$dbuser=DB_USERNAME;
$dbpass=DB_PASSWORD;
$dbname=DB_DATABASE;
try {
$dbConnection = new PDO("mysql:host=$dbhost;dbname=$dbname", $dbuser, $dbpass);
$dbConnection->exec("set names utf8");
$dbConnection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return $dbConnection;
}
catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}

}

引用方式
$pdo = connect();

以上紀錄~

 

台北市內湖區江南街71巷75弄 Go

https://innstory.com/story-PDO連接Mysql方式_MVC上應用-1404
寫程式筆記

Prev
 有沒有試過被自己小孩叫醒的經驗

Next
沒有月亮卻豐盛的月亮節 

Nearby Attractions

台北市內湖區江南街71巷75弄-Nearby Attractions

  • 國立臺灣大學日式宿舍-福州街... Go
  • 建國中學紅樓 Go
  • 骨科醫院及住宅 Go
  • 七海寓所(蔣經國故居) Go
  • 三芝三板橋 Go
  • 臺大醫學院舊館 Go

About the Author

Chung

我是chung
網路工作者
主業是網站系統開發建置
副業是做夢,寫故事
作品請參考/teme.biz
做夢請參考/innstory.com
聯絡/chung.teme@gmail.com

#有人用筆寫日記,有人用歲月寫日記,有人用照片寫日記,而我,用innstory寫日記。

Visitor message

Leave some footprints to prove that you visited me

Recommended reading

Author's other related stories

研究著vps的設定...

研究著vps的設定...

現在在研究著vps的設定... 上次發生怪客入侵事件後...原本已經把所有系統都重新檢查後移入國內空...

網站植入Facebook登入FB.api請求修改

網站植入Facebook登入...

會特別紀錄下來的原因是因為FB.api請求又調整了~ function fblogin() {//開...

解決png圖檔GD合圖後背景色塊問題

解決png圖檔GD合圖後背景...

重點在於設定圖片走透明通道~ $img = imagecreatefrompng($src); im...

Recommended reading

Other stories happened at this address

懷念的防無聊小品遊戲釣魚

懷念的防無聊小品遊戲釣魚

說了我念舊不是沒有原因的...... 剛剛在電腦裡找資料....又翻到了這個~ game 有印象嗎?...

桌底下的探險

桌底下的探險

拿著我的手電筒像似如獲至寶般的鑽進桌底下。 U開始了他在桌底下的探險。 看著他開心極了的笑臉,倒也覺...

日是好日,年是好年,2017年新年快樂!!

日是好日,年是好年,2017...

即將到來的年會是個什麼樣的年呢? 年的日子,家裡有了新成員~ 而我,當了爸爸。 對我的人生來說~是個...

有興趣寫故事的人可以自行加入開始安裝你自己的故事~

有興趣寫故事的人可以自行加入...

innstory 每個人,都有自己的故事。 故事,都值得被紀錄下來。 innstory紀錄你我的故事...

原來種九層塔並不需要種子啊~

原來種九層塔並不需要種子啊~...

我真的很愛九層塔的香味~ 在台灣,從小吃鹹酥雞到家庭料理九層塔煎蛋都少不了這一味。 當然更別說是南洋...

我以前不可能做這些事~

我以前不可能做這些事~

我以前~ 不可能在坐在電腦前時還得抱著你。 不可能在應該拿著滑鼠的手卻得要拿著奶瓶。 不可能走在外頭...

Please select an option

error

Hi, thank you for your participation, but you cannot vote repeatedly~

Join innstory now and start recording your story.

"Innstory" is a place to store stories. We are committed to becoming a warm platform. Deepening the bonds between people is our direction.
We are convinced that the blockchain between people is not just a cold calculation. Join us now.

Wrong format