4 and d.host='".$host."' group by d.id,d.uuid,d.path"; $result = pg_query($link, $sql); $numrows = pg_num_rows($result); $content=''; for($ri = 0; $ri < $numrows; $ri++) { $row = pg_fetch_array($result, $ri); $content.=$row['uuid']."\t"; $content.=$row['volume']."\t"; $content.=$row['fcount']."\t"; $content.=$row['path']."\n"; } $filename='./dataset-0.txt'; if (!empty($content)) if (!file_put_contents($filename, $content, LOCK_EX)) { sleep(1); if (!file_put_contents($filename, $content, LOCK_EX)) { sleep(1); if (!file_put_contents($filename, $content, LOCK_EX)) die("error in write dataset-0.txt"); } } pg_free_result($result); pg_close($link);