sql - RETURNING clause for PostgreSQL UPDATE with PHP/PDO -


I execute a simple postgresql update:

  Update data SET gender = TMP WHERE data from bottom (tmp .champ2) .mail = tmp.champs1 and (data is generated or data. Gender = '') and not TMP.chips2 and TMP.chips2! Returning gender   

But how do I get this result with PhD, PDO?

I try to do something like this:

  echo $ requete = "update data" $ value. "TMP WHERE data from" = less (tmp.champs ". $ Num.") .mail = tmp champs ". $ Email "and (Data is". $ Value. "Tap or data. $$ Value." = '') And tmp.champs is not ". $ Num." And neither tmp.champs "$ Num." = '' Returning ''. $ Value; $ Db-> Executive ($ requete); $ Db-> Launch (PDO :: FETCH_NUM); $ Row echo [0];  

The correct number of updated rows does not return.

According to:

PDO: exec () executes a SQL statement in a function call, returns the number of rows affected by the statement.

Your current code is $ Db-> exec ($ requete); ignores return value, which is a mistake, for example Should be:

  $ affect_root = $ db-> exec ($ requete);  

A to affect the number of rows Returning clause is not necessary (except this, it does not exist in some backends which supports the PDO) In addition to updating the purpose of Returning , all in the same question .

In this case where the back / <> code is necessary the results are received Should be used instead, the PHP code is similar to receiving results if the question is a SELECT .


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Algorithm negotiation fail SSH in Jenkins -

java - Messages from .properties file do not display UTF-8 characters -