Skip navigation
Help

InsertQuery_sqlite

user warning: Got error 28 from storage engine query: SELECT ad.branch_id, ad.title, ad.object_name, ad.summary, ad.object_type, ad.file_name, ao.overrides_did, ad.did FROM api_members am INNER JOIN api_documentation ad ON ad.did = am.did LEFT JOIN api_overrides ao ON ao.did = am.did WHERE am.class_did = 18407 ORDER BY title in /srv/www/api.ubercart.me/drupal/sites/all/modules/api/api.pages.inc on line 741.
  1. drupal
    1. 7 drupal/includes/database/sqlite/query.inc

SQLite specific implementation of InsertQuery.

We ignore all the default fields and use the clever SQLite syntax: INSERT INTO table DEFAULT VALUES for degenerated "default only" queries.

Hierarchy

File

drupal/includes/database/sqlite/query.inc, line 20
Query code for SQLite embedded database engine.

View source
class InsertQuery_sqlite extends InsertQuery {

  public function execute() {
    if (!$this->preExecute()) {
      return NULL;
    }
    if (count($this->insertFields)) {
      return parent::execute();
    }
    else {
      return $this->connection->query('INSERT INTO {' . $this->table . '} DEFAULT VALUES', array(), $this->queryOptions);
    }
  }

  public function __toString() {
    // Create a sanitized comment string to prepend to the query.
    $comments = $this->connection->makeComment($this->comments);

    // Produce as many generic placeholders as necessary.
    $placeholders = array_fill(0, count($this->insertFields), '?');

    // If we're selecting from a SelectQuery, finish building the query and
    // pass it back, as any remaining options are irrelevant.
    if (!empty($this->fromQuery)) {
      return $comments . 'INSERT INTO {' . $this->table . '} (' . implode(', ', $this->insertFields) . ') ' . $this->fromQuery;
    }

    return $comments . 'INSERT INTO {' . $this->table . '} (' . implode(', ', $this->insertFields) . ') VALUES (' . implode(', ', $placeholders) . ')';
  }

}

Related topics