Edit
by marcelo benitez - 10 years ago (2015-03-01)
I need arrays from a database ; also json format
| I need to extract rows from a database in array format |
- 1 Clarification request
1.
by Manuel Lemos - 10 years ago (2015-03-04) Reply
What database are you using? Is it MySQL or something else?
Ask clarification
2 Recommendations
Ultimate MySQL: MySQL database access wrapper
This class is the ultimate MySQL database access wrapper
It can:
- Establish MySQL server connections
- Execute SQL queries
- Query a single value or a single row
- Retrieve query results into arrays or resource objects
- Retrieve the last inserted ID
- Manage transactions (transaction processing)
- Retrieve the list tables of a database
- Retrieve the list fields of a table
- Retrieve the length or position of a field
- Measure the time a query takes to execute
- Display query results in an HTML table
- Format SQL parameters (safe against SQL injection hacks)
- Generate SQL
- Handle errors (optional Exception handling)
- Convert records into XML or JSON
- Uses the mysqli extension
| by Manuel Lemos 26695 - 9 years ago (2015-05-08) Comment
I think most MySQL database access classes can return results in arrays. If you need the results in JSON format, it is just a matter of using json_encode.
Anyway, this class can already return the results in JSON format already.
It also uses the MySQLi extension, so it will work in newer PHP versions. |
Database Manager: Connect and query several databases using PDO
This package connect and Query several databases using PDO.
There is a base class that can establish connections to different databases using PDO. Currently it supports MySQL, PostgreSQL, SQL Server and SQLite.
The query sub-class extends the connection class can execute arbitrary queries and retrieve the results as an array or a string.
| by Samuel Adeshina package author 1015 - 9 years ago (2015-05-07) Comment
Try out this class. It returns the result of a query as an array. The catch is that, the class is database-independent. It can work with a mysql, sql server, sqlite or even pgresql database |