开发者

File open by Mysql for writing shouldn't be allowed to read from php

开发者 https://www.devze.com 2023-02-27 06:25 出处:网络
I have a requirement where I write regular data from Mysql to an output folder using select * into outfile \'filename\' from table...

I have a requirement where I write regular data from Mysql to an output folder using

select * into outfile 'filename' from table...

I have a cronjob written in php which reads these files and upload to a backup.

My worry is that it might not try to read a file which is still being written by MySql.

My question is:

1)Is it possible at first place?

2)Can we use some locking mechanism in this case and if yes which one.

I am solvi开发者_C百科ng the issue where data is written by another files using flock.

Thanks


The file locking should be handled by the OS. E.G - if mysql has opened the file for writing, and you attempt to open it for writing from PHP, you should be denied access. However, in some systems, you should be able to open the file as read only still.

$fh = fopen($file,'r');
0

精彩评论

暂无评论...
验证码 换一张
取 消