这是我的代码:
$query = "SELECT Username, EmailVerified, Blocked FROM user";
$result = mysql_query($query, $link);
$row = mysql_fetch_assoc($result);
print_r($row);
字段Username
为字符串,EmailVerified
和Blocked
的类型为位。行print_r($row)
显示Username
字段的值,但不显示其他两个字段的值。我也尝试了mysql_fetch_object(),mysql_fetch_row(),mysql_fetch_array(),但结果相同。
我们不能用mysql_query()获取位字段吗?
答案 0 :(得分:8)
我认为您需要将BIT字段转换为整数 - >
SELECT Username, CAST(EmailVerified AS unsigned integer) AS EmailV, CAST(Blocked AS unsigned integer) AS Block FROM User
答案 1 :(得分:4)
是的,你可以,但它们被检索为字符串,很可能最终成为不可打印的字符。您可以将值作为数字得到:
$query = "SELECT Username, EmailVerified, Blocked FROM user";
$result = mysql_query($query, $link);
$row = mysql_fetch_assoc($result);
$row['EmailVerified'] = ord( $row['EmailVerified'] );
$row['Blocked'] = ord( $row['Blocked'] );
print_r($row);
答案 2 :(得分:2)