{ $conn = $this->connect(); if ($conn == true) { $sql = "SELECT name from helloworld"; $stmt = db2_exec($conn, $sql); $num_rows = db2_num_rows($stmt); if ($num_rows == 0 || $num_rows == "") { $sql = "INSERT INTO helloworld(NAME) VALUES ('Hello World')"; $stmt = db2_exec($conn, $sql); } } } function select() { $conn = $this->connect(); if ($conn == true) { $sql = "SELECT name from helloworld"; $result = db2_exec($conn, $sql); while ($row = db2_fetch_array($result)) { echo $text = $row[0]; } } } } $class = new MyClass(); $class->connect(); $class->insert(); ?>