Take Current Snapshot of DB and send it to FTP in same PHP Scripts: Advice Needed

Posted by Rachel on Stack Overflow See other posts from Stack Overflow or by Rachel
Published on 2010-03-15T14:48:45Z Indexed on 2010/03/16 16:41 UTC
Read the original article Hit count: 325

Filed under:
|
|

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 !!!

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql