/ LJCPHPCodeDoc / LJCDataManagerLib / LJCDataManager / Retrieve


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

Returns

An array of record columns.

Syntax

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

Retrieves the record for the provided values.

Remarks

Retrieves a single record 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
 // Retrieves the record for the provided values.
 private static function Retrieve(LJCDataManager $manager)
 {
   $nameValue = "NameValue";
   $methodName = "Retrieve()";
 
   $data = new LJCDbColumns();
   $data->Add("Name", value: $nameValue);
   $affectedCount = $manager->Add($data);
 
   // Retrieve the test data.
   // See constructor for how to create $manager.
   $keys = new LJCDbColumns();
   $keys->Add("Name", value: $nameValue);
   $row = $manager->Retrieve($keys);
   if (null == $row
     || !is_array($row)
     || 0 == count($row))
   {
     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.