PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, February 20, 2022

[FIXED] How to set AUTO_INCREMENT in Laravel with Eloquent?

 February 20, 2022     laravel, laravel-4, mysql     No comments   

Issue

I am working on an application and my employer wants that the id in the user table should begin from 100,000 instead of 1. How can accomplish that? Is it a parameter in the Schema Builder itself? Or would I have to set something in the MySQL instead?


Solution

You can use SQL its self to do this. ALTER TABLE <table_name> AUTO_INCREMENT=100000;.

Or

Do it like here

And use a unprepared statement;

$statement = "ALTER TABLE MY_TABLE AUTO_INCREMENT = 100000;";

DB::unprepared($statement);

or

DB::update("ALTER TABLE {your table name} AUTO_INCREMENT = 100000;");

Which could then be put within the migration that creates the table.



Answered By - Matt Burrow
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing