换句话说,不能用套用设计模式.
这个理由已足以使我从PHP转向JSP了,唉...

解决方案 »

  1.   

    我看也没什么,简单是php的一大特点,如果要复杂,干脆用C算了,反正C也不是不能用在web上。我用到的所有功能都没有涉及类。
      

  2.   

    以下是我写的ORACLE数据库调用的基础类部分
    谢提供出来供大家参考分析,我觉得基本的继承就足够了
    <?php
    class orasql
    {
    var $conn=''; 
     function orasql($user,$password,$database)
         {
      $conn=OCILogon($user,$password,$database);
      $this->conn=$conn;
      return true;
         }
      function select($strsql="")
         {
      if (empty($strsql))return false;
      if (empty($this->conn))return false;
      $conn=$this->conn;
      $stmt=OCIParse($conn, $strsql); 
      $num=0;
      $data=array();
      $results=OCIexecute($stmt);
      if ((!$results)or(empty($results))){return false;}
      while($row=OCIFetch($stmt))
      {
       $data[$num]=$row; 
       $num++;      
      }
      OCIFreeStatement($stmt);
      return $data;
         }   
         
       function insert($strsql="")
         {
      if (empty($strsql))return false;
      if (empty($this->conn))return false;
      $conn=$this->conn;
      $stmt=OCIParse($conn, $strsql); 
      $results=OCIexecute($stmt);
      if (!$results) return false;
      OCIFreeStatement($stmt); 
      return $results;
         }     
       
       function update($strsql="")
         {
      if (empty($strsql))return false;
      if (empty($this->conn))return false;
      $conn=$this->conn;
      $stmt=OCIParse($conn, $strsql); 
      OCIexecute($stmt);
      $results=OCIexecute($stmt);
      OCIFreeStatement($stmt); 
      return $results;
         } 
         
       function delete($strsql="")
         {
      if (empty($strsql))return false;
      if (empty($this->conn))return false;
      $conn=$this->conn;
      $stmt=OCIParse($conn, $strsql); 
      OCIexecute($stmt);
      $results=OCIexecute($stmt);
      OCIFreeStatement($stmt); 
      return $results;
         }         
    }
    ?>