I have a need to have many tables, all with the same schema. Imagine many Customers, and each Customer has Products - lots of them - far too many to put in a single table.
What I want to avoid is having to bake a lot of model code for each table. So basically I want to reuse the Entity and Table classes for all the database tables. Way I see I have 2 options:
One database with many tables. The table names would be prefixed. For example customer1_products / customer2_products.
Many databases with 1 table, all the tables have the same name.
Which option would play nicest with Cake? I want to keep things as simple as possible and avoid duplicate code in my app.
You want to create a separate products table for each customer? Why not just have a single products table with a customer ID column in it that tells you which customer the product belongs to? That’s the standard approach.
I guess the same connection but different DB prefixes works easiest
No connection switching needed, only different instances of the table class with a custom table name then.