<?php
require('path/to/DatabaseAccess.Class.php');
$DbAccess = new DatabaseAccess("yourHost", "dbName", "dbUser", "dbUserPassword");
$userDatas = $DbAccess->SimpleGet("SELECT * FROM `UserAccounts`");
// Create some placeholders for the data
$ID = "";
$FirstName = "";
// Here we prepare the query that we will reuse
$DbAccess->PrepareStatement("UPDATE `UserAccounts` SET `FirstName` = :FirstName WHERE `ID` = :ID");
// Now bind the parameters that will later hold the data to use in the query
$DbAccess->BindParameter(":ID", $ID);
$DbAccess->BindParameter(":FirstName", $newFirstName);
// we want to use the key to access the array values
foreach (array_keys($userDatas) as $key)
{
// Update the placeholders
$ID = $userDatas[$key]['ID'];
$FirstName = ucfirst($userDatas[$key]['FirstName']);
// Run the query, the parameters are automaticly updated with the placeholders
$numberOfRowsUpdated = $GLOBALS['DatabaseAccess']->ExecuteQuery_Non();
}
|