コード例 #1
0
ファイル: ListAssociation.php プロジェクト: ablyler/phan
 /**
  * @param Database $database
  * The database to write to
  *
  * @param ModelOne $model
  * The source model of the association
  *
  * @return void
  */
 public function write(Database $database, ModelOne $model)
 {
     // Ensure that we've initialized this model
     $this->schema->initializeOnce($database);
     $write_closure = $this->write_closure;
     $primary_key_value = $model->primaryKeyValue();
     foreach ($write_closure($model) as $key => $value) {
         // Write the association
         $query = $this->schema->queryForInsert(['source_pk' => $primary_key_value, 'value' => $value]);
         $database->exec($query);
     }
 }
コード例 #2
0
 /**
  * @param Database $database
  * The database to write to
  *
  * @param ModelOne $model
  * The source model of the association
  *
  * @return void
  */
 public function write(Database $database, ModelOne $model)
 {
     // Ensure that we've initialized this model
     $this->schema->initializeOnce($database);
     $write_closure = $this->write_closure;
     $source_pk = $model->primaryKeyValue();
     foreach ($write_closure($model) as $key => $target) {
         // Write the target out
         $target->write($database);
         // Write the association
         $query = $this->schema->queryForInsert(['source_pk' => $source_pk, 'target_pk' => (string) $target->primaryKeyValue()]);
         $database->exec($query);
     }
 }