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/
48 class Notice_title extends Memcached_DataObject
52 public $__table = 'notice_title'; // table name
53 public $notice_id; // int(4) primary_key not_null
54 public $title; // varchar(255)
57 * Get an instance by key
59 * This is a utility method to get a single instance with a given key value.
61 * @param string $k Key to use to lookup (usually 'user_id' for this class)
62 * @param mixed $v Value to lookup
64 * @return Notice_title object found, or null for no hits
68 function staticGet($k, $v=null)
70 return Memcached_DataObject::staticGet('Notice_title', $k, $v);
74 * return table definition for DB_DataObject
76 * DB_DataObject needs to know something about the table to manipulate
77 * instances. This method provides all the DB_DataObject needs to know.
79 * @return array array of column definitions
84 return array('notice_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
85 'title' => DB_DATAOBJECT_STR);
89 * return key definitions for DB_DataObject
91 * @return array list of key field names
96 return array_keys($this->keyTypes());
100 * return key definitions for Memcached_DataObject
102 * @return array list mapping field names to key types
107 return array('notice_id' => 'K');
111 * Magic formula for non-autoincrementing integer primary keys
113 * @return array magic three-false array that stops auto-incrementing.
116 function sequenceKey()
118 return array(false, false, false);
122 * Get a notice title based on the notice
124 * @param Notice $notice Notice to fetch a title for
126 * @return string title of the notice, or null if none
129 static function fromNotice($notice)
131 $nt = Notice_title::staticGet('notice_id', $notice->id);