Gossamer Forum
Home : Products : DBMan : Customization :

add one record in two different '.db' files

Quote Reply
add one record in two different '.db' files
Hi

i need to include simultanuously one record in two different '.db' files (ex: '1.db' and '2.db') which are managed by two different '.cfg' files (with same number of fields).

the backup mod doesn t suit because each time i add a record in 'db1' the mod replaces ALL the content of '2.db'.
i want just to add ONE record in the '1.db' and '2.db', that wouldn t affect all the records of '2.db'.

what for ?
when i add a 'page' with 'page-db', i want it to be manageable by 'menu-db'.
then, with the 'menu-db', i get the 'title' and 'ID' of the 'page-db'.
but in the 'menu-db' i want to modify, add new records, ... i want 'menu-db' to be independent while receiving new records from 'page-db' (without deleting the 'menu.db' content).

not sure i explain well. do u understand what i mean ???

Quote Reply
Re: [jigme] add one record in two different '.db' files In reply to
Not sure I understand, but sounds somewhat like what I do. What I do is have 1 database with 2 configs and 2 html.pl

The reason is so that registered users can add, modify etc. and everyone else can view. Also the view html.pl displays records very differently (displays more records). I use the 2 html.pl files mostly to make the formatting different for the 2 types of users, if I tried to keep it all in one html.pl file it might get too confusing (I like to work on either the view format or the add/modify format at a time). The 2 configs of course control the permissions.

Sorry if that's not the same thing.


Quote Reply
Re: [joematt] add one record in two different '.db' files In reply to
Jigme,

if what you want to do is have different html displayed (which also might include enabling certain functions for some users, and others for others), I think joematt's suggestion is a better idea: use the same database file, but code different html routines. These might also be included in one and the same html.pl; it all depends on your preferences and how much of the code differs for the various setups you want.

You can then use name/value-pairs passed through a query-string to filter html output.

For example: I have databases which are accessed (a) by a restricted group of users that modify, add or delete records, and (b) via the web through a default user who only gets to view entries as results of specific search operations, but not all entries.

I have coded the search results differently, depending on whether there is an input name "generate". If this name has a value in the query-string, then html_view_success calls html_record_generate for the default webpage html, if it doesn't, it calls ordinary html_record for the restricted user page html. Add to which, in html_record there is information which is only displayed for users with admin permissions.

Example:
<a href="http://myserver.com/cgi-bin/dbman/db.cgi?db=default&uid=default&generate=stuff&ID=*&view_records=1&sb1=1&so1=ascend">get all records from database for default user and web display, sorted ascending on field number 1</a>

Code in html_view_success:
...
if ($in{'generate'}) { html_record_generate(&array_to_hash($_, @hits));}
else { html_record(&array_to_hash($_, @hits));}
...

Using two different databases if they have the same field structure sounds too much work to me. I just took a brief look at db.cgi, but I believe you'd have to change quite a lot in order to make all operations - adding, modifying, deleting - work simultaneously on two databases; you'd have to change even more to make only *some* operations work on both databases, and others only on one.

I hope this was somewhat helpful.
kellner