I have two Model definition in my Cakephp app
Customer.php
class Customer extends AppModel {
var $name = 'Customer';
public function Customer($tableId){
//.. code to assign a table name based on $tableId
return parent::__construct("id", $this->useTable);
}
}
and CustomerOrder.php
class CustomerOrder extends AppModel {
var $name = 'CustomerOrder';
var $belongsTo = array('Customer ' => array(
'className' => 'Customer',
'foreignKey' => 'customer_id'
));
}
Here Customer model would get its database tablename dynamically out of three mysql tables based from that constructor argument. When i query second model because Customer has overridden constructor i get mysql error because it cannot invoke right constructor in bind model.
is there additional parameter in $belongsTo to do this? or how can achieve this.
thanks in advance.