在 php 代码替代中存储数据库 pk ID?
我们有数十万个查找值,并且由于产品仍处于开发阶段,ID 尚未固定。因此,每当更新 ID 时,我们都必须返回并更新整个代码中的数千个 ID,以使其正常工作。它按时吃掉。
是否有另一种方法可以使 ID 在代码中保持动态,以便:随着表中 ID 的更改,它们会自动更新,或者它们都存储在所有数据库表的 1 个文件中,这样可以使开发和测试的更新变得更加容易和快捷看法?
平台是Mysq + codeignitor php。
We have hundreds of thousands of lookup values and since the product is still in dev the IDs are not fixed. So anytime an ID is updated we have to go back and updated thousands of IDs all over the code to make it work properly. It eats away on time.
Is there another method to keep IDs as dynamic in the code so either: they auto update as IDs are changed in the tables, or they are all stored in 1 file for all database tables so it makes updates much easier and quicker from development and testing perspective?
Platform is Mysq + codeignitor php.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在代码中为 id 定义常量,而不是硬编码 id 值。这是一个例子:
Define constants in your code for the ids instead of hard-coding id values. Here's an example: