public function testQuoteColumns() { $columns = ['id', 'name']; $this->adapter->expects($this->any())->method('quoteColumnName')->will($this->returnCallback(function ($name) { return "`{$name}`"; })); $expected = ['`id`', '`name`']; $this->assertEquals($expected, $this->helper->quoteColumns($columns)); }
/** * @param integer $lowest * @param integer $highest * @return string */ protected function copy($lowest, $highest) { $originName = $this->adapter->quoteTableName($this->origin->getName()); $destinationName = $this->adapter->quoteTableName($this->destination->getName()); $destinationColumns = implode(',', $this->sqlHelper->quoteColumns($this->intersection->destination())); $originColumns = implode(',', $this->sqlHelper->typedColumns($originName, $this->sqlHelper->quoteColumns($this->intersection->origin()))); return implode(" ", ["INSERT IGNORE INTO {$destinationName} ({$destinationColumns})", "SELECT {$originColumns} FROM {$originName}", "WHERE {$originName}.{$this->primaryKey} BETWEEN {$lowest} AND {$highest}"]); }
/** * @return string */ protected function createUpdateTrigger() { $destinationColumns = implode(',', $this->sqlHelper->quoteColumns($this->intersection->destination())); $originColumns = implode(',', $this->sqlHelper->typedColumns('NEW', $this->sqlHelper->quoteColumns($this->intersection->origin()))); $name = $this->trigger('update'); $originName = $this->adapter->quoteTableName($this->origin->getName()); $destinationName = $this->adapter->quoteTableName($this->destination->getName()); return implode("\n ", ["CREATE TRIGGER {$name}", "AFTER UPDATE ON {$originName} FOR EACH ROW", "REPLACE INTO {$destinationName} ({$destinationColumns}) {$this->sqlHelper->annotation()}", "VALUES ({$originColumns})"]); }