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

使用jquery animate達到動態效果

使用jquery anima...

首先..雖然在寫系統時常常會用到jquery 但我並沒有針對他的指令有做太深入的研究... 剛好這一...

PHP 時間時區修正

PHP 時間時區修正

一般來說...PHP取得的時間,是格林威治的時間: 但如果要將時間調成臺灣的時區,或其他時區的話,必...

apache下設置不顯示目錄列表 Indexes FollowSymLinks

apache下設置不顯示目錄...

pexelsphoto5 選擇編輯httpd.conf文件 vi conf/httpd.conf 找...

Recommended reading

Other stories happened at this address

桌底下的探險

桌底下的探險

拿著我的手電筒像似如獲至寶般的鑽進桌底下。 U開始了他在桌底下的探險。 看著他開心極了的笑臉,倒也覺...

噓~

噓~

年紀越來越大,古靈精怪的表情越來越多~ 現在還會噓我咧~ 只是,你是否手指比錯方向啊?

紅燒豆腐佐海尼根

紅燒豆腐佐海尼根

e 其實我並不愛把豆腐弄熱來吃~ 小時後的記憶~豆腐就是該從冰箱拿出來淋上點醬油.... 冰冰涼涼的...

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

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

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

關掉phpinfo()

關掉phpinfo()

pexelsphotod 配置php環境的時候往往都會寫 phpinfo(); 這個函數來測試php...

情境Blog

情境Blog

一直都認為,除了文字跟圖片外,應該要有其他的方式來將寫故事時的心情帶給閱讀者。 很久很久以前,我們會...

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