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
  • 福州街11號日式宿舍 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

jQuery效果滑動隱藏

jQuery效果滑動隱藏

因為需要所以紀錄下來,主要是要透過點選按鈕將字串隱藏或顯示出來... 雖說可以直接用hide或是sh...

Apache無法執行.htaccess?

Apache無法執行.hta...

pexelsphoto5 首先.htaccess是在Apache HTTP Server服務器架設下...

CSS透明度

CSS透明度

CSS 透明度的實作, 各種瀏覽器和標準如下:(數字越小越透明) 標準: opacity:~ (Fi...

Recommended reading

Other stories happened at this address

第一次吃副食品,你這表情也太有戲了吧!! 是有難吃到這樣嗎?

第一次吃副食品,你這表情也太...

第一次吃副食品,你這表情也太有戲了吧!! 是有難吃到這樣嗎?

參巴炒四大天王佐檳城的記憶

參巴炒四大天王佐檳城的記憶

s 這幾天,同Mandy在住家附近的市場發現了楊桃豆。 老實說,這東西我第一次吃也是在檳城美食中心,...

看來我們家有好些日子可以充滿南洋風味~

看來我們家有好些日子可以充滿...

看來我們家有好些日子可以充滿南洋風味~

5G餵食秀

5G餵食秀

餵食前,一刻也不能等,哭得我心慌意亂。 餵食後,笑中還帶著淚。 我知道妳要的很簡單,但也請妳多給我些...

突然想聽(王藍茵)-惡作劇

突然想聽(王藍茵)-惡作劇

某些時候,總會想起某些歌.... 這些歌都曾經為了生命中的一段記憶而存在。 哪怕這些記憶早已塵封在心...

Today home activity: Learning variety shapes and their names

Today home act...

Today home activity: Learning variety shapes and t...

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