Note that there are some explanatory texts on larger screens.

plurals
  1. POinitializing a private array in a class in php
    text
    copied!<p>yes...im creating a class where i want to use a predefined (ie const) array as a private class member yet php isn't loading the array ie when i try the array_flip in constructor its telling $fieldnamemap is empty.</p> <pre><code>class RETS_translate { // hold the datebase connection that gets passed in constructor private $dbConn; // IMPORTANT! this is the bridge between old system and new system...handle with care private $fieldNameMap = array( "StreetNumber" =&gt; "street_number", "StreetName" =&gt; "street_name", "StreetSuffix" =&gt; "street_suffix", "City" =&gt; "city", "StateOrProvince" =&gt; "state_province", "PostalCode" =&gt; "postal_code", "YearBuilt" =&gt; "year_built", "PropertyType" =&gt; "property_type", "SqFtLivingArea" =&gt; "square_footage", "Bedrooms" =&gt; "bedrooms" , "BathsTotal" =&gt; "bathrooms", "PoolPresent" =&gt; "pool", "WaterFrontPresent" =&gt; "waterfront", "WaterFrontageDesc" =&gt; "water_type", "Parking" =&gt; "parking", "SplitYN" =&gt; "Spli,Floorplan", "HomeOwnersAssocYN" =&gt; "hoa", "AssociationFee" =&gt; "hoa_dues", "Construction" =&gt; "construction", "ExteriorFinish" =&gt; "exterior_finish", "Roof" =&gt; "roof_type", "FireplacesYN" =&gt; "fireplace", "County" =&gt; "county", "Gates" =&gt; "gated_community", "FurnishingstoStay" =&gt; "furnishing", "HomeWarrantyYN" =&gt; "home_warranty", "TaxYear" =&gt; "tax_year", "TaxAmount" =&gt; "tax_amount", "Community55YN" =&gt; "over_55", "ShortSaleYN" =&gt; "Short Sale/Bank Owned", "DwellingStyle" =&gt; "home_style", "PublicRemarks" =&gt; "remarks", "ExteriorFeatures" =&gt; "exterior_features", "InteriorFeatures" =&gt; "interior_features", "PoolDescription" =&gt; "pool_features", "Utilities" =&gt; "utilities", "EquipmentAndAppliances" =&gt; "equipment_appliances", "Floor" =&gt; "floor", "Subdivision" =&gt; "subdivision", "DwellingView" =&gt; "home_view", "AdditionalRooms" =&gt; "additional_rooms", ); private $fieldNameMapFlip; function __construct($inDb=NULL) { // store db connection for later use... $this-&gt;dbConn = $db; $fieldNameMapFlip = array_flip($fieldNameMap); } // end constructor } </code></pre>
 

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