Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
How can I use a data type of 'bit' or 'tinyint' in my model?
  • When using oil, I tried to do type:bit[1], but I don't think it worked. When trying to insert via the default scaffolding, I get an error saying the "1" I entered is too long for that column in the database (most likely because its being inserted as a string. How can I use bit and tinyint?
  • Not sure that is supported, but I'll have to look into the code.

    Problem with this is that oil tries to be generic, while these datatypes are MySQL specific.
  • Here's the error I'm getting on create:

    Fuel\Core\Database_Exception [ 22001 ]: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'enhancement' at row 1 with query: "INSERT INTO `series` (`name`, `name_en`, `name_fr`, `description_en`, `description_fr`, `decimals`, `enhancement`, `frequency_code`, `cur`) VALUES ('srthrthrth', 'srthsrt', 'rtyjhrd', 'rtu', 'r56u', '2', '1', '1', '1')"

    'enhancement', 'frequency_code' and 'curr' are all of the type "bit"
  • Which RDBMS is that?
    BIT column is a binary type in MySQL (though it's documented as
    numeric type - that's not precisely true) and I advice to avoid it due to problems with client libraries (which PDO issue proves). You will spare yourself a lot of trouble if you modify type of column to TINYINT(1).

    TINYINT(1) will of course consume full byte of storage for every row, but according to MySQL docs BIT(1) will do as well.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion