/ LJCPHPCodeDoc / LJCDataManagerLib / LJCDataManager / Load


Parameters
$keyColumns - The where clause key columns.
$propertyNames - The included column property names.
$joins - _ParamSummary_
$filter - _ParamSummary_

Returns

An array of data records.

Syntax

PHP
public function Load(?LJCDbColumns $keyColumns = null
, ?array $propertyNames = null, ?LJCJoins $joins = null
, ?string $filter = null): ?array

Loads the records for the provided values.

Remarks

Loads records from the database.

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

The optional $propertyNames array parameter contains the names of the properties that will be retrieved. All columns are retrieved if it is null.

Example

PHP
 // Loads the records for the provided values.
 private static function Load(LJCDataManager $manager)
 {
   $nameValue = "NameValue";
   $methodName = "Load()";
 
   $data = new LJCDbColumns();
   $data->Add("Name", value: $nameValue);
   $affectedCount = $manager->Add($data);
 
   // Load the test data.
   // See constructor for how to create $manager.
   $keys = new LJCDbColumns();
   $keys->Add("Name", value: $nameValue);
   $rows = $manager->Load($keys);
   if (null == $rows
     || !is_array($rows)
     || 0 == count($rows))
   {
     echo($manager->SQL);
     echo("\r\n{$methodName} No data retrieved.");
   }
 
   // $manager->SQL =
   // select
   //   TableName.ID,
   //   TableName.Name
   // from TableName
   // where TableName.Name = 'NameValue'
 
   $keys = new LJCDbColumns();
   $keys->Add("Name", value: $nameValue);
   $affectedCount = $manager->Delete($keys);
 }

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