Esempio n. 1
0
}
$content = SpeechWords(Assign($params['content']));
$word_id = explode(',', GetKeyword($content));
## 構建現象查詢SQL
$condition_sub = array('schema' => array('car_symptom', 'car_symptom_fenxi', 'car_word'), 'fields' => array('resultid', 'keyid', 'title', 'miaoshu', 'lable', '(CASE oftype WHEN 3 THEN 100 WHEN 4 THEN 80 WHEN 5 THEN 60 WHEN 1 THEN 100 ELSE 10 END) AS wordtype', 'SUM((1-text_step))*20+score AS fenshu'), 'filter' => array('t1.resultid' => 't0.id', 't1.keyid' => 't2.id', 'keyid' => array('IN', $word_id)), 'others' => 'GROUP BY resultid, keyid');
$condition = array('schema' => '(' . SQLSub($condition_sub) . ') AS tb', 'fields' => array('resultid AS id', 'title', 'miaoshu', 'lable', 'sum(wordtype + fenshu) AS score'), 'others' => 'GROUP BY resultid ORDER BY score DESC');
## 統計查詢總數
$count = StorageRows($condition);
## 截獲最新20條數據
$condition['others'] .= ' LIMIT 20';
$recordset = StorageFind($condition);
if (is_array($recordset) and empty($recordset) == FALSE) {
    $result = array('code' => '101', 'data' => array());
    $item = array('total' => $count, 'list' => array(), 'keys' => array());
    foreach ($recordset as $index => $row) {
        $item['list'][] = array('id' => $row['id'], 'title' => fmtstr($row['title']), 'lable' => fmtstr($row['lable']), 'miaoshu' => fmtstr($row['miaoshu']));
    }
    $condition_buf = array('schema' => 'car_word', 'filter' => array('id' => array('IN', $word_id)));
    $buf = StorageFind($condition_buf);
    if (is_array($buf) and empty($buf) == FALSE) {
        foreach ($buf as $row) {
            $item['keys'][] = $row['keyword'];
            for ($index = 1; $index <= 9; $index++) {
                if (empty($row['keyword' . $index]) == FALSE) {
                    $item['keys'][] = $row['keyword' . $index];
                }
            }
        }
    }
    $result['data'][] = $item;
    ## 積累積分
Esempio n. 2
0
if (!defined('HHXC')) {
    die('Permission denied');
}
if (CheckOpenID($params['openid'], $params['uid']) == FALSE and FALSE) {
    $result['msg'] = MESSAGE_WARNING;
} else {
    $result = array('code' => '101', 'data' => array());
    $caseid = Assign($params['caseid'], 0);
    $subsql = 'SELECT ofurl FROM search_result WHERE id=ofanli';
    $condition = array('schema' => 'hh_techuser_anli', 'fields' => array('id', 'ofuser', 'DATE(createdat) AS savetime', '(SELECT title FROM search_result WHERE id=ofanli) AS pheno', '(SELECT maintext FROM search_result WHERE id=ofanli) AS maintext', 'search', 'ofanli', '(SELECT havpic FROM search_result WHERE id=ofanli) AS havpic', '(SELECT words FROM search_result WHERE id=ofanli) AS words', "(SELECT title FROM search_result WHERE id=({$subsql})) AS fromurl"), 'filter' => array('id' => $caseid > 0 ? array('LT', $caseid) : array('GT', $caseid)));
    if (empty($params['uid']) == FALSE) {
        $condition['filter']['ofuser'] = Assign($params['uid'], 0);
    }
    $recordset = StorageFind($condition);
    if (is_array($recordset) == FALSE or empty($recordset) == TRUE) {
        $result['msg'] = MESSAGE_EMPTY;
    } else {
        $url_anli = sprintf(PAGE_ANLI, $params['uid'], $params['openid'], DEBUG);
        foreach ($recordset as $index => $row) {
            if ($index == 0) {
                $result['databasever'] = $row['id'];
            }
            $item = array('ofanli' => $row['ofanli'], 'search' => $row['search'], 'cid' => $row['ofanli'], 'caseid' => $row['ofanli'], 'savetime' => $row['savetime'], 'title' => $row['pheno'], 'fromurl' => fmtstr($row['fromurl']), 'havpic' => $row['havpic'], 'words' => $row['words'], 'collect' => '0', 'caseurl' => $url_anli . $row['id']);
            $filter = array('uid' => Assign($params['uid'], 0), 'tid' => $item['cid'], 'tag' => '5', 'type' => '1');
            if (StorageCount('hh_techuser_shoucang', $filter)) {
                $item['collect'] = '1';
            }
            $result['data'][] = $item;
        }
    }
}