Jump to content

Dir + MySQL problem


duncan121

Recommended Posts

I have an interesting challenge.

So, I have a simple table displaying files in a directory. These files are waiting to be approved and installed. When they are installed they are entered into the MySQL database.

Very straight forward and easy so far.  However the directory of files list files waiting to be installed and have been installed.

So I want to do a comparison between a directory and a database and ONLY display the items which are not in the database.

Once I have got all the files from the directory I am using a simple ignore script and trying to get to include the database values.  But it doesn’t work.

Please see the code below…

Thanks for your help.

Duncan


//Database call
      $get_modules2 = new DB();
      $get_modules2->query("SELECT * FROM ".DB_PREFIX."_modules");
      while ($display_modules2 = $get_modules2->next_record()) {
      $mods = $display_modules2['name'];
      }
     

//Directory call
      $this_dir = dir('modules/');
      while ($file = $this_dir->read()) {
        if($file != '.' && $file != '..' && $file != $mods)
        {
        echo $file;
        }
      }
Link to comment
Share on other sites

Do you need to keep the files in the original location even after they are approved and uploaded into the mysql database?  If not, why not delete them at that point or at least move them to another location and rename them...to say filenameOLD.whatever...?  For example, one could approve the file and upload to mysql and another function of that same php could be to send an email to whomever stating that the file was uploaded and copied to the 'old' file folder for backup...and deleted from the original location.

Would this work?



Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.