0
다른 테이블의 열을 참조하는 기본 키가있는 두 개의 테이블이 있습니다. 이제 모든 기본 키를 두 번째 테이블에 복사해야합니다.한 테이블에서 다른 테이블로 데이터를 삽입하십시오.
나는이 두 가지 모델이 있습니다 작동되지만,
$data = Products::get(['seller_sku']);
foreach ($data as $a) {
$skuean = SkutoEAN::create(['seller_sku' => $a->seller_sku]);
$skuean->save();
}
에 대한 취
class Products extends Eloquent implements UserInterface, RemindableInterface {
use UserTrait, RemindableTrait;
protected $connection = 'mysql3';
protected static $_table;
public function setTable($table)
{
static::$_table = $table;
}
public function getTable()
{
return static::$_table;
}
public function skuEAN() {
return $this->hasOne('SkutoEAN', 'seller_sku', 'seller_sku');
}
내 컨트롤러 이제
class SkutoEAN extends Eloquent implements UserInterface, RemindableInterface {
use UserTrait, RemindableTrait;
protected $connection = 'mysql3';
protected static $_table;
public function setTable($table)
{
static::$_table = $table;
}
public function getTable()
{
return static::$_table;
}
protected $fillable = ['seller_sku','EAN','fallback'];
public function connectToproducts() {
return $this->belongsTo('de_products');
}
을, 나는이 일을 해요 2500 엔트리를 복사하는 데 3 분이 걸리지 만 올바른 것은 아닙니다. 메모리에 데이터를 먼저 저장하지 않고 설득력있게 직접 데이터를 복사하는 방법이 있습니까?
대단히 감사합니다! – baao