Multiple Table ,same model

Table structure is the same, different table names, how to use the same model:

(SELECT id FROM bj_income UNION ALL SELECT id FROM sd_income) as income



78.1k

you can, but you shouldnt change model source ( table) dynamically.

Hi there you can try with inheritance for example


abstract class Base {

private $id;
private $name;

public function initialize() {
$this->setSource('same_table');
}

}

class ModelOne extends Base {
//empty model 
}

class ModelTwo extends Base {
//empty model
}