Search code examples
phpsqllookup-tablesretsphrets

RETS DMQL2 Query Issues


I am having trouble getting data when I use the system name "proptype".

Here is my code for the DMQL2 Query (Using PHRets):

 $search = $rets->SearchQuery(
        "Property",             // Resource
        tt_res,                 // Class
        "(dtlist=1990-01-01+), (proptype=1)",   // DMQL
        array(
            "Select" => "listno,taxes,taxid,status,premarket,ownertype,image,dtphoto,housenum,dirpre,street,dirpost,coordew,coordns,city,state,zip,nonstandaddress,latitude,longitude,proptype,style,listprice,agent,contact,contacttype,contactph1,totbathfull,totbathhalf,totbath,totbed,totsqf,publicremarks,taxid,taxes,dimacres,yearblt,featuresint,featuresext,dtlist,windows,heating,aircon,basmntfin,floor,proptype,lotfacts,roof,landscape,exterior,deck,patio,garage,capgarage,capcarport,inclusions,amenities,water,utilities,pool,zoningchar,cooling,heating,dtlist,schooldistrict,schoolelem,schooljunior,schoolprivate,schoolsenior,schoolother",
            //'Select' => *,
            "Format"    => "COMPACT",
            "Count"     => 1,
            "Limit"     => 99
        )
        );

If I remove the (proptype=1) from the search query, the query brings back data. With it (proptype=1), I get the following error:

Array ( [type] => rets [code] => 20203 [text] => Internal SQL error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1')))' at line 1 )

If I put (proptype='1'), I get the following error:

Array ( [type] => rets [code] => 20203 [text] => Could not parse DMQL2 Query: Lookup PROPTYPE_16 defines no lookup type with value: ''1'' at or near position 94. [...(proptype= !-->'1')),((sta] )

From my understanding, and information given from retsmd, "proptype" or property type, is a LookupMulti (MultiValue Lookup) interpretation type. It also has 6 rows, with values 1-6. I am not sure I am structuring the query correctly MultiValue Lookup.

Can anybody help shed light on this for me? I am stumped.


Solution

  • The proptype field is a look up field. RETS requires queries use the lookup operator (=|) when using searching on codes of a lookup field.

    Try using (proptype=|1)