1--TEST--
2PostgreSQL pg_fetch_object()
3--SKIPIF--
4<?php include("skipif.inc"); ?>
5--FILE--
6<?php
7error_reporting(E_ALL);
8
9include 'config.inc';
10
11class test_class {
12    function __construct($arg1, $arg2) {
13        echo __METHOD__ . "($arg1,$arg2)\n";
14    }
15}
16
17$db = pg_connect($conn_str);
18
19$sql = "SELECT * FROM $table_name WHERE num = 0";
20$result = pg_query($db, $sql) or die('Cannot query db');
21$rows = pg_num_rows($result);
22
23var_dump(pg_fetch_object($result, NULL, 'test_class', array(1, 2)));
24
25try {
26    var_dump(pg_fetch_object($result, NULL, 'does_not_exist'));
27} catch (TypeError $e) {
28    echo $e->getMessage(), "\n";
29}
30
31echo "Ok\n";
32?>
33--EXPECT--
34test_class::__construct(1,2)
35object(test_class)#1 (3) {
36  ["num"]=>
37  string(1) "0"
38  ["str"]=>
39  string(3) "ABC"
40  ["bin"]=>
41  NULL
42}
43pg_fetch_object(): Argument #3 ($class) must be a valid class name, does_not_exist given
44Ok
45