Ejemplo n.º 1
0
 public function downloader()
 {
     $query = "SELECT * FROM app_table";
     if ($stmt = mysqli_prepare(Db_Connection::getInstance()->getConnection(), $query)) {
         $stmt->execute();
         /* bind variables to prepared statement */
         //$stmt->bind_result($id, $name, $url, $html);
         /* fetch values */
         $result = $stmt->get_result();
         $resultArray = $result->fetch_all(MYSQLI_ASSOC);
         foreach ($resultArray as $entry) {
             if ($entry["html"] == '') {
                 $html = $this->downloadHtml($entry["url"]);
                 $html = preg_replace('[\\r\\n]', '', $html);
                 $html = mysqli_real_escape_string(Db_Connection::getInstance()->getConnection(), $html);
                 $id = $entry["id"];
                 $query2 = "UPDATE app_table SET html ='" . $html . "' WHERE id ='" . $id . "'";
                 $stmt2 = mysqli_prepare(Db_Connection::getInstance()->getConnection(), $query2);
                 if (!$stmt2) {
                     die('mysqli error: ' . mysqli_error(Db_Connection::getInstance()->getConnection()));
                 }
                 $stmt2->execute();
             }
             // Db_Connection::getInstance()->executeQuery($stmt2);
             // $files = $this->getFiles($html);
             // echo $url."<br>";
             // print_r($files);
             // $query3 = "INSERT INTO files (appId, filename, path) VALUES (?, ?, ?)";
             // $stmt3 = mysqli_prepare(Db_Connection::getInstance()->getConnection(), $query3);
             // mysqli_stmt_bind_param($stmt3, "sss", $id, $files[1], $files[2]);
             // Db_Connection::getInstance()->executeQuery($stmt3);
         }
     }
 }