Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7758425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:21:24+00:00 2026-06-01T13:21:24+00:00

The only similar question I have found is: Insert php boolean into mysql bit

  • 0

The only similar question I have found is: Insert php boolean into mysql bit column with Zend_Db but this has no answer.

Please see below a simplified test:

The ‘allow’ column type is BIT.
The ‘roleID’ column type is INT.
The ‘permID’ column type is INT.

$dbo = new PDO("mysql:dbname=database;host=127.0.0.1", "phpuser", "pass");

$query = $dbo->prepare("INSERT INTO ws_role_perms (allow, roleID, permID)
                            VALUES (:allow, :roleID, :permID)");

$query->bindValue("allow", true, PDO::PARAM_BOOL);
$query->bindValue("roleID", 1, PDO::PARAM_STR);
$query->bindValue("permID", 2, PDO::PARAM_STR);

if ($query->execute() == false) {
    throw new Exception(print_r($query->errorInfo(), true));
}

The error message I receive is:

Array (
    [0] => 22001
    [1] => 1406
    [2] => Data too long for column 'allow' at row 1
)

If I attempt to put the equivalent query straight into MySQL, i.e. by running the query: INSERT INTO ws_role_perms (allow, roleID, permID) VALUES (true, 1, 2)
I have no problems.

Is this a bug in the MySQL PDO driver, or is it just me?

Many thanks in anticipation of your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T13:21:26+00:00Added an answer on June 1, 2026 at 1:21 pm

    It seems as though PHP is not interpreting ‘true’ as a boolean. PHP.NET indicates that PDO::PARAM_BOOL is an integer. The MySQL interpretation of a column with datatype ‘bit’ changed after around version 5.0. What this means is that PHP is probably trying to insert a full integer (32 bits) into a column that has an unpredictable number of bits (1-64).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found this question but it was only similar and, more importantly, dated by
Similar to this question only the other way of flow. Insert Picture into SQL
I found a similar question here, but didn't help me. I basically have apache
My question is pretty similar to that except but I need only the header
I found a similar question about getting just the rotation, but as I understand
I have found a few good replies to similar content so far, but never
I have searched through stackoverflow and has found similar question. As I am still
I'll preface this question with the note that I have looked at this similar
The title might be somewhat ambiguous, but bear with me (The only similar question
My question is similar to this one , but is different enough that I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.