如何基于抽象实体类在学说中动态创建实体?表名必须不同。例如
// abstract entity model
class Transport {
// $name, $type and other columns
}
创作看起来像:
class TransportManager {
public function registerTransport($name) {
$car = ...
// here create table $name if does not exist,
// and if it exists then just
// return Car instance of this $name table
return $car;
}
用法:
$car = $transportManager->registerTransport('car');
$airplain = $transportManager->registerTransport('airplain');
$train = $transportManager->registerTransport('train');
$helicopter = $transportManager->registerTransport('helicopter');
原因?我有几个(> 10)具有相同结构的表,我想将所有数据保存在单独的表中,以防止每个表的加载