ad

Saturday, 24 October 2015

PHP Script | Store all $_SERVER variable data into database and retrieve


This script will stores all the data that resides in $_SERVER variable into one field in databse which can be retrived as a regular array


How to use:
To use this object instantiate the Server class and pass the required parameters. Required parameters are: ($database_object, $table_name, $field_name). This object offers two method, one to save data to databse, another to retrived saved data.

Requred variables: 
  • $id variable takes the column you are selecting.  
  • $datbase_object takes the databse object that is from database connection.
  • $table_name takes the name of the table that you want to select data from.  
  • $field_name if the name of the field in table where the server information will be or is stored 

Methods:
  • save_data() method will return true or false if data fails to insert into server, like $_Server->save_data();
  • get_data() method will return the exact array that was saved in database, from where you can either loop through it or get each value using its key like, $Server->get_data()['HTTP_HOST'] This method requires and arguement $id 

Storage:
storing server variable in database


 
Retrieval:
php array unserialized






https://github.com/phpdevsami/Store-SERVER-array-into-database
https://dl.dropboxusercontent.com/u/28490184/webdevtown/store%20server%20into%20db.rar

No comments:

Post a Comment