GetLastInsertIncrement() public method

 public function FillPrimaryKeys(IConnection $Connection, array $UnkeyedRows)
 {
     //Mysql will return the first auto increment from a multi insert
     $FirstInsertId = (int) $Connection->GetLastInsertIncrement();
     $IncrementId = $FirstInsertId;
     foreach ($UnkeyedRows as $Row) {
         $Row[$this->IncrementColumn] = $this->IncrementColumn->ToPersistenceValue($IncrementId);
         $IncrementId++;
     }
 }
Example #2
0
 public function FillPrimaryKeys(IConnection $Connection, array $UnkeyedRows)
 {
     $PriamryKeyColumns = $this->GetPrimaryKeyColumns();
     $PrimaryKeyColumn = reset($PriamryKeyColumns);
     $QueryBuilder = $Connection->QueryBuilder();
     $QueryBuilder->AppendIdentifier('INSERT INTO # ', [$this->SequenceTable->GetName()]);
     $QueryBuilder->AppendIdentifier('(#)', [$this->SequenceTable->SequenceNameColumn->GetName()]);
     $QueryBuilder->Append(' VALUES ');
     $InsertRows = array_fill(0, count($UnkeyedRows), '(#)');
     $QueryBuilder->AppendValue(implode(',', $InsertRows), $this->SequenceName);
     $QueryBuilder->Build()->Execute();
     //Mysql will return the first inserted id
     $IncrementId = (int) $Connection->GetLastInsertIncrement();
     foreach ($UnkeyedRows as $UnkeyedRow) {
         $UnkeyedRow[$PrimaryKeyColumn] = $PrimaryKeyColumn->ToPersistenceValue($IncrementId);
         $IncrementId++;
     }
 }
 public function FillPrimaryKey(IConnection $Connection, Row $UnkeyedRow)
 {
     $InsertId = (int) $Connection->GetLastInsertIncrement();
     $UnkeyedRow[$this->IncrementColumn] = $this->IncrementColumn->ToPersistenceValue($InsertId);
 }