Gossamer Forum
Home : Products : DBMan : Customization :

Relational database not working

Quote Reply
Relational database not working
Hello.

I read JPDeni's doc about relational databases (and some more) and made the changes to the standard DBMan. After a few tries it worked... but I must say that I thought that it had worked.

The problem that I have is that when the admin wants to see all the users and the items each one owns, DBMan shows, for each user, all the items in the database. But if a user chooses to see a complete list too, it is only showed to him the items he really owns :-?

(using both the admin and the user the same "frontend" and databases)

I soppose that's a problem due to the fact that the admin can see everything.

How can I fiz this?

Thanks in advance.

Quote Reply
Re: Relational database not working In reply to
Can you post the part of sub html_record where the database does the search for the items that belong to each user? I just need from

&switch_to_whatever

through

my ($status2,@hits2) = &query("view");



JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Relational database not working In reply to
Of course:
---------------------
&switch_to_buzones; undef %in;
$in{'Identificador'} = $rec{'Identificador'};
$in{'mh'} = 100;
my ($status2,@hits2) = &query("view");
----------------------------

It's really strange, in the db.cgi I made a mistake and didn't put in the correct order the first two fields (the key field and userid field) of the second database (with the items), but if I put it in the correct order it doesn't work at all.

Thanks.

Quote Reply
Re: Relational database not working In reply to
Then it looks like I'm going to need to see your "switch_to" subroutines. Seems like the problem is there.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Relational database not working In reply to
OK.

Here's that portion of the db.cgi code:

sub switch_to_clientes {
#-----------------------------------------------------
$cols = 'Identificador,Fecha de alta,Nombre,Apellidos,Empresa,NIF/CIF,Teléfono,Tipo de vía,Nombre de vía,Número de vía,Detalles,Población,Provincia,País,Código postal,E-mail,URL,Forma de pago,Número,Titular';
@db_cols = split /,/,$cols;
$db_file_name = $db_script_path . "/clientes.db";
$db_key_pos = 0;
}

sub switch_to_buzones {
#-----------------------------------------------------
$cols = 'Artículo,Identificador,Tipo,Fecha de inicio,Fecha de fin,Tiempo,Dirección,Contraseña,Precio';
@db_cols = split /,/,$cols;
$db_file_name = $db_script_path . "/buzones.db";
# $db_sort{'Fecha de inicio'} = 'date';
}

The main database is clientes.db, which key field is "Identificador".
In the second database, buzones.db, the field "Identificador" should be in the first position, but if I do so it doesn't work.

Thanks again.

Quote Reply
Re: Relational database not working In reply to
You say that when the fields are in the correct order "it doesn't work at all."

Nothing prints out?

I really think we ought to work on getting it to give you your results when the fields are in proper order. That would be best.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Relational database not working In reply to
When the fields are in the correct order and you select "List all", the fields of the main database are shown, but none relationg to the second database.

But if the fields are in the wrong order, they appear correctly to each user, except when the admin watches them.

Quote Reply
Re: Relational database not working In reply to
I'll need you to put your fields in the correct order.

In sub html_record, after

my ($status2,@hits2) = &query("view");

add

print "--$status2--";

That will tell us if anything was returned from the search and, if not, why not.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Relational database not working In reply to
It shows:

--no matching records.--

Even if I "List all" as a normal user or as admin.

Quote Reply
Re: Relational database not working In reply to
Your auth_user_field is the same field number for both databases, right?

Do you have $auth_view_own = 1; set in your .cfg file?

Try (temporarily) changing

$in{'Identificador'} = $rec{'Identificador'};

to be the name of a user you know is in the database -- something like

$in{'Identificador'} = "jpdeni";

if I had records in your database.

Oh. Wait a minute. I think I need to make a change to the mod file.

Before you do what I said above, in sub html_record, after

my (%rec) = @_;

add

$rec{$db_key} =~ s/<.?B>//g;

Try that and see if it works. If it doesn't try setting the variable as I stated above.

(I'm off to add this to the relational mod file.)

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Relational database not working In reply to
> Your auth_user_field is the same field number for both databases, right?

Yes, 0.

> Do you have $auth_view_own = 1; set in your .cfg file?

Yes, in both databases.

I've tried adding
$rec{$db_key} =~ s/<.?B>//g;
but didn't work.

If I modify this:
$in{'Identificador'} = "jpdeni";
it nearly works as if I had the fields in the wrong order: user jpdeni sees it's own products, the rest of the users can't see any of their products (normal, as the userid is fixed) and the admin sees that everyuser owns the products of jpdeni.

OK, now it nearly works putting the fields in the correct order and specifying the username.
Quote Reply
Re: Relational database not working In reply to
I'm going to have to see your database in action. That's the only way I might be able to figure out what is going on.

Could you set up a userid and password for me? You can send me the information in a private message here on the forum.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Relational database not working In reply to
Ups! Now if I click on a product I can't see it's description, it returns a non found product message.

You want a l/p for the database or for a shell account (the last one can't be)?

Quote Reply
Re: Relational database not working In reply to
I just want to log in to your database so I can see it in action.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Relational database not working In reply to
Did you receive my private messages JP?

Quote Reply
Re: Relational database not working In reply to
Yes, I did. Sorry. I'll go take a look at your site now.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Relational database not working In reply to
I can't see anything there.

I'm still not sure what code you have and where. Can I see all of your files? Copy them to a web-accessible directory and rename them so they have a .txt extension. Then let me know where I can find the directory.

I'll need to see your db.cgi file, both .cfg files, and both html.pl files.

JPD
http://www.jpdeni.com/dbman/