开发者

MySQL SELECT with PK as key of result set

Is it possible to use SELECT state开发者_StackOverflowment in MySQL such that key of the result-set rows is the actual PK of table rows?

result set = PHP associative arrays

PK is auto-increment


There is no native function to do that.

But you can quite easily iterate that resultset and set keys by your own.

$data = array();
while ($row = mysql_fetch_assoc($result)) {
    $data[ $row['id'] ] = $row;
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜