[ Index ]
 

Code source de Symfony 1.0.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/vendor/propel/map/ -> DatabaseMap.php (source)

   1  <?php
   2  
   3  /*
   4   *  $Id: DatabaseMap.php 64 2005-05-13 02:43:56Z root $
   5   *
   6   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   7   * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   8   * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
   9   * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  10   * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  11   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  12   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  13   * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  14   * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  15   * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  16   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  17   *
  18   * This software consists of voluntary contributions made by many individuals
  19   * and is licensed under the LGPL. For more information please see
  20   * <http://propel.phpdb.org>.
  21   */
  22  
  23  include_once 'propel/map/TableMap.php';
  24  
  25  /**
  26   * DatabaseMap is used to model a database.
  27   *
  28   * GENERAL NOTE
  29   * ------------
  30   * The propel.map classes are abstract building-block classes for modeling
  31   * the database at runtime.  These classes are similar (a lite version) to the
  32   * propel.engine.database.model classes, which are build-time modeling classes.
  33   * These classes in themselves do not do any database metadata lookups, but instead 
  34   * are used by the MapBuilder classes that were generated for your datamodel. The 
  35   * MapBuilder that was created for your datamodel build a representation of your
  36   * database by creating instances of the DatabaseMap, TableMap, ColumnMap, etc. 
  37   * classes. See propel/templates/om/php5/MapBuilder.tpl and the classes generated
  38   * by that template for your datamodel to further understand how these are put 
  39   * together.
  40   * 
  41   * @author Hans Lellelid <hans@xmpl.org> (Propel)
  42   * @author John D. McNally <jmcnally@collab.net> (Torque)
  43   * @author Daniel Rall <dlr@collab.net> (Torque)
  44   * @version $Revision: 64 $
  45   * @package propel.map
  46   */
  47  class DatabaseMap {
  48  
  49      /** Name of the database. */
  50      private $name;
  51  
  52      /** Name of the tables in the database. */
  53      private $tables;
  54  
  55      /**
  56       * Constructor.
  57       *
  58       * @param string $name Name of the database.
  59       */
  60      function __construct($name)
  61      {
  62          $this->name = $name;
  63          $this->tables = array();
  64      }
  65  
  66      /**
  67       * Does this database contain this specific table?
  68       *
  69       * @param string $name The String representation of the table.
  70       * @return boolean True if the database contains the table.
  71       */
  72      public function containsTable($name)
  73      {
  74          if ( strpos($name, '.') > 0) {
  75              $name = substr($name, 0, strpos($name, '.'));
  76          }
  77          return isset($this->tables[$name]);
  78      }
  79  
  80      /**
  81       * Get the name of this database.
  82       *
  83       * @return string The name of the database.
  84       */
  85      public function getName()
  86      {
  87          return $this->name;
  88      }
  89  
  90      /**
  91       * Get a TableMap for the table by name.
  92       *
  93       * @param string $name Name of the table.
  94       * @return TableMap A TableMap
  95       * @throws PropelException if the table is undefined
  96       */
  97      public function getTable($name)
  98      {
  99          if (!isset($this->tables[$name])) {
 100              throw new PropelException("Cannot fetch TableMap for undefined table: " . $name);
 101          }
 102          return $this->tables[$name];
 103      }
 104  
 105      /**
 106       * Get a TableMap[] of all of the tables in the database.
 107       *
 108       * @return array A TableMap[].
 109       */
 110      public function getTables()
 111      {
 112          return $this->tables;
 113      }
 114  
 115      /**
 116       * Add a new table to the database by name.  It creates an empty
 117       * TableMap that you need to populate.
 118       *
 119       * @param string $tableName The name of the table.
 120     * @return TableMap The newly created TableMap.
 121       */
 122      public function addTable($tableName)
 123      {
 124          $this->tables[$tableName] = new TableMap($tableName, $this);
 125      return $this->tables[$tableName];
 126      }
 127  }


Généré le : Fri Mar 16 22:42:14 2007 par Balluche grâce à PHPXref 0.7