]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - classes/Foreign_user.php
PostgreSQL - added the rest of the recently added tables for blocking, notice inboxes...
[quix0rs-gnu-social.git] / classes / Foreign_user.php
1 <?php
2 /**
3  * Table Definition for foreign_user
4  */
5 require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
6
7 class Foreign_user extends Memcached_DataObject 
8 {
9     ###START_AUTOCODE
10     /* the code below is auto generated do not remove the above tag */
11
12     public $__table = 'foreign_user';                    // table name
13     public $id;                              // int(4)  primary_key not_null
14     public $service;                         // int(4)  primary_key not_null
15     public $uri;                             // varchar(255)  unique_key not_null
16     public $nickname;                        // varchar(255)  
17     public $created;                         // datetime()   not_null
18     public $modified;                        // timestamp()   not_null default_CURRENT_TIMESTAMP
19
20     /* Static get */
21     function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Foreign_user',$k,$v); }
22
23     /* the code above is auto generated do not remove the tag below */
24     ###END_AUTOCODE
25         
26         // XXX:  This only returns a 1->1 single obj mapping.  Change?  Or make
27         // a getForeignUsers() that returns more than one? --Zach
28         static function getForeignUser($id, $service) {         
29                 $fuser = new Foreign_user();
30                 $fuser->whereAdd("service = $service");
31                 $fuser->whereAdd("id = $id");
32                 $fuser->limit(1);
33                 
34                 if ($fuser->find()) {
35                         $fuser->fetch();
36                         return $fuser;
37                 }
38                 
39                 return NULL;            
40         }
41         
42         function updateKeys(&$orig) {
43                 $parts = array();
44                 foreach (array('id', 'service', 'uri', 'nickname') as $k) {
45                         if (strcmp($this->$k, $orig->$k) != 0) {
46                                 $parts[] = $k . ' = ' . $this->_quote($this->$k);
47                         }
48                 }
49                 if (count($parts) == 0) {
50                         # No changes
51                         return true;
52                 }
53                 $toupdate = implode(', ', $parts);
54
55                 $table = $this->tableName();
56                 if(common_config('db','quote_identifiers')) {
57                         $table = '"' . $table . '"';
58                 }
59                 $qry = 'UPDATE ' . $table . ' SET ' . $toupdate .
60                   ' WHERE id = ' . $this->id;
61                 $orig->decache();
62                 $result = $this->query($qry);
63                 if ($result) {
64                         $this->encache();
65                 }
66                 return $result;
67         }
68
69         
70 }