3 * Table Definition for fave
5 require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
7 class Fave extends Memcached_DataObject
10 /* the code below is auto generated do not remove the above tag */
12 public $__table = 'fave'; // table name
13 public $notice_id; // int(4) primary_key not_null
14 public $user_id; // int(4) primary_key not_null
15 public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
18 function staticGet($k,$v=null)
19 { return Memcached_DataObject::staticGet('Fave',$k,$v); }
21 /* the code above is auto generated do not remove the tag below */
24 static function addNew($user, $notice) {
26 $fave->user_id = $user->id;
27 $fave->notice_id = $notice->id;
28 if (!$fave->insert()) {
29 common_log_db_error($fave, 'INSERT', __FILE__);
35 function &pkeyGet($kv)
37 return Memcached_DataObject::pkeyGet('Fave', $kv);
40 function stream($user_id, $offset=0, $limit=NOTICES_PER_PAGE)
42 $ids = Notice::stream(array('Fave', '_streamDirect'),
44 'fave:ids_by_user:'.$user_id,
49 function _streamDirect($user_id, $offset, $limit, $since_id, $before_id, $since)
53 $fav->user_id = $user_id;
56 $fav->selectAdd('notice_id');
59 $fav->whereAdd('notice_id > ' . $since_id);
62 if ($before_id != 0) {
63 $fav->whereAdd('notice_id < ' . $before_id);
66 if (!is_null($since)) {
67 $fav->whereAdd('modified > \'' . date('Y-m-d H:i:s', $since) . '\'');
70 // NOTE: we sort by fave time, not by notice time!
72 $fav->orderBy('modified DESC');
74 if (!is_null($offset)) {
75 $fav->limit($offset, $limit);
81 while ($fav->fetch()) {
82 $ids[] = $fav->notice_id;