eZ components PHP Cross Reference Developer Tools

Source: /Database/src/sqlabstraction/implementations/utilities_pgsql.php - 72 lines - 1859 bytes - Summary - Text - Print

Description: File containing the ezcDbUtilities class.

   1  <?php
   2  /**
   3   * File containing the ezcDbUtilities class.
   4   *
   5   * @package Database
   6   * @version 1.4.7
   7   * @copyright Copyright (C) 2005-2010 eZ Systems AS. All rights reserved.
   8   * @license http://ez.no/licenses/new_bsd New BSD License
   9   * @access private
  10   */
  11  
  12  /**
  13   * Various database methods.
  14   *
  15   * This implementation is postgreSQL specific.
  16   *
  17   * This class inherits most of its database handling functionality from
  18   * PDO ({@link http://php.net/PDO}) -- an object-oriented database abstraction
  19   * layer that is going to become a new standard for PHP applications.
  20   *
  21   * @package Database
  22   * @todo this class must be renamed
  23   * @access private
  24   * @version 1.4.7
  25   */
  26  class ezcDbUtilitiesPgsql extends ezcDbUtilities
  27  {
  28      /**
  29       * Constructs a new db util using the db handler $db.
  30       *
  31       * @param ezcDbHandler $db
  32       */
  33      public function __construct( $db )
  34      {
  35          parent::__construct( $db );
  36      }
  37  
  38      /**
  39       * Remove all tables from the database.
  40       */
  41      public function cleanup()
  42      {
  43          $this->db->beginTransaction();
  44  
  45          // drop tables
  46          $rslt = $this->db->query( "SELECT tablename FROM pg_tables WHERE schemaname = 'public' AND tablename NOT LIKE 'pg_%'" );
  47          $rslt->setFetchMode( PDO::FETCH_NUM );
  48          $rows = $rslt->fetchAll();
  49          unset( $rslt );
  50          foreach ( $rows as $row )
  51          {
  52              $table = $row[0];
  53              $this->db->exec( "DROP TABLE $table" );
  54          }
  55  
  56          // drop sequences
  57          $rslt = $this->db->query( "SELECT relname FROM pg_catalog.pg_class WHERE relkind='S'" );
  58          $rslt->setFetchMode( PDO::FETCH_NUM );
  59          $rows = $rslt->fetchAll();
  60          foreach ( $rows as $row )
  61          {
  62              $seq = $row[0];
  63              $this->db->exec( "DROP SEQUENCE $seq" );
  64          }
  65  
  66          // FIXME: drop triggers?
  67  
  68          $this->db->commit();
  69      }
  70  }
  71  
  72  ?>

title

Description

title

Description

title

Description

title

title

Body