Answer the question
In order to leave comments, you need to log in
Why is the auto-increment field filled in so strangely?
I'm trying to use Laravel.
Here is the controller I wrote:
public function store(Request $request)
{
$arr = $request->input('post');
$post = new Posts();
$post->create(['post'=>$arr]);
return redirect('recommendations');
}
class Posts extends Model
{
protected $table = 'posts';
protected $fillable = ['post'];
}
<form method="post" action="/addpost">
<div class="form-group">
<label for="post">Добавить запись:</label>
<textarea rows="10" name="post" class="form-control"></textarea>
</div>
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<input class="btn btn-primary" type="submit">
public function up()
{
Schema::create('posts', function (Blueprint $table) {
$table->increments('id');
$table->text('post');
$table->timestamps();
});
}
Answer the question
In order to leave comments, you need to log in
Не нужно менять автоинкремент. Так задумано разработчиками MySQL.
Сдвиг в 10 значений добавили чтобы поддерживать master-master архитектуру и избегать коллизий.
Скорее всего у вас для этой таблицы стоит шаг инкремента 10. Посмотрите в параметрах таблицы. Например через phpMyAdmin
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question