0

I'd like to create a column which will contain boolean values, I don't want to use TINYINT(0) and store 0 for false and 1 for true, instead i'd like to store "true" or "false" values but not as VARCHAR values.

I'm doing this because I'm using Extjs, and I'm dynamically creating comboboxes, I need those boolean values to use as parameters like so :

function createComboBox(editable) {
var combo = new Ext.form.ComboBox({
    typeAhead: true,
    mode: 'local',
    forceSelection: true,
    triggerAction: 'all',
    emptyText: 'Select item...',
    selectOnFocus: true,
    //...other settings
    editable: editable // true or false
});
return combo;
};

And editable would be "true" or "false" (without quotes).

Should I just use a varchar column and remove the quotes in Extjs? Is there a better way?

codemania
  • 1,098
  • 1
  • 9
  • 26
salamey
  • 3,633
  • 10
  • 38
  • 71
  • I thing `MySQL` has not a `boolean` datatype: http://dev.mysql.com/doc/refman/5.0/en/numeric-type-overview.html – Oscar Pérez Mar 04 '14 at 08:55
  • Here is a good answer: http://stackoverflow.com/questions/289727/which-mysql-datatype-to-use-for-storing-boolean-values – Jehy Oct 05 '15 at 20:49

2 Answers2

0

You could use ENUM('true', 'false') as the column data type.

Tero Kilkanen
  • 328
  • 1
  • 12
0

Use an int and cast it to a boolean (but it is probably not really needed):

var boolValue = !!intValue;
rixo
  • 23,815
  • 4
  • 63
  • 68