[ Index ]

PHP Cross Reference of phpBB-3.3.14-deutsch

title

Body

[close]

/phpbb/db/driver/ -> mysql_base.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\db\driver;
  15  
  16  /**
  17  * Abstract MySQL Database Base Abstraction Layer
  18  */
  19  abstract class mysql_base extends \phpbb\db\driver\driver
  20  {
  21      /**
  22      * {@inheritDoc}
  23      */
  24  	public function sql_concatenate($expr1, $expr2)
  25      {
  26          return 'CONCAT(' . $expr1 . ', ' . $expr2 . ')';
  27      }
  28  
  29      /**
  30      * Build LIMIT query
  31      */
  32  	function _sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
  33      {
  34          $this->query_result = false;
  35  
  36          // if $total is set to 0 we do not want to limit the number of rows
  37          if ($total == 0)
  38          {
  39              // MySQL 4.1+ no longer supports -1 in limit queries
  40              $total = '18446744073709551615';
  41          }
  42  
  43          $query .= "\n LIMIT " . ((!empty($offset)) ? $offset . ', ' . $total : $total);
  44  
  45          return $this->sql_query($query, $cache_ttl);
  46      }
  47  
  48      /**
  49      * {@inheritDoc}
  50      */
  51  	function get_estimated_row_count($table_name)
  52      {
  53          $table_status = $this->get_table_status($table_name);
  54  
  55          if (isset($table_status['Engine']))
  56          {
  57              if ($table_status['Engine'] === 'MyISAM')
  58              {
  59                  return $table_status['Rows'];
  60              }
  61              else if ($table_status['Engine'] === 'InnoDB' && $table_status['Rows'] > 100000)
  62              {
  63                  return '~' . $table_status['Rows'];
  64              }
  65          }
  66  
  67          return parent::get_row_count($table_name);
  68      }
  69  
  70      /**
  71      * {@inheritDoc}
  72      */
  73  	function get_row_count($table_name)
  74      {
  75          $table_status = $this->get_table_status($table_name);
  76  
  77          if (isset($table_status['Engine']) && $table_status['Engine'] === 'MyISAM')
  78          {
  79              return $table_status['Rows'];
  80          }
  81  
  82          return parent::get_row_count($table_name);
  83      }
  84  
  85      /**
  86      * Gets some information about the specified table.
  87      *
  88      * @param string $table_name        Table name
  89      *
  90      * @return array
  91      *
  92      * @access protected
  93      */
  94  	function get_table_status($table_name)
  95      {
  96          $sql = "SHOW TABLE STATUS
  97              LIKE '" . $this->sql_escape($table_name) . "'";
  98          $result = $this->sql_query($sql);
  99          $table_status = $this->sql_fetchrow($result);
 100          $this->sql_freeresult($result);
 101  
 102          return $table_status;
 103      }
 104  
 105      /**
 106      * Build LIKE expression
 107      * @access private
 108      */
 109  	function _sql_like_expression($expression)
 110      {
 111          return $expression;
 112      }
 113  
 114      /**
 115      * Build NOT LIKE expression
 116      * @access private
 117      */
 118  	function _sql_not_like_expression($expression)
 119      {
 120          return $expression;
 121      }
 122  
 123      /**
 124      * Build db-specific query data
 125      * @access private
 126      */
 127  	function _sql_custom_build($stage, $data)
 128      {
 129          switch ($stage)
 130          {
 131              case 'FROM':
 132                  $data = '(' . $data . ')';
 133              break;
 134          }
 135  
 136          return $data;
 137      }
 138  }


Generated: Mon Nov 25 19:05:08 2024 Cross-referenced by PHPXref 0.7.1