Beispiel #1
0
 function isChild($catID, $rootCatID)
 {
     // FIXME: rewrite without using the database
     $query = "SELECT parent_id FROM " . SQLPREFIX . "faqcategories WHERE id = " . $rootCatID;
     $result = $this->db->query($query);
     while ($row = $this->db->fetch_object($result)) {
         if ($row->parent_id == $catID) {
             return FALSE;
         } else {
             return TRUE;
         }
     }
     return FALSE;
 }
Beispiel #2
0
 /**
  * retrieves stored link state and validates timestamp
  *
  * @param   int     $id
  * @param   string  $artlang
  * @param   boolean $checkDate
  * @result  mixed   false if entry does not exist. true if status expired, otherwise last link state text
  * @access  public
  * @author  Minoru TODA <*****@*****.**>
  * @since   2005-09-29
  */
 function getEntryState($id = 0, $artlang = "", $checkDate = false)
 {
     global $PMF_CONF;
     $interval = $this->getURLValidateInterval();
     $query = "SELECT links_state, links_check_date FROM " . SQLPREFIX . "faqdata WHERE id = " . $id . " AND lang='" . $artlang . "'";
     if ($result = $this->db->query($query)) {
         while ($row = $this->db->fetch_object($result)) {
             $_linkState = $row->links_state;
             if (trim($_linkState) == "") {
                 $_linkState = true;
             }
             if ($row->links_check_date > $interval) {
                 return $_linkState;
             } else {
                 if ($checkDate == false) {
                     return $_linkState;
                 } else {
                     return true;
                 }
             }
         }
     } else {
         return false;
     }
 }
Beispiel #3
0
 /**
  * 返回数据集
  * 
  * @param string $type 返回结果类型
  * 
  * @return array 数据集合
  */
 public function result($type = 'object')
 {
     $rows = array();
     if ($type == 'array') {
         while ($row = $this->result->fetch_array(MYSQLI_ASSOC)) {
             //MYSQLI_ASSOC
             $rows[] = $row;
         }
     } else {
         while ($row = $this->result->fetch_object()) {
             $rows[] = $row;
         }
     }
     return $rows;
 }
 /**
  * Retrieve all batch number details link to a shipment line
  *
  * @param	object	$db				Database object
  * @param	int		$id_line_expdet	id of shipment line
  *
  * @return	variant				-1 if KO, array of ExpeditionLigneBatch if OK
  */
 static function FetchAll($db, $id_line_expdet)
 {
     $sql = "SELECT rowid,";
     $sql .= "fk_expeditiondet";
     $sql .= ", sellby";
     $sql .= ", eatby";
     $sql .= ", batch";
     $sql .= ", qty";
     $sql .= ", fk_origin_stock";
     $sql .= " FROM " . MAIN_DB_PREFIX . self::$_table_element;
     $sql .= " WHERE fk_expeditiondet=" . (int) $id_line_expdet;
     dol_syslog(__METHOD__ . " sql=" . $sql, LOG_DEBUG);
     $resql = $db->query($sql);
     if ($resql) {
         $num = $db->num_rows($resql);
         $i = 0;
         while ($i < $num) {
             $tmp = new self($db);
             $obj = $db->fetch_object($resql);
             $tmp->sellby = $db->jdate($obj->sellby);
             $tmp->eatby = $db->jdate($obj->eatby);
             $tmp->batch = $obj->batch;
             $tmp->id = $obj->rowid;
             $tmp->fk_origin_stock = $obj->fk_origin_stock;
             $tmp->fk_expeditiondet = $obj->fk_expeditiondet;
             $tmp->dluo_qty = $obj->qty;
             $ret[] = $tmp;
             $i++;
         }
         $db->free($resql);
         return $ret;
     } else {
         return -1;
     }
 }
Beispiel #5
0
 /**
  * @param  object $db
  * @param  int    $childId
  * @return array
  */
 public static function getParentRoles(&$db, $childId)
 {
     $allParentIds = array();
     if (is_numeric($childId) && $childId > 0) {
         $sql = 'SELECT rld_rol_id_parent FROM ' . TBL_ROLE_DEPENDENCIES . ' WHERE rld_rol_id_child = ' . $childId;
         $db->query($sql);
         $num_rows = $db->num_rows();
         if ($num_rows) {
             while ($row = $db->fetch_object()) {
                 $allParentIds[] = $row->rld_rol_id_parent;
             }
         }
     }
     return $allParentIds;
 }
Beispiel #6
0
 /**
  * retrieves stored link state and validates timestamp
  *
  * @param   int     $id
  * @param   string  $artlang
  * @param   boolean $checkDate
  * @result  mixed   false if entry does not exist. true if status expired, otherwise last link state text
  */
 function getEntryState($id = 0, $artlang = '', $checkDate = false)
 {
     $interval = $this->getURLValidateInterval();
     $query = sprintf("\n            SELECT \n                links_state, links_check_date \n            FROM \n                %sfaqdata \n            WHERE \n                id = %d \n            AND \n                lang = '%s'", SQLPREFIX, $id, $this->db->escape_string($artlang));
     if ($result = $this->db->query($query)) {
         while ($row = $this->db->fetch_object($result)) {
             $_linkState = $row->links_state;
             if (trim($_linkState) == "") {
                 $_linkState = true;
             }
             if ($row->links_check_date > $interval) {
                 return $_linkState;
             } else {
                 if ($checkDate == false) {
                     return $_linkState;
                 } else {
                     return true;
                 }
             }
         }
     } else {
         return false;
     }
 }
Beispiel #7
0
 /**
  * Set icon data
  * @param object $result
  * @return array
  */
 private function setIcon($result, $single = false)
 {
     $data = array();
     if ($result->num_rows > 0) {
         while ($row = $result->fetch_object()) {
             $row->icon_path = $this->cfg['server'] . Ut::getImageOrPlaceholder('storage/icons/' . $row->icon);
             $row->file_path = is_file('storage/icons/' . $row->file) ? $this->cfg['server'] . 'storage/icons/' . $row->file : NULL;
             $row->preview_path = $this->cfg['server'] . 'storage/icons/' . $row->name . '/';
             $row->server_path = $this->cfg['server'];
             $single ? $data = $row : array_push($data, $row);
         }
     }
     return $data;
 }