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

php函式紀錄

php函式紀錄

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

CentOS 5.2 使用 YUM 將 PHP 5.1.6 更新到 5.2.6

CentOS 5.2 使用 ...

CentOS 5. 版內建的 PHP 版本為 5..,甚至於 5. 版仍舊是 5.. 版本。 基於系...

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

Android Studio...

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

Recommended reading

Other stories happened at this address

拼圖時間

拼圖時間

父子時間。 發現原來玩拼圖也可以教母語,我一邊拚著一邊用客家話要U去找同顏色的拼圖。 這傢伙就一直檢...

寶貝計劃.

寶貝計劃.

期待卻又往往失敗...這是我目前的心境.... 結婚了...長輩們..朋友們..開始催促著小孩呢?....

沒想過,無心插柳的地瓜葉也能像黃金葛一樣給人滿滿的成就感~

沒想過,無心插柳的地瓜葉也能...

沒想過,無心插柳的地瓜葉也能像黃金葛一樣給人滿滿的成就感~

酸辣過癮的東炎泡飯

酸辣過癮的東炎泡飯

s 午餐,弄了一碗東炎泡飯嚐嚐~ s 用的是Mandy昨晚用醬料包煮的東炎湯。 當然還加了不少海鮮,...

5個多月,學會了向後爬行。

5個多月,學會了向後爬行。

個多月,學會了向後爬行。

我以前不可能做這些事~

我以前不可能做這些事~

我以前~ 不可能在坐在電腦前時還得抱著你。 不可能在應該拿著滑鼠的手卻得要拿著奶瓶。 不可能走在外頭...

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