开发者

query blob as varchar

I'm trying to get a blob field returned to php as a varchar.

The field is a blob named "ssn".

If I do:

select cast(ssn as char) from staff

I get a bunch of entries (with what appears to be garbage that messes with my javascript).

I don't even know the column name to reference them.

If I try to grab it in PHP using thusly:

mysql_result( $result, $index, "ssn" )

I get:

... ssn not found in MySQL result ...

Any suggestions?

How do I avoid getting garbage back? Is 开发者_StackOverflow中文版it just that my client's ssn's are scrambled so I can't see them? Are there similar types I should consider casting to? And how do I reference it in my mysql_result() call?


You can give columns aliases like this:

SELECT cast(ssn AS char) AS ssn_c FROM staff

Then you can use ssn_c to refer to the column.


Do you mean with varchar return as string? If yes then you can just get the contents of the blob field as you normally would do with a varchar field - either use mysql_fetch_array or mysql_fetch_object.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜