/[cvs]/nfo/php/libs/com.newsblob.phphtmllib/widgets/data_source/GenericDataSource.inc
ViewVC logotype

Diff of /nfo/php/libs/com.newsblob.phphtmllib/widgets/data_source/GenericDataSource.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by joko, Sat Mar 1 21:47:15 2003 UTC revision 1.2 by joko, Sun Mar 2 01:05:13 2003 UTC
# Line 17  Line 17 
17   * $Id$   * $Id$
18   *   *
19   * $Log$   * $Log$
20     * Revision 1.2  2003/03/02 01:05:13  joko
21     * - purged old code
22     *
23   * Revision 1.1  2003/03/01 21:47:15  joko   * Revision 1.1  2003/03/01 21:47:15  joko
24   * renamed from AbstractDataSource.inc   * renamed from AbstractDataSource.inc
25   *   *
# Line 302  class GenericDataSource extends MemoryDa Line 305  class GenericDataSource extends MemoryDa
305        
306      }      }
307    
         function O_do_query() {  
                 $this->_result = $this->_db->query($this->_query);  
                 if (DB::isError($this->_result)) {  
                         $msg = $this->_result->getMessage();  
                         user_error("PEARSQLDataListSource::do_query() - query failed : ".$msg);  
                 }  
         }  
308    
309          function build_handler_options() {          function build_handler_options() {
310    
# Line 386  class GenericDataSource extends MemoryDa Line 382  class GenericDataSource extends MemoryDa
382      $this->fetch_result();      $this->fetch_result();
383      $this->handle_result();      $this->handle_result();
384    }    }
385    
386      function do_query_schema() {
387        user_error("FIXME: do_query_schema");
388        // $this->do_handler_call( ... );
389      }
390                    
391    function get_header() {    function get_header() {
392      $this->fetch_result();      $this->fetch_result();
# Line 394  class GenericDataSource extends MemoryDa Line 395  class GenericDataSource extends MemoryDa
395    }    }
396    
397    
     function O_do_prequery() {  
                 //print "prequery!<br/>";  
                 // HACK!!!  
       // modify behaviour here: for now it is needed to call for the schem  
       // eventually modify here to get schema from some registry component (already locally available)  
       $this->fetch_result();  
       //print Dumper($this->_result);  
       //print Dumper($this->_result[0]);  
       //exit;  
         
       //$this->_get_header();  
     }  
   
   
         function O_get_header() {  
                   //$this->do_prequery();  
                   // FIXME: prevent multi-calls by base class  
          $this->fetch_result();  
                   foreach($this->_result[0] as $key => $value) {  
                                 array_push($this->_data_keys, $key);  
                         }              
   
     $this->set_schema($this->_result[0]);  
       
     //$this->_get_header();  
     //return $this->_data_keys;  
   
         }  
   
   
   
   
   
   
398    
   
   
   
         /**  
          * This function gets the next data row  
          * from the query()  
          *  
          * @return array()  
          */  
         function O_get_next_data_row() {  
                 return $this->_result->fetchRow(DB_FETCHMODE_ASSOC);  
         }  
   
         /**  
      * This function builds the limit  
      * clause portion of a DB query.  
      *  
      * @return string - the limit portion of  
      *                  the query.  
      */  
     function O_build_limit_clause($offset, $limit) {  
         if ($this->get_limit() != -1 ) {  
                         if ($offset == '' || $offset == "none") {  
                                 $offset = 0;  
                         }  
                         switch(get_class($this->_db)) {  
                         case "db_mysql":  
                                 $clause = " LIMIT $offset, $limit ";  
                                 break;  
                         case "db_pgsql":  
                                 $clause = " LIMIT $limit, $offset ";  
                                 break;  
                         default:  
                                 $clause = " LIMIT $offset, $limit ";  
                                 break;  
                         }  
             return $clause;  
         } else {  
             return NULL;  
         }  
     }  
       
     /**  
      * find the number of rows to be returned  
      * from a query from a table and where clause  
      *  
      * @param string $table - the table to count from  
      * @param string $where_clause - a where clause  
      *  
      * @return int the # of rows  
      */  
     function O_count($tables, $where_clause='', $count_clause='*') {  
                 $query = "select count(".$count_clause.") as COUNT from ".$tables." ".$where_clause;  
         $result = $this->_db->query($query);  
                 if (DB::isError($this->_result)) {  
                         $msg = $result->getMessage();  
                         user_error("PEARSQLDataListSource::count() - query failed : ".$msg);  
                 }  
                 $value = $result->fetchRow(DB_FETCHMODE_ASSOC);  
         return ($value ? (int)$value["COUNT"] : NULL);  
     }  
399            
400  }  }
401    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed