[mapguide-users] Create new column in data source

Jim O'Leary joleary.public at gmail.com
Tue Sep 18 14:19:34 EDT 2007


I am able to add the new property to the class definition like this:

$propertyCollection = new MgPropertyCollection();
$textProperty = new MgDataPropertyDefinition('AText');
$textProperty->SetDataType(MgPropertyType::String);
$textProperty->SetReadOnly(false);
$textProperty->SetLength(255);
$resId = new MgResourceIdentifier($layer->GetFeatureSourceId()); // $layer
is already defined
$schemaClass = explode(':', $layer->GetFeatureClassName());
$classDefinition = $featureService->GetClassDefinition($resId,
$schemaClass[0], $schemaClass[1]);
$properties = $classDefinition->GetProperties();
$properties->Add($textProperty);

Looping through the properties shows that the property has been added:

$numberProperties = $properties->GetCount();
for($i=0;$i<$numberProperties;$i++)
{
        $propertyDef = $properties->GetItem($i);
        print $propertyDef->GetName() . "<br>";
}

However, the new property appears to be only in memory. Is there a way to
permanently ALTER (to use an SQL term) the class with the new property?

Thanks





Jim O'Leary wrote:
> 
> I would like my user to be able to add a new column to a SHP / SDF file at
> run time. I have the code from the GT sample that shows how to create a
> new MgDataPropertyDefinition:
> 
> $textProperty = new MgDataPropertyDefinition('Text');
> $textProperty->SetDataType(MgPropertyType::String);
> $textProperty->SetReadOnly(false);
> $textProperty->SetLength(255);
> 
> However, this code goes on to create a new class and then a new feature
> source. I already have those, but want only to add this new column. Any
> suggestions?
> 
> Thanks.
> 

-- 
View this message in context: http://www.nabble.com/Create-new-column-in-data-source-tf4471689s16610.html#a12763007
Sent from the MapGuide Users mailing list archive at Nabble.com.



More information about the mapguide-users mailing list