Ejemplo n.º 1
0
 function loadByParams($params = array(), $limit = FALSE, $offset = FALSE, $debug = FALSE)
 {
     global $database;
     $extra_clause = "";
     if ($limit !== FALSE and !empty($limit)) {
         $extra_clause .= " LIMIT {$limit}";
     }
     if ($offset !== FALSE and !empty($offset)) {
         $extra_clause .= " OFFSET {$offset}";
     }
     $query = "SELECT " . $this->_tbl . ".id FROM " . $this->_tbl . " " . buildWhere($params) . " {$extra_clause}";
     jTipsLogger::_log($query, "DEBUG");
     $database->setQuery($query);
     $database->query();
     if ($database->getNumRows() > 1) {
         $jObjs = array();
         $list = (array) $database->loadResultArray();
         foreach ($list as $id) {
             $jObj = new jHistory($database);
             $jObj->load($id);
             array_push($jObjs, $jObj);
         }
         return $jObjs;
     } else {
         if ($database->getNumRows() == 1) {
             $this->load($database->loadResult());
             return $this;
         } else {
             return FALSE;
         }
     }
 }