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

Welcome To Google

Welcome To Goo...

Top第一天,參訪了Google APAC HQ 第一次來到Google,難掩興奮心情,拼命的拍了一...

研究著vps的設定...

研究著vps的設定...

現在在研究著vps的設定... 上次發生怪客入侵事件後...原本已經把所有系統都重新檢查後移入國內空...

php函式紀錄

php函式紀錄

常常忘記,只得紀錄下來...... AddSlashes: 字符串加入斜線。 binhex: 二進位...

Recommended reading

Other stories happened at this address

9個月了​​​​​​​,有時希望他快點長大​​​​​​​,有時又希望時間慢一點​​​​​​​。

9個月了​​​​​​​,有時...

s 個月了,看看這傢伙學會了些甚麼? 笑點一樣很低,呵呵呵的笑聲總是能讓我暫時放下手邊的一切只是看著...

筋疲力盡

筋疲力盡

在洗澡間淋著浴,這是我稍稍可以喘息的時間。 腦袋裡閃過Men of Honor裡的台詞~ 這是我非常...

發發來囉~還表演了很多才能哩!!非常厲害爬啊~

發發來囉~還表演了很多才能哩...

發發來囉~還表演了很多才能哩!!非常厲害爬啊~

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

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

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

一早開機就遇到這畫面,是說我可以提早收工了嗎?

一早開機就遇到這畫面,是說我...

一早開機就遇到這畫面,是說我可以提早收工了嗎?

8個月了,開始進入了孕後期~

8個月了,開始進入了孕後期~...

週,個月了,開始進入了孕後期~ 小傢伙每天都賣力的扭動,深怕我們不知道他的存在似的.... 據Man...

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