Search Postgresql Archives

Re: Upsert error "column reference is ambiguous"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2025-04-29 at 08:36 +1000, Tim Starling wrote:
> My code would be like
> 
> function upsert( $table, $names, $values, $key, $set ) {
>      if ( $this->type === 'mysql' ) {
>          $conflict = 'ON DUPLICATE KEY UPDATE';
>      } else {
>          $conflict = "ON CONFLICT ($key) DO UPDATE SET";
>      }
>      return $this->query( "INSERT INTO $table ($names) " .
>          "VALUES ($values) $conflict $set" );
> }
> 
> The parameters are a little bit more structured than that, but that 
> gives you the idea.

Another litle "if" to cater for PostgreSQL's "EXCLUDED." would be
such a big problem?

Yours,
Laurenz Albe






[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux