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

圖型插件Elastislide

圖型插件Elastislid...

teach Elastislide是一款好用的圖形插件......

分享 (励志短片) 王德顺 《最炫东北人》 完整版 Wang Deshun - Coolest Northeasterner (Inspirational Short Film)

分享 (励志短片) 王德顺 ...

我們都還年輕啊~ 還是可以一直做夢下去的。 只要有夢,我將可以走的更遠。 我是chung 主業做夢,...

Mysql 查詢時間區間是否包含特定日期

Mysql 查詢時間區間是否...

這其實只是一個簡單的問題,以前並不常用... 但這陣子寫的案子比較偏系統面,這樣的查詢問題變多了@@...

Recommended reading

Other stories happened at this address

5U要上學囉~

5U要上學囉~

U要上學囉~ 早上拿到書包就這樣背著一整天。 看起來是很開心,就是不知道等真正的那一天到來他會是甚麼...

10個月的5U,吃個飯像大爺啊~( ̄∇ ̄)

10個月的5U,吃個飯像大爺...

image U十個月了。 充滿好奇心的年紀,雖然會認人了,但試驗了幾次之後似乎不怎麼怕生。 不挑食,...

假日就是該吃咖哩麵

假日就是該吃咖哩麵

s 假日,可以說是我最放鬆的時間。 不用一個人照顧小孩、不用下廚房煮飯,就算要開伙,廚房的事也是交給...

php函式紀錄

php函式紀錄

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

Mysql查詢特定欄位相乘總合

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

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

Apache無法執行.htaccess?

Apache無法執行.hta...

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

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