Gossamer Forum
Home : Products : DBMan : Customization :

When field is duplicate: put in another database

Quote Reply
When field is duplicate: put in another database
Hi,

I want to make a list of ppl from different country's. When a user adds himself and the country is already in default.db, I want to add him automatically in <countryname.db>. I have a list like 'au australia', 'nl netherlands' ... I want to make the databases from all country's like 'au.db' and 'nl.db', so only the first two characters of the countryname. Is 't possible to make this? (e.g. with a sort of left$ like in Basic)?

One example:

if nl Netherlands is in the default.db already, the whole record has to be placed in 'nl.db', not in the default.db.


------------------
Jan
Quote Reply
Re: When field is duplicate: put in another database In reply to
Yes, there is a similar function to the Basic $left. The syntax is

$value = substr($string,$offset,$length);

where
$string is the whole string
$offset is the point at which you start (the first character is at position 0)
$length is how long you want it.

So, if your "au australia" was in a string called $countries, you would use

$abbrev = substr($countries,0,2);

As for the other part of what you want to do, I wouldn't even know where to start. Smile

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





Quote Reply
Re: When field is duplicate: put in another database In reply to
Do you mean it's that difficult? Or do you have to less information?
Quote Reply
Re: When field is duplicate: put in another database In reply to
I just wouldn't know where to start. It might not be that hard to actually accomplish, but I would need a lot of "pondering" time to think about it.


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





Quote Reply
Re: When field is duplicate: put in another database In reply to
Why do you want the separate databases? Why not just add country as a field? Then if you want all from Australia, just add that as a search option?

Or is the reason strictly volume related? There is an SQL version available, email me for details..

Cheers,

Alex
Quote Reply
Re: When field is duplicate: put in another database In reply to
Well, I have to make a database with ppl from country's in the whole world, let's say about 200 country's. I want to make one list with 1 person per country (the one who added him-/herself first). But other ppl who want to be on the list (where their country already is) I have to put in another db. Because if I put all users in one list, I will get thousands of records and then it's very slow! So I thought, maybe I can check in the 'add'-function if the country is already there (if(rec'Country') or something like that) then add the record to (rec'country'.db). Do you think this is possible? I will get 200 databases, but it's faster and also easier to show the list from one member per country. Or do you have a better idea? Maybe it isn't as slow as I think?


------------------
Jan
Quote Reply
Re: When field is duplicate: put in another database In reply to
I think I have to add my routine (that is looking for duplicates and then saves it in another db) in db.cgi right? At this point:

if ($status eq "ok") {
open (DB, ">>$db_file_name")

I have to change it ($db_file_name="rec{'country')"+".db") or something?



------------------
Jan