Skip to content

Replace $tbpref #164

Description

@HugoFara

$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!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

databaseDatabase-related issuesenhancementDevelop an existing feature

Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions