Previously I had two tables. I have a php script to copy the contents of one table one to table 2, to identify the ids which are copied I made a csv file to check for the last row inserted id like below
"Date",lastid(int)
Previously I was checking the last id using the index of csv by using fopen as 0 and 1.
But now I have another table 3 to copy to table 2 and the process is same. but When i write for the new table it gets overwritten so I cant identifiy for the previous table. If i append it the file will get extended. Is there any way to put the table 1 contents in the first line and table two last id in the second line as
"Date",lastid(int), // for t1 copied to t2
"Date",lastid(int) // for t3 copied to t2
and taking 0, 1 for table 1 and 2,3 for table 2. Even when table 2 is done first.
public function writeNumberOfRowsCopiedForTable2FromTable1($row_write)
{
$file = fopen('rowsCopied.csv', 'w+');
fputcsv($file, $row_write);
fclose($file);
}
calling it by
writeNumberOfRowsCopiedForTable2FromTable1([$this->global_date, $last_row_copied]);
getting values for inserted values in t2 from t1
public function getLastRowCopied()
{
$end_row_id = 0;
if (file_exists('rowsCopied.csv')) {
$handle = fopen('rowsCopied.csv', 'r');
$data = fgetcsv($handle);
$end_row_id += intval($data[1]);
$this->global_date = $data[0];
fclose($handle);
}
return $end_row_id;
}
Hope I explained the question. Someone knows the answer?