0

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.

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" => "street_number",
        "StreetName" => "street_name",
        "StreetSuffix" => "street_suffix",
        "City" => "city",        
        "StateOrProvince" => "state_province",
        "PostalCode" => "postal_code", 
        "YearBuilt" => "year_built",
        "PropertyType" => "property_type",
        "SqFtLivingArea" => "square_footage",
        "Bedrooms" => "bedrooms" ,
        "BathsTotal" => "bathrooms",
        "PoolPresent" => "pool",
        "WaterFrontPresent" => "waterfront",
        "WaterFrontageDesc" => "water_type",
        "Parking" => "parking",  
        "SplitYN" => "Spli,Floorplan",
        "HomeOwnersAssocYN" => "hoa",
        "AssociationFee" => "hoa_dues",
        "Construction" => "construction",
        "ExteriorFinish" => "exterior_finish",
        "Roof" => "roof_type",       
        "FireplacesYN" => "fireplace",
        "County" => "county",  
        "Gates" => "gated_community",
        "FurnishingstoStay" => "furnishing",
        "HomeWarrantyYN" => "home_warranty",
        "TaxYear" => "tax_year",     
        "TaxAmount" => "tax_amount",
        "Community55YN" => "over_55",
        "ShortSaleYN" => "Short Sale/Bank Owned",
        "DwellingStyle" => "home_style",
        "PublicRemarks" => "remarks",
        "ExteriorFeatures" => "exterior_features",
        "InteriorFeatures" => "interior_features",
        "PoolDescription" => "pool_features",
        "Utilities" => "utilities",  
        "EquipmentAndAppliances" => "equipment_appliances",
        "Floor" => "floor",          
        "Subdivision" => "subdivision",    
        "DwellingView" => "home_view", 
        "AdditionalRooms" => "additional_rooms",

        );  

        private $fieldNameMapFlip;                                   

      function __construct($inDb=NULL) {

        // store db connection for later use...
        $this->dbConn = $db;

        $fieldNameMapFlip = array_flip($fieldNameMap);

      }  // end constructor 

    }
0

2 Answers 2

1

Since it's part of the class you need to access the array using $this. Change

$fieldNameMapFlip = array_flip($fieldNameMap);

to

$fieldNameMapFlip = array_flip($this->fieldNameMap);
Sign up to request clarification or add additional context in comments.

Comments

0

$fieldNameMapFlip = array_flip($this->fieldNameMap);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.