日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

PHP5 OOP編程中的代理與異常(2)_PHP教程

編輯Tag賺U幣
教程Tag:暫無Tag,歡迎添加,賺取U幣!

推薦:詳細(xì)介紹php5編程中的異常處理
1 首先是try,catch <?php $path = "D:\\in.txt"; try //檢測異常 { file_open($path); } catch(Exception $e) //捕獲異常 { echo $e->getMessage(); } function

為此,你需要修改DBQuery對象以便包括所有的函數(shù)—它們操作一個(gè)來自DB對象的結(jié)果資源。當(dāng)執(zhí)行查詢以調(diào)用DB對象的相應(yīng)函數(shù)并且返回它的結(jié)果時(shí),你需要使用存儲(chǔ)的結(jié)果。下列函數(shù)將被添加:

列表2:使用代理擴(kuò)展DBQuery類。

class DBQuery
{
 .....

 public function fetch_array()
 {  
  if (! is_resource($this->result)) {
   throw new Exception('Query not executed.');
  }

  return $this->db->fetch_array($this->result);
 }

 public function fetch_row()
 {
  if (! is_resource($this->result)) {
   throw new Exception('Query not executed.');
  }

  return $this->db->fetch_row($this->result);
 }

 public function fetch_assoc()
 {
  if (! is_resource($this->result)) {
   throw new Exception('Query not executed.');
  }

  return $this->db->fetch_assoc($this->result);
 }

 public function fetch_object()
 {
  if (! is_resource($this->result)) {
   throw new Exception('Query not executed.');
  }

  return $this->db->fetch_object($this->result);
 }

 public function num_rows()
 {
  if (! is_resource($this->result)) {
   throw new Exception('Query not executed.');
  }

  return $this->db->num_rows($this->result);
 }
}

每個(gè)函數(shù)的實(shí)現(xiàn)相當(dāng)簡單。它首先進(jìn)行檢查,以確保已經(jīng)執(zhí)行查詢,然后把任務(wù)代理到DB對象,返回它的結(jié)果就好象它是查詢對象本身(稱作是基本數(shù)據(jù)庫函數(shù))一樣。

分享:Zend Framework 入門——頁面布局
Zend Framework 的頁面布局模塊——Zend_Layout——既可以跟 MVC 一起使用,也可以單獨(dú)使用。本文只討論與 MVC 一起使用的情況。 1. 布局腳本 在 application/views 下

來源:模板無憂//所屬分類:PHP教程/更新時(shí)間:2008-08-22
相關(guān)PHP教程