3 * Table Definition for foreign_user
5 require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
7 class Foreign_user extends Managed_DataObject
10 /* the code below is auto generated do not remove the above tag */
12 public $__table = 'foreign_user'; // table name
13 public $id; // bigint(8) primary_key not_null
14 public $service; // int(4) primary_key not_null
15 public $uri; // varchar(191) unique_key not_null not 255 because utf8mb4 takes more space
16 public $nickname; // varchar(191) not 255 because utf8mb4 takes more space
17 public $created; // datetime() not_null
18 public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
20 /* the code above is auto generated do not remove the tag below */
23 public static function schemaDef()
27 'id' => array('type' => 'int', 'size' => 'big', 'not null' => true, 'description' => 'unique numeric key on foreign service'),
28 'service' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to service'),
29 'uri' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'identifying URI'),
30 'nickname' => array('type' => 'varchar', 'length' => 191, 'description' => 'nickname on foreign service'),
31 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
32 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
34 'primary key' => array('id', 'service'),
35 'foreign keys' => array(
36 'foreign_user_service_fkey' => array('foreign_service', array('service' => 'id')),
38 'unique keys' => array(
39 'foreign_user_uri_key' => array('uri'),
44 static function getForeignUser($id, $service)
46 if (empty($id) || empty($service)) {
47 throw new ServerException('Empty foreign user id or service for Foreign_user::getForeignUser');
50 $fuser = new Foreign_user();
52 $fuser->service = $service;
55 if (!$fuser->find(true)) {
56 throw new NoResultException($fuser);
62 static function getByNickname($nickname, $service)
64 if (empty($nickname) || empty($service)) {
65 throw new ServerException('Empty nickname or service for Foreign_user::getByNickname');
68 $fuser = new Foreign_user();
69 $fuser->service = $service;
70 $fuser->nickname = $nickname;
73 if (!$fuser->find(true)) {
74 throw new NoResultException($fuser);