How can I implement a DataSet
in PHP like .NET?
I want this class to read data from database only once, then I should be able to use the data without connecting again to MySQL to run queries.
select * from user
When I run this query on the DataSet
the data is fetched from memory.
How can I implement this mechanism in PHP?
I don't think php can provide what you're looking for as it's very much text code and HTML driven, so you don't get the fancy GUI objects like you do in .net. PEAR provides a lot of source code that will produce data grids, that you could possibly investigate, all stored in code like arrays etc. I'm relatively new to php, so maybe someone would disagree...
What you are describing is the
DataSet
/DataTable
data container classes of .NET which can work in disconnected mode.A
DataReader
is kind of a cursor and needs to have the connection open in order to move through the result set of the underlying query.In PHP you could do this:
You could push your data into an array like this:
Then you can do whatever operations you want on the array...