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

JavaScript 檢查 Radio Button

JavaScript 檢查 ...

要用 JavaScript 來檢查同一組的 radio button 是否已選,可用以下方法: if...

RewriteRule仿靜態連結

RewriteRule仿靜態...

前幾天寫了關於頁面導向位置的定義。https://innst...

使用jquery animate達到動態效果

使用jquery anima...

首先..雖然在寫系統時常常會用到jquery 但我並沒有針對他的指令有做太深入的研究... 剛好這一...

Recommended reading

Other stories happened at this address

鄰居種植的鬼椒,據說很辣,歡迎我們採用,但我實在沒有勇氣嚐試@@

鄰居種植的鬼椒,據說很辣,歡...

鄰居種植的鬼椒,據說很辣,歡迎我們採用,但我實在沒有勇氣嚐試@@

ajax防止重複提交

ajax防止重複提交

會發生重提交的原因,大致上是因為考驗人與系統間的耐性~ AJAX(非同步的JavaScript與XM...

相簿功能導入

相簿功能導入

首先,非常感謝U今天肯給我個小時的時間。 讓我可以完成這個功能。 會想要這功能原因是我會有想要看照片...

innstory首頁設計

innstory首頁設計

年,再次幫Innstory換上了新版的首頁。 這次使用了bootstrap RWD 設計。 Boot...

音樂,就像是時光機器。許茹芸-獨角戲

音樂,就像是時光機器。許茹芸...

音樂,就像是時光機器。 聽著聽著.......,不小心就跌入了記憶的漩渦裡~ 這也是一個人寫code...

啟動休假模式

啟動休假模式

s 其實打從月日開始,就一直是呈現休假狀態~( ̄∇ ̄) 只是今天下午還是很認份的去客戶那邊做完教育訓...

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