We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

MSSQL - convert bit valut to boolean

Any idea how I can convert bit value to boolean? Function describeColumns contains part when I define column:

case 'bit':
    $definition["type"] = Column::TYPE_BOOLEAN;
    $definition['bindType'] = Column::BIND_PARAM_BOOL;

however in result i still see string value.



98.9k

Does column type is exactly 'bit'?

Hmm aye:

array(19) {
  ["TABLE_QUALIFIER"] => string(6) "testDb"
  ["TABLE_OWNER"] => string(3) "dbo"
  ["TABLE_NAME"] => string(14) "CalendarEvents"
  ["COLUMN_NAME"] => string(11) "AllDayEvent"
  ["DATA_TYPE"] => string(2) "-7"
  ["TYPE_NAME"] => string(3) "bit"
  ["PRECISION"] => string(1) "1"
  ["LENGTH"] => string(1) "1"
  ["SCALE"] => NULL
  ["RADIX"] => NULL
  ["NULLABLE"] => string(1) "0"
  ["REMARKS"] => NULL
  ["COLUMN_DEF"] => string(5) "((0))"
  ["SQL_DATA_TYPE"] => string(2) "-7"
  ["SQL_DATETIME_SUB"] => NULL
  ["CHAR_OCTET_LENGTH"] => NULL
  ["ORDINAL_POSITION"] => string(1) "9"
  ["IS_NULLABLE"] => string(2) "NO"
  ["SS_DATA_TYPE"] => string(2) "50"
}

Data are loaded trough relation $model->getCalendarEvents($params); and converted to array. Response is JSON string:

"AllDayEvent":"0"