sqlsrv insert data into filestream column

Notice: This thread is very old.
Michal Schneider
Member | 13
+
0
-

Hi,

I'm using Nette 2.1.0 and I'm trying to insert data info filestream column, but without success.

My code:

<?php
$values->data = fopen($values->data->getTemporaryFile(), "r"); // uploaded file
$this->db->table("rawdata")->insert($data);
?>

Error message: Implicit conversion from data type nvarchar to varbinary(max) is not allowed. Use the CONVERT function to run this query.

I also tried something like this, but without success:

<?php
$this->db->query("INSERT INTO rawdata ([data]) VALUES (CAST ('?' as varbinary(max)))", $data->data);
?>

I would apprisiate any useful advise.

Thanks a lot!

Milo
Nette Core | 1221
+
0
-

I'm not sure if Nette Database is prepared for this. It is an edge case a little bit.

found (example at the end), PDO supports it by statement prepare and parameter binding. Nette\Database\Connection is evelope over PDO and you can:

$pdo = $connection->getPdo();
Michal Schneider
Member | 13
+
0
-

I found that example too, I'll try it via PDO. I'll send a resulting code, if I'm sucessful.

Thanks a lot!