【发布时间】:2015-02-22 20:44:23
【问题描述】:
我正在尝试使用 Laravel 4 将数据从 Localhost 数据库同步到 Live 数据库。除了列是动态的表之外,一切正常。所以在我的模型中我做了类似的事情:
<?php
class myModel extends \Eloquent {
protected $fillable = [];
protected $connection = 'live';
protected $table = "myLiveTable";
public function __construct()
{
$this->setFillable();
}
public function setFillable()
{
$fields = someSQLHandler::getColumns('myLocalTable');
$this->fillable = $fields;
}
}
为了防止手动输入$fillable中的字段,因为这是不可能的!
有没有办法让它自动分配或至少防止批量分配错误,即使我知道这是一种不好的做法?
谢谢!
【问题讨论】: