问题描述
数据库中的ID以abc_001,abc_002的形式保存,或者它们可能是abc_asd,abc_a12
我运行一个代码来检查ID的最高数字后缀。,它将返回 3 。
这里是代码。
IDs in the database are saved in the form of abc_001, abc_002 or they may be abc_asd, abc_a12
I run a code to check the highest numerical suffix of the ids.
in the above case, it would return 3.
Here''s the code for that.
推荐答案
实际上它看起来有点复杂。 Ids,不仅可以是 abc_001 的形式,还可以是 xyz_001 或 abc_xxx 或简单地 abcdef 。而且ID不是由用户制作的,而是由管理员制作的。因此,如果他输入前缀 abc 并想要生成10个ID,Ajax将检查数据库中所请求后缀的最高前缀(我正在做给定的代码片段并弹出一个div,其中一个表单显示那些10个ID的注册。所以自动增量无法解决。希望你了解我的情况。
谢谢:)
Harpeet
Actually its a little bit complex than it seems. Ids, can not only be in the form of abc_001, but also xyz_001 or abc_xxx or simply abcdef. And Ids are not made by user, but by an administrator. So if he will enter a prefix say abc and want to generate 10 ids, Ajax will check for the highest prefix with that requested suffix in the database (with I am doing in the given snippet) and pop-up a div with a form showing registration for those 10 ids. So auto increment was no solution. Hope you understand my situation.
Thanks :)
Harpeet
这篇关于不使用try catch重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!