Esempio n. 1
0
 public function addManyOne(Table $table, Table $glueTable, Row $row, $columnName = null, $otherColumnName = null)
 {
     list($thisKey, $thisGlueKey) = $this->getTable()->getReferenceKeyNames($glueTable, $columnName);
     list($otherKey, $otherGlueKey) = $table->getReferenceKeyNames($glueTable, $otherColumnName);
     if (!$table->equals($row->getTable())) {
         throw new Exception("Failed to addManyOne( {$table}, row ): Passed row's table doesnt match expected table {$table}");
     }
     if (!isset($this->_data[$thisKey])) {
         throw new Exception("Failed to addManyOne: Row has no {$thisKey} value");
     }
     if (!isset($row->_data[$otherKey])) {
         throw new Exception("Failed to addManyOne: Row has no {$otherKey} value");
     }
     return $glueTable->insert([$thisGlueKey => $this->_data[$thisKey], $otherGlueKey => $this->_data[$otherKey]]);
 }