Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $mysqli = new mysqli('localhost', 'root', '', 'fusionpbx');
- if ($mysqli->connect_errno) {
- print 'Error: '.$mysqli->connect_error.PHP_EOL;
- exit (1);
- }
- $mysqli_archive = new mysqli('voiply.mysql.database.azure.com', 'voipadmin@voiply', 'V01Padmin2016', 'fusionpbx');
- if ($mysqli_archive->connect_errno) {
- print 'Error 2: '.$mysqli_archive->connect_error.PHP_EOL;
- exit (1);
- }
- $sql = 'SELECT * FROM v_xml_cdr WHERE answer_stamp < DATE_SUB(NOW(), INTERVAL 30 DAY) limit 1';
- if ($result = $mysqli->query($sql)){
- while ($row = $result->fetch_assoc()){
- $cols = implode(',', array_keys($row));
- foreach (array_values($row) as $value){
- isset($vals) ? $vals .= ',' : $vals = '';
- $vals .= '\''.$mysqli_archive->real_escape_string($value).'\'';
- }
- $sql_archive = 'INSERT INTO v_xml_cdr ('.$cols.') VALUES ('.$vals.')';
- echo $sql_archive;
- $mysqli_archive->query($sql_archive);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement