Relation.class.php 2.66 KB
Newer Older
doctrine's avatar
doctrine committed
1 2 3 4 5 6 7 8 9 10 11 12
<?php
/**
 * @class Doctrine_Relation
 *
 * @author      Konsta Vesterinen
 * @package     Doctrine ORM
 * @url         www.phpdoctrine.com
 * @license     LGPL
 * @version     1.0 alpha
 *
 */
class Doctrine_Relation {
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
    /**
     * RELATION CONSTANTS
     */

    /**
     * constant for ONE_TO_ONE and MANY_TO_ONE aggregate relationships
     */
    const ONE_AGGREGATE         = 0;
    /**
     * constant for ONE_TO_ONE and MANY_TO_ONE composite relationships
     */
    const ONE_COMPOSITE         = 1;
    /**
     * constant for MANY_TO_MANY and ONE_TO_MANY aggregate relationships
     */
    const MANY_AGGREGATE        = 2;
    /**
     * constant for MANY_TO_MANY and ONE_TO_MANY composite relationships
     */
    const MANY_COMPOSITE        = 3;
    
    
doctrine's avatar
doctrine committed
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
    /**
     * @var Doctrine_Table $table     foreign factory
     */
    private $table;
    /**
     * @var string $local           local field
     */
    private $local;
    /**
     * @var string $foreign         foreign field
     */
    private $foreign;
    /**
     * @var integer $type           bind type
     */
    private $type;
    /**
     * @param Doctrine_Table $table
     * @param string $local
     * @param string $foreign
     * @param integer $type
     */
    public function __construct(Doctrine_Table $table,$local,$foreign,$type) {
        $this->table    = $table;
        $this->local    = $local;
        $this->foreign  = $foreign;
        $this->type     = $type;
    }
    /**
     * @return integer              bind type 1 or 0
     */
    public function getType() {
        return $this->type;
    }
    /**
     * @return object Doctrine_Table    foreign factory object
     */
    public function getTable() {
        return $this->table;
    }
    /**
     * @return string               the name of the local column
     */
    public function getLocal() {
        return $this->local;
    }
    /**
     * @return string               the name of the foreign column where
     *                              the local column is pointing at
     */
    public function getForeign() {
        return $this->foreign;
    }
    /**
     * __toString
     */
    public function __toString() {
        $r[] = "<pre>";
        $r[] = "Class       : ".get_class($this);
        $r[] = "Component   : ".$this->table->getComponentName();
        $r[] = "Table       : ".$this->table->getTableName();
        $r[] = "Local key   : ".$this->local;
        $r[] = "Foreign key : ".$this->foreign;
        $r[] = "Type        : ".$this->type;
        $r[] = "</pre>";
        return implode("\n", $r);
    }
}

?>