3 * Table Definition for user_username
5 require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
7 class User_username extends Managed_DataObject
10 /* the code below is auto generated do not remove the above tag */
12 public $__table = 'user_username'; // table name
13 public $user_id; // int(4) not_null
14 public $provider_name; // varchar(255) primary_key not_null
15 public $username; // varchar(255) primary_key not_null
16 public $created; // datetime() not_null
17 public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
19 /* the code above is auto generated do not remove the tag below */
22 public static function schemaDef()
26 'provider_name' => array('type' => 'varchar', 'length' => 255, 'description' => 'provider name'),
27 'username' => array('type' => 'varchar', 'length' => 255, 'description' => 'username'),
28 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice id this title relates to'),
29 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
30 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
32 'primary key' => array('provider_name', 'username'),
34 'user_id_idx' => array('user_id')
36 'foreign keys' => array(
37 'user_username_user_id_fkey' => array('user', array('user_id' => 'id')),
43 * Register a user with a username on a given provider
44 * @param User User object
45 * @param string username on the given provider
46 * @param provider_name string name of the provider
47 * @return mixed User_username instance if the registration succeeded, false if it did not
49 static function register($user, $username, $provider_name)
51 $user_username = new User_username();
52 $user_username->user_id = $user->id;
53 $user_username->provider_name = $provider_name;
54 $user_username->username = $username;
55 $user_username->created = common_sql_now();
57 if($user_username->insert()){
58 return $user_username;