Jump to content

PHP PDO


razorsese

Recommended Posts

How I can increment a value into database ?!

When I try whit my code it's replacing the data from mysql database not summing up

 

$conn = new PDO( DBN, DB_USER, DB_PASS );
      $sql = "UPDATE articles SET rating =:rating+1, totalv=:totalv+1 WHERE id = :id";
  $st = $conn->prepare ( $sql );
  $st->bindValue( ":rating", $this->rating, PDO::PARAM_INT );
  $st->bindValue( ":id", $this->id, PDO::PARAM_INT );
  $st->bindValue( ":totalv", $this->totalv, PDO::PARAM_INT );
  $st->execute();
      $conn = null;

Link to comment
https://forums.phpfreaks.com/topic/260279-php-pdo/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.