日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
zend_db正確連接MySQL數(shù)據(jù)庫(kù)的實(shí)際操作方案

以下的文章主要描述的是在實(shí)際操作中zend_db正確連接MySQL數(shù)據(jù)庫(kù)的正確解決方案,假如你在實(shí)際操作中遇到相似的情況,但是你卻不知道對(duì)其如何正確的解決,那么以下的文章對(duì)你而言一定是良師益友。

為三亞等地區(qū)用戶提供了全套網(wǎng)頁(yè)設(shè)計(jì)制作服務(wù),及三亞網(wǎng)站建設(shè)行業(yè)解決方案。主營(yíng)業(yè)務(wù)為成都做網(wǎng)站、成都網(wǎng)站設(shè)計(jì)、三亞網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠(chéng)的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會(huì)得到認(rèn)可,從而選擇與我們長(zhǎng)期合作。這樣,我們也可以走得更遠(yuǎn)!

在看這些之前請(qǐng)確保你正確加載了PDO擴(kuò)展。

作法是編輯php.ini

手動(dòng)增加下面這兩行(前面要沒有分號(hào);)

 
 
 
  1. extension=php_pdo.dll  
  2. extension=php_pdo_MySQL(和PHP搭配之最佳組合).dll 

然后要把extension_dir

指向php_pdo.dll及php_pdo_MySQL(和PHP搭配之最佳組合).dll所在目錄,如

 
 
 
  1. extension_dir = "C:\php5\ext" 
  2. OK,let's go..  

index.php 網(wǎng)站首頁(yè),也是唯一入口

PHP代碼如下:

省略

 
 
 
  1. $params = array ('host' => '127.0.0.1',  
  2. 'username' => 'root',  
  3. 'password' => '123456',  
  4. 'dbname' => 'happycms');  
  5. $db = Zend_Db::factory('pdoMySQL(和PHP搭配之最佳組合)', $params);  
  6. Zend::register('db', $db);  
  7. ?>   
  8. lib/App/Article.php  

PHP代碼如下:

 
 
 
  1. class App_Article {  
  2. private $db;  
  3. function App_Article() {  
  4. $this->db = Zend::registry('db');  
  5. }  
  6. function listAll() {  
  7. $result = $this->db->query('SELECT * FROM article');  
  8. $rows = $result->fetchAll();  
  9. Zend::dump($rows);  
  10. }  
  11. function listByCategory() {  
  12. }  

省略

 
 
 
  1. }  
  2. ?>   

zend_db連接MySQL(附完整代碼)的實(shí)際操作中我們要用到PHP代碼如下:

 
 
 
  1. ArticleController.php  
  2. class articleController extends Zend_Controller_Action {  
  3. private $view;  
  4. private $article;  
  5. function __construct() {   
  6. $this->view = Zend::registry('view');  
  7. $this->article = new App_Article();   
  8. }   
  9. public function listAllAction() {  
  10. $this->article->listAll();  
  11. $this->view->title='View Articles';   
  12. echo $this->view->render(TPL_DIR.'/tplView.php');  
  13. }  
  14. function __call($action, $arguments)  
  15. {   
  16. $this->_redirect('./');  
  17. print_r($action);  
  18. print_r($arguments);  
  19. }  
  20. }  
  21. ?>   

訪問(wèn) http://happycms/article/listall

得到以下輸出:

 
 
 
  1. array(1) {  
  2. [0] => array(15) {  
  3. ["articleid"] => string(1) "1"  
  4. ["categoryid"] => string(1) "0"  
  5. ["articletitle"] => string(4) "test\"  
  6. ["articlefromwhere"] => string(3) "sdf"  
  7. ["articlekeywords"] => string(5) "sdfds"  
  8. ["articledescription"] => string(4) "test"  
  9. ["articlebody"] => string(9) "sffsdfsdf"  
  10. ["authorname"] => string(8) "haohappy"  
  11. ["authoremail"] => string(11) "s...@df.com"  
  12. ["issticky"] => string(1) "0"  
  13. ["isrecommanded"] => string(1) "0"  
  14. ["includeattachment"] => string(1) "0"  
  15. ["addtime"] => string(19) "0000-00-00 00:00:00"  
  16. ["lastedittime"] => string(19) "0000-00-00 00:00:00"  
  17. ["checktime"] => string(19) "0000-00-00 00:00:00"  

以上的相關(guān)內(nèi)容就是對(duì)zend_db連接MySQL(附完整代碼)的介紹,望你能有所收獲。

【編輯推薦】

  1. MySQL AUTO_INCREMENT的正確用法
  2. MySQL數(shù)據(jù)庫(kù)在linux下遠(yuǎn)程的連接錯(cuò)誤
  3. MySQL分頁(yè)查詢通用存儲(chǔ)過(guò)程的代碼總結(jié)
  4. MySQL數(shù)據(jù)庫(kù)中MySQL_real_connect的基本設(shè)置
  5. 在Windows環(huán)境下的MySQL數(shù)據(jù)庫(kù),精彩比賽

當(dāng)前名稱:zend_db正確連接MySQL數(shù)據(jù)庫(kù)的實(shí)際操作方案
文章地址:http://www.5511xx.com/article/copeopo.html