27e4405d1305184c5dc21df7a0d8a31b90e09f00
[fa-stable.git] / includes / db / comments_db.inc
1 <?php
2
3 //--------------------------------------------------------------------------------------------------
4
5 function get_comments($type, $type_no)
6 {
7         $sql = "SELECT * FROM ".TB_PREF."comments WHERE type=$type AND id=$type_no";
8         
9         return db_query($sql, "could not query comments transaction table");
10 }
11
12 //--------------------------------------------------------------------------------------------------
13
14 function add_comments($type, $type_no, $date_, $memo_)
15 {
16         if ($memo_ != null && $memo_ != "") 
17         {       
18         $date = date2sql($date_);
19         $sql = "INSERT INTO ".TB_PREF."comments (type, id, date_, memo_)
20                 VALUES ($type, $type_no, '$date', '$memo_')";
21                                 
22         db_query($sql, "could not add comments transaction entry");
23         }                               
24 }
25
26 //--------------------------------------------------------------------------------------------------
27
28 function update_comments($type, $id, $date_, $memo_)
29 {
30         if ($date_ == null) 
31         {
32         delete_comments($type, $id);
33         add_comments($type, $id, '', $memo_);
34         } 
35         else 
36         {
37                 $date = date2sql($date_);
38         $sql = "UPDATE ".TB_PREF."comments SET memo_='$memo_' WHERE type=$type AND id=$id AND date_='$date'";
39         db_query($sql, "could not update comments");
40         }
41 }
42
43 //--------------------------------------------------------------------------------------------------
44
45 function delete_comments($type, $type_no)
46 {
47         $sql = "DELETE FROM ".TB_PREF."comments WHERE type=$type AND id=$type_no";
48         
49         db_query($sql, "could not delete from comments transaction table");
50 }
51
52 //--------------------------------------------------------------------------------------------------
53
54 ?>