Take Current Snapshot of DB and send it to FTP in same PHP Scripts: Advice Needed
- by Rachel
Not sure if I can do it this way. I want to get current snapshot of the database and send it via FTP Server, both of this functionality should be implemented in PHP scripts.
Here are the steps I am thinking on right now.
In my php scripts(basically am extending an PDO into my Dao class and then preparing the query),
$qry = SELECT * FROM MyTablename;
$stmt = $this->prepare($qry);
$stmt = $this->execute();
Now I will store $stmt in csv file using fputcsv or I will execute the sql command from the script itself and than try to store the result in the $file(csv file) note here that I do not have any csv file with me at this point to basically I will have to create one and let's say its $file, so then
$file = fputcsv($stmt); or $file = exec("Select * from MyTablename");
Will this put all records in the file ? If yes, then I will use FTP Functionality to transfer file to the FTP Folder.
I am not sure if this approach would work and also have concerns regarding the need of preparing the $qry
Any suggestions or different approach advised would be highly appreciated.
Thanks !!!