【问题标题】:zend framework and doctrine 2 - save and download image from database to image fieldzend 框架和学说 2 - 将图像从数据库保存并下载到图像字段
【发布时间】:2011-11-16 07:34:53
【问题描述】:

我在应用程序中使用 zf 和教义 2,但在尝试将图像保存到数据库中的字段并从 mysql blob 字段下载图像时遇到问题?

谁有我可以借鉴的小例子?

谢谢

【问题讨论】:

    标签: php zend-framework doctrine


    【解决方案1】:

    我认为:https://gist.github.com/525030/38a0dd6a70e58f39e964ec53c746457dd37a5f58

    正是你想要的。因为默认不支持 blob 数据类型,所以您可以将自己的数据类型添加到 Doctrine2。使用链接中的示例,您可以为 BLOB 字段设置 @Column(type="blob")。

    如果您使用 Bisna 胶水来集成 Doctrine2 和 ZF,您可以在引导程序中执行以下操作:

    <?php
    protected function _initDoctrineExtraDatatypes() {
        $this->bootstrap('doctrine');
    
        $doctrine = $this->getPluginResource('doctrine');
        $em = $doctrine->getEntityManager();
    
        // types registration
        Doctrine\DBAL\Types\Type::addType('blob', 'Doctrine\DBAL\Types\Blob');
        $em->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('BLOB', 'blob');        
    
        //off course you could ask some more types here you want to be integrated.
    }
    ?>
    

    祝你好运!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-19
      • 1970-01-01
      • 2017-05-11
      • 2020-05-25
      相关资源
      最近更新 更多