PHP Classes

File: Example.UpdateSingleRow.php

Recommend this page to a friend!
  Classes of Dustin Ruckman   DB Access using PDO   Example.UpdateSingleRow.php   Download  
File: Example.UpdateSingleRow.php
Role: Example script
Content type: text/plain
Description: Update a single row by ID using parameters.
Class: DB Access using PDO
Query MySQL tables with prepared queries using PDO
Author: By
Last change: My variable names were wrong
Date: 9 years ago
Size: 561 bytes
 

Contents

Class file image Download
<?php

require('path/to/DatabaseAccess.Class.php');

$DbAccess = new DatabaseAccess("yourHost", "dbName", "dbUser", "dbUserPassword");

$ID = "1000"; // Some ID to update
$newFirstName = "Tom";
$newLastName = "Someuser";

$DbAccess->PrepareStatement("UPDATE `UserAccounts` SET `FirstName` = :FirstName, `LastName` = :LastName WHERE `ID` = :ID");
$DbAccess->BindParameter(":ID", $ID);
$DbAccess->BindParameter(":FirstName", $newFirstName);
$DbAccess->BindParameter(":LastName", $newLastName);
$numberOfRowsUpdated = $DbAccess->ExecuteQuery_Non();