sql - PHP filter attachment more fast solution?

13

In my database i have a table for orders and sometime i need to attach files at one specific order.

I find two way for doing this job :

1) storing a file into the attachement dir with manipulated name es. 12-user01-nameoffile.pdf where 12 is number order and after filter all the content of the attachment dir

2) create a db table for storing the attachment information into column orderID. username, filename and filter with sql query

Witch is the more (or best) fast solution for the future when there are many files into the attachment dir ?

MY PHP CODE FOR FILTER ATTACHMENT DIR

$directory = ($_SERVER['DOCUMENT_ROOT'] . "/orders/attachments/");
$rowcount=0;
if (is_dir($directory)) {
   if ($directory_handle = opendir($directory)) {
      while (($file = readdir($directory_handle)) !== false) {
          if((!is_dir($file))&($file!=".")&($file!="..")) { 
              $attachments = explode('-', $file) ;
                 if($attachments[0] == $_SESSION['orderId']) {
                     $rowcount++; 
                 }
          }
     }
      closedir($directory_handle);
   }
}

If $rowcount >0 i show an icon with link for the page with attachments list filterd.

People are also looking for solutions to the problem: How do i get variables from a html form using a session wrapper class in PHP?

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.