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

動態留言功能調整

動態留言功能調整

guestmap55 最近改進了朋友動態的發文方式.... 一開始在功能方面加上了googlemap...

JavaScript 檢查 Radio Button

JavaScript 檢查 ...

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

Mysql查詢特定欄位相乘總合

Mysql查詢特定欄位相乘總...

最近常常會用到的查詢方式... 問題是這樣的,我有一個資料表內容結構如下: +++++ | id |...

Recommended reading

Other stories happened at this address

兒子不在身邊~坐在電腦前的時間拉長了許多,雖然還是很多東西沒完成,但...是時後來一杯了。

兒子不在身邊~坐在電腦前的時...

兒子不在身邊~坐在電腦前的時間拉長了許多,雖然還是很多東西沒完成,但...是時後來一杯了。

慘了,這小子竟然給我看電視看到入神,立馬把電視關掉。

慘了,這小子竟然給我看電視看...

慘了,這小子竟然給我看電視看到入神,立馬把電視關掉。

相簿功能導入

相簿功能導入

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

Mandy下廚了~

Mandy下廚了~

Mandy下廚了~

笑成這樣叫我怎能不愛妳

笑成這樣叫我怎能不愛妳

笑成這樣叫我怎能不愛妳~ G,個多月,還不會翻身但是會抬頭,只是角度還需要多練習。 喜歡坐著多過於躺...

PHP取得檔案路徑及檔案名稱

PHP取得檔案路徑及檔案名稱...

例如我有一支檔案是放在根目錄下的demo資料夾中,檔案名稱為test.php 、首先取得目前網頁的檔...

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