3 * Data class for notice titles
9 * @author Evan Prodromou <evan@status.net>
10 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
11 * @link http://status.net/
13 * StatusNet - the distributed open-source microblogging tool
14 * Copyright (C) 2010, StatusNet, Inc.
16 * This program is free software: you can redistribute it and/or modify
17 * it under the terms of the GNU Affero General Public License as published by
18 * the Free Software Foundation, either version 3 of the License, or
19 * (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU Affero General Public License for more details.
26 * You should have received a copy of the GNU Affero General Public License
27 * along with this program. If not, see <http://www.gnu.org/licenses/>.
30 if (!defined('STATUSNET')) {
34 require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
37 * Data class for notice titles
41 * @author Evan Prodromou <evan@status.net>
42 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
43 * @link http://status.net/
47 class Notice_title extends Memcached_DataObject
51 public $__table = 'notice_title'; // table name
52 public $notice_id; // int(4) primary_key not_null
53 public $title; // varchar(255)
56 * Get an instance by key
58 * This is a utility method to get a single instance with a given key value.
60 * @param string $k Key to use to lookup (usually 'user_id' for this class)
61 * @param mixed $v Value to lookup
63 * @return Notice_title object found, or null for no hits
66 function staticGet($k, $v=null)
68 return Memcached_DataObject::staticGet('Notice_title', $k, $v);
72 * return table definition for DB_DataObject
74 * DB_DataObject needs to know something about the table to manipulate
75 * instances. This method provides all the DB_DataObject needs to know.
77 * @return array array of column definitions
81 return array('notice_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
82 'title' => DB_DATAOBJECT_STR);
86 * return key definitions for DB_DataObject
88 * @return array list of key field names
92 return array_keys($this->keyTypes());
96 * return key definitions for Memcached_DataObject
98 * @return array list mapping field names to key types
102 return array('notice_id' => 'K');
106 * Magic formula for non-autoincrementing integer primary keys
108 * @return array magic three-false array that stops auto-incrementing.
110 function sequenceKey()
112 return array(false, false, false);
116 * Get a notice title based on the notice
118 * @param Notice $notice Notice to fetch a title for
120 * @return string title of the notice, or null if none
122 static function fromNotice($notice)
124 $nt = Notice_title::staticGet('notice_id', $notice->id);