[ Index ]

PHP Cross Reference of phpBB-3.2.8-deutsch

title

Body

[close]

/phpbb/textreparser/plugins/ -> poll_option.php (source)

   1  <?php
   2  /**
   3  *
   4  * This file is part of the phpBB Forum Software package.
   5  *
   6  * @copyright (c) phpBB Limited <https://www.phpbb.com>
   7  * @license GNU General Public License, version 2 (GPL-2.0)
   8  *
   9  * For full copyright and license information, please see
  10  * the docs/CREDITS.txt file.
  11  *
  12  */
  13  
  14  namespace phpbb\textreparser\plugins;
  15  
  16  class poll_option extends \phpbb\textreparser\base
  17  {
  18      /**
  19      * @var \phpbb\db\driver\driver_interface
  20      */
  21      protected $db;
  22  
  23      /**
  24      * Constructor
  25      *
  26      * @param \phpbb\db\driver\driver_interface $db Database connection
  27      */
  28  	public function __construct(\phpbb\db\driver\driver_interface $db)
  29      {
  30          $this->db = $db;
  31      }
  32  
  33      /**
  34      * {@inheritdoc}
  35      */
  36  	public function get_max_id()
  37      {
  38          $sql = 'SELECT MAX(topic_id) AS max_id FROM ' . POLL_OPTIONS_TABLE;
  39          $result = $this->db->sql_query($sql);
  40          $max_id = (int) $this->db->sql_fetchfield('max_id');
  41          $this->db->sql_freeresult($result);
  42  
  43          return $max_id;
  44      }
  45  
  46      /**
  47      * {@inheritdoc}
  48      */
  49  	protected function get_records_by_range($min_id, $max_id)
  50      {
  51          $sql = 'SELECT o.topic_id, o.poll_option_id, o.poll_option_text AS text, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.bbcode_uid
  52              FROM ' . POLL_OPTIONS_TABLE . ' o, ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p
  53              WHERE o.topic_id BETWEEN ' . $min_id . ' AND ' . $max_id .'
  54                  AND t.topic_id = o.topic_id
  55                  AND p.post_id = t.topic_first_post_id';
  56          $result = $this->db->sql_query($sql);
  57          $records = $this->db->sql_fetchrowset($result);
  58          $this->db->sql_freeresult($result);
  59  
  60          return $records;
  61      }
  62  
  63      /**
  64      * {@inheritdoc}
  65      */
  66  	protected function save_record(array $record)
  67      {
  68          $sql = 'UPDATE ' . POLL_OPTIONS_TABLE . "
  69              SET poll_option_text = '" . $this->db->sql_escape($record['text']) . "'
  70              WHERE topic_id = " . $record['topic_id'] . '
  71                  AND poll_option_id = ' . $record['poll_option_id'];
  72          $this->db->sql_query($sql);
  73      }
  74  }


Generated: Tue Apr 7 19:42:26 2020 Cross-referenced by PHPXref 0.7.1