I know I'm 12 years late but I just had the same problem and it's still not magically solved in recent versions. However, I found another solution that might be interesting for someone like me who stumbles across this and has the same problem!

Similar to pg, I tried to insert a 1 or a 0 to a BIT(1) field in a MySQL table via DBI with placeholders. It did not work, same error. But I remembered that I previously had to convert the values from a query on said field that were returned by DBI (i.e. make "perl numbers" from the binary data):

my $perl_value = unpack("b", $dbi_returned_value);

Et voilá, the reverse (pack) worked fine with DBI, I didn't even needed to use bind_params()!

use strict; use warnings; use DBI; my $dbh = DBI->connect("DBI:mysql:database=Foo", "user", "password", { +mysql_enable_utf8 => 1, RaiseError => 1, AutoCommit => 0}) or die "Ca +nnot connect to database: $DBI::errstr"; my $statement = "insert into testtable(bitfield) values(?);"; my $insertnumber = pack("b",0); my $sth = $dbh->prepare($statement); $sth->execute($insertnumber); $dbh->commit; $dbh->disconnect;

In reply to Re^3: Handle MySQL BIT data type in Perl by mable
in thread Handle MySQL BIT data type in Perl by pg

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.