Paginate Dynamically created table in Cakephp?

See sample code

mysql_query('SET AUTOCOMMIT=0;'); mysql_query('START TRANSACTION;'); $tableName = rand().'_table;' $this->loadModel('Home'); // Model for homes_table $sql = 'CREATE TABLE '.$tableName.'_table LIKE homes_table'; mysql_query($sql); // FEW INSERT STATEMENTS ON THE NEW TABLE $tableName // /* Here I want to paginate the new table using $this->paginate(); HOW? */ mysql_query('TRUNCATE table '.$tableName); mysql_query('COMMIT;'); 

I want to create a new page to create a new table? Logic every time a person runs a script, a new random name table will be created β†’ then paginated β†’ then ... Or how to assign a model to dynamically created tables in cakePHP.

+1
php dynamic cakephp model
source share
1 answer

its sounds, like what you do, are bad. Also, you shouldn't name things like CREATE TABLE, TRUNCATE, COMMIT, etc.

Look at the set of settings for the correct creation and deletion of tables, read the api on how to do transactions. things like http://api13.cakephp.org/class/data-source#method-DataSourcebegin

also, the table name must be multiple for the cake in order to be able to do this automatically, so your example will not work.

You can get an instance of the model by doing

 $Something = ClassRegistry::init(Inflector::classify($tableName . '_suffix')); 
+1
source share

All Articles