如何编写php子类将数据和文件插入数据库?

I'm using this method to try to allow users to upload files within an ajax form. I have isolated the file portion of the form in an iframe, because some of the JS for the form and the file upload system clashed. The system now works - with one critical exception. It's a beautiful system but it appears to my limited ability, quite complex. It saves a file successfully to the server disk, but it seems I have to write a sub class to make it save the file as a blob into the mysql database. I've been trying to get this to work for days without success. I'm not familiar with classes - although have read a lot (and not understood as much as I would like).

This is the code where my attempted subclass entry is going, and where the file upload script talks to immediately upon submission.

<?php
/*
 * jQuery File Upload Plugin PHP Example 5.14
 * https://github.com/blueimp/jQuery-File-Upload
 *
 * Copyright 2010, Sebastian Tschan
 * https://blueimp.net
 *
 * Licensed under the MIT license:
 * http://www.opensource.org/licenses/MIT
 *
 */
error_reporting(E_ALL | E_STRICT);
require('UploadHandler.php');

class MyUploadHandler extends UploadHandler {
    /*
    * Maintain our database:
    * For each uploaded file, add an entry to the tbl_xxx
    */
    protected function handle_file_upload($uploaded_file, $name, $size, $type, $error, $index = null, $content_range = null) {
        // this does what would have automatically been done before we subclasses anything
        $file = parent::handle_file_upload($uploaded_file, $name, $size, $type, $error, $index, $content_range);

        // Now we add some extra processing if the file uploaded with no problems
        if(empty($file->error)) {
            // include the funky stuff

            // Grab the includes
            include '../conf/Funcs.php';
            include '../conf/DBconfig.php';

            // Grab critical data
            $appID = $_POST['appID'];
            $uaID = $_POST['uaID'];
            $uploaders_uID = $_POST['uID'];
            $applicationKey = $_POST['applicationKey'];
            $token = $_POST['token'];
            $dateUploaded = time();

            // Define our arrays which we will be using
            $fileName = array();
            $fileMime = array();
            $fileSize = array();
            $fileData = array();

            // And grab our file data
            $fileName = $_FILES['files']['name'];
            $fileMime = $_FILES['files']['type'];
            $fileSize = $_FILES['files']['size'];
//          $fileData = fopen($_FILES['files']['tmp_name'], "rb");
            $fileData = $_FILES['files']['files[]'];



            foreach ($fileName as $nameitem) {
                foreach ($fileMime as $mimeitem) {
                    foreach ($fileSize as $sizeitem) {
//                      foreach ($fileData as $dataitem) {
                            echo "$nameitem
";
                            echo "$mimeitem
";
                            echo "$sizeitem
";
//                          echo "$dataitem
";
//           THIS IS WHERE THE DB COMMUNICATION CHUNK
//           WOULD BE GOING IF THIS WORKED.


//                      }
                    }
                }
            }


        }

    return $file;
    }
} // end of class

$upload_handler = new MyUploadHandler($site_params);

// THIS IS THE DB COMMUNICATION PART THAT WILL GO
// AS MARKED UP ABOVE, ONCE THE THING WORKS
//  try {
//      $stmt = $conn->prepare("INSERT INTO $database.appsFiles (`appID`, `uaID`, `uploaders_uID`, `dateUploaded`, `applicationKey`, `fileName`, `fileMime`, `fileSize`, `file`)
//      VALUES
//      (?,?,?,?,?,?,?,?,?)");
        // Bind Values
//      $stmt->bindParam(1, $appID, PDO::PARAM_INT, 11);
//      $stmt->bindParam(2, $uaID, PDO::PARAM_INT, 11);
//      $stmt->bindParam(3, $uploaders_uID, PDO::PARAM_INT, 11);
//      $stmt->bindParam(4, time(), PDO::PARAM_INT, 11);
//      $stmt->bindParam(5, $applicationKey, PDO::PARAM_STR, 8);
//      $stmt->bindParam(6, $fileName, PDO::PARAM_STR, 255);
//      $stmt->bindParam(7, $fileMime, PDO::PARAM_STR, 128);
//      $stmt->bindParam(8, $fileSize, PDO::PARAM_INT, 20);
//      $stmt->bindParam(9, $file, PDO::PARAM_LOB, 5120000);

        // Execute the query
//      $stmt->execute();
//  } catch(PDOException $e) { catchMySQLerror($e->getMessage()); }
?>

I am aware there is no data checking at this point. I will add that in later as soon as I solve how to just get the file with all the relevant information into the database.

Help is greatly appreciated.