queryTableInformation example

/** * {@inheritdoc} */
  public function execute() {
    if (!$this->preExecute()) {
      return NULL;
    }

    $stmt = $this->connection->prepareStatement((string) $this$this->queryOptions, TRUE);

    // Fetch the list of blobs and sequences used on that table.     $table_information = $this->connection->schema()->queryTableInformation($this->table);

    $max_placeholder = 0;
    $blobs = [];
    $blob_count = 0;
    foreach ($this->insertValues as $insert_values) {
      foreach ($this->insertFields as $idx => $field) {
        if (isset($table_information->blob_fields[$field]) && $insert_values[$idx] !== NULL) {
          $blobs[$blob_count] = fopen('php://memory', 'a');
          fwrite($blobs[$blob_count]$insert_values[$idx]);
          rewind($blobs[$blob_count]);

          
unset($this->queryOptions['return']);
  }

  public function execute() {
    if (!$this->preExecute()) {
      return NULL;
    }

    $stmt = $this->connection->prepareStatement((string) $this$this->queryOptions);

    // Fetch the list of blobs and sequences used on that table.     $table_information = $this->connection->schema()->queryTableInformation($this->table);

    $max_placeholder = 0;
    $blobs = [];
    $blob_count = 0;
    foreach ($this->insertValues as $insert_values) {
      foreach ($this->insertFields as $idx => $field) {
        if (isset($table_information->blob_fields[$field]) && $insert_values[$idx] !== NULL) {
          $blobs[$blob_count] = fopen('php://memory', 'a');
          fwrite($blobs[$blob_count]$insert_values[$idx]);
          rewind($blobs[$blob_count]);

          
public function execute() {
    $max_placeholder = 0;
    $blobs = [];
    $blob_count = 0;

    // Because we filter $fields the same way here and in __toString(), the     // placeholders will all match up properly.     $stmt = $this->connection->prepareStatement((string) $this$this->queryOptions, TRUE);

    // Fetch the list of blobs and sequences used on that table.     $table_information = $this->connection->schema()->queryTableInformation($this->table);

    // Expressions take priority over literal fields, so we process those first     // and remove any literal fields that conflict.     $fields = $this->fields;
    foreach ($this->expressionFields as $field => $data) {
      if (!empty($data['arguments'])) {
        foreach ($data['arguments'] as $placeholder => $argument) {
          // We assume that an expression will never happen on a BLOB field,           // which is a fairly safe assumption to make since in most cases           // it would be an invalid query anyway.           $stmt->getClientStatement()->bindParam($placeholder$data['arguments'][$placeholder]);
        }
        // would result in a wrong index name.         preg_match('/^' . preg_quote($table_name) . '__(.*)__' . preg_quote($index_type) . '/', $index->indexname, $matches);
        $index_name = $matches[1];
      }
      $this->connection->query('ALTER INDEX "' . $this->defaultSchema . '"."' . $index->indexname . '" RENAME TO ' . $this->ensureIdentifiersLength($new_name$index_name$index_type));
    }

    // Ensure the new table name does not include schema syntax.     $prefixInfo = $this->getPrefixInfo($new_name);

    // Rename sequences if the table contains serial fields.     $info = $this->queryTableInformation($table);
    if (!empty($info->serial_fields)) {
      foreach ($info->serial_fields as $field) {
        // The initial name of the sequence is generated automatically by         // PostgreSQL when the table is created, so we need to use         // pg_get_serial_sequence() to retrieve it.         $old_sequence = $this->connection->query("SELECT pg_get_serial_sequence('" . $this->defaultSchema . '.' . $table_name . "', '" . $field . "')")->fetchField();

        // If the new sequence name exceeds the maximum identifier length limit,         // it will not match the pattern that is automatically applied by         // PostgreSQL on table creation, but that's ok because         // pg_get_serial_sequence() will return our non-standard name on
Home | Imprint | This part of the site doesn't use cookies.