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

關於資安防護

關於資安防護

一直以來我都不敢寫跟資安有關的文章..對我來說...資安一直是一個課題..XSS...CSRF......

解決png圖檔GD合圖後背景色塊問題

解決png圖檔GD合圖後背景...

重點在於設定圖片走透明通道~ $img = imagecreatefrompng($src); im...

Welcome To Google

Welcome To Goo...

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

Recommended reading

Other stories happened at this address

Android Studio 2.3 陽春型計算機進階版

Android Studio...

andrio 將之前的陽春型計算機用了不怎麼聰明的方式改善了幾個地方。 首先,我將數字的宣告由int...

獨自做夢的人一段時間就要拿些事情來鼓勵自己

獨自做夢的人一段時間就要拿些...

s 獨自做夢的人,一段時間就要拿些事情來鼓勵自己。 就算寫個鼓勵的字眼也好~恩.....突然有點悲慘...

就是要一杯美式配上小美手工鳳梨酥...

就是要一杯美式配上小美手工鳳...

繼天然美味好吃的小美冰淇淋....啊不...是手工餅乾後.... 我心中的烘培達人小美,又一力作,小...

總之我先玩起來了~

總之我先玩起來了~

s 這些都是要給U的火材盒小車~還有一架飛機。 索性就來個圍城,沒了跑道這下飛機飛不起來了吧,哈哈哈...

還是Chloe魅力無敵啊~

還是Chloe魅力無敵啊~

趁著兒子午睡,悄悄的把他懷中百味雜陳的Chloe送去洗澡~ 想說要過年了,也該清潔一下了。 怎知兒子...

5G看起來好像有美人尖哩~

5G看起來好像有美人尖哩~

G看起來好像有美人尖哩~

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