nextras / orm

Orm with clean object design, smart relationship loading and powerful collections.
https://nextras.org/orm
MIT License
309 stars 59 forks source link

Blob support #84

Closed PeterBocan closed 9 years ago

PeterBocan commented 9 years ago

Is there any kind of support for blobs?

hrach commented 9 years ago

Probably not, but I have never used it, it will be also highly connected to nextras/dbal.

hrach commented 9 years ago

Implemented support for both ORM and DBAL. The basic possible impl.:

/**
 * @param string $contents
 */
class File extends Nextras\Orm\Entity\Entity
{
}

class FilesMapper extends DbalMapper
{
    protected function createStorageReflection()
    {
        $reflection = parent::createStorageReflection();
        $reflection->addMapping('contents', 'contents', NULL, function($val, & $key) {
             $key .= '%blob';
             return $val;
        });
        return $reflection;
    }
}

This functionality will be available in ORM v1.1 and DBAL v1.1, currently both devs versions.

insekticid commented 9 years ago

after update to orm 1.1 clear memcache, otherwise you will get an error - Fatal error: Call to undefined function d() in nextras\orm\src\Mapper\Dbal\StorageReflection\StorageReflection.php