Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace $tbpref #164

Open
HugoFara opened this issue Dec 25, 2023 · 0 comments
Open

Replace $tbpref #164

HugoFara opened this issue Dec 25, 2023 · 0 comments
Labels
database Database-related issues enhancement Develop an existing feature
Milestone

Comments

@HugoFara
Copy link
Owner

$tbpref short for "table prefix", was a hacky way to add a multi-user system in LWT. By prefixing any table (e. g.: "_Words" instead or "Words") it allows to create a table custom table for each user.

However, $tbpref is managed by PHP, which leads to several issues:

  • SQL cannot use it, so most operations have to be decided by a PHP script
  • It is sensitive to SQL injection, as it is a string.
  • Database migration becomes tedious.

For those reason I was looking for a replacement, here is the current alternative. A new database "Users", with "ID" and "Name" dimensions. "Name" should store the value of the old $tbpref. Every relation would have a new column with the users ID of the word.

In short we would come from:

SELECT * FROM {$tbpref}Words

To

SELECT * FROM Words WHERE WoUserID = {$user_id}

A bit longer but much cleaner. At the current development level, I am very open to any suggestion or alternative, so don't hesitate to comment!

@HugoFara HugoFara added database Database-related issues enhancement Develop an existing feature labels Dec 25, 2023
@HugoFara HugoFara added this to the LWT 3 milestone Dec 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
database Database-related issues enhancement Develop an existing feature
Projects
Status: Todo
Development

No branches or pull requests

1 participant