示例#1
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;
     $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);
     }
 }
 /**
  * @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);
     }
 }
示例#3
0
文件: CalledBy.php 项目: actank/phan
 public static function read(Database $database, $primary_key_value) : CalledBy
 {
     return parent::read($database, $primary_key_value);
 }
示例#4
0
 /**
  * @param Database $database
  * A database to write this model to
  *
  * @return void
  */
 public function write(Database $database)
 {
     parent::write($database);
     $this->primary_key_value = $database->lastInsertRowID();
 }