123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- <?php
- if (!defined('STATUSNET')) {
- exit(1);
- }
- require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
- class Twitter_synch_status extends Managed_DataObject
- {
- public $__table = 'twitter_synch_status';
- public $foreign_id;
- public $timeline;
- public $last_id;
- public $created;
- public $modified;
- public static function schemaDef()
- {
- return array(
- 'fields' => array(
- 'foreign_id' => array('type' => 'int', 'size' => 'big', 'not null' => true, 'description' => 'Foreign message ID'),
- 'timeline' => array('type' => 'varchar', 'length' => 255, 'description' => 'timeline name'),
- 'last_id' => array('type' => 'int', 'size' => 'big', 'not null' => true, 'description' => 'last id fetched'),
- 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
- 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
- ),
- 'primary key' => array('foreign_id', 'timeline'),
- );
- }
- static function getLastId($foreign_id, $timeline)
- {
- $tss = self::pkeyGet(array('foreign_id' => $foreign_id,
- 'timeline' => $timeline));
- if (empty($tss)) {
- return null;
- } else {
- return $tss->last_id;
- }
- }
- static function setLastId($foreign_id, $timeline, $last_id)
- {
- $tss = self::pkeyGet(array('foreign_id' => $foreign_id,
- 'timeline' => $timeline));
- if (empty($tss)) {
- $tss = new Twitter_synch_status();
- $tss->foreign_id = $foreign_id;
- $tss->timeline = $timeline;
- $tss->last_id = $last_id;
- $tss->created = common_sql_now();
- $tss->modified = $tss->created;
- $tss->insert();
- return true;
- } else {
- $orig = clone($tss);
- $tss->last_id = $last_id;
- $tss->modified = common_sql_now();
- $tss->update();
- return true;
- }
- }
- }
|