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

分享到各社群的方式

分享到各社群的方式

每次在寫網站系統時..客戶總會要求希望他們的網站可以有分享到社群網站的功能... 所以把一些常用的方...

客語檢定

客語檢定

恭喜通過客語基礎檢定,期待你將來可以直接用客語跟我對話。

CSS Radio Button

CSS Radio Butt...

寫系統的時候三不五時總會用到Radio Button 和 Checkboxes 目前就在寫這個部份@...

Recommended reading

Other stories happened at this address

噓~

噓~

年紀越來越大,古靈精怪的表情越來越多~ 現在還會噓我咧~ 只是,你是否手指比錯方向啊?

是說我的好日子快到了嗎???

是說我的好日子快到了嗎???...

個多月的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