fetchOne(array('event_id' => $event_id), 'likes'); return (int) $result['likes']; } public function incrLikes($event_id) { if (!Verify::unsignedInt($event_id)) { return false; } $tableInfo = array( 'event_id' => $event_id, 'likes' => 1, ); $onDuplicate = array( 'likes' => SqlHelper::wrapperNoQuote('`likes`+1'), ); $tmpResult = $this->insertDuplicate($tableInfo, $onDuplicate); if (!$tmpResult) { return false; } return true; } public function decrLikes($event_id) { if (!Verify::unsignedInt($event_id)) { return false; } $updateResult = $this->update(array( 'likes' => SqlHelper::wrapperNoQuote('`likes` - 1'), ), array( 'event_id' => $event_id, )); if (!$updateResult) { return false; } return true; } }