Reputation: 510
My doubt is, I had few tables named client1,client2,client3 etc., I need to get the data of each client in single controller without creating any model/controller for each table. Can any one explain how to get those values.
Upvotes: 1
Views: 1972
Reputation: 449
You can use dynamic models
app/client_model.php
<?php
class ClientModel extends Model {
var $name = 'Client';
var $alias = 'Client';
function __construct($table) {
$this->useTable = $table;
parent::__construct();
}
}
?>
And Use like this for client1 table
App::import('model','Client');
$client = new ClientModel('client1');
$client->find('all');
Upvotes: 5
Reputation: 371
You Can do it by firing normal mysql queries selecting table and fetching values in controller as we do in core php.
Upvotes: -1