Gossamer Forum
Home : Products : DBMan : Customization :

ID field = nr. 1 instead of nr. 0 -> can this cause problems?

Quote Reply
ID field = nr. 1 instead of nr. 0 -> can this cause problems?
Hi all!
I want to sort the records descend according to the time they are added (i.e., the youngest first).

I know that there are more sophisticated ways to do so (combination of date and time), but I would like to sort by the ID number (automatically tracked). However, dbman cannot sort by field nr. 0 (this is what one former posting said and I made the same experience). Therefore, I thought that I could set the ID to field 1.

However, I remember that "somewhere out there" somebody said that the ID should be in field nr. 0.

My question: Do you think it can cause any serious long-time problems if I use field nr. 1 for the ID field and nr. 0 for any of the other fields (until now the test-database works fine)?

Thanks and all the best,
Michael
Quote Reply
Re: [Michael R.] ID field = nr. 1 instead of nr. 0 -> can this cause problems? In reply to
I have never seen where you couldn't use the ID field of 0 as the sort by field?

What I do is setup a global sort value in my .cfg files, such as:

$sort_field ='37'; # sort by start date
$sortorder = 'descend'; # last first

Then I use the variable within the subs:

sub html_view_search
sub html_view_failure

as hidden fields in the forms:

<input type="hidden" name="sb" value="$sort_field">
<input type="hidden" name="so" value="$sortorder">

I also use the variables in all the links within the script and footer (view all)

&sb=$sort_field&so=$sortorder

I know I've used the same variables to sort by ID in a few databases. Perhaps you are not currently defining the sort order with view_search?

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] ID field = nr. 1 instead of nr. 0 -> can this cause problems? In reply to
LoisC,
thank you for the reply.
I was looking around and found the posting I referred to. It is:
http://www.gossamer-threads.com/...gforum.cgi?post=3290

In this posting, NgtCrwlr wrote that "Sort-by and sort-order both work properly with any field number that is in the db_def other than 0(zero) being used for sort-by."

Therefore, I thought that this should be the reason for my problem.

Actually, I tried Gossamer's on-line demo and changed the browser address to ... sb=0&so=descend ... and it works!

So, I must have done something wrong in my database and will try to find the problem.
Thank you for the idea to setup a global sort values. I will try this as well.
Greetings,
Michael
Quote Reply
Re: [Michael R.] ID field = nr. 1 instead of nr. 0 -> can this cause problems? In reply to
I'm curious about this as well, as I'm having the same problem: no sort on field no. 0. Are you using the multiple sort mod, by any chance? (I am)
kellner
Quote Reply
Re: [kellner] ID field = nr. 1 instead of nr. 0 -> can this cause problems? In reply to
Just in case - I figured out what the problem was. It had something to do with my parse_form routine: I had replaced the original dbman routine with a "home-made" one that didn't take proper care of cases where a name has the value "0".
kellner
Quote Reply
Re: [kellner] ID field = nr. 1 instead of nr. 0 -> can this cause problems? In reply to
Glad you found the problem and got it working :)

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/