123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- <?php
- 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() {
-
- $comments = $this->connection->makeComment($this->comments);
-
- $placeholders = array_fill(0, count($this->insertFields), '?');
-
-
- if (!empty($this->fromQuery)) {
- $insert_fields_string = $this->insertFields ? ' (' . implode(', ', $this->insertFields) . ') ' : ' ';
- return $comments . 'INSERT INTO {' . $this->table . '}' . $insert_fields_string . $this->fromQuery;
- }
- return $comments . 'INSERT INTO {' . $this->table . '} (' . implode(', ', $this->insertFields) . ') VALUES (' . implode(', ', $placeholders) . ')';
- }
- }
- class UpdateQuery_sqlite extends UpdateQuery {
- public function execute() {
- if (!empty($this->queryOptions['sqlite_return_matched_rows'])) {
- return parent::execute();
- }
-
- $fields = $this->expressionFields + $this->fields;
-
- $condition = new DatabaseCondition('OR');
- foreach ($fields as $field => $data) {
- if (is_array($data)) {
-
- $condition->where($field . ' <> ' . $data['expression']);
- $condition->isNull($field);
- }
- elseif (!isset($data)) {
-
- $condition->isNotNull($field);
- }
- else {
- $condition->condition($field, $data, '<>');
- $condition->isNull($field);
- }
- }
- if (count($condition)) {
- $condition->compile($this->connection, $this);
- $this->condition->where((string) $condition, $condition->arguments());
- }
- return parent::execute();
- }
- }
- class DeleteQuery_sqlite extends DeleteQuery {
- public function execute() {
- if (!count($this->condition)) {
- $total_rows = $this->connection->query('SELECT COUNT(*) FROM {' . $this->connection->escapeTable($this->table) . '}')->fetchField();
- parent::execute();
- return $total_rows;
- }
- else {
- return parent::execute();
- }
- }
- }
- class TruncateQuery_sqlite extends TruncateQuery {
- public function __toString() {
-
- $comments = $this->connection->makeComment($this->comments);
- return $comments . 'DELETE FROM {' . $this->connection->escapeTable($this->table) . '} ';
- }
- }
|