/ LJCPHPCodeDoc / LJCDataManagerLib / LJCDataManager / Add


Parameters
$dataColumns - The data columns.

Returns

The count of affected records.

Syntax

PHP
public function Add(LJCDbColumns $dataColumns) : int

Adds the record for the provided values.

Remarks

The Add() method uses the values from the $dataColumns collection parameter to insert a record into the database.

Example

PHP
 include_once "LJCRoot.php";
 $prefix = RelativePrefix();
 include_once "$prefix/LJCPHPCommon/LJCDataManagerLib.php";
 include_once "$prefix/LJCPHPCommon/LJCDBAccessLib.php";
 
 // See constructor for how to create $connectionValues.
 $tableName = "TableName";
 $manager = new LJCDataManager($connectionValues, $tableName);
 
 $dataColumns = new LJCDbColumns();
 $dataColumns->Add("Name", value:"NameValue");
 $affectedCount = $manager->Add($dataColumns);
 
 // $manager->SQL =
 // insert into TableName
 // (
 //   Name
 // )
 // values
 // (
 //   Name = 'NameValue'
 // )

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