/ LJCPHPCodeDoc / LJCDataManagerLib / LJCDataManager / MapNames


Parameters
$key - The column property name.
$propertyName - The new property name.
$renameAs - The rename as value.
$caption - The caption value.

Syntax

PHP
public function MapNames(string $key, ?string $propertyName = null
, ?string $renameAs = null, ?string $caption = null)

Sets PropertyName, RenameAs and Caption values for a schema column.

Example

PHP
 // Sets PropertyName, RenameAs and Caption values for a schema column.
 private static function MapNames(LJCDataManager $manager)
 {
   $methodName = "MapNames";
 
   $propertyNames = [
     "Name",
   ];
   // See constructor for how to create $manager.
   $columns = $manager->Columns($propertyNames);
   if ($columns != null
     && count($columns) > 0)
   {
     // Change schema column PropertyName value.
     // Matches by key which is the current PropertyName value.
     $manager->MapNames("Name", "NewName", "", "Caption");
 
     // Get changed column.
     $propertyNames = [
       "NewName",
     ];
     $columns = $manager->Columns($propertyNames);
     if (null == $columns
       || 0 == count($columns))
     {
       echo("{$methodName}: PropertyName change failed.");
     }
 
     // Check changes.
     if ($columns != null
       && count($columns) > 0)
     {
       // Get column by key which is the PropertyName value.
       $column = $columns->Retrieve("NewName");
       $result = "{$column->PropertyName},{$column->RenameAs}";
       $result .= ",{$column->Caption}";
 
       // result:
       // NewName,,Caption
     }
 
     // Reset original column properties.
     // Matches by key which is the current PropertyName value.
     $manager->MapNames("NewName", "Name", "", "Caption");
   }
 }

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