dqqy64515 2011-01-31 15:41
浏览 17
已采纳

从数据库中拉出以前看不见的记录

I have a web app (built with codeigniter) that runs every n amount of time. It will execute a stored procedure that gets a list of recent orders. Part of the task is to use the stored procedure but I'm sure if a solution requires another method that shouldn't be a problem.

The records retrieved will each have a unique order id. When the records are pulled out the order data is taken, put together as a pdf, and sent in an email to the order owner.

My question is which is the best way to go about only retrieving records that haven't been processed before. My initial thought was to store the last record processed in a file. Each time the applcation is run, look up the file, get the last stored ID, and then pull out records with an id > that that.

A while back I wrote a Perl script that did something similar with a log file using the Tail module. It would look up and file and see a new line it hadn't processed then process it, but then again that scipt was constatly running. I know it's quite different but is there anything similar I can do in PHP with a db?

I'd prefer not to have to store anything in a DB, only querying via a stored procedure.

Thanks,

Billy

  • 写回答

2条回答 默认 最新

  • doulei1965 2011-01-31 15:55
    关注

    IMHO the best way to retrieve records that haven't been processed before is to fetch records with certain status.

    You mentioned:

    I'd prefer not to have to store anything in a DB, only querying via a stored procedure.

    I'm suggesting adding status field into your orders table and change the order status once the order has been sent.

    I wouldn't trust the fetching order IDs > previously sent order ID. What happens if you need to update an old already sent order and you need to send it again?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用