Beispiel #1
0
 /** 
  * Constructor
  * @since Version 3.0.1
  * @version 3.0.1
  * @param object $db
  * @param int|string $topic_id
  */
 public function __construct($topic_id = false)
 {
     parent::__construct();
     if (filter_var($topic_id, FILTER_VALIDATE_INT)) {
         $this->id = $topic_id;
         $this->load();
     }
     if (is_string($topic_id)) {
         if (!($id = $this->Memcached->fetch(sprintf("railpage:news.topic.name=%s", $topic_id)))) {
             $id = $this->db->fetchOne("SELECT topicid FROM nuke_topics WHERE topicname = ?", $topic_id);
             $this->Memcached->save(sprintf("railpage:news.topic.name=%s", $topic_id), $id);
         }
     }
     if (isset($id) && filter_var($id, FILTER_VALIDATE_INT)) {
         $this->id = $id;
         $this->load();
     }
 }
Beispiel #2
0
 /** 
  * Constructor
  * @since Version 3.0.1
  * @version 3.0.1
  * @param object $db
  * @param int $topic_id
  */
 public function __construct($topic_id = false)
 {
     $this->id = $topic_id;
     parent::__construct();
     if ($this->id) {
         $this->mckey = "railpage:news.topic=" . $topic_id;
         if ($this->db instanceof \sql_db) {
             $query = "SELECT * FROM nuke_topics WHERE topicid = '" . $this->db->real_escape_string($this->id) . "'";
             if ($rs = $this->db->query($query)) {
                 if ($rs->num_rows == 1) {
                     $row = $rs->fetch_assoc();
                     $this->id = $row['topicid'];
                     $this->alias = $row['topicname'];
                     $this->title = $row['topictext'];
                     $this->image = $row['topicimage'];
                     $this->desc = $row['desc'];
                 }
             } else {
                 trigger_error(__CLASS__ . ": Could not retrieve topic ID " . $topic_id);
                 trigger_error($this->db->error);
                 trigger_error($query);
                 return false;
             }
         } else {
             if (!($row = getMemcacheObject($this->mckey))) {
                 $query = "SELECT * FROM nuke_topics WHERE topicid = ?";
                 $row = $this->db_readonly->fetchRow($query, $this->id);
                 setMemcacheObject($this->mckey, $row, strtotime("+6 months"));
             }
             $this->id = $row['topicid'];
             $this->alias = $row['topicname'];
             $this->title = $row['topictext'];
             $this->image = $row['topicimage'];
             $this->desc = isset($row['desc']) ? $row['desc'] : "";
         }
     }
     if (!empty($this->alias)) {
         $this->url = new Url(sprintf("%s/t/%s", $this->Module->url, $this->alias));
     }
 }
Beispiel #3
0
 /**
  * Constructor
  * @since Version 3.0.1
  * @version 3.3
  * @param int $id
  * @param boolean $pending
  */
 public function __construct($id = false, $pending = false)
 {
     $this->pending = $pending;
     // Set the parent constructor
     parent::__construct();
     if ($id) {
         $this->id = intval($id);
         $this->fetch();
     }
 }