As part of the PHP for i series we will be using a MySQL database as well as the DB2 database to show how to interact with each.
When we installed ZendServer we also took the default MySQL install, once installed we started the servers using the menus provided before starting a QP2TERM session where we set the root password for MySQL. To do this simply start the QP2TERM session
CALL QP2TERM, cd to the /usr/local/mysql directory, enter the following command
./bin/mysqladmin -u root password 'yourpassword'.
To use PHP you point your browser at the appropriate website and add the phpmyadmin directory (http://myserver/phpmyadmin/ in our case because we unzipped the files into phpmyadmin directory the the servers root directory) . You will need to sign in using root and the password you had set earlier. Then create a user called phpuser with a password, create a new database called phpproj and a new table called users. The content of the users table should be the same as the DB2 table except for a new field which we added to the start of the row. This field needs to be of type INT and have the Auto increment flag set and Not NULL. We will use this id for retrieving specific records in a later exercise.
You should now have a table which looks like the following.
We will be adding data to the table using the phpusers profile so it is important to set the privileges to the table for the user. We added all privileges but you can decide the best options to suit your environment.
Thats all for this post, next we will be showing how to select a user in the PHPPROJ and display the additional information for each user using both DB2 and MySQL.