Rets to MySQL

332 views
Skip to first unread message

gg

unread,
Jan 26, 2016, 11:23:33 AM1/26/16
to PHRETS
Is it possible to create a MySQL table with V 2?

This does not seem to work with my install and do not see any information for V2
https://github.com/troydavisson/PHRETS/wiki/Create%20MySQL%20tables%20from%20RETS%20metadata

Thanks

gg

unread,
Jan 26, 2016, 1:15:59 PM1/26/16
to PHRETS
Nevermind phpmyadmin created the proper structure automatically.

Gennadiy Kofman

unread,
Jan 26, 2016, 1:55:36 PM1/26/16
to PHRETS
How did phpmyadmin create the proper structure?  What did you feed it?  phpmyadmin can't actually accept any php scripts, it just executes mysql queries.  But you still need to generate the query with php.

The link you posted is for version 2 and it works fine on my machine.

gg

unread,
Jan 27, 2016, 12:42:06 PM1/27/16
to PHRETS
I exported the RETS response to csv and then imported the csv manually into an empty table with phpmyadmin, It created the appropriate column types. Current issue is the mls here seems to limit listings returned to 2500 which is around half of everything active. I would like to be able to order by a field and use a limit to get 2 responses containing everything. Right now I am doing it using start and end dates that stay under 2500, but would rather find a solution that did not require manual changing.

Gennadiy Kofman

unread,
Jan 27, 2016, 1:04:28 PM1/27/16
to PHRETS
Oh... you were talking about the data, not the structure (metadata)?

You can use limit / offset to get what you need.  You just put it in a loop and then it doesn't matter how many records there are.

So first call would be limit 2500, offset 0.  Second call would be limit 2500, offset 2500.  Third call would be limit 2500, offset 5000, etc. Until you have all of them.

Although sometimes I have to start at offset 1 (I'm not entirely sure why).

gg

unread,
Jan 27, 2016, 2:01:56 PM1/27/16
to PHRETS
I did want to create the structure first - however the phpmyadmin figured out the best choice from the type of data in the cells I guess. I'm not sure the magic, but seems to be appropriate enough for my use.

For something like this how would I put the limit and offset?
foreach ($property_classes as $pc) {
    // generate the DMQL query
    $query = "(L_StatusCatID=1),(L_State=ID),(L_ListingDate=2010-01-01-2015-10-31),(L_SaleRent=S)";

    // make the request and get the results
    $results = $rets->Search('Property', $pc, "(L_StatusCatID=1),(L_State=ID),(L_ListingDate=2010-01-01-2015-10-31),(L_SaleRent=S)");

    // save the results in a local file
    file_put_contents('data/Property_' . $pc . 'a.csv', $results->toCSV());
}

Thanks. I can look further on my own but did not see it initially and moved on.

Mario Lacunza

unread,
Jan 27, 2016, 2:05:10 PM1/27/16
to PHRETS

check examples in the wiki.

Enviado desde mi LG G3

--
You received this message because you are subscribed to the Google Groups "PHRETS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phrets+un...@googlegroups.com.
To post to this group, send email to phr...@googlegroups.com.
Visit this group at https://groups.google.com/group/phrets.
For more options, visit https://groups.google.com/d/optout.

Gennadiy Kofman

unread,
Jan 27, 2016, 3:08:01 PM1/27/16
to PHRETS
I doubt it did it the right way.  Not sure how it would know how many decimal places from a csv or max length of var chars, or text field vs var char, etc.  It might seem correct at first glance, but you might have problems in the future.

As for an example:

$results = $rets->Search('Property', $pc, $query, ["Limit" => 2500, "Offset" => 1]);

gg

unread,
Jan 27, 2016, 3:40:34 PM1/27/16
to PHRETS
Yes. You are right. I thought of that. It seems to have created the max needed for the 100 properties I loaded initially - however there may be eventually an 8 figure home so I will bump a few up. Rets is probably good for some but this db is stupidly large - like 300 columns - half of which are not used and many seem redundant. So I really only use maybe 40 of them and those I can check. I could not get the script for structure creation to work and the errors I received I saw only responses here that it was not 2.0. Thanks for the advice.
Reply all
Reply to author
Forward
0 new messages