简体   繁体   中英

Symfony2 Doctrine blob type

I have legacy database that I am working with, which has binary column and stores some strings in it (I know that this is stupid, but I am not allowed to change that). I had problem that those string in that blob are stored in 'UTF-16LE' charset, but I solved it by using php iconv function in my getter.

return iconv('UTF-16LE', 'UTF-8', $this->binstring);

Now the problem is that have doctrine annotation

/**
 * @var string
 *
 * @ORM\Column(name="colname", type="string", nullable=true)
 */
 private $binstring;

and the column type in database is "BINARY(40)" and when I use doctrine migrations or update schema directly it tryes to change that type to "VARCHAR" this is unwanted behavior and I would like to eliminate it. How could I do that?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM