1 <?php # vim:ts=2:sw=2:et:
2 /* For licensing and copyright terms, see the file named LICENSE */
6 public $description = null;
8 public $snippet = null;
9 public $created = null;
10 public $updated = null;
12 static function loadById($id)
14 foreach (MTrackDB::q('select snid from snippets where snid = ?', $id)
15 ->fetchAll() as $row) {
16 return new self($row[0]);
21 function __construct($id = null)
26 list($row) = MTrackDB::q('select * from snippets where snid = ?', $id)
27 ->fetchAll(PDO::FETCH_ASSOC);
28 foreach ($row as $k => $v) {
34 function save(MTrackChangeset $CS)
36 $this->updated = $CS->cid;
38 if ($this->snid === null) {
39 $this->created = $CS->cid;
44 $this->description . ':' .
48 MTrackDB::q('insert into snippets
49 (snid, created, updated, description, lang, snippet)
50 values (?, ?, ?, ?, ?, ?)',
59 MTrackDB::q('update snippets set updated = ?,
60 description = ?, lang = ?, snippet = ?