Beispiel #1
0
 /**
  * 构造函数
  *
  * 开发者不应该自行构造 FLEA_Db_TableLink 实例。而是应该通过
  * FLEA_Db_TableLink::createLink() 静态方法来构造实例。
  *
  * @param array $define
  * @param enum $type
  * @param FLEA_Db_TableDataGateway $mainTDG
  *
  * @return FLEA_Db_TableLink
  */
 function FLEA_Db_TableLink($define, $type, &$mainTDG)
 {
     static $defaultDsnId = null;
     // 检查必须的属性是否都已经提供
     foreach ($this->_req as $key) {
         if (!isset($define[$key]) || $define[$key] == '') {
             FLEA::loadClass('FLEA_Db_Exception_MissingLinkOption');
             return __THROW(new FLEA_Db_Exception_MissingLinkOption($key));
         } else {
             $this->{$key} = $define[$key];
         }
     }
     // 设置可选属性
     foreach ($this->_optional as $key) {
         if (isset($define[$key])) {
             $this->{$key} = $define[$key];
         }
     }
     $this->type = $type;
     $this->mainTDG =& $mainTDG;
     $this->dbo =& $this->mainTDG->getDBO();
     $dsnid = $this->dbo->dsn['id'];
     if (is_null($defaultDsnId)) {
         $defaultDSN = FLEA::getAppInf('dbDSN');
         if ($defaultDSN) {
             $defaultDSN = FLEA::parseDSN($defaultDSN);
             $defaultDsnId = $defaultDSN['id'];
         } else {
             $defaultDsnId = -1;
         }
     }
     if ($dsnid == $defaultDsnId) {
         $this->assocTDGObjectId = null;
     } else {
         $this->assocTDGObjectId = "{$this->tableClass}-{$dsnid}";
     }
 }