将PDF存储在MySQL数据库中 [英] Store PDF in MySQL database

查看:628
本文介绍了将PDF存储在MySQL数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发应用程序,我需要创建PDF发票.我正在使用 pdfbundle ,并且PDF文件已正确创建:

I am developing an application and I need to create invoices in PDF. I'm using pdfbundle and PDF files are created correctly:

public function helloAction()
{
    $format = $this->get('request')->get('_format');
    $name = "work!!!";
    return $this->render(sprintf('miomioBundle:Venta:helloAction.%s.twig', $format), array('name' => $name));
}

但是我如何将该文件存储在数据库中?

But how could I store that file in the database?

推荐答案

最好将它们作为文件存储在磁盘上,并引用它们在数据库中的位置.因此存储:

You'd be far better off storing them on disk as files and reference their location in your DB. So store:

/path/to/store/invoice_434992.pdf

/path/to/store/invoice_434992.pdf

在相关表中,每个表都有唯一的文件名,并在需要时引用它.

in a relevant table, each with a unique filename and reference it where you need to.

这篇关于将PDF存储在MySQL数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆