[mapguide-users] Mix of selectfeature and selectaggregate query
Jackie Ng
jumpinjackie at gmail.com
Fri Dec 18 08:28:45 EST 2009
Two things I see:
- It looks like 'Postcode' is not part of the properties to be returned.
Only 'Postcodegroup' is there.
- You're closing the $dataReader before you're iterating through your
results, and that call is not correct PHP syntax ($dataReader->Close()
instead of $dataReader.close())
Hope that helps
- Jackie
Jo Cook wrote:
>
> Hi Dave,
>
> Thanks for that- I've tried to implement it as a single selectaggregate
> query, but I'm still missing something. I suspect (though I don't really
> understand what I'm doing) that it's falling over at the dataReader
> section. If you (or someone could have a look at my code I'd really
> appreciate it. The relevant code is as follows:
>
> MgInitializeWebTier ($webconfigFilePath);
>
> $userInfo = new MgUserInformation($sessionId);
> $siteConnection = new MgSiteConnection();
> $siteConnection->Open($userInfo);
>
> $map = new MgMap($siteConnection);
> $map->Open($mapName);
>
> $filter = "POSTCODE LIKE '$SMAlocation%'";
> //echo $filter;
>
> $queryOptions = new MgFeatureAggregateOptions();
> $queryOptions->SelectDistinct(true);
> $queryOptions->AddFeatureProperty("Postcodegroup");
> $queryOptions->SetFilter($filter);
>
>
> $layers = $map->GetLayers();
> $selLayer = $layers->GetItem($SMAlayer);
>
>
> $featureresourceID = new MgResourceIdentifier($selLayer->
> GetFeatureSourceID());
> $featureclassname = $selLayer->GetFeatureClassName();
> $featureService = new MgFeatureService;
> $dataReader =
> $featureService->SelectAggregate($featureresourceID, $featureclassname,
> $queryOptions);
> print_r($dataReader);
> $dataReader.close();
>
> echo "<p>Postcodes matching your criteria:</p>";
>
> while ($dataReader->ReadNext()) {
>
> $postcode = $dataReader->GetString('Postcode');
> echo $postcode."<br />";
> }
> echo"</p>";
>
> }
>
> Thanks
>
> Jo
>
> Dave Wilson wrote:
>>
>> There is a filter on SelectAggregates just like SelectFeatures. You
>> should be able to add a PostalCode LIKE clause using this if I am not
>> mistaken.
>>
>> Dave
>>
>>
>>
>
>
--
View this message in context: http://n2.nabble.com/Mix-of-selectfeature-and-selectaggregate-query-tp4176453p4186531.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list