Upsert.php 836 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace Drupal\Core\Database\Driver\sqlite;
  3. use Drupal\Core\Database\Query\Upsert as QueryUpsert;
  4. /**
  5. * SQLite implementation of \Drupal\Core\Database\Query\Upsert.
  6. */
  7. class Upsert extends QueryUpsert {
  8. /**
  9. * {@inheritdoc}
  10. */
  11. public function __toString() {
  12. // Create a sanitized comment string to prepend to the query.
  13. $comments = $this->connection->makeComment($this->comments);
  14. // Default fields are always placed first for consistency.
  15. $insert_fields = array_merge($this->defaultFields, $this->insertFields);
  16. $query = $comments . 'INSERT OR REPLACE INTO {' . $this->table . '} (' . implode(', ', $insert_fields) . ') VALUES ';
  17. $values = $this->getInsertPlaceholderFragment($this->insertValues, $this->defaultFields);
  18. $query .= implode(', ', $values);
  19. return $query;
  20. }
  21. }