【发布时间】:2014-03-04 08:50:24
【问题描述】:
我想创建一个包含布尔值的列,我不想使用 TINYINT(0) 并将 0 存储为 false 并将 1 存储为 true,而是我想存储“true”或“false” " 值,但不是 VARCHAR 值。
我这样做是因为我使用的是 Extjs,并且我正在动态创建组合框,我需要将这些布尔值用作参数:
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;
};
并且可编辑为“true”或“false”(不带引号)。
我应该只使用 varchar 列并删除 Extjs 中的引号吗?有没有更好的办法?
【问题讨论】:
-
我的东西
MySQL没有boolean数据类型:dev.mysql.com/doc/refman/5.0/en/numeric-type-overview.html -
这是一个很好的答案:stackoverflow.com/questions/289727/…