How to Get data from mysql table using simple Automation - DataFetcher

Sunday, April 23, 2017 Ankit Palli 0 Comments

Automation tool :

Go to Datafetcher

Why do we write different php files to get data from different tables of our mysql database. We can save our disk space by reducing all your php files to get data from database. Here i introduce Datafetcher.php which will get data from table seamlessly and generate output in Json format for you.

Datafetcher will provide you output in JSON format. The format used to display data is JSON array of Object. So its important to know how to parse JSON data from server.

How does datafetcher.php work ?

1. It fetches all columns in your table.
2. Then it displays all rows in table by formatting it into json string which can be used by your application.

How to use Datafetcher.php ?

Steps :

1. Just supply your database details into Datafetcher.php and copy Datafetcher.php into your xampp project.
2. Edit database details code to point to your database.
3. Now Datafetcher is ready to run.
4. Now go to your Chrome browser in url section type following :


Replace YourTableName with any table name in your database.
Replace YourProjectName with your project name or folder name.
5. You will get all data in json format.

How to use Datafetcher.php with Condition ?

Consider you want to display records based on condition.
Note : only one condition is allowed for now.

For example :
If you want to display records having id =5 or Name=ankit, You can do this by supplying condition to Datafetcher.php.

How to supply condition ?

Steps :

1. Just type following :


For Example :

To fetch row with Username 'Ankit' i would write url as follows :


How to get all data from Foreign table with Id field in current table ?

Consider you have a table named TableLogin which has following fields :

1. UserId
2. Email
3. Password

Now you want to display Address of User which is in Foreign table i.e another table whose name is TableUserDetails,

What would you usually do ?

Create another query which will take UserId from current table and fetch all data related to that id in Foreign Table.

But with Datafetcher.php you would not required to do all these staff.

Now data fetcher would only require to change url that we send to PHP file as follows :



TableName : Your table name.

ForeignTableName : Tablename from which you want to fetch all data depending on ForeignKey available in current table.

ForeignKey : It is any Id or Unique column name which identifies Unique record in foreign table.

Important Note : ForeignKey name must be same in current table as well as foreign table

By providing this option in url you will be able to get all data in foreign table matching foreign key provided. 

If everything is good and correct

You will get a JSON response with all real data from Foreign table matching ForeignKey in current table.

Thank you Enjoy Coding !
+1 Post and comment