示例#1
0
文件: HotKeys.php 项目: bmchun/sunset
 function hotkeyAdd($key)
 {
     $arr = array('');
     $su = new KeyWord();
     $orderby = '`id` desc';
     $limit = 1;
     $data = mysql_fetch_assoc($su->keyword_select_oderby($orderby));
     $id = $data['id'] + 1;
     //取id号命名热词
     $arr = array('id' => $id, 'keyword' => $key);
     $re = KeyWord::keyword_insert($arr);
     return $re;
 }
示例#2
0
    {
        $query = sprintf("SELECT * FROM %s LIMIT %d, %d", "keywords", ($this->page - 1) * $this->size, $this->size);
        mysql_query("set names utf8");
        $results = mysql_query($query, $this->dbc);
        $back = [];
        while ($rows = mysql_fetch_array($results)) {
            array_push($back, ['word' => $rows['word'], 'url' => $rows['url']]);
            // $results[] = [
            // 'word' => $rows['word'],
            // 'url' => $rows['url']
            // ];
        }
        return $back;
    }
}
$kw = new KeyWord();
switch (strtoupper($_GET["action"])) {
    case "GET":
        $kw->page = isset($_GET["page"]) ? (int) $_GET["page"] : 1;
        $kw->size = isset($_GET["size"]) ? (int) $_GET["size"] : 10;
        $rows = $kw->get();
        $res = ['isok' => '1', 'info' => '', 'rows' => $rows];
        echo json_encode($res);
        break;
    default:
        $kw->word = $_GET['word'];
        $kw->url = $_GET['url'];
        $kw->save();
        break;
}
/*