Pedramch Pedramch - 1 year ago 75
MySQL Question

Laravel : Function Always Insert One Number To DB In LOOP

I want create some random codes based on miliseconds.
when i use "var_dump" it shows my function is working correctly and too many $result numbers are created. but when i use ORM INSERT Statement to save them into my database , it always SAVE : 2147483648 in database and it seems it's not depended on my $result !!!!!
here is my code :

public function Timer($Number)
while ($i<$Number)
$microtime = microtime(true);
$milliseconds = sprintf("%02d", ($microtime - floor($microtime)) * 96 * 62 * 23 * 43);
$result=date('His'. $milliseconds, $microtime)."";
'Number' => $result,
'IsValid' => false

Answer Source

2147483647 is maximum number for signed INT. So, try to use unsigned BIGINT or VARCHAR to store the value.

Or you could use another way to build random codes, like str_random() or something similar.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download