ilanle
(Ilan Lewin)
September 12, 2012, 11:42am
1
Hello guys,
I am completely new to Yii, used to work on PHP without a framework.
My question is:
I expect to have several thousand users at a time, and each has about 100 records (rows) of data.
I was thinking of dynamically creating an individual table for each user upon registration, for performance reasons.
I know how to create tables dynamically through PHP, but how do I create a model-controller for each (model+crud) programmatically ?
Thanks
Ilan
If your user tables have the same schema then you can create only one model and define method tableName in it, returning appropriate table name depending on some condition (for example, user session var, or some model property).
Docs:
http://www.yiiframework.com/doc/api/1.1/CActiveRecord#tableName-detail
PS. IMHO table switching should be done by DB.
For example, this is how it can be managed in PostgreSQL:
http://www.postgresql.org/docs/9.2/static/sql-createrule.html