Skip to content
Advertisement

php/mysql: get data from one table, convert and insert in another table

Ok I will try to explain, (I am Portuguese lol).

I have a Database where I have the fallowing MySQL:

Database: ad
Table: notebooks
Fields: ID, tag, so, lastlogon, lastlogh

My ldap query gets data from ldap server (active directory) and stores it in my MySQL database (ad/notebooks). I get tag which is tag number is unique. I get so which is the OS installed in the notebook. I get lastlogh which is the last logon time stamp, and it is unique too. ID field is auto increment and key but I can set the tag filed to be key.

I have a config_notebooks.php where I set all the variables to connect to ldap and MySQL servers.

Now the query script

In this query the last logon timestamp is coded like 130276262860634000

So I can export everything to excel and decode it, but I found a code that does that, so it saves time. I created a new field in the database (lastlogon) and I need to fetch the data from lastlogh field, decode with the new script and store it in the lastlogon field.

This is the script that I found:

Advertisement

Answer

Using Mysql API

I hope this solves your problem.

Note: Mysql API is deprecated as of PHP 5.5.0. So, It’s highly recommended to use Mysqli API for newer developments.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement