public static function createKeywords($item) { if (!$item || empty($item)) { return false; } KeywordIndexer::model()->deleteAll('logid=:logid AND classify="poi"', array(':logid' => $item['id'])); $_data = array('logid' => $item['id'], 'classify' => 'poi', 'areaid' => $item['areaid'], 'status' => $item['status']); if ($item['title_cn'] != '') { $_data['len'] = mb_strlen($item['title_cn'], 'GBK'); $_data['title'] = $item['title_cn']; $hash = md5($_data['title']); $_data['hash'] = $hash; $_exinfo = KeywordIndexer::model()->find('areaid=:areaid AND classify="poi" AND hash=:hash', array(':areaid' => $item['areaid'], ':hash' => $hash)); if (!$_exinfo) { $_data['times'] = 0; } elseif ($item['status'] != Posts::STATUS_PASSED) { $_data['times'] = 1; } else { $_data['times'] = 1; KeywordIndexer::model()->updateCounters(array('times' => 1), 'id=:id', array(':id' => $_exinfo['id'])); } $model = new KeywordIndexer(); $model->attributes = $_data; $model->save(false); } if ($item['title_en'] != '') { $_data['len'] = mb_strlen($item['title_en'], 'GBK'); $_data['title'] = $item['title_en']; $hash = md5($_data['title']); $_data['hash'] = $hash; $_exinfo = KeywordIndexer::model()->find('areaid=:areaid AND classify="poi" AND hash=:hash', array(':areaid' => $item['areaid'], ':hash' => $hash)); if (!$_exinfo) { $_data['times'] = 0; } elseif ($item['status'] != Posts::STATUS_PASSED) { $_data['times'] = 1; } else { $_data['times'] = 1; KeywordIndexer::model()->updateCounters(array('times' => 1), 'id=:id', array(':id' => $_exinfo['id'])); } $model = new KeywordIndexer(); $model->attributes = $_data; $model->save(false); } if ($item['title_local'] != '') { $_data['len'] = mb_strlen($item['title_local'], 'GBK'); $_data['title'] = $item['title_local']; $hash = md5($_data['title']); $_data['hash'] = $hash; $_exinfo = KeywordIndexer::model()->find('areaid=:areaid AND classify="poi" AND hash=:hash', array(':areaid' => $item['areaid'], ':hash' => $hash)); if (!$_exinfo) { $_data['times'] = 0; } elseif ($item['status'] != Posts::STATUS_PASSED) { $_data['times'] = 1; } else { $_data['times'] = 1; KeywordIndexer::model()->updateCounters(array('times' => 1), 'id=:id', array(':id' => $_exinfo['id'])); } $model = new KeywordIndexer(); $model->attributes = $_data; $model->save(false); } $nicks = array(); if ($item['nickname'] != '') { $nicks = explode('#', $item['nickname']); } if (!empty($nicks)) { foreach ($nicks as $nick) { $_data = array('logid' => $item['id'], 'classify' => 'poi', 'areaid' => $item['areaid']); $_data['len'] = mb_strlen($nick, 'GBK'); $_data['title'] = $nick; $hash = md5($_data['title']); $_data['hash'] = $hash; $_exinfo = KeywordIndexer::model()->find('areaid=:areaid AND classify="poi" AND hash=:hash', array(':areaid' => $item['areaid'], ':hash' => $hash)); if (!$_exinfo) { $_data['times'] = 0; } elseif ($item['status'] != Posts::STATUS_PASSED) { $_data['times'] = 1; } else { $_data['times'] = 1; KeywordIndexer::model()->updateCounters(array('times' => 1), 'id=:id', array(':id' => $_exinfo['id'])); } $model = new KeywordIndexer(); $model->attributes = $_data; $model->save(false); } } return true; }