PDO with BIT type

Asked

Viewed 101 times

3

I was now doing an instruction with on Duplicate and I have some fields like BIT. My class DB does the typing using PDO::PARAM_STR, PDO::PARAM_BOOL, PDO::PARAM_INT... but the use of these constants is optional, and when not informed follows the standard of PDO.

SQLSTATE[22001]: String data, right truncated: 1406 Data Too long for column 'FIELD' at Row 1' in [ ... ]

I omitted the constants at run time, so it was with the default value, but I received the above error message. The value passed was an integer 1 - not a string '1'.

I’m trying to understand the difference between 1 guy int and 1 guy str. Like the MYSQL receives the same number and knows that one is a string and another is an integer?

  • i had a very similar problem, the cause was the PDO driver, remember this error happens only in some versions, you can add the versions of PHP and Mysql?

  • PHP : 5.4.28, MYSQL : 5.5.36-log

1 answer

1

If you can query in mysql just pass the querys create a table.

something of the kind

/* will give you a field that is null in the table SELECT ISNULL(CAST(TEMP AS BIT),0) AS STATUS

then in Where compare with not null or null

  • I don’t think that answers my question...

Browser other questions tagged

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