使用Laravel 5.1在Sybase int列中插入问题

I'm having problems to insert values in tables with integer data type columns using Laravel 5.1 and Sybase.

The error 257 is listed when in an exception. In Sybases's docs it seems to be a conversion problem. I can see the insert sql builded by the framework is something like

insert into [table_name] ([col1], [col2]) values ('AAA', '999'))

So, I can see that Laravel is passing all value into single quotes, and seems to me that Sybase do not accept this kind of construction.

I 'm using Linux Ubuntu with freetds installed with the 5.0 protocol version.

Someone has solved this kind of problem already? Am I missing some configuration or do I have to write an driver extension for Sybase work with Laravel 5.1?

Assuming you are using Sybase ASE, the problem is database specific and it is inherited from PHP PDO whereby it by default will bind all parameters as string unless you specify the data type to bind using the bindValue() function

<?php
/* Execute a prepared statement by binding PHP variables */
$calories = 150;
$colour = 'red';
$sth = $dbh->prepare('SELECT name, colour, calories
    FROM fruit
    WHERE calories < :calories AND colour = :colour');
$sth->bindValue(':calories', $calories, PDO::PARAM_INT);
$sth->bindValue(':colour', $colour, PDO::PARAM_STR);
$sth->execute();
?>

The datatype must match your table definition.

In Laravel, if you are using eloquent you may need to rewrite the Connection.php to bind the parameter accordingly due to current code in laravel does not use bindValue to bind the parameters and as such, PDO will use the default datatype which is a string.