Sybase 15 and Laravel 5.1 via ODBC and Error 3811

Asked

Viewed 253 times

0

I have a database in Sybase (Adaptive Server Enterprise) and we started using the Laravel framework to transfer existing systems to it (a migration in BD cannot be contemplated).

Laravel by default cannot connect to the ODBC protocol, let alone Sybase. It is possible, through Freetds, to use Dblib from Sqlserver for this task, but it works only on Linux and I need this to be possible on both Windows and Linux.

Knowing that Laravel uses the PDO function, I implemented, from the Sqlserver codes, classes to be possible to connect to Sybase (from the ODBC protocol and the Adaptive Server Enterprise driver).

I can do absolutely everything with Sybase from PDO with pure php, but in Laravel, only SELECT works, giving the same error at least in UPDATE and INSERT. I am using the same settings in both cases, and it gives the following errors:

Error 1/2:

PDOException in Connection.php line 358: SQLSTATE[ZZZZZ]: <<Unknown error>>: 3811 [Sybase][ODBC Driver][Adaptive Server Enterprise]Um datastream incorreto foi enviado ao servidor. O servidor esperava o token 1 porém recebeu o token 0. Isto é um erro interno. (SQLExecute[3811] at ext\pdo_odbc\odbc_stmt.c:254)

Error 2/2

QueryException in Connection.php line 621: SQLSTATE[ZZZZZ]: <<Unknown error>>: 3811 [Sybase][ODBC Driver][Adaptive Server Enterprise]Um datastream incorreto foi enviado ao servidor. O servidor esperava o token 1 porém recebeu o token 0. Isto é um erro interno. (SQLExecute[3811] at ext\pdo_odbc\odbc_stmt.c:254) (SQL: insert into [produtos] ([nome], [descr]) values (teste, teste))

The detail is that in Linux with Dblib, works with the same settings for Grammar and Postprocessor.

1 answer

0


Somehow I was able to discover the nature of the mistake but I couldn’t find another alternative.

Basically Sybase (or ODBC, but kick that does not) does not support this type of insertion:

$pdo->prepare("INSERT INTO tabela (campo) VALUES (?)")->execute(array("valor"));

So, I have to assemble the query in a rustic way, with explodes and loops and use the command $pdo->query() for it to work. The big problem is that Sybase does not accept insertion of all kinds of data between apostrophes and there is the next big challenge. :)

  • 1

    Probably Sysbase does not accept Prepared statments.

  • It has more to do with ODBC on PDO, because Dblib on Linux works without any choking, or maybe it’s another dark mystery about Sybase.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.