php - Multi-tenancy - Create tables up-front or as needed?
Get the solution ↓↓↓Solution:
Using an insert to test whether a table exists may not be your best bet, particularly considering the size of the row and latency to the database server. A better solution might be to use 'show tables', i.e.:
SHOW TABLES LIKE 'TABLENAME';
The resultset will be something like this:
Tables_in_DATABASENAME (TABLENAME)
If the number of rows is zero, clearly the table does not exist.
As far as your process is concerned -- I think I'd take a hybrid approach. When the customer upgrades and as part of your provisioning workflow create all the tables needed to provide the new services to the customer. That way the customer doesn't take up any more resources (disk mainly, in this case) than they're paying for, and you're not causing yourself the pain of provisioning dynamically.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: trying to access array offset on value of type bool in
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.