/ LJCPHPCodeDoc / LJCDataManagerLib / LJCDataManager / Update


Parameters
$keyColumns - The where clause key columns.
$dataColumns - The data columns.

Returns

The count of affected records.

Syntax

PHP
public function Update(LJCDbColumns $keyColumns, LJCDbColumns $dataColumns)

Updates the records for the provided values.

Remarks

The Update() method updates records in the database using the values from the $dataColumns collection parameter.

The $keyColumns collection parameter contains the data for the where clause.

The $keyColumns parameter is required and must have collection elements or the Update will not be executed.

Example

PHP
 $webCommonPath = "c:/inetpub/wwwroot/LJCPHPCommon";
 require_once "$webCommonPath/LJCDataManagerLib.php";
 require_once "$webCommonPath/LJCDBAccessLib.php";
 
 // See constructor for how to create $connectionValues.
 $tableName = "TableName";
 $manager = new LJCDataManager($connectionValues, $tableName);
 
 $keyColumns = new LJCDbColumns();
 $keyColumns->Add("ID", value:1);
 
 $dataColumns = new LJCDbColumns();
 $dataColumns->Add("Name", value:"NameValue");
 $affectedCount = $manager->Update($keyColumns, $dataColumns);
 
 // $manager->SQL =
 // update TableName
 //   set Name = 'NameValue'
 // where TableName.ID = 1;

Copyright © Lester J. Clark and Contributors.
Licensed under the MIT License.