Sybase 15 and Laravel 5.1 via ODBC and error 3811

0

I have a database in Sybase (Adaptive Server Enterprise) and we started using the Laravel framework to transfer systems that already exist, for him (a migration in the DB can not be considered).

Laravel by default can not connect to the ODBC protocol, let alone to Sybase. It is possible through FreeTDS to use SQLServer's DBLib for this task, but it works only on Linux and I need this to be possible in both Windows and Linux.

Knowing that Laravel uses the PDO function, I have implemented, from the SQLServer code, classes to be able 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'm 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, it works with the same settings for the Grammar and PostProcessor.

    
asked by anonymous 11.08.2015 / 22:46

1 answer

0

In a way I was able to find out the nature of the error, but I did not find another alternative.

Basically Sybase (or ODBC, but damn it not) does not support this type of insert:

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

So, I have to mount the query in a rough way, with exploits and loops and use the $pdo->query() command 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. :)

    
14.08.2015 / 04:54