12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- namespace Cas\Dao;
- use KIF\Dao\AbstractDao;
- use KIF\Verify;
- /**
- * 文章点赞
- * @author lishumingoo@gmail.com
- */
- class ArticleLike extends AbstractDao {
- protected $tableName = 'article_like';
-
- /**
- * 点赞
- * @param int $event_id
- * @param int $uid
- * @return boolean
- */
- public function like($event_id, $uid) {
- if (!Verify::unsignedInt($event_id)) {
- return false;
- }
-
- if (!Verify::unsignedInt($uid)) {
- return false;
- }
-
- $tableInfo = array(
- 'event_id' => $event_id,
- 'uid' => $uid,
- );
- $tmpResult = $this->create($tableInfo);
- if (!$tmpResult) {
- return false;
- }
-
- return true;
- }
-
- /**
- * 取消点赞
- * @param int $event_id
- * @param int $uid
- * @return boolean
- */
- public function cancalLike($event_id, $uid) {
- if (!Verify::unsignedInt($event_id)) {
- return false;
- }
-
- if (!Verify::unsignedInt($uid)) {
- return false;
- }
-
- $condition = array(
- 'event_id' => $event_id,
- 'uid' => $uid,
- );
- $tmpResult = $this->delete($condition);
- if (!$tmpResult) {
- return false;
- }
-
- return true;
- }
-
- /**
- * 是否已经喜欢
- * @param int $event_id
- * @param int $uid
- * @return boolean
- */
- public function isHasLike($event_id, $uid) {
- if (!Verify::unsignedInt($event_id)) {
- return false;
- }
-
- if (!Verify::unsignedInt($uid)) {
- return false;
- }
-
- $condition = array(
- 'event_id' => $event_id,
- 'uid' => $uid,
- );
- $tmpResult = $this->fetchOne($condition);
- if (!$tmpResult) {
- return false;
- }
-
- return true;
- }
-
-
- }
|