搜索时增加关键字的计数值 - 数据库错误

Increase count value for keyword when searched - Database error

已更新

我有一个功能,可以从搜索查询中提取关键字,并向用户提供 returns 相关结果。我正在尝试更新我的关键字 table 中的计数列,当搜索该关键字时,每个关键字的值增加 1。但是,我得到:

Unknown column '0' in 'field list'

UPDATE keywords SET 0 = Array WHERE id = '|'

我的部分搜索功能:

$query = $this->db->select('*')->from('keywords')->WHERE('keyword', $term)->get();

        // array used to save individual strings to DB with their ranking & ids
        $tempArray = array();

        if($query->num_rows() > 0){
            foreach($query->result() as $row){

                $entry_ids = json_decode($row->entry_ids);
                $initial_count = $row->count;

                foreach($entry_ids as $id){
                    $item = explode("|", $id);

                    if(!$this->search_array($item[0], $tempArray)){
                        $search['count'] = $initial_count++;
                        $search['keyword'] = $term;
                        $search['id'] = $item[0];
                        $search['ranking'] = $item[1];

                        array_push($tempArray, $search);

                        $this->db->where('id', $id);
                        $this->db->update('keywords', $tempArray);

最后一个 if 似乎不正确。这就是我会做的:

if(!$this->search_array($item[0], $tempArray))
{
      $updatedData = array(
         "count"   => $row->count + 1, 
         "keyword" => $term,   //As I see it, this is unnecessary
         "id"      => $item[0],
         "ranking" => $item[1]
      );
      //I suppose that count, keyword, id and rankings are columns name in your table named keywords

      $this->db->where('keyword', $term);
      $this->db->update('keywords', $updatedData);
}