Ejemplo n.º 1
0
    public static function sanitizeShowData($d)
    {
        if ($d['syn_need_mission'] == 0) {
            $d['m_subject'] = '無';
        }
        if (in_array($d['d_type'], array(5, 6))) {
            $d['d_name'] .= '*' . $d['syn_num'];
        }
        $tmplist = explode(',', $d['syn_element']);
        $itemlist = $listmap = [];
        $listmap = [];
        $result = array();
        foreach ($tmplist as $v) {
            $v = explode('*', $v);
            $itemlist[] = $v[0];
            $listmap[$v[0]] = $v[1];
        }
        $query = DBC::query('
			SELECT d_id, d_name
			FROM wog_df
			WHERE d_id IN (' . implode(',', $itemlist) . ')
		');
        while ($item = $query->fetchAssoc()) {
            $result[] = $item['d_name'] . '*' . $listmap[$item['d_id']];
        }
        $d['syn_name'] = implode(', ', $result);
        unset($d['d_type']);
        return $d;
    }
Ejemplo n.º 2
0
 public final function getMasteryName()
 {
     //抓取職業列表
     $query = DBC::query('SHOW COLUMNS FROM wog_ch_exp');
     $list = array();
     while ($d = $query->fetchAssoc()) {
         if (preg_match('/[\\w]+_([\\d]+)/i', $d['Field'], $match)) {
             $list[] = $match[1];
         }
     }
     $result = array();
     $query = DBC::query('SELECT ch_id, ch_name FROM wog_character WHERE ch_id IN (' . implode(',', array_unique($list)) . ')');
     while ($d = $query->fetchAssoc()) {
         $result[$d['ch_id']] = $d['ch_name'];
     }
     return $result;
 }
Ejemplo n.º 3
0
    public function getJQGridGridData($filters, $options = array())
    {
        if (isset($options['idName'])) {
            $pk = $options['idName'];
        } else {
            $pk = DBC::getPrimaryKey($this->table);
            if (count($pk) == 1) {
                $pk = $pk[0];
            }
        }
        $params = self::getJQGridPagerParams($this->getTotal($filters));
        $result = array('columns' => array(), 'page' => $params['page'], 'rows' => array(), 'total' => $params['pages'], 'records' => $params['total']);
        //提供兩種覆蓋SQL的方式: 覆蓋整個SQL或覆蓋部分條件
        $options = array_merge(array('SQL_SELECT' => property_exists(get_class($this), 'fields') ? implode(',', $this->fields) : '*', 'SQL_FROM' => $this->table, 'SQL_WHERE' => $filters, 'SQL_ORDERBY' => $params['sidx'] . ' ' . $params['sord'], 'SQL_LIMIT' => $params['start'] . ', ' . $params['limit']), $options);
        //若其中的參數為陣列,則視為call_user_func_array的參數
        if (is_array($options['SQL_ORDERBY'])) {
            $options['SQL_ORDERBY'] = call_user_func_array($options['SQL_ORDERBY'], array($params['sidx'], $params['sord']));
        }
        $sql = isset($options['SQL']) ? $options['SQL'] : '
			SELECT ' . $options['SQL_SELECT'] . '
			FROM ' . $options['SQL_FROM'] . '
			WHERE ' . $options['SQL_WHERE'] . '
			ORDER BY ' . $options['SQL_ORDERBY'] . '
			LIMIT ' . $options['SQL_LIMIT'] . '
		';
        $query = DBC::query($sql);
        $func = array('self', 'buildID');
        while ($d = $query->fetchAssoc()) {
            if (isset($options['sanitize']) && is_array($options['sanitize'])) {
                $d = call_user_func_array($options['sanitize'], array($d));
            }
            //var_export(array($pk, $d, $this->separator));
            if (!$result['columns']) {
                $result['columns'] = array_keys($d);
            }
            $result['rows'][] = array_values($d);
            //			$result['rows'][] = array(
            //					'id' => is_array($pk) ? call_user_func_array($func, array($pk, $d, $this->separator)) : $d[$pk],
            //					'cell' => array_values($d)
            //			);
        }
        return $result;
    }
Ejemplo n.º 4
0
 public function update($data = null)
 {
     if (is_null($data) || !is_array($data)) {
         $data = $this->dumpChanged();
     } else {
         $param = self::getParams(get_called_class());
         $this->updateData($data, $param);
         $data = $this->dumpChanged();
     }
     //		$filter = array();
     //		foreach($data as $k=>$v) {
     //			if(!isset($param[$k])) {
     //				alert("未知的欄位資訊:".$key);
     //			}
     //			$filter[$k] = $param[$k];
     //		}
     //		$changed = filter_var_array($changed, $filter);
     //		if(in_array(null, $changed, true)) {
     //			$key = array_search(null, $changed, true);
     //			alert("缺乏欄位資訊:".$key);
     //		}
     $this->validate($data, true);
     $this->sanitize($data);
     DBC::query(DBC::wrapUpdateSQL($this->tablename, $data, $this->pk));
 }