CakePHP Accessing Dynamically Created Tables?

Posted by Dave on Stack Overflow See other posts from Stack Overflow or by Dave
Published on 2009-05-14T09:01:42Z Indexed on 2010/05/01 4:27 UTC
Read the original article Hit count: 335

Filed under:
|
|
|

As part of a web application users can upload files of data, which generates a new table in a dedicated MySQL database to store the data in. They can then manipulate this data in various ways.

The next version of this app is being written in CakePHP, and at the moment I can't figure out how to dynamically assign these tables at runtime.

I have the different database config's set up and can create the tables on data upload just fine, but once this is completed I cannot access the new table from the controller as part of the record CRUD actions for the data manipulate.

I hoped that it would be along the lines of

function controllerAction(){ 
$this->uses[] = 'newTable'; 
$data = $this->newTable->find('all'); 

//use data 
}

But it returns the error

Undefined property: ReportsController::$newTable

Fatal error: Call to a member function find() on a non-object in /app/controllers/reports_controller.php on line 60

Can anyone help.

© Stack Overflow or respective owner

Related posts about cakephp

Related posts about mysql