Gossamer Forum
Home : Products : DBMan : Customization :

Date -lt and -gt functions still do not work after bug fix was implemented.

Quote Reply
Date -lt and -gt functions still do not work after bug fix was implemented.
The same problem occurs when I try to use the -lt and -gt parameters on the Date field in my DBMan setup. The symptoms are that the browser sits there and thinks for a very long time and then comes back with a "document contains no data" error. A direct query on the Date field (Date=...) works very quickly adn just fine.

any thoughts?

James

------------------
JSS
Quote Reply
Re: Date -lt and -gt functions still do not work after bug fix was implemented. In reply to
Seems we're having a rash of "Document contains no data" errors, but for different reasons. Smile

I think I'll need to look at your database in action before I can even try to come up with a solution.


------------------
JPD





Quote Reply
Re: Date -lt and -gt functions still do not work after bug fix was implemented. In reply to
No problem. Go to http://www.clickhear.com/news/index.shtml. I dont have any links setup in the menu to do -lt or -gt but if you do a manual edit of the URL you can test to see if you see the problem i see...

------------------
JSS
Quote Reply
Re: Date -lt and -gt functions still do not work after bug fix was implemented. In reply to
Okay. I see what you mean. (Nice layout, BTW. Smile)

There could be something wrong with the bugfix. Could you post the code for the bugfix? It's probably something I did.


------------------
JPD





Quote Reply
Re: Date -lt and -gt functions still do not work after bug fix was implemented. In reply to
Thanks!

The code I added to my db.cgi was form the Newest Record Mod that you have listed on your site. The parts I updated are below (sub query and sub get_gate):

If this is hard to read then go to http://www.clickhear.com/news/db.txt.

sub query {
# --------------------------------------------------------
# First let's get a list of database fields we want to search on and
# store it in @search_fields

my ($i, $column, @search_fields, @search_gt_fields, @search_lt_fields, $maxhits, $numhits, $nh,
$field, @regexp, $line, @values, $key_match, @hits, @sortedhits, $next_url, $next_hit, $prev_hit,
$first, $last, $upper, $lower, $left, $right, $restricted);
local (%sortby);

# First thing we do is find out what we are searching for. We build a list of fields
# we want to search on in @search_fields.
if ($in{'keyword'}) { # If this is a keyword search, we are searching the same
$i = 0; # thing in all fields. Make sure "match any" option is
$in{'ma'} = "on"; # on, otherwise this will almost always fail.
foreach $column (@db_cols) {
if (($db_sort{$column} eq 'date') or &date_to_unix($in{'keyword'})) { $i++; next; }
if ($i == $auth_user_field) { $i++; next; }
push (@search_fields, $i); # Search every column
$in{$column} = $in{'keyword'}; # Fill %in with keyword we are looking for.
$i++;
}
}
# else { # Otherwise this is a regular search, and we only want records
# $i = 0; # that match everything the user specified for.
# foreach $column (@db_cols) {
# if ($in{$column} =~ /^\>(.+)$/) { ($db_sort{$column} eq 'date') and (&date_to_unix($1) or return "Invalid date format: '$1'");
# push (@search_gt_fields, $i); $in{"$column-gt"} = $1; $i++; next; }
# if ($in{$column} =~ /^\<(.+)$/) { ($db_sort{$column} eq 'date') and (&date_to_unix($1) or return "Invalid date format: '$1'");
# push (@search_lt_fields, $i); $in{"$column-lt"} = $1; $i++; next; }
# if ($in{$column} !~ /^\s*$/) { ($db_sort{$column} eq 'date') and (&date_to_unix($in{$column}) or return "Invalid date format: '$in{$column}'");
# push(@search_fields, $i); $i++; next; }
# if ($in{"$column-gt"} !~ /^\s*$/) { ($db_sort{$column} eq 'date') and (&date_to_unix($in{"$column-gt"}) or return "Invalid date format: '$in{$column}'");
# push(@search_gt_fields, $i); }
# if ($in{"$column-lt"} !~ /^\s*$/) { ($db_sort{$column} eq 'date') and (&date_to_unix($in{"$column-lt"}) or return "Invalid date format: '$in{$column}'");
# push(@search_lt_fields, $i); }
# $i++;
# }
# }
# Mod for newest records feature
else { # Otherwise this is a regular search, and we only want records
$i = 0; # that match everything the user specified for.
foreach $column (@db_cols) {
if ($in{$column} =~ /^\>(.+)$/) { ($db_sort{$column} eq 'date') and (&date_to_unix($1) or return "Invalid date format: '$1'");
push (@search_gt_fields, $i); $in{"$column-gt"} = $1; $i++; next; }
if ($in{$column} =~ /^\<(.+)$/) { ($db_sort{$column} eq 'date') and (&date_to_unix($1) or return "Invalid date format: '$1'");
push (@search_lt_fields, $i); $in{"$column-lt"} = $1; $i++; next; }
if ($in{$column} !~ /^\s*$/) { push(@search_fields, $i); $i++; next; }
if ($in{"$column-gt"} !~ /^\s*$/) { ($db_sort{$column} eq 'date') and (&date_to_unix($in{"$column-gt"}) or return "Invalid date format: '$in{$column}'");
push(@search_gt_fields, $i); }
if ($in{"$column-lt"} !~ /^\s*$/) { ($db_sort{$column} eq 'date') and (&date_to_unix($in{"$column-lt"}) or return "Invalid date format: '$in{$column}'");
push(@search_lt_fields, $i); }
$in{$column} =~ s/~~/$db_delim/og;
$i++;
}
}


##########################################


sub get_date {
# --------------------------------------------------------
# Returns the date in the format "dd-mmm-yy".
# Warning: If you change the default format, you must also modify the &date_to_unix
# subroutine below which converts your date format into a unix time in seconds for sorting
# purposes.

# my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime(time());
# my (@months) = qw!Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec!;
# ($day < 10) and ($day = "0$day");
# $year = $year + 1900;
#
# return "$day-$months[$mon]-$year";
#}
# Mods for newest record feature

my ($time) = $_[0];
($time) or ($time = time());
my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime($time);
my (@months) = qw!Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec!;
($day < 10) and ($day = "0$day");
$year = $year + 1900;

return "$day-$months[$mon]-$year";
}



------------------
JSS
Quote Reply
Re: Date -lt and -gt functions still do not work after bug fix was implemented. In reply to
Have you made any changes to sub date_to_unix? That's the only other thing I can think of that might be a problem. Except that searches for a specific date work just fine.

I'm trying to think where and what we could add that would help in debugging your script.

What I would do (since I tend to use a "sledge hammer" approach to debugging Smile ) is to set up another database -- just a little temporary one with two fields -- one for a record ID and one for a Date. (Use the autogenerate feature so you don't have to mess with creating forms.) Add 4 or 5 records to it and then try to do a search and see what happens. Use the same db.cgi file that you're using now.

If it works okay, your problem is within your database. If it doesn't work right, I'll try using your little database on my server to see if it's a problem with your server. If it gives me the same problem, then we'll have to see what's up with your db.cgi file.


------------------
JPD





Quote Reply
Re: Date -lt and -gt functions still do not work after bug fix was implemented. In reply to
Try using the code from the "bugfix" mod on my site -- http://www.jpdeni.com/dbman/Mods/bugfix.txt . I made a few changes in the date fix, which I forgot to add to the what's new mod. I did that today, though.


------------------
JPD





Quote Reply
Re: Date -lt and -gt functions still do not work after bug fix was implemented. In reply to
Alas the same problem occurs...maybe I have something corrupt in my database?

------------------
JSS