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

IE10 在 fckeditor無正常顯示及無法輸入任何字元

IE10 在 fckedit...

於fckorcodeie.js 檔案中, 在B.open(‘GET’, A, false); 及 B...

判斷捲軸的位置

判斷捲軸的位置

當捲軸往下移動時,判段目前移動到哪個位置... Javascript部份 $(function(){...

吉他手

吉他手

回屏東,跟外甥女借了吉他回台北,想說,兒子二胡學習的還不錯,會不會是有部份也是遺傳了我未開發音樂基因...

Recommended reading

Other stories happened at this address

1歲9個月

1歲9個月

歲個月~ 凡事都有第一次,對於這麼小的年紀,一切更是新鮮有趣~但可不包括現在這樣子。 人生第一次長針...

1歲6個多月,小小孩愛學大人樣~

1歲6個多月,小小孩愛學大人...

歲個多月,小小孩愛學大人樣~

看來白川鄉,得再去一次了~

看來白川鄉,得再去一次了~

看來白川鄉,得再去一次了~

沒想過,無心插柳的地瓜葉也能像黃金葛一樣給人滿滿的成就感~

沒想過,無心插柳的地瓜葉也能...

沒想過,無心插柳的地瓜葉也能像黃金葛一樣給人滿滿的成就感~

5G抬頭練習

5G抬頭練習

G在練習著抬頭,U隨侍一旁( ̄∇ ̄) 還有U說他也要練習抬頭。 我說親愛的,你好不好先練習一下如何保...

下雨天,只能在家被小孩玩~

下雨天,只能在家被小孩玩~

下雨天,只能在家被小孩玩~

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