Add/Edit in Admin mode not working if alias for table has been specified

More
2 years 4 months ago #5438 by alk
Hello Team

Using v3.9.7, if trying to save an edited DB record from the admin-view for a DB-table with an alias set, I get:

1054 Unknown column 'alias' in 'where clause'

I do not expercience this error if no alias is set for the DB-table.

Looking into the code of:

administrator/components/com_joodb/helpers/form.php

I feel in function checkAlias() this line:

$db->setQuery("SELECT `".$jb->fid."` FROM `".$jb->table."` WHERE alias=".$db->quote($item->{$falias}));

should look like this:

$db->setQuery("SELECT `".$jb->fid."` FROM `".$jb->table."` WHERE $falias=".$db->quote($item->{$falias}));

At least the above change fixed the error. ;)

Cheers/Tschüss
/alk

Please Log in or Create an account to join the conversation.

More
2 years 4 months ago #5439 by Dirk

alk wrote: $db->setQuery("SELECT `".$jb->fid."` FROM `".$jb->table."` WHERE $falias=".$db->quote($item->{$falias}));


Thank you for reporting this bug. I never recognized it because my alias field is always alias!

But I wouldn't write variables directly in the SQL String and escape the variable..
$db->setQuery("SELECT `".$jb->fid."` FROM `".$jb->table."` WHERE `".$db->eacape($falias)."`=".$db->quote($item->{$falias}));

Please Log in or Create an account to join the conversation.

More
2 years 4 months ago #5440 by alk

Dirk wrote: ... because my alias field is always alias!

I almost thought so. ;)

/alk

Please Log in or Create an account to join the conversation.

More
2 years 4 months ago #5441 by alk

Dirk wrote:

.$db->eacape($falias)


Typo alert above!

Please Log in or Create an account to join the conversation.

Moderators: Dirkjoest