/** * Test that epilog() will actually append a string to an update query * * @return void */ public function testAppendUpdate() { $query = new Query($this->connection); $sql = $query->update('articles')->set(['title' => 'foo'])->where(['id' => 1])->epilog('RETURNING id')->sql(); $this->assertContains('UPDATE', $sql); $this->assertContains('SET', $sql); $this->assertContains('WHERE', $sql); $this->assertEquals(' RETURNING id', substr($sql, -13)); }
/** * Create an update query. * * This changes the query type to be 'update'. * Can be combined with set() and where() methods to create update queries. * * @param string|null $table Unused parameter. * @return $this */ public function update($table = null) { $table = $table ?: $this->repository()->table(); return parent::update($table); }
/** * Quotes the table name for an update query * * @param \Cake\Database\Query $query The update query to quote. * @return void */ protected function _quoteUpdate($query) { $table = $query->clause('update')[0]; if (is_string($table)) { $query->update($this->_driver->quoteIdentifier($table)); } }