开发者

Displaying mysql results as an object?

If I have a database with the structure:

___id_____|____value____
   1      |    value1
   2      |    value2
   3      |    value3

How can I pull data from this MySQL database in PHP and have it formatted like this:

Array ( [0] => stdClass Object ( [id] => 1 [value] => value1 ) [1] => stdClass Object ( [i开发者_如何学God] => 2 [value] => value2 ) [2] => stdClass Object ( [id] => 3 [value] => value3 ) )


You can use the mysql_fetch_object() function instead of mysql_fetch_array() and manually create new objects.

Read more about it here: http://php.net/manual/en/function.mysql-fetch-object.php

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜