source: branches/rsr.v5.1.1/web/app/data/modules/data_forum.php @ 10

Last change on this file since 10 was 1, checked in by dj3c1t, 13 years ago

import initial

File size: 1.6 KB
Line 
1<?php
2
3  class data_forum extends data
4  {
5    function forums()
6    { $forums = array();
7      try
8      { $sql = "SELECT * FROM #--pun_forums";
9        $rst = $this->sql->query($sql);
10        while($v_rst = $this->sql->fetch_assoc($rst)) $forums[$v_rst["id"]] = $v_rst;
11      }
12      catch(Exception $_e) { $forums = false; }
13      return $forums;
14    }
15
16    function forum_last_messages($max, $id_forum = null)
17    { $messages = array();
18      try
19      { $query =
20         "SELECT p.id as post_id, p.posted, t.id as topic_id, t.subject, f.forum_name"
21        ." FROM #--pun_posts p, #--pun_topics t, #--pun_forums f"
22        ." WHERE p.topic_id=t.id"
23        ." AND t.forum_id=f.id"
24        .(isset($id_forum) ? " AND f.id=".$id_forum : "")
25        ." ORDER BY p.posted DESC"
26        ." LIMIT 0,".$max;
27        $rst = $this->sql->query($query);
28        while($v_rst = $this->sql->fetch_assoc($rst)) $messages[$v_rst["post_id"]] = $v_rst;
29      }
30      catch(Exception $_e) { $messages = false; }
31      return $messages;
32    }
33
34    function nous_y_etions()
35    {
36      // adapter ici avec l'identifiant du forum
37      $forum_id = 84;
38
39      $post = array();
40      try
41      { $query =
42         "SELECT p.id as post_id, p.posted, t.id as topic_id, t.subject, f.forum_name"
43        ." FROM #--pun_posts p, #--pun_topics t, #--pun_forums f"
44        ." WHERE p.topic_id=t.id"
45        ." AND t.forum_id=f.id"
46        ." AND f.id=".$forum_id
47        ." ORDER BY RAND()"
48        ." LIMIT 0,1";
49        $rst = $this->sql->query($query);
50        if($v_rst = $this->sql->fetch_assoc($rst)) $post = $v_rst;
51      }
52      catch(Exception $_e) { $post = false; }
53      return $post;
54    }
55
56  }
57
58?>
Note: See TracBrowser for help on using the repository browser.