1--TEST-- 2PostgreSQL pg_fetch_object() 3--EXTENSIONS-- 4pgsql 5--SKIPIF-- 6<?php include("inc/skipif.inc"); ?> 7--FILE-- 8<?php 9error_reporting(E_ALL); 10 11include 'inc/config.inc'; 12$table_name = "table_22pg_fetch_object"; 13 14class test_class { 15 function __construct($arg1, $arg2) { 16 echo __METHOD__ . "($arg1,$arg2)\n"; 17 } 18} 19 20$db = pg_connect($conn_str); 21pg_query($db, "CREATE TABLE {$table_name} (num int, str text, bin bytea)"); 22pg_query($db, "INSERT INTO {$table_name} VALUES(0, 'ABC', null)"); 23 24$sql = "SELECT * FROM $table_name WHERE num = 0"; 25$result = pg_query($db, $sql) or die('Cannot query db'); 26$rows = pg_num_rows($result); 27 28var_dump(pg_fetch_object($result, NULL, 'test_class', array(1, 2))); 29 30try { 31 var_dump(pg_fetch_object($result, NULL, 'does_not_exist')); 32} catch (TypeError $e) { 33 echo $e->getMessage(), "\n"; 34} 35 36echo "Ok\n"; 37?> 38--CLEAN-- 39<?php 40include('inc/config.inc'); 41$table_name = "table_22pg_fetch_object"; 42 43$db = pg_connect($conn_str); 44pg_query($db, "DROP TABLE IF EXISTS {$table_name}"); 45?> 46--EXPECTF-- 47test_class::__construct(1,2) 48object(test_class)#%d (3) { 49 ["num"]=> 50 string(1) "0" 51 ["str"]=> 52 string(3) "ABC" 53 ["bin"]=> 54 NULL 55} 56pg_fetch_object(): Argument #3 ($class) must be a valid class name, does_not_exist given 57Ok 58