Tag Archives: db2_connect

Manage DB2 Table Security and Accessing It Using PHP

Security always considered on many application especially when dealing with e-commerce. DB2 has an ability to set table security with only one line of codes.

Some tables might be accessed by public or anonymous users but others can only be accessed by private users. In order to set that we need to understand grant and revoke DB2 syntax.

Grant is giving user some permissions to a table whereas Revoke is taking user from some table permissions.

I will give example of DB2 syntaxes to set tables security start from creating DB2 instance, create a database, schema, table and grant tables. Also there is PHP web apps to ‘select’, ‘insert’ and ‘update’ to these tables. I’ve used Windows OS and DB2 (ver)..

I am using db2admin user to set initial configuration. db2admin is OS and DB2 user created when I installed DB2 software. db2admin acts as administrator in DB2. FYI DB2 user is also OS user.

Continue reading

Useful PHP DataTable Class Example To Store Objects including Recordset

Introduction

Any table like objects like array and recordset have same structure. They have rows and columns.
Usually column is a key and row is a value.

A recordset that comes from database ‘select’ operation usually stored in array or OOP object variable on MVC concept or any kind of business logic and view layer.
A web page access this variable to show its data. View layer only include database and datatable class files. So web page users doesn’t access database operational directly.

With this concept, I have build a simple DataTable class to store those kind of objects.
This DataTable has functions to add columns and rows and get their values so that we can extract information from DataTable with easy and use same methods repeatedly.
Also we can get DataTable object value on another page with SESSION functionality.

Continue reading

PHP Example Retrieve DB2 Records Per Page

Retrieving large recordset contains so many rows on web page will consume a lot of resources both server and client. Responsiveness of web page decreasing.

We need to retrieve that recordset part by part and display it using web paging method. In my previous post about Limiting DB2 Record Number I had show sql example to limit large recordset on SAMPLE Database.

This php example show employee’s related project:
Continue reading

Remote DB2 Database Connection Setup

Installation of DB2 Linux, Unix, Window (LUW) contains server and client tools. That means DB2 LUW can act as server and also as a client.

Every database connection on DB2 registered on catalog. Database has parent node catalog. So catalogues are tree view looks like. Local databases are automatically registered in database catalog.

To connect to remote database server we need to make catalog for the remote connection. After remote catalog has been registered, remote server will appear as local.
Continue reading

Connect to DB2 & Run a Query with PHP Example

PHP support a way to connect to db2 database. As a matter of fact, PHP is more prefered as web scripting that connect to db2 because so many documentation on web or IBM explaining about PHP and DB2.

PHP has extension library to work against db2. You has to enable the extension at PHP.ini file. On my Win box, the line looks like this “extension=php_ibm_db2.dll”. If you see the line commented with (;) then uncomment it and restart your IIS or apache service.
Continue reading