PHP Classes

MySQL to JSON: Convert data from MySQL query results into JSON

Recommend this page to a friend!
  Info   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum (4)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 51%Total: 9,539 All time: 152 This week: 48Up
Version License Categories
mysql2json 1.0.0The PHP LicenseDatabases
Description 

Author

This class can be used to convert data from MySQL query results into a JavaScript expression in JavaScript Object Notation.

It takes a MySQL query result handle and retrieves the query result column names and the query result data.

The class generates the definition of a JavaScript object in JSON that contains an array of a rows of query result data.

Each array element represents an object with the properties set to the query result column names. The property values are the query results for the respective row and column.

Innovation Award
PHP Programming Innovation award nominee
July 2006
Number 3
Since the raise of interest on the development AJAX based applications, JavaScript Object Notation (JSON) has became a relevant topic.

JSON is often used by Web server applications to serialize objects that are recreated on the browser side by Javascript code that handles AJAX based interactions.

A great part of the AJAX applications are database driven. Frequently, PHP applications retrieve data from MySQL databases to respond to AJAX requests.

This class helps implementing AJAX based PHP database driven applications with MySQL by serializing query results using JSON.

Manuel Lemos
Picture of Adnan Siddiqi
Name: Adnan Siddiqi is available for providing paid consulting. Contact Adnan Siddiqi .
Classes: 1 package by
Country: Pakistan Pakistan
Age: 123
All time rank: 2582 in Pakistan Pakistan
Week rank: 312 Down6 in Pakistan Pakistan Down
Innovation award
Innovation award
Nominee: 1x

Details

class name: mysql2json FUNCTION ========= getJSON($result,$num) The method which returns sql returned data from MYSQL database into JSON format.It takes two parameters: a)$result:resultset data returns from mysql_query() method. b)$num:Number of affected rows.Usually value returns from mysql_affected_rows(). If you find this piece of code useful, and need enhancements or find bugs... please do write to me, Thanks Adnan Siddiqi

  Files folder image Files  
File Role Description
Accessible without login Plain text file example.php Example Example
Accessible without login Plain text file jsontest2.html Data HTML file parsing returned JSON data
Plain text file mysql2json.class.php Class Main Class File
Accessible without login Plain text file README.txt Doc. Help File

 Version Control Unique User Downloads Download Rankings  
 0%
Total:9,539
This week:0
All time:152
This week:48Up
User Ratings User Comments (2)
 All time
Utility:62%StarStarStarStar
Consistency:68%StarStarStarStar
Documentation:62%StarStarStarStar
Examples:75%StarStarStarStar
Tests:-
Videos:-
Overall:51%StarStarStar
Rank:2412