3 * StatusNet - the distributed open-source microblogging tool
4 * Copyright (C) 2011, StatusNet, Inc.
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 if (!defined('STATUSNET')) {
24 class Profile_detail extends Memcached_DataObject
26 public $__table = 'submirror';
32 public $field_index; // relative ordering of multiple values in the same field
34 public $value; // primary text value
35 public $rel; // detail for some field types; eg "home", "mobile", "work" for phones or "aim", "irc", "xmpp" for IM
36 public $ref_profile; // for people types, allows pointing to a known profile in the system
41 public /*static*/ function staticGet($k, $v=null)
43 return parent::staticGet(__CLASS__, $k, $v);
47 * return table definition for DB_DataObject
49 * DB_DataObject needs to know something about the table to manipulate
50 * instances. This method provides all the DB_DataObject needs to know.
52 * @return array array of column definitions
57 return array('id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
59 'profile_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
60 'field' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
61 'field_index' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
63 'value' => DB_DATAOBJECT_STR,
64 'rel' => DB_DATAOBJECT_STR,
65 'ref_profile' => DB_DATAOBJECT_ID,
67 'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL,
68 'modified' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL);
71 static function schemaDef()
73 // @fixme need a reverse key on (subscribed, subscriber) as well
74 return array(new ColumnDef('id', 'integer',
77 // @fixme need a unique index on these three
78 new ColumnDef('profile_id', 'integer',
80 new ColumnDef('field', 'varchar',
82 new ColumnDef('field_index', 'integer',
85 new ColumnDef('value', 'text',
87 new ColumnDef('rel', 'varchar',
89 new ColumnDef('ref_profile', 'integer',
92 new ColumnDef('created', 'datetime',
94 new ColumnDef('modified', 'datetime',
99 * Temporary hack to set up the compound index, since we can't do
100 * it yet through regular Schema interface. (Coming for 1.0...)
102 * @param Schema $schema
105 static function fixIndexes($schema)
108 // @fixme this won't be a unique index... SIGH
109 $schema->createIndex('profile_detail', array('profile_id', 'field', 'field_index'));
110 } catch (Exception $e) {
111 common_log(LOG_ERR, __METHOD__ . ': ' . $e->getMessage());
116 * return key definitions for DB_DataObject
118 * DB_DataObject needs to know about keys that the table has; this function
121 * @return array key definitions
126 return array_keys($this->keyTypes());
130 * return key definitions for Memcached_DataObject
132 * Our caching system uses the same key definitions, but uses a different
133 * method to get them.
135 * @return array key definitions
141 // need a sane key for reverse lookup too
142 return array('id' => 'K');
145 function sequenceKey()
147 return array('id', true);