I hope you can help me. In my database (supermarket) I have a table for orders and other for order_details and I would like to add the PDF of each invoice (associated to the order_number) to the database. Is this possible in mySQL? How can I do it?
2,717 2 2 gold badges 18 18 silver badges 38 38 bronze badges asked Dec 28, 2014 at 17:47 1 2 2 bronze badgesYou could store the PDF in an orders directory and insert the link into the db so when it is sent to the customer it would provide the link to the invoice
answered Dec 28, 2014 at 17:50 346 4 4 silver badges 15 15 bronze badgesThanks for your help. Should I insert a column in my table "orders" with the link to the invoice? My doubt relies on the fact that I can have more than one invoice for each order (because the products can arrive at different dates). The "orders" table refers to the orders that the supermaket perform to the suppliers.
Commented Dec 28, 2014 at 18:07Yes a column for the link to the invoice, if you have multiple invoices then you could put a link tothe page containing links to two invoices or add a new column for each invoice so the first invoice would be in "initialInvoice" column and second invoice would be inserted into "secondInvoice" column
Commented Dec 28, 2014 at 18:12There are three possible ways I can think of to go about this.
Method 1. Have a directory in which all the pdfs are stored. Give each PDF a name that is the order number found in the database.
Method 2. Store the PDFs in a directory like method 1, but in your database store a file path to the PDF as a varchar. eg: /orderPdfs/124.pdf
Method 3. Create a BLOB column in your order table and store the PDFs in this field. Information on how to do this with PHP can be found in the answer to this post: How to store .pdf files into MySQL as BLOBs using PHP?