Моя установка — Laravel 5.3.29, работающая на Windows. База данных SqlServer 2012.
У меня есть 2 модели, документ с идентификатором первичного ключа и эти 3 метода:
// Each doc needs to link to the older version of itself and the newer version too.
public function parent() {
return $this->belongsToOne(static::class, 'prevId');
}
//each category might have multiple children
public function children() {
return $this->hasMany(static::class, 'prevId');
}public function tags()
{
return $this->belongsToMany('App\Models\Tag');
}
и модель Tag с идентификатором первичного ключа и:
function documents()
{
return $this->belongsToMany('App\Models\Document');
}
есть сводная таблица document_tag
и метод store в DocumentController содержит:
...
$document->save();
$tags = explode(',', $this->tags); // coma seperated list of tag id's
if($this->tags) {
foreach($tags as $tag) {
$document->tags ()->attach ($tag);
}
}
Я перенес данные из существующей системы, и когда я получаю документ 2101, я получаю сообщение об ошибке ниже. Если я закомментирую блок attach (), то все будет работать гладко, но, конечно, без каких-либо тегов, связанных с документами.
Next Illuminate\Database\QueryException: SQLSTATE[IMSSP]: Tried to bind parameter number 2101. SQL Server supports a maximum of 2100 parameters. (SQL:
select laravel-5.3phppivot-tablesql-server-2012. *,
[document_tag]. [document_id] as [pivot_document_id],
[document_tag]. [tag_id] as [pivot_tag_id]
от laravel-5.3phppivot-tablesql-server-2012 внутреннее объединение [document_tag] в laravel-5.3phppivot-tablesql-server-2012. [id] = [document_tag]. [tag_id]
где [document_tag]. [document_id] в (1948, 1949, 1950, 1951, 1952, 1953, 1954, 1955, 1956, 1957, 1958, 1959, 1960, 1961, 1962, 1963, 1964, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, ... удалил пару тысяч удостоверений личности ... 7866))
[/ NOEDIT]
У кого-нибудь есть идеи или кто-нибудь может указать мне правильное направление, чтобы решить эту проблему, пожалуйста?
Задача ещё не решена.
Других решений пока нет …