コード例 #1
0
ファイル: database.php プロジェクト: ateliee/pmp
 function __construct($name, ModelReference $reference)
 {
     $this->name = $name;
     $this->table_name = $reference->getModel()->getTableName();
     $this->column = $reference->getColumn()->getName();
     $this->update = $reference->getUpdate();
     $this->delete = $reference->getDelete();
 }
コード例 #2
0
ファイル: modelColumn.php プロジェクト: ateliee/pmp
 /**
  * @return null
  */
 protected function getReference()
 {
     if ($this->connection && !$this->reference) {
         $reference = null;
         // create reference
         if ($model_name = ModelManager::find($this->connection->getTargetName())) {
             $model = new $model_name();
             $column_name = $this->connection->getTargetColumn();
             if ($model && $model->isExists($column_name)) {
                 $column = $model->getColumn($column_name);
                 $reference = new ModelReference($model, $column);
                 if ($this->connection->getDelete()) {
                     $reference->setDelete($this->connection->getDelete());
                 }
                 if ($this->connection->getUpdate()) {
                     $reference->setUpdate($this->connection->getUpdate());
                 }
                 $this->reference = $reference;
             } else {
                 throw new \Exception('not found connection target paramater.column name is "' . $this->connection->getTargetName() . '"');
             }
         } else {
             throw new \Exception('not found connection target paramater.column name is "' . $this->connection->getTargetName() . '"');
         }
     }
     return $this->reference;
 }