Get Most Recent Entry

313 views
Skip to first unread message

ChUzEk

unread,
Nov 4, 2009, 7:34:27 AM11/4/09
to PHRETS
Is there a quick way to retrieve the last row (most recent entry) of a
resultant search?

Troy Davisson

unread,
Nov 4, 2009, 7:39:09 AM11/4/09
to phr...@googlegroups.com
Not really, no.  A RETS server typically doesn't send back sorted results so you'd probably have to read through the results yourself, identify which record has the highest modification timestamp and then do something with that record's data.  The times I have seen results sorted, it's usually in ascending order so even it being sorted on the modification timestamp would still make a Limit=1 useless (since you'd get the first record rather than the last).

ChUzEk

unread,
Nov 4, 2009, 8:34:45 AM11/4/09
to PHRETS
OK, I'll figure something out.

Also, I noticed that you have released a new version of PHRETS. I was
fooling around with it and have found that the code does not easily
upgrade. I cannot even log onto the RETS server now, I get a error
reading:

Array ( [type] => phrets [code] => -1 [text] => Cookie file
"phrets_cookies.txt" cannot be written to. Must be an absolute path
and must be writable ) GetMetadataTypes() called but unable to find
GetMetadata location. Failed login?

I created an absolute path and CHMODed the file, but no luck. Any
advice?

Thanks

Gregory Moore

unread,
Nov 4, 2009, 9:21:38 AM11/4/09
to phr...@googlegroups.com
Be sure the file is being written to the correct directory. If you are
pulling the class in from another directory it could be kinda confusing.

If I am correct (and someone tell me if I am wrong), but you shouldn't
have to create a "phrets_cookie.txt" file and CHMOD it... I believe
this file file is created dynamically... you just need to be sure you
have stated correctly where the file needs to be.

Gregg

Troy Davisson

unread,
Nov 4, 2009, 1:05:54 PM11/4/09
to phr...@googlegroups.com
This did change, sort of.  You shouldn't need to declare the SetParam for the cookie_file now.  If you do, I suggest making the file path you give that an absolute path.  For example:

$rets->SetParam("cookie_file", "/home/username/phrets/phrets_cookies.txt");

By not including that SetParam line now, PHRETS will attempt to use the system's temporary directory and create it's own file there.  If it can't do that, it's usually been due to PHP not knowing where the system's temporary folder is but I haven't run into this enough to say for sure.

PHRETS will attempt to create the file it needs to manage the session cookie but if there are folder permission issues keeping that from happening, PHRETS will complain.

ChUzEk

unread,
Nov 5, 2009, 7:02:39 AM11/5/09
to PHRETS
Still no luck. When I put an absolute path, I still get the error:

Array ( [type] => phrets [code] => -1 [text] => Cookie file "/app/
webroot/xml/mris/v1.0rc1/phrets_cookies.txt" cannot be written to.
Must be an absolute path and must be writable ) GetMetadataTypes()
called but unable to find GetMetadata location. Failed login?

And I CHMOD 777 the entire directory, so it should be writable.

If I omit the SetParam line, I get the error:

Warning: tempnam() [function.tempnam]: open_basedir restriction in
effect. File() is not within the allowed path(s): (/home/admin/:/tmp:/
usr/local/lib/php/) in /home/admin/domains/domain.com/public_html/app/
webroot/xml/RETS/phrets_v1.0rc1.php on line 1250
Array ( [type] => phrets [code] => -1 [text] => Cookie file "" cannot
be written to. Must be an absolute path and must be writable )
GetMetadataTypes() called but unable to find GetMetadata location.
Failed login?

Any advice?

Thanks


On Nov 4, 1:05 pm, Troy Davisson <troy.davis...@gmail.com> wrote:
> This did change, sort of.  You shouldn't need to declare the SetParam for
> the cookie_file now.  If you do, I suggest making the file path you give
> that an absolute path.  For example:
>
> $rets->SetParam("cookie_file", "/home/username/phrets/phrets_cookies.txt");
>
> By not including that SetParam line now, PHRETS will attempt to use the
> system's temporary directory and create it's own file there.  If it can't do
> that, it's usually been due to PHP not knowing where the system's temporary
> folder is but I haven't run into this enough to say for sure.
>
> PHRETS will attempt to create the file it needs to manage the session cookie
> but if there are folder permission issues keeping that from happening,
> PHRETS will complain.
>

Gregory Moore

unread,
Nov 5, 2009, 7:05:42 AM11/5/09
to phr...@googlegroups.com
This might seem useless, but it worked for me...

Try writing the entire path to where the PHRETS class resides. Then,
work backwards...

Gregg

ChUzEk

unread,
Nov 5, 2009, 7:34:01 AM11/5/09
to PHRETS
In an offline message, Greg wrote:

If you still get errors... just set the path like so: $rets->SetParam
("cookie_file", "phrets_cookies.txt");

Thanks.

However, that seemed to fix the immediate issue, but created some new
ones. Most notably, I get an error that reads:

Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION
cannot be activated when in safe_mode or an open_basedir is set in /
home/admin/domains/domain.com/public_html/app/webroot/xml/RETS/
phrets_v1.0rc1.php on line 1278

Gregory Moore

unread,
Nov 5, 2009, 7:42:07 AM11/5/09
to phr...@googlegroups.com
cURL needs to be enabled/installed/configured??

Just a guess

Gregory Moore

unread,
Nov 5, 2009, 7:43:13 AM11/5/09
to phr...@googlegroups.com
What version of PHP are you running?

G

ChUzEk

unread,
Nov 5, 2009, 7:50:54 AM11/5/09
to PHRETS
PHP Version 5.2.9

Gregory Moore

unread,
Nov 5, 2009, 7:52:15 AM11/5/09
to phr...@googlegroups.com
I'll look into the bug/error when I get a chance this afternoon...

G


On Nov 5, 2009, at 7:50 AM, ChUzEk wrote:

>
> PHP Version 5.2.9
> >

ChUzEk

unread,
Nov 5, 2009, 8:20:01 AM11/5/09
to PHRETS
Well, with the exception of the curl_setopt error:

Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION
cannot be activated when in safe_mode or an open_basedir is set in /
home/admin/domains/domain.com/public_html/app/webroot/xml/RETS/
phrets_v1.0rc1.php on line 1278

...one of my old scripts seems to be running otherwise. How is the
function used?

The reason I'm looking to upgrade all my previous scripts is that they
totally crash my server if I run them concurrently. The release notes
say that SearchQuery() uses less memory, so I'm looking to see it that
solves my problems.

Troy Davisson

unread,
Nov 5, 2009, 10:49:25 AM11/5/09
to phr...@googlegroups.com
This safemode error is caused by something else.  You need a new SetParam() line:

$rets->SetParam("disable_follow_location", true);

to disable that within cURL.  It's enabled by default to follow the RETS spec but I've rarely seen it used so it's probably OK to disable it.

ChUzEk

unread,
Nov 5, 2009, 12:40:37 PM11/5/09
to PHRETS
Thanks, although a bit tedious making the upgrade. Everything now
seems to work.

BTW, what sort of performance upgrade should one see from using
SearchQuery over Search?

Thanks!

Troy Davisson

unread,
Nov 5, 2009, 12:42:58 PM11/5/09
to phr...@googlegroups.com
Similar speed, greatly reduced memory usage since records are given back to you one-at-a-time in the while looping structure rather than parsing and passing an entire array of results at once.
Reply all
Reply to author
Forward
0 new messages