[英]Trying to figure out why a sub is causing 27 entries into a mysql database
So I have a subroutine in my software that generates a temporary invoice. 所以我的软件中有一个生成临时发票的子程序。 I really only need the temporary invoice to then add line items to it and publish the invoice for payment. 我真的只需要临时发票然后添加订单项并发布付款发票。 All works well expect the snip of code causes a number of temporary invoices to be generated. 所有工作都很好,期望代码片段导致生成许多临时发票。 I say a number because one time it will be 27 then the next time will be 26.. 25.. 20... and so on.. I don' see anything on here that would loop the sub to cause this. 我说一个数字,因为有一次它将是27然后下一次将是26 .. 25 .. 20 ......等等......我没有看到任何东西在这里会循环子导致这个。 Typically all db calls are done from a separate file and called via a sub but for reference Ive added it into the sub. 通常所有的db调用都是从一个单独的文件中完成的,并通过sub调用,但是作为参考,我已将它添加到sub中。 ** I have removed parts of the code at a time to see if it was causing it, found no issues. **我一次删除部分代码,看它是否导致它,发现没有问题。 I have also tried adding a temp invoice via the sub call from another page without issue. 我还尝试通过来自另一个页面的子调用添加临时发票而没有问题。 My issue is in this code somewhere! 我的问题是在这个代码的某个地方!
Instead of all those selects, do just one?? 而不是所有这些选择,只做一个?
$sql = "SELECT fname, lname, ...
FROM customer
WHERE customer_id = '$customer_id'";
The result is an array of fname, lname, etc. 结果是一个fname,lname等数组。
I ending up figuring out the issue with some help from a user over at reddit. 我最后通过reddit上的用户提供了一些帮助来解决问题。 Since Im using mod rewrite apparently items were being called under the link causing the main program to run X extra times and create the random junk entrees. 因为我使用mod重写显然在链接下调用了项目,导致主程序额外运行X并创建随机垃圾主菜。 Needless to say it had nothing to do with the script at all! 不用说它根本与脚本无关!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.