/[cvs]/nfo/php/libs/com.newsblob.phphtmllib/widgets/data_list/PEARSQLDataListSource.inc
ViewVC logotype

Diff of /nfo/php/libs/com.newsblob.phphtmllib/widgets/data_list/PEARSQLDataListSource.inc

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

revision 1.2 by jonen, Sat Feb 22 21:08:37 2003 UTC revision 1.3 by jonen, Thu May 6 12:59:55 2004 UTC
# Line 72  class PEARSQLDataListSource extends SQLD Line 72  class PEARSQLDataListSource extends SQLD
72       * Set the DB object we will use       * Set the DB object we will use
73       * to talk to the DB.       * to talk to the DB.
74       *       *
75       * @param   object - $db the babw_db object.       * @param  object - $db the babw_db object.
      *  
76       */       */
77      function set_db_object( &$db ) {      function set_db_object( &$db ) {
78          $this->_db = &$db;          $this->_db = &$db;
79      }      }
80    
81        /**
82             * This is the function that does the data fetching,
83             * and sorting if needed.  
84             * If the source is a sql database, this is where the
85             * query gets called.  This function doesn't actually read the
86             * data from the DB yet.  That is what get_next_data_row()
87             * does.
88         *  
89             * @return boolean - the query passed/failed.
90             */
91          function do_query() {          function do_query() {
92                  $this->_result = $this->_db->query($this->_query);                  $this->_result = $this->_db->query($this->_query);
93                  if (DB::isError($this->_result)) {                  if (DB::isError($this->_result)) {
94                          $msg = $this->_result->getMessage();                          $msg = $this->_result->getMessage();
95                          user_error("PEARSQLDataListSource::do_query() - query failed : ".$msg);                          user_error("PEARSQLDataListSource::do_query() - query failed : ".$msg);
96                  }              return false;
97                    } else {
98                return true;
99            }
100          }          }
101    
102                    
# Line 140  class PEARSQLDataListSource extends SQLD Line 152  class PEARSQLDataListSource extends SQLD
152      function count($tables, $where_clause='', $count_clause='*') {      function count($tables, $where_clause='', $count_clause='*') {
153                  $query = "select count(".$count_clause.") as COUNT from ".$tables." ".$where_clause;                  $query = "select count(".$count_clause.") as COUNT from ".$tables." ".$where_clause;
154          $result = $this->_db->query($query);          $result = $this->_db->query($query);
155                  if (DB::isError($this->_result)) {                  if (DB::isError($result)) {
156                          $msg = $result->getMessage();                          $msg = $result->getMessage();
157                          user_error("PEARSQLDataListSource::count() - query failed : ".$msg);                          user_error("PEARSQLDataListSource::count() - query failed : ".$msg);
158                  }              return 0;
159                  $value = $result->fetchRow(DB_FETCHMODE_ASSOC);                  } else {
160          return ($value ? (int)$value["COUNT"] : NULL);              $value = $result->fetchRow(DB_FETCHMODE_ASSOC);
161                return ($value ? (int)$value["COUNT"] : NULL);
162            }              
163      }      }
164            
165  }  }

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

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