Note that there are some explanatory texts on larger screens.

plurals
  1. PONeed to sort large amount of data via a WSDL return
    primarykey
    data
    text
    <p>I have a complex problem that I need some guidance on. We are a non-profit that certifies factories throughout the world as ethical or not. We have a WSDL web service that returns the names and contact info for certified factories in countries around the globe. It accepts a three letter string as the parameter (i.e. <code>BGD</code> for Bangladesh, <code>CHN</code> for China, <code>COL</code> for Colombia).</p> <p>I've designed a page with an HTML select so that the user can pick a country and see a list of factories. I'd like to be able to write a filter of some kind that only puts countries with certified factories in this list and keeps out the ones that don't.</p> <p>I have written the following code that does get this done, however it is excruciatingly slow and really bogs down the site. (For the sake of brevity, I have included only the first few countries. The full array includes about 210 countries. Also, the <code>factCountByCountryID()</code> function returns the number of factories currently in the given country.</p> <pre><code>&lt;?php ini_set("soap.wsdl_cache_enabled", "0"); $client = new SoapClient("http://apollov-dev.worlddata.com:8080/WrapSystem/services/FactoriesWS?wsdl",array("trace" =&gt; 1, "exceptions" =&gt; 0)); $countryList=array("AFG"=&gt;"Afghanistan","ALA"=&gt;"Aland Islands","ALB"=&gt;"Albania","DZA"=&gt;"Algeria","ASM"=&gt;"American Samoa","AND"=&gt;"Andorra","AGO"=&gt;"Angola","AIA"=&gt;"Anguilla","ATG"=&gt;"Antigua and Barbuda","ARG"=&gt;"Argentina","ARM"=&gt;"Armenia","ABW"=&gt;"Aruba","AUS"=&gt;"Australia","AUT"=&gt;"Austria","AZE"=&gt;"Azerbaijan","BHS"=&gt;"Bahamas","BHR"=&gt;"Bahrain","BGD"=&gt;"Bangladesh","BRB"=&gt;"Barbados","BLR"=&gt;"Belarus","BEL"=&gt;"Belgium","BLZ"=&gt;"Belize","BEN"=&gt;"Benin","BMU"=&gt;"Bermuda","BTN"=&gt;"Bhutan","BOL"=&gt;"Bolivia","BIH"=&gt;"Bosnia and Herzegovina","BWA"=&gt;"Botswana","BRA"=&gt;"Brazil","VGB"=&gt;"British Virgin Islands","BRN"=&gt;"Brunei Darussalam","BGR"=&gt;"Bulgaria","BFA"=&gt;"Burkina Faso","BDI"=&gt;"Burundi","KHM"=&gt;"Cambodia","CMR"=&gt;"Cameroon","CAN"=&gt;"Canada","CPV"=&gt;"Cape Verde","CYM"=&gt;"Cayman Islands"); foreach($countryList as $code=&gt;$country) { $params-&gt;countryCd=$code; $number=$client-&gt;factCountByCountryID($params); $factval=$number-&gt;factCountByCountryIDReturn; if($factval!=0) { $countriesWithFactories["$code"]="$country"; } else continue; } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload