예제 #1
0
 public function saveLinkTable($record)
 {
     $linkTable = $this->linkTable();
     $ownForeignKey = $this->createForeignKey($this->source());
     $ownForeignKeyId = $record->id();
     $property = $this->target();
     $associated = $record->{$property};
     $targetForeignKey = $this->createForeignKey($this->target());
     if (empty($associated)) {
         return true;
     }
     foreach ($associated as $obj) {
         $success = BaseRecord::insertAll($linkTable, [$ownForeignKey => $ownForeignKeyId, $targetForeignKey => $obj->id()]);
         if (!$success) {
             return false;
         }
     }
     return true;
 }
예제 #2
0
 public function testInsertAll()
 {
     $this->assertEquals(true, BaseRecord::insertAll(Mock::tableName(), ['name' => 'new']));
 }