[ Index ]

PHP Cross Reference of MyBB 1.8.32

title

Body

[close]

/inc/ -> db_pgsql_pdo.php (source)

   1  <?php
   2  /**
   3   * MyBB 1.8
   4   * Copyright 2020 MyBB Group, All Rights Reserved
   5   *
   6   * Website: http://www.mybb.com
   7   * License: http://www.mybb.com/about/license
   8   */
   9  
  10  class PostgresPdoDbDriver extends AbstractPdoDbDriver
  11  {
  12      /**
  13       * The title of this layer.
  14       *
  15       * @var string
  16       */
  17      public $title = "PostgreSQL (PDO)";
  18  
  19      /**
  20       * The short title of this layer.
  21       *
  22       * @var string
  23       */
  24      public $short_title = "PostgreSQL (PDO)";
  25  
  26      /**
  27       * Explanation of a query.
  28       *
  29       * @var string
  30       */
  31      public $explain = '';
  32  
  33  	protected function getDsn($hostname, $db, $port, $encoding)
  34      {
  35          $dsn = "pgsql:host={$hostname};dbname={$db}";
  36  
  37          if ($port !== null) {
  38              $dsn .= ";port={$port}";
  39          }
  40  
  41          if (!empty($encoding)) {
  42              $dsn .= ";options='--client_encoding={$encoding}'";
  43          }
  44  
  45          return $dsn;
  46      }
  47  
  48  	public function query($string, $hideErrors = false, $writeQuery = false)
  49      {
  50          $string = preg_replace("#LIMIT (\s*)([0-9]+),(\s*)([0-9]+);?$#im", "LIMIT $4 OFFSET $2", trim($string));
  51  
  52          return parent::query($string, $hideErrors, $writeQuery);
  53      }
  54  
  55  	public function explain_query($string, $qtime)
  56      {
  57          $duration = format_time_duration($qtime);
  58          $queryText = htmlspecialchars_uni($string);
  59  
  60          if (preg_match('/^\\s*SELECT\\b/i', $string) === 1) {
  61              $query = $this->current_link->query("EXPLAIN {$string}");
  62  
  63              $this->explain .= <<<HTML
  64  <table style="background-color: #666;" width="95%" cellpadding="4" cellspacing="1" align="center">
  65      <tr>
  66          <td colspan="8" style="background-color: #ccc;">
  67              <strong>#{$this->query_count} - Select Query</strong>
  68          </td>
  69      </tr>
  70      <tr>
  71          <td colspan="8" style="background-color: #fefefe;">
  72              <span style=\"font-family: Courier; font-size: 14px;">{$queryText}</span>
  73          </td>
  74      <tr style="background-color: #efefef">
  75          <td>
  76              <strong>Info</strong>
  77          </td>
  78      </tr>
  79  HTML;
  80  
  81              while ($table = $query->fetch(PDO::FETCH_ASSOC)) {
  82                  $this->explain .= <<<HTML
  83      <tr style="background-color: #fff">
  84          <td>{$table['QUERY PLAN']}</td>
  85      </tr>
  86  HTML;
  87              }
  88  
  89              $this->explain .= <<<HTML
  90      <tr>
  91          <td colspan="8" style="background-color: #fff;">
  92              Query Time: {$duration}
  93          </td>
  94      </tr>
  95  </table>
  96  <br />
  97  HTML;
  98          } else {
  99              $this->explain .= <<<HTML
 100  <table style="background-color: #666;" width="95%" cellpadding="4" cellspacing="1" align="center">
 101      <tr>
 102          <td style="background-color: #ccc;">
 103              <strong>#{$this->query_count} - Write Query</strong>
 104          </td>
 105      </tr>
 106      <tr style="background-color: #fefefe;">
 107          <td>
 108              <span style="font-family: Courier; font-size: 14px;">{$queryText}</span>
 109          </td>
 110      </tr>
 111      <tr>
 112          <td style="background-color: #fff">
 113              Query Time: {$duration}
 114          </td>
 115      </tr>
 116  </table>
 117  <br />
 118  HTML;
 119          }
 120  
 121          $this->querylist[$this->query_count]['query'] = $string;
 122          $this->querylist[$this->query_count]['time'] = $qtime;
 123      }
 124  
 125  	public function list_tables($database, $prefix = '')
 126      {
 127          if ($prefix) {
 128              $query = $this->write_query("SELECT table_name FROM information_schema.tables WHERE table_schema='public' AND table_name LIKE '{$this->escape_string($prefix)}%'");
 129          } else {
 130              $query = $this->write_query("SELECT table_name FROM information_schema.tables WHERE table_schema='public'");
 131          }
 132  
 133          return $query->fetchAll(PDO::FETCH_COLUMN);
 134      }
 135  
 136  	public function table_exists($table)
 137      {
 138          $query = $this->write_query("SELECT COUNT(table_name) as table_names FROM information_schema.tables WHERE table_schema = 'public' AND table_name='{$this->table_prefix}{$table}'");
 139  
 140          $exists = $this->fetch_field($query, 'table_names');
 141  
 142          return $exists > 0;
 143      }
 144  
 145  	public function field_exists($field, $table)
 146      {
 147          $query = $this->write_query("SELECT COUNT(column_name) as column_names FROM information_schema.columns WHERE table_name='{$this->table_prefix}{$table}' AND column_name='{$field}'");
 148  
 149          $exists = $this->fetch_field($query, 'column_names');
 150  
 151          return $exists > 0;
 152      }
 153  
 154  	public function simple_select($table, $fields = "*", $conditions = "", $options = array())
 155      {
 156          $query = "SELECT {$fields} FROM {$this->table_prefix}{$table}";
 157          if ($conditions != "") {
 158              $query .= " WHERE {$conditions}";
 159          }
 160  
 161          if (isset($options['group_by'])) {
 162              $query .= " GROUP BY {$options['group_by']}";
 163          }
 164  
 165          if (isset($options['order_by'])) {
 166              $query .= " ORDER BY {$options['order_by']}";
 167              if (isset($options['order_dir'])) {
 168                  $query .= " {$options['order_dir']}";
 169              }
 170          }
 171  
 172          if (isset($options['limit_start']) && isset($options['limit'])) {
 173              $query .= " LIMIT {$options['limit']} OFFSET {$options['limit_start']}";
 174          } else if (isset($options['limit'])) {
 175              $query .= " LIMIT {$options['limit']}";
 176          }
 177  
 178          return $this->query($query);
 179      }
 180  
 181  	public function insert_query($table, $array)
 182      {
 183          global $mybb;
 184  
 185          if (!is_array($array)) {
 186              return false;
 187          }
 188  
 189          foreach ($array as $field => $value) {
 190              if (isset($mybb->binary_fields[$table][$field]) && $mybb->binary_fields[$table][$field]) {
 191                  $array[$field] = $value;
 192              } else {
 193                  $array[$field] = $this->quote_val($value);
 194              }
 195          }
 196  
 197          $fields = implode(",", array_keys($array));
 198          $values = implode(",", $array);
 199          $this->write_query("
 200              INSERT
 201              INTO {$this->table_prefix}{$table} ({$fields})
 202              VALUES ({$values})
 203          ");
 204  
 205          return $this->insert_id();
 206      }
 207  
 208  	private function quote_val($value, $quote = "'")
 209      {
 210          if (is_int($value)) {
 211              return $value;
 212          }
 213  
 214          return "{$quote}{$value}{$quote}";
 215      }
 216  
 217  	public function insert_query_multiple($table, $array)
 218      {
 219          global $mybb;
 220  
 221          if (!is_array($array)){
 222              return;
 223          }
 224  
 225          // Field names
 226          $fields = array_keys($array[0]);
 227          $fields = implode(",", $fields);
 228  
 229          $insert_rows = array();
 230          foreach ($array as $values) {
 231              foreach ($values as $field => $value) {
 232                  if(isset($mybb->binary_fields[$table][$field]) && $mybb->binary_fields[$table][$field]) {
 233                      $values[$field] = $value;
 234                  } else {
 235                      $values[$field] = $this->quote_val($value);
 236                  }
 237              }
 238  
 239              $insert_rows[] = "(".implode(",", $values).")";
 240          }
 241  
 242          $insert_rows = implode(", ", $insert_rows);
 243  
 244          $this->write_query("
 245              INSERT
 246              INTO {$this->table_prefix}{$table} ({$fields})
 247              VALUES {$insert_rows}
 248          ");
 249      }
 250  
 251  	public function update_query($table, $array, $where = "", $limit = "", $no_quote = false)
 252      {
 253          global $mybb;
 254  
 255          if (!is_array($array)) {
 256              return false;
 257          }
 258  
 259          $comma = "";
 260          $query = "";
 261          $quote = "'";
 262  
 263          if ($no_quote == true) {
 264              $quote = "";
 265          }
 266  
 267          foreach($array as $field => $value) {
 268              if(isset($mybb->binary_fields[$table][$field]) && $mybb->binary_fields[$table][$field]) {
 269                  $query .= "{$comma}{$field}={$value}";
 270              } else {
 271                  $quoted_value = $this->quote_val($value, $quote);
 272  
 273                  $query .= "{$comma}{$field}={$quoted_value}";
 274              }
 275  
 276              $comma = ', ';
 277          }
 278  
 279          if(!empty($where)) {
 280              $query .= " WHERE {$where}";
 281          }
 282  
 283          return $this->write_query("
 284              UPDATE {$this->table_prefix}$table
 285              SET $query
 286          ");
 287      }
 288  
 289  	public function delete_query($table, $where = "", $limit = "")
 290      {
 291          $query = "";
 292          if (!empty($where)) {
 293              $query .= " WHERE {$where}";
 294          }
 295  
 296          return $this->write_query("
 297              DELETE
 298              FROM {$this->table_prefix}$table
 299              $query
 300          ");
 301      }
 302  
 303  	public function optimize_table($table)
 304      {
 305          $this->write_query("VACUUM {$this->table_prefix}{$table};");
 306      }
 307  
 308  	public function analyze_table($table)
 309      {
 310          $this->write_query("ANALYZE {$this->table_prefix}{$table};");
 311      }
 312  
 313  	public function show_create_table($table)
 314      {
 315          $query = $this->write_query("
 316              SELECT a.attnum, a.attname as field, t.typname as type, a.attlen as length, a.atttypmod as lengthvar, a.attnotnull as notnull
 317              FROM pg_class c
 318              LEFT JOIN pg_attribute a ON (a.attrelid = c.oid)
 319              LEFT JOIN pg_type t ON (a.atttypid = t.oid)
 320              WHERE c.relname = '{$this->table_prefix}{$table}' AND a.attnum > 0
 321              ORDER BY a.attnum
 322          ");
 323  
 324          $lines = array();
 325          $table_lines = "CREATE TABLE {$this->table_prefix}{$table} (\n";
 326  
 327          while ($row = $this->fetch_array($query)) {
 328              // Get the data from the table
 329              $query2 = $this->write_query("
 330                  SELECT pg_get_expr(d.adbin, d.adrelid) as rowdefault
 331                  FROM pg_attrdef d
 332                  LEFT JOIN pg_class c ON (c.oid = d.adrelid)
 333                  WHERE c.relname = '{$this->table_prefix}{$table}' AND d.adnum = '{$row['attnum']}'
 334              ");
 335  
 336              if (!$query2) {
 337                  unset($row['rowdefault']);
 338              } else {
 339                  $row['rowdefault'] = $this->fetch_field($query2, 'rowdefault');
 340              }
 341  
 342              if ($row['type'] == 'bpchar') {
 343                  // Stored in the engine as bpchar, but in the CREATE TABLE statement it's char
 344                  $row['type'] = 'char';
 345              }
 346  
 347              $line = "  {$row['field']} {$row['type']}";
 348  
 349              if (strpos($row['type'], 'char') !== false) {
 350                  if ($row['lengthvar'] > 0) {
 351                      $line .= '('.($row['lengthvar'] - 4).')';
 352                  }
 353              }
 354  
 355              if (strpos($row['type'], 'numeric') !== false) {
 356                  $line .= '('.sprintf("%s,%s", (($row['lengthvar'] >> 16) & 0xffff), (($row['lengthvar'] - 4) & 0xffff)).')';
 357              }
 358  
 359              if (!empty($row['rowdefault'])) {
 360                  $line .= " DEFAULT {$row['rowdefault']}";
 361              }
 362  
 363              if ($row['notnull'] == 't') {
 364                  $line .= ' NOT NULL';
 365              }
 366  
 367              $lines[] = $line;
 368          }
 369  
 370          // Get the listing of primary keys.
 371          $query = $this->write_query("
 372              SELECT ic.relname as index_name, bc.relname as tab_name, ta.attname as column_name, i.indisunique as unique_key, i.indisprimary as primary_key
 373              FROM pg_class bc
 374              LEFT JOIN pg_index i ON (bc.oid = i.indrelid)
 375              LEFT JOIN pg_class ic ON (ic.oid = i.indexrelid)
 376              LEFT JOIN pg_attribute ia ON (ia.attrelid = i.indexrelid)
 377              LEFT JOIN pg_attribute ta ON (ta.attrelid = bc.oid AND ta.attrelid = i.indrelid AND ta.attnum = i.indkey[ia.attnum-1])
 378              WHERE bc.relname = '{$this->table_prefix}{$table}'
 379              ORDER BY index_name, tab_name, column_name
 380          ");
 381  
 382          $primary_key = array();
 383          $primary_key_name = '';
 384  
 385          $unique_keys = array();
 386  
 387          // We do this in two steps. It makes placing the comma easier
 388          while ($row = $this->fetch_array($query)) {
 389              if ($row['primary_key'] == 't') {
 390                  $primary_key[] = $row['column_name'];
 391                  $primary_key_name = $row['index_name'];
 392              }
 393  
 394              if ($row['unique_key'] == 't') {
 395                  $unique_keys[$row['index_name']][] = $row['column_name'];
 396              }
 397          }
 398  
 399          if (!empty($primary_key)) {
 400              $lines[] = "  CONSTRAINT $primary_key_name PRIMARY KEY (".implode(', ', $primary_key).")";
 401          }
 402  
 403          foreach ($unique_keys as $key_name => $key_columns) {
 404              $lines[] = "  CONSTRAINT $key_name UNIQUE (".implode(', ', $key_columns).")";
 405          }
 406  
 407          $table_lines .= implode(", \n", $lines);
 408          $table_lines .= "\n)\n";
 409  
 410          return $table_lines;
 411      }
 412  
 413  	public function show_fields_from($table)
 414      {
 415          $query = $this->write_query("SELECT column_name FROM information_schema.constraint_column_usage WHERE table_name = '{$this->table_prefix}{$table}' and constraint_name = '{$this->table_prefix}{$table}_pkey' LIMIT 1");
 416          $primary_key = $this->fetch_field($query, 'column_name');
 417  
 418          $query = $this->write_query("
 419              SELECT column_name, data_type, is_nullable, column_default, character_maximum_length, numeric_precision, numeric_precision_radix, numeric_scale
 420              FROM information_schema.columns
 421              WHERE table_name = '{$this->table_prefix}{$table}'
 422          ");
 423  
 424          $field_info = array();
 425          while ($field = $this->fetch_array($query)) {
 426              if ($field['column_name'] == $primary_key) {
 427                  $field['_key'] = 'PRI';
 428              } else {
 429                  $field['_key'] = '';
 430              }
 431  
 432              if (!is_null($field['column_default']) && stripos($field['column_default'], 'nextval') !== false) {
 433                  $field['_extra'] = 'auto_increment';
 434              } else {
 435                  $field['_extra'] = '';
 436              }
 437  
 438              // bit, character, text fields.
 439              if (!is_null($field['character_maximum_length'])) {
 440                  $field['data_type'] .= '('.(int)$field['character_maximum_length'].')';
 441              }
 442              // numeric/decimal fields.
 443              else if ($field['numeric_precision_radix'] == 10 && !is_null($field['numeric_precision']) && !is_null($field['numeric_scale'])) {
 444                  $field['data_type'] .= '('.(int)$field['numeric_precision'].','.(int)$field['numeric_scale'].')';
 445              }
 446  
 447              $field_info[] = array(
 448                  'Field' => $field['column_name'],
 449                  'Type' => $field['data_type'],
 450                  'Null' => $field['is_nullable'],
 451                  'Key' => $field['_key'],
 452                  'Default' => $field['column_default'],
 453                  'Extra' => $field['_extra'],
 454              );
 455          }
 456  
 457          return $field_info;
 458      }
 459  
 460  	function is_fulltext($table, $index = "")
 461      {
 462          return false;
 463      }
 464  
 465  	public function supports_fulltext($table)
 466      {
 467          return false;
 468      }
 469  
 470  	public function index_exists($table, $index)
 471      {
 472          $err = $this->error_reporting;
 473          $this->error_reporting = 0;
 474  
 475          $tableName = $this->escape_string("{$this->table_prefix}{$table}");
 476  
 477          $query = $this->write_query("SELECT * FROM pg_indexes WHERE tablename = '{$tableName}'");
 478  
 479          $exists = $this->fetch_field($query, $index);
 480          $this->error_reporting = $err;
 481  
 482          return (bool)$exists;
 483      }
 484  
 485  	public function supports_fulltext_boolean($table)
 486      {
 487          return false;
 488      }
 489  
 490  	public function create_fulltext_index($table, $column, $name = "")
 491      {
 492          return false;
 493      }
 494  
 495  	public function drop_index($table, $name)
 496      {
 497          $this->write_query("
 498              ALTER TABLE {$this->table_prefix}{$table}
 499              DROP INDEX {$name}
 500          ");
 501      }
 502  
 503  	public function drop_table($table, $hard = false, $table_prefix = true)
 504      {
 505          if ($table_prefix == false) {
 506              $table_prefix = "";
 507          } else {
 508              $table_prefix = $this->table_prefix;
 509          }
 510  
 511          $table_prefix_bak = $this->table_prefix;
 512          $this->table_prefix = '';
 513          $fields = array_column($this->show_fields_from($table_prefix.$table), 'Field');
 514  
 515          if ($hard == false) {
 516              if($this->table_exists($table_prefix.$table))
 517              {
 518                  $this->write_query("DROP TABLE {$table_prefix}{$table}");
 519              }
 520          } else {
 521              $this->write_query("DROP TABLE {$table_prefix}{$table}");
 522          }
 523  
 524          $this->table_prefix = $table_prefix_bak;
 525  
 526          if(!empty($fields)) {
 527              foreach ($fields as &$field) {
 528                  $field = "{$table_prefix}{$table}_{$field}_seq";
 529              }
 530              unset($field);
 531  
 532              if (version_compare($this->get_version(), '8.2.0', '>=')) {
 533                  $fields = implode(', ', $fields);
 534                  $this->write_query("DROP SEQUENCE IF EXISTS {$fields}");
 535              } else {
 536                  $fields = "'" . implode("', '", $fields) . "'";
 537                  $query = $this->query("SELECT sequence_name as field FROM information_schema.sequences WHERE sequence_name in ({$fields}) AND sequence_schema = 'public'");
 538                  while ($row = $this->fetch_array($query)) {
 539                      $this->write_query("DROP SEQUENCE {$row['field']}");
 540                  }
 541              }
 542          }
 543      }
 544  
 545  	public function rename_table($old_table, $new_table, $table_prefix = true)
 546      {
 547          if ($table_prefix == false) {
 548              $table_prefix = "";
 549          } else {
 550              $table_prefix = $this->table_prefix;
 551          }
 552  
 553          return $this->write_query("ALTER TABLE {$table_prefix}{$old_table} RENAME TO {$table_prefix}{$new_table}");
 554      }
 555  
 556  	public function replace_query($table, $replacements = array(), $default_field = "", $insert_id = true)
 557      {
 558          global $mybb;
 559  
 560          if ($default_field == "") {
 561              $query = $this->write_query("SELECT column_name FROM information_schema.constraint_column_usage WHERE table_name = '{$this->table_prefix}{$table}' and constraint_name = '{$this->table_prefix}{$table}_pkey' LIMIT 1");
 562              $main_field = $this->fetch_field($query, 'column_name');
 563          } else {
 564              $main_field = $default_field;
 565          }
 566  
 567          $update = false;
 568          $search_bit = array();
 569  
 570          if (!is_array($main_field)) {
 571              $main_field = array($main_field);
 572          }
 573  
 574          foreach ($main_field as $field) {
 575              if (isset($mybb->binary_fields[$table][$field]) && $mybb->binary_fields[$table][$field]) {
 576                  $search_bit[] = "{$field} = ".$replacements[$field];
 577              } else {
 578                  $search_bit[] = "{$field} = ".$this->quote_val($replacements[$field]);
 579              }
 580          }
 581  
 582          $search_bit = implode(" AND ", $search_bit);
 583          $query = $this->write_query("SELECT COUNT(".$main_field[0].") as count FROM {$this->table_prefix}{$table} WHERE {$search_bit} LIMIT 1");
 584  
 585          if ($this->fetch_field($query, "count") == 1) {
 586              $update = true;
 587          }
 588  
 589          if ($update === true) {
 590              return $this->update_query($table, $replacements, $search_bit);
 591          } else {
 592              return $this->insert_query($table, $replacements);
 593          }
 594      }
 595  
 596  	public function drop_column($table, $column)
 597      {
 598          return $this->write_query("ALTER TABLE {$this->table_prefix}{$table} DROP {$column}");
 599      }
 600  
 601  	public function add_column($table, $column, $definition)
 602      {
 603          return $this->write_query("ALTER TABLE {$this->table_prefix}{$table} ADD {$column} {$definition}");
 604      }
 605  
 606  	public function modify_column($table, $column, $new_definition, $new_not_null = false, $new_default_value = false)
 607      {
 608          $result1 = $result2 = $result3 = true;
 609  
 610          if ($new_definition !== false) {
 611              $result1 = $this->write_query("ALTER TABLE {$this->table_prefix}{$table} ALTER COLUMN {$column} TYPE {$new_definition}");
 612          }
 613  
 614          if ($new_not_null !== false) {
 615              $set_drop = "DROP";
 616  
 617              if (strtolower($new_not_null) == "set") {
 618                  $set_drop = "SET";
 619              }
 620  
 621              $result2 = $this->write_query("ALTER TABLE {$this->table_prefix}{$table} ALTER COLUMN {$column} {$set_drop} NOT NULL");
 622          }
 623  
 624          if ($new_default_value !== null) {
 625              if($new_default_value !== false) {
 626                  $result3 = $this->write_query("ALTER TABLE {$this->table_prefix}{$table} ALTER COLUMN {$column} SET DEFAULT {$new_default_value}");
 627              } else {
 628                  $result3 = $this->write_query("ALTER TABLE {$this->table_prefix}{$table} ALTER COLUMN {$column} DROP DEFAULT");
 629              }
 630          }
 631  
 632          return $result1 && $result2 && $result3;
 633      }
 634  
 635  	public function rename_column($table, $old_column, $new_column, $new_definition, $new_not_null = false, $new_default_value = false)
 636      {
 637          $result1 = $this->write_query("ALTER TABLE {$this->table_prefix}{$table} RENAME COLUMN {$old_column} TO {$new_column}");
 638          $result2 = $this->modify_column($table, $new_column, $new_definition, $new_not_null, $new_default_value);
 639  
 640          return $result1 && $result2;
 641      }
 642  
 643  	public function fetch_size($table = '')
 644      {
 645          if (!empty($table)) {
 646              $query = $this->query("SELECT SUM(reltuples), SUM(relpages) FROM pg_class WHERE relname = '{$this->table_prefix}{$table}'");
 647          } else {
 648              $query = $this->query("SELECT SUM(reltuples), SUM(relpages) FROM pg_class");
 649          }
 650  
 651          if (null === $query) {
 652              return 0;
 653          }
 654  
 655          $result = $this->fetch_array($query, PDO::FETCH_NUM);
 656  
 657          if (false === $result) {
 658              return 0;
 659          }
 660  
 661          return $result[0] + $result[1];
 662      }
 663  
 664  	public function fetch_db_charsets()
 665      {
 666          return false;
 667      }
 668  
 669  	public function fetch_charset_collation($charset)
 670      {
 671          return false;
 672      }
 673  
 674  	public function build_create_table_collation()
 675      {
 676          return '';
 677      }
 678  
 679  	public function insert_id()
 680      {
 681          try {
 682              return $this->write_link->lastInsertId();
 683          } catch (PDOException $e) {
 684              // in order to behave the same way as the MySQL driver, we return false if there is no last insert ID
 685              return false;
 686          }
 687      }
 688  
 689  	public function escape_binary($string)
 690      {
 691          $hex = bin2hex($string);
 692          return "decode('{$hex}', 'hex')";
 693      }
 694  
 695  	public function unescape_binary($string)
 696      {
 697          // binary fields are treated as streams
 698          /** @var resource $string */
 699          return fgets($string);
 700      }
 701  
 702      /**
 703       * @param string $table
 704       * @param string $append
 705       *
 706       * @return string
 707       */
 708  	public function build_fields_string($table, $append="")
 709      {
 710          $fields = $this->show_fields_from($table);
 711          $comma = $fieldstring = '';
 712  
 713          foreach($fields as $key => $field)
 714          {
 715              $fieldstring .= "{$comma}{$append}{$field['Field']}";
 716              $comma = ',';
 717          }
 718  
 719          return $fieldstring;
 720      }
 721  
 722  	public function __set($name, $value)
 723      {
 724          if ($name === 'type') {
 725              // NOTE: This is to prevent the type being set - this type should appear as `pgsql` to ensure compatibility
 726              return;
 727          }
 728      }
 729  
 730  	public function __get($name)
 731      {
 732          if ($name === 'type') {
 733              // NOTE: this is to ensure compatibility checks on the DB type will work
 734              return 'pgsql';
 735          }
 736  
 737          return null;
 738      }
 739  }


2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup Cross-referenced by PHPXref