// 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");
}
}
|