smirik/propel-likeable-behavior

为对象添加点赞功能。

此包的官方仓库似乎已不存在,因此该包已被冻结。

dev-master 2012-09-09 17:05 UTC

This package is not auto-updated.

Last update: 2021-07-09 22:29:59 UTC


README

安装

下载 LikeableBehavior.php 并将其放置在某个位置。

propel.behavior.likeable.class = path.to.likeable.behavior

如果您正在使用 composer,只需添加

{
    "require": {
        "smirik/propel-likeable-behavior": "*"
    }
}

使用

添加到 schema.xml

<behavior name="likeable" />

行为将创建 likes 表并给模型添加几个方法

public function addLike($user_id, $mark = 1, PropelPDO $con = null);
public function removeLike($user_id, PropelPDO $con = null)
public function hasLike($user_id, PropelPDO $con = null)
public function countLikes(PropelPDO $con = null)

user_id 可以是任何整数。

要求

  • 模型应具有 getId() 方法。
  • 类型将根据类名(带命名空间)自动放置

致谢