Gossamer Forum
Home : Products : Links 2.0 : Discussions :

changing the Field #

Quote Reply
changing the Field #
I've seen a couple of MODs that renumber the Field #. They just insert the new field in links.cfg and renumber the subsequent fields.

What is the danger in doing this?

Things that I know that would have to happen
-- Several other assignments in links.cfg such as "Field Number of some important fields," "Field number to sort," "Field names to search on."

--the Database delimeter | would have to be inserted at the appropriate place in links.db

Anything else...

Quote Reply
Re: changing the Field # In reply to
The new field would go in links.def not links.cfg

All you need to do is add the new field and then add $db_newfield = 14; in the "Important Fields" section.

Obviously change newfield and 14 to the correct values.

You would then have to modify add.html add_error.html modify.html modify_error.html.

Paul Wilson. Shocked
(Dont blame me if I'm wrong!)
Quote Reply
Re: changing the Field # In reply to
sorry bout the cfg vs def thing ---brain thinking one thing and fingrers typing another....! Old timers disease.

Here's another way of looking at it

If I had the following

# Definition of your database file.
%db_def = (
ID => [0, 'numer', 5, 8, 1, '', ''],
Title => [1, 'alpha', 40, 75, 1, '', ''],
URL => [2, 'alpha', 40, 75, 1, 'http://', '^http|news|mailto|ftp'],
Date => [3, 'date', 15, 15, 1, \&get_date, ''],
Category => [4, 'alpha', 0, 150, 1, '', ''],
Description => [5, 'alpha', '100x6', 600, 0, '', ''],
'Contact Name' => [6, 'alpha', 40, 75, 1, '', ''],
'Contact Email' => [7, 'alpha', 40, 75, 1, '', '.+@.+\..+'],
Hits => [8, 'numer', 10, 10, 1, '0', '\d+'],
isNew => [9, 'alpha', 0, 5, 0, 'No', ''],
isPopular => [10, 'alpha', 0, 5, 0, 'No', ''],
Rating => [11, 'numer', 10, 10, 1, 0, '^[\d\.]+$'],
Votes => [12, 'numer', 10, 10, 1, 0, '^\d+$'],
ReceiveMail => [13, 'alpha', 10, 10, 1, 'Yes', 'No|Yes'],

and I did the following

# Definition of your database file.
%db_def = (
ID => [0, 'numer', 5, 8, 1, '', ''],
Title => [1, 'alpha', 40, 75, 1, '', ''],
URL => [2, 'alpha', 40, 75, 1, 'http://', '^http|news|mailto|ftp'],
Date => [3, 'date', 15, 15, 1, \&get_date, ''],
Category => [4, 'alpha', 0, 150, 1, '', ''],
AltCategories => [5, 'alpha', 0, 150, 1, '', ''],
Description => [6, 'alpha', '100x6', 600, 0, '', ''],
'Contact Name' => [7, 'alpha', 40, 75, 1, '', ''],
'Contact Email' => [8, 'alpha', 40, 75, 1, '', '.+@.+\..+'],
Hits => [9, 'numer', 10, 10, 1, '0', '\d+'],
isNew => [10, 'alpha', 0, 5, 0, 'No', ''],
isPopular => [12, 'alpha', 0, 5, 0, 'No', ''],
Rating => [13, 'numer', 10, 10, 1, 0, '^[\d\.]+$'],
Votes => [14, 'numer', 10, 10, 1, 0, '^\d+$'],
ReceiveMail => [15, 'alpha', 10, 10, 1, 'Yes', 'No|Yes'],

Here I have inserted AltCategories => [5, ...

and renumbered all fields below it.

What else would I have to do...?

I know that some of the "stuff" in links.def would need to be changed....that I would have to renumber the "Field Number of some important fields," "Field number to sort," "Field names to search on," etc,
and add to the database etc.

But what other implications are there of "inserting" instead of "appending" like below?????

# Definition of your database file.
%db_def = (
ID => [0, 'numer', 5, 8, 1, '', ''],
Title => [1, 'alpha', 40, 75, 1, '', ''],
URL => [2, 'alpha', 40, 75, 1, 'http://', '^http|news|mailto|ftp'],
Date => [3, 'date', 15, 15, 1, \&get_date, ''],
Category => [4, 'alpha', 0, 150, 1, '', ''],
Description => [5, 'alpha', '100x6', 600, 0, '', ''],
'Contact Name' => [6, 'alpha', 40, 75, 1, '', ''],
'Contact Email' => [7, 'alpha', 40, 75, 1, '', '.+@.+\..+'],
Hits => [8, 'numer', 10, 10, 1, '0', '\d+'],
isNew => [9, 'alpha', 0, 5, 0, 'No', ''],
isPopular => [10, 'alpha', 0, 5, 0, 'No', ''],
Rating => [11, 'numer', 10, 10, 1, 0, '^[\d\.]+$'],
Votes => [12, 'numer', 10, 10, 1, 0, '^\d+$'],
ReceiveMail => [13, 'alpha', 10, 10, 1, 'Yes', 'No|Yes'],
AltCategories => [14, 'alpha', 0, 150, 1, '', ''],

Here I have appended AltCategories => [14, ...


Thanks for the response!!!!

Gene

Quote Reply
Re: changing the Field # In reply to
There should be none.

Links2 will automatically update itself. All you have to do is add the new fields in your add.html add_error.html modify.html modify_error.html templates is necessary.

Paul Wilson. Shocked
(Dont blame me if I'm wrong!)
Quote Reply
Re: changing the Field # In reply to
In Reply To:
What else would I have to do...?
If you already have an existing database, then this is a huge problem you've created. If you do not have any records in your database, then there is no problem.

The best thing to do with adding fields to LINKS.DEF when you already have records in the LINKS.DB file is to use the upgrade.pl script that is posted in the Links 2.0 Customization Forum.

In Reply To:

Links2 will automatically update itself...


Absolutely not correct...if you have records in your links.db file and you add a field or re-number fields, then the links.db file will become corrupted. Yes...records in MYSQL are updated automatically when you add new fields, however, in flat file systems like LINKS 2.0, you have to update the FLAT FILE anytime you add new fields.


Regards,

Eliot Lee
Quote Reply
Re: changing the Field # In reply to
Yes, I know what you are saying. If I append a new field to an existing database, then I have to add the delimiter at the end of each record -- either manually or by the program you suggest.

I would assumme ( have to be careful with THAT word ), that if I "inserted" a field into an existing database, that I would have to "insert" the delimiter in the appropriate place in the database -- that would be a manual process -- and a trickey one, at that.

And as a theoretical discussion, I could rearrange the links.def field definitions as long as I rearranged the actual database file

For example if my Links.def file looked like

%db_def = (
ID => [0, 'numer', 5, 8, 1, '', ''],
Title => [1, 'alpha', 40, 75, 1, '', ''],
URL => [2, 'alpha', 40, 75, 1, 'http://', '^http|news|mailto|ftp'],
Date => [3, 'date', 15, 15, 1, \&get_date, '']
)

and my data looked like

2|ABC Signs|http://www.abcsign.com|12-Dec-2000
3|Loves Hdwe|http://www.loveshd.com|16-Dec-2000
4|Gills Rest|http://www.gilleys.com|11-Dec-2000
5|NCR|http://www.ncr.com|18-Dec-2000

that I could change it to look like

%db_def = (
ID => [0, 'numer', 5, 8, 1, '', ''],
Date => [1, 'date', 15, 15, 1, \&get_date, ''],
URL => [2, 'alpha', 40, 75, 1, 'http://', '^http|news|mailto|ftp'],
Title => [3, 'alpha', 40, 75, 1, '', '']
)

2|12-Dec-2000|http://www.abcsign.com|ABC Signs
3|16-Dec-2000|http://www.loveshd.com|Loves Hdwe
4|11-Dec-2000|http://www.gilleys.com|Gills Rest
5|18-Dec-2000|http://www.ncr.com|NCR

with no real harm...as long as I kept things "matched up"

( and assumming I changed all that "stuff" immediately below the definitions in Links.def )


--------------------------
Could I also change the order of the records from immediately above to the following?

2|11-Dec-2000|http://www.gilleys.com|Gills Rest
3|16-Dec-2000|http://www.loveshd.com|Loves Hdwe
4|18-Dec-2000|http://www.ncr.com|NCR
5|12-Dec-2000|http://www.abcsign.com|ABC Signs

This is a little tickier if I have another file "related" to the links.db file. For example, if I have the comments2 MOD installed where a comment record is created using the ID to link the two together.

Are there any other situations....?

--------------------------

No, I am not planning on doing that to my own database...too much trouble and too much room for error....but not too hard either....

I just want to know what the boundaries are...what I can or cannot do, and if I do something, what effect will that have...

This started when I saw a MOD that "inserted" a new field instead of "appending" a new field which almost all of the MOD were doing.....

So my question was --- what if I "insert" a field....Am I OK as long as I "match up" the fields in the database ( where the data in the data field does in fact match the database definition of that field )? And change the "important" stuff, etc just below in the links.def file. What else do I have to be aware of....?

Like I said, I don't plan on doing this---I just want to know the theoretical boundaries....besides, this is the place for discussion, right...!?!?

Thanks for your thoughts and input.

Gene

Quote Reply
Re: changing the Field # In reply to
In Reply To:
If I append a new field to an existing database, then I have to add the delimiter at the end of each record -- either manually or by the program you suggest.
Right...if you add a field at the END of the %db_def hash in the links.def file, then you would add a delimiter character at the END of each line in the links.db.

In Reply To:
), that if I "inserted" a field into an existing database, that I would have to "insert" the delimiter in the appropriate place in the database -- that would be a manual process -- and a trickey one, at that.
IF you do want to do it "manually", although NOT really recommended, then you SHOULD use an offline spreadsheet or database program, like Access or Excel. And if you want more information on using these programs, search the forums for offline editing Access.

In Reply To:
And as a theoretical discussion, I could rearrange the links.def field definitions as long as I rearranged the actual database file
Okay...you're right...but again, the key thing here is that you do not simply use a TEXT EDITOR to update your existing database file (as mentioned a number of times in these forums). You should either use the script I recommended OR use a database program like ACCESS to update your EXISTING links.db file.

In Reply To:
Could I also change the order of the records from immediately above to the following?
That would NOT be wise, especially if you are going to use USER interactive features like EXTERNAL RATING FORM or OUTSIDE SEARCH BOX modification. Plus when you email LINK OWNERS about their links, their IDs will constantly change. Re-arranging records by ID is NOT a smart thing to do at all.

In Reply To:
This is a little tickier if I have another file "related" to the links.db file. For example, if I have the comments2 MOD installed where a comment record is created using the ID to link the two together.
Right...if you re-arrange the records in the links.db, then you will have to PAINSTAKINGLY update the comments2.db file...which is NOT a very easy thing to do at all.

In Reply To:
what if I "insert" a field....Am I OK as long as I "match up" the fields in the database ( where the data in the data field does in fact match the database definition of that field )? And change the "important" stuff, etc just below in the links.def file. What else do I have to be aware of....?
Other than the heeding advise I've given you so far, there is really no harm in ADDING fields in the links.db JUST so that you properly update your EXISTING database file. With MySQL and other SQL applications (like MSQL), adding fields and removing them is NOT a big deal AT all, but with a flat file system like LINKS 2.0, you do need to PAY close attention to how you change the database definition files.

In Reply To:
Like I said, I don't plan on doing this---I just want to know the theoretical boundaries....besides, this is the place for discussion, right...!?!?
That is correct...although this issue has been covered quite a few times in the past...with a bit of searching, you will find relevant Threads where these issues have been raised and addressed.

Good luck!




Regards,

Eliot Lee
Quote Reply
Re: changing the Field # In reply to
Thanks....

That is exactly what I needed to know....

As I said, I don't plan on doing any of those...I just want to know so I could learn....

My field count is now at 25....so I have I've done a lot....just wanted to improve my underdstanding....

Gene

Quote Reply
Re: changing the Field # In reply to
Keep in mind that some users have experienced problems with more than 150 fields in their flat file programs, like DBMAN and LINKS. And the more fields (data) you add, the larger your database file will become and many users have found the maximum number of records to be between 3,000 and 6,000 records with a size of 1.0 MGs to 1.5 MGs.

There are MANY limits to flat file systems...read the MySQL Threads I've posted replies to in the Perl/CGI Forum and you will see that there are MANY limits to flat file applications...too many that I have switched to MySQL using LINKS SQL and a variation of DBMAN SQL.

Regards,

Eliot Lee
Quote Reply
Re: changing the Field # In reply to
Thanks for the info...

I have seen a comment or two from you on that subject before....

Just after coming across Links one of my first questions to you was whether to use Links or Links MySQL. You recommended getting to know Links and possibly switching later. Which was good advice....I doubt that I approach the limits you mentioned....But I work with SQL so I thought maybe that was the place to start.

I'm pleased with Links but if you need more, then it is nice to know the SQL version exists....