fetchAll() as $row) { return new MTrackKeyword($row[0]); } return null; } function __construct($id = null) { if ($id !== null) { list($row) = MTrackDB::q('select keyword from keywords where kid = ?', $id)->fetchAll(); $this->kid = $id; $this->keyword = $row[0]; return; } } function loadByIds($value) { $ar = explode(',', $value); $ret = array(); foreach($ar as $k) { if (empty($k)) { continue; } $ret[] = new MTrackKeyword($k); } return $ret; } function toHtml() { return htmlentities($this->keyword, ENT_QUOTES, 'utf-8') ; } function save(MTrackChangeset $CS) { if ($this->kid === null) { MTrackDB::q('insert into keywords (keyword) values (?)', $this->keyword); $this->kid = MTrackDB::lastInsertId('keywords', 'kid'); $CS->add("keywords:keyword", null, $this->keyword); } else { throw new Exception("not allowed to rename keywords"); } } }