Gossamer Forum
Home : Products : DBMan : Discussions :

how to open 2 non related databases

Quote Reply
how to open 2 non related databases
I inserted this in the default.cgi

sub switch_to_miembros
{
#-----------------------------------------------------
$cols = 'ID,Date,Email,Nombre,Nombre2,Apellido,Apellido2,Casada,Folio,Tomo,Asiento,Residencia,Oficina,Celular,Posicion,Posicion2,Posicion3,Remuneracion,Experiencia,Sector,Sector2,Estudios,Idiomas,Idiomas2,Confidencial,Confidencial1,Confidencial2,Confidencial3,Userid,Ubicacion,Ubicacion2,Dia,Mes,Ano ,RecibirMail,Computadoras,Programas,Programas2,Programas3';

@db_cols = split (/,/,$cols);
$db_file_name = $db_script_path . "/inscribir/yep/miembros.db";
}
sub switch_to_vacantes
{
#-----------------------------------------------------
$cols = 'ID,Date,Email,Empresa,Sexo,Posicion,Remuneracion,Experiencia,Sector,Estudios,Idiomas,Idiomas2,Confidencial,Userid,Ubicacion,Computadoras,16,17,18,19';
@db_cols = split (/,/,$cols);
$db_file_name = $db_script_path . "/registro/yep/vacantes.db";
$db_key_pos = 0;
}

and this to the html.pl in the sub html_record {


# Tell DBMan which database to look in
&switch_to_miembros;
# Get the associated record
%rec2 = &get_record($rec{'Userid'});
# Tell DBMan to go back to the original database
&switch_to_vacantes;
and between the print qq this
$rec{'Idiomas'}
 $rec2{'Userid'}
  $rec{'Idiomas2'}

what im tring to do is to open the miembros database to call its values but there is no relation between the two databases here is how it works...

the vacantes database is created by companies that have their own password file and its accesed by the users password file...

we are already logged in the vacantes database or vacantes.db but we also want to open the miembros.db and call the values of the user actually loged in the vacantes database

if yo can see any mistake please let me know, its truning me crazy this relation...



Quote Reply
Re: how to open 2 non related databases In reply to
I read this over a number of times to try to figure out what you were doing. I think I finally figured it out.

In your code, use

Code:

&switch_to_miembros;
# Get the associated record
%rec2 = &get_record($db_userid); # Gets the record for the currently logged in user
# Tell DBMan to go back to the original database
&switch_to_vacantes;
Also, if you want to use &get_record, you must define the position of the key field in your "switch" subroutine. It appears that the Userid field is the key field, so you would add the following line to sub switch_to_miembros;

$db_key_pos = 27;

I think I counted correctly. Make sure that it is the number of your Userid field. I am, of course, assuming that the Userid field is the key field in your miembros db.



JPD
Quote Reply
Re: how to open 2 non related databases In reply to
Ok ill try this, but the UserID field in the vacantes.db is diferent as the one used in the miembros.db file does this matter ore its just the name of the field that works.. ill try this and let you know
thanks

Quote Reply
Re: how to open 2 non related databases In reply to
It depends on which one you want to use. The Userid from the miembros database will be in $rec2{'Userid'} and the Userid from the vacantes database will be in $rec{'Userid'}. It would be preferable to give the fields different names in the databases, though.


JPD
Quote Reply
Re: how to open 2 non related databases In reply to
well i cant open them

&switch_to_miembros;
%rec2 = &get_record($db_userid);
&switch_to_vacantes;

and this between th print qq
$rec2{'Userid'} didnt work

in the cgi
sub switch_to_miembros {
#-----------------------------------------------------
$cols = 'ID Date Email Nombre Nombre2 Apellido Apellido2 Casada Folio Tomo Asiento Residencia Oficina Celular Posicion Posicion2 Posicion3 Remuneracion Experiencia Sector Sector2 Estudios Idiomas Idiomas2 Confidencial Confidencial1 Confidencial2 Confidencial3 Userid Ubicacion Ubicacion2 Dia Mes Ano RecibirMail Computadoras Programas Programas2 Programas3 Url libre libre1 libre2 libre3';
@db_cols = split (/,/,$cols);
$db_file_name = $db_script_path . "/inscribir/yep/miembros.db";
$db_key_pos = 29;





Quote Reply
Re: how to open 2 non related databases In reply to
Then we have to figue out why the record isn't being retrieved. There are a number of possiblities for this.

1--
In sub get_record, did you delete the line

($restricted = 1) if ($auth_modify_own and !$per_admin);

2--
Are you sure there is a record in miembros that matches the currently logged in user?

------------------
Wait a minute. If you want the userid from miembros, and the userid is the key field, then all you need to do is use $db_userid.

Or do you want other information from the miembros database?

JPD