0

I am trying to execute a prepared statement on MySQL server, I am generating Insert, Update and Select query and run it on the server. Update query is failing with no error (returning rowCount() as zero) but Insert ans Select are successful. but when I replace the paramValue with its value and run it on MySQL its successfull

            public function __connectToDB() {
            try {
                $this->__connection = new PDO ( "mysql:host=localhost;dbname=spatim-user", DATABASE_USERNAME, DATABASE_PASSWORD );
                $this->__connection->setAttribute ( PDO::ATTR_EMULATE_PREPARES, false );
                $this->__connection->setAttribute ( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );

            } catch ( PDOException $e ) {
                die ( "connection failed: " . $e->getMessage () );
            }
        }

        try {
            $this->__connectToDB ();
            $stmt = $this->__connection->prepare("UPDATE `user-flags` SET `profile-configured`=':set_profile_configured' WHERE `user-id`=':get_user_id';");
            if($stmt->execute(array("set_profile_configured" => "1", "get_user_id" => "58325edf7998c")) !== true) {
                return false;
            }
            return $stmt->rowCount();
        } catch ( PDOException $e ) {
            return false;
        }

This is the SQL command and parameters I am passing:

Masoud
  • 333
  • 1
  • 10

0 Answers0