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

.sql檔過大無法匯入phpMyAdmin

.sql檔過大無法匯入php...

修改phpMyAdmin資料夾中的config.inc.php檔。 打開後找到下列兩行或自行加入: ...

PHP取得檔案路徑及檔案名稱

PHP取得檔案路徑及檔案名稱...

例如我有一支檔案是放在根目錄下的demo資料夾中,檔案名稱為test.php 、首先取得目前網頁的檔...

動態留言功能調整

動態留言功能調整

guestmap55 最近改進了朋友動態的發文方式.... 一開始在功能方面加上了googlemap...

Recommended reading

Other stories happened at this address

小老虎探險~

小老虎探險~

s 住家後頭的小公園,是我們每天都會經過幾次的地方~ 早上,去吃早餐,我們會讓U在這公園小徑上走著。...

innstory首頁設計

innstory首頁設計

年,再次幫Innstory換上了新版的首頁。 這次使用了bootstrap RWD 設計。 Boot...

目前奶量最高紀錄是160cc

目前奶量最高紀錄是160cc...

m 小悠第天,目前奶量最高紀錄是cc,但也只有出現一次而已。 大部份白天的時間還算好帶。 但到了每天...

毛豆紅蘿蔔馬鈴薯炒肉片佐鄉愁

毛豆紅蘿蔔馬鈴薯炒肉片佐鄉愁...

毛豆加上紅蘿蔔切丁、馬鈴薯切丁炒上豬肉片。 嗯,這是我小時候熟悉的味道。我們家常煮~ 雖說Mandy...

小黃便利貼

小黃便利貼

news 小黃便利貼~是Innstory系統技術性介紹配置。 呈現的位置為版面左上角九宮格上方。 簡...

很久沒畫了~2015年11月29日這是我第一張嘗試畫在手機裡~

很久沒畫了~2015年11月...

s 小時候~喜歡畫畫,但其實是模仿著家姐的腳步~ 我姐姐以前畫畫很灑脫~隨便幾筆、隨便上色~看起來都...

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