Fevelix Posted October 4, 2015 Report Posted October 4, 2015 Lieta tāda ka nezinu ka izvilkt pirmos 6 ciparus no 8ņām! Ideja ir ID sistēma. pirmie 6 cipari atbilst gadam, menesim un datumam. Piem., 15091401 - 15 - gads, 09 - menesis, 14 - diena un 01 - dienas id. vajadzētu kodu kas parbauda vai pirmie 6 cipari atbilst date("ymd"), ja atbilst true, ja ne, False. Quote
Kaklz Posted October 4, 2015 Report Posted October 4, 2015 http://php.net/manual/en/datetime.createfromformat.php datetime::createfromformat('ymd', substr($id, 0, 6)); Quote
briedis Posted October 4, 2015 Report Posted October 4, 2015 explode() funkcija arī var noderēt Quote
Fevelix Posted October 7, 2015 Author Report Posted October 7, 2015 http://php.net/manual/en/datetime.createfromformat.php datetime::createfromformat('ymd', substr($id, 0, 6)); Nu man labi noredeeja substr(); :) un re kas sanaaca! function makeID($target, $location) { global $db; $row = $db->getRow("SELECT ".$target." FROM ".$location." ORDER BY ID DESC LIMIT 1"); if(substr($row->$target, 0, 6) == date("ymd")) { return $row->$target+1; } else { return date("ymd")."01"; } } Quote
Kaklz Posted October 8, 2015 Report Posted October 8, 2015 Esi padomājis par to, kas notiks, ja tev vienā dienā būs 100 ieraksti? 05100801 ... 05100899 05100900 <---- nākamais datums. un pēc tam tev visi nākamie ieraksti veidosies ar 05100901 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.