zendframework / zend-db

Db component from Zend Framework
BSD 3-Clause "New" or "Revised" License
101 stars 122 forks source link

Zend\Db\Sql\Replace? #6

Open Koopzington opened 9 years ago

Koopzington commented 9 years ago

Zend\Db\Sql is missing a way to create a REPLACE INTO table_name VALUES(row_data) statement. Thought, I'd add this here 'cause apparently noone else was missing that feature.

weierophinney commented 9 years ago

We've purposely not implemented the feature in the past, as it's not part of any ANSI SQL standards, which means it would require emulation on many platforms. However, it appears that in recent years, most platforms implement it (see http://troels.arvin.dk/db/rdbms/#functions-REPLACE), and do so in essentially the same way. (SQLite even implements it, though that comparison does not include SQLite.)

As such, we can potentially add it as a feature at this time.

mattfletcher commented 7 years ago

@weierophinney the link you have given refers to the REPLACE string function, rather than REPLACE INTO syntax referred to by @Koopzington

REPLACE INTO allows one to ask if a matching record exists, and then either INSERT or UPDATE a record depending on the answer, in a single statement.

froschdesign commented 7 years ago

@mattfletcher

the link you have given refers to the REPLACE string function, rather than REPLACE INTO syntax

Right!

REPLACE INTO allows one to ask if a matching record exists, and then either INSERT or UPDATE a record depending on the answer, in a single statement.

The same applies here:

We've purposely not implemented the feature in the past, as it's not part of any ANSI SQL standards, which means it would require emulation on many platforms.

The problem: every DBMS uses an own implementation outside from any standard. For example:

So the labels for this issue are correct: "help wanted"

michalbundyra commented 4 years ago

This repository has been closed and moved to laminas/laminas-db; a new issue has been opened at https://github.com/laminas/laminas-db/issues/147.