3 * Table Definition for oauth_application_user
5 require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
7 class Oauth_application_user extends Memcached_DataObject
10 /* the code below is auto generated do not remove the above tag */
12 public $__table = 'oauth_application_user'; // table name
13 public $profile_id; // int(4) primary_key not_null
14 public $application_id; // int(4) primary_key not_null
15 public $access_type; // tinyint(1)
16 public $token; // varchar(255)
17 public $created; // datetime not_null
18 public $modified; // timestamp not_null default_CURRENT_TIMESTAMP
21 function staticGet($k,$v=NULL) {
22 return Memcached_DataObject::staticGet('Oauth_application_user',$k,$v);
24 /* the code above is auto generated do not remove the tag below */
27 static function getByUserAndToken($user, $token)
29 if (empty($user) || empty($token)) {
33 $oau = new Oauth_application_user();
35 $oau->profile_id = $user->id;
39 $result = $oau->find(true);
41 return empty($result) ? null : $oau;
44 function updateKeys(&$orig)
48 foreach (array('profile_id', 'application_id', 'token', 'access_type') as $k) {
49 if (strcmp($this->$k, $orig->$k) != 0) {
50 $parts[] = $k . ' = ' . $this->_quote($this->$k);
53 if (count($parts) == 0) {
57 $toupdate = implode(', ', $parts);
59 $table = $this->tableName();
60 if(common_config('db','quote_identifiers')) {
61 $table = '"' . $table . '"';
63 $qry = 'UPDATE ' . $table . ' SET ' . $toupdate .
64 ' WHERE profile_id = ' . $orig->profile_id
65 . ' AND application_id = ' . $orig->application_id
66 . " AND token = '$orig->token'";
68 $result = $this->query($qry);