M
M
Maxim Barulin2015-11-17 13:59:02
PHP
Maxim Barulin, 2015-11-17 13:59:02

[Symfony, Doctrine] How to save files to ms sql db using pdo?

Good day!
There is a need to save files in the mssql2008r2 database.
The field is described in orm as follows:

data:
            type: blob
            nullable: true
            length: null
            fixed: false
            column: Data

but when saving, even if there is no data in the field, sql server gives an error:
SQLSTATE[42000]: [Microsoft][SQL Server Native Client 11.0][SQL Server]Implicit conversion from data type char to varbinary(max) is not allowed. To execute this query, use the CONVERT function.

Having attached the profiler, I see something like the following preparatory request:
declare @p1 int
set @p1=NULL
exec sp_prepexec @p1 output,N'@P1 nvarchar(36),@P2 nvarchar(53),@P3 char(1)',N'INSERT INTO [Table] ("Id", "FileName", "Data") VALUES (@P1, @P2, @P3)',N'C8A56AE1-82F8-4CF7-BD8C-6F8254D7806C',N'Новый документ',NULL
select @p1

The driver from microsoft php_sqlsrv_56_nts is used. So far, the only way out that is visible is to abandon the doctrine in this place, but this is still an extreme option. What am I doing wrong?
UPD: The trigger doesn't fire because sql server checks the data types before the trigger fires.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Svirsky, 2015-11-17
@e_svirsky

As an option - create a second connection with the type - mssql. It says here that this type of database is supported:
doctrine-orm.readthedocs.org/projects/doctrine-dba...
And in this place, use this connection and run Query Builder?
So have you tried it?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question