I am writing a SQL query results to a file and once I am done writing it to a file I need to output the file to user for download. My Question is how do i know when the file is completely written as different SQL query takes different amount of time. Is there anyway I can know that a file is completely written using PHP ?
3条回答 默认 最新
- dongye9820 2011-11-22 05:22关注
Your question lacks a lot of details, so I don't think a definitive answer can be given.
If the file system you are using allows you to open a file with exclusive write access, then the query script can open the file in that way, and then on the other script you simply try to open the file with write access repeatedly until the call succeeds, at which point you know the other process closed it.
Assuming the above is not possible, another option is to implement some mechanism by which the query script can signal to the other script that the writing is complete. For example, you could write some sort of marker as the last line of the file, something that is guaranteed to never appear as part of the output of the SQL query.
I hope this helps. If it doesn't, you may want to add more details to your question so that the problem can be understood better.
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 求一下解题思路,完全不懂
- ¥15 tensorflow
- ¥15 densenet网络结构中,特征以cat方式复用后是怎么进行误差回传的
- ¥15 STM32G471芯片spi设置了8位,总是发送16位
- ¥15 R语言并行计算beta-NTI中tree文件的类型
- ¥15 如何解读marsbar导出的ROI数据?
- ¥20 求友友协助弄一下基于STC89C52单片机的声光控制灯原理图
- ¥15 arduino双向交通灯设计
- ¥15 有没有会粒子群算法的大能(○゜ε^○)求带不会出收敛图😭
- ¥15 Matlab读取根元素出错