HugoFara / lwt

Learn languages by reading! A language learning app stemmed from Learning with Texts (LWT).
https://hugofara.github.io/lwt/
The Unlicense
164 stars 19 forks source link

Replace $tbpref #164

Open HugoFara opened 7 months ago

HugoFara commented 7 months ago

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

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!