1--TEST-- 2PostgreSQL create db 3--EXTENSIONS-- 4pgsql 5--SKIPIF-- 6<?php include("inc/skipif.inc"); ?> 7--FILE-- 8<?php 9// create test table 10 11include('inc/config.inc'); 12$table_name = 'table_01createdb'; 13$table_name_92 = 'table_01createdb_92'; 14$view_name = "view_01createdb"; 15 16$db = pg_connect($conn_str); 17if (!($q = @pg_query($db, "SELECT * FROM ".$table_name)) || !@pg_num_rows($q)) 18{ 19 pg_query($db, "CREATE TABLE {$table_name} (num int, str text, bin bytea)"); // Create table here 20} 21else { 22 echo pg_last_error()."\n"; 23} 24 25$v = pg_version($db); 26if (version_compare($v['server'], '9.2', '>=') && (!($q = @pg_query($db, "SELECT * FROM ".$table_name_92)) || !@pg_num_rows($q))) 27{ 28 pg_query($db, "CREATE TABLE {$table_name_92} (textary text[], jsn json)"); // Create table here 29} 30else { 31 echo pg_last_error()."\n"; 32} 33 34// Create view here 35pg_query($db, "CREATE VIEW {$view_name} AS SELECT * FROM {$table_name}"); 36 37pg_close($db); 38 39echo "OK"; 40?> 41--CLEAN-- 42<?php 43include('inc/config.inc'); 44$table_name = 'table_01createdb'; 45$table_name_92 = 'table_01createdb_92'; 46 47$db = pg_connect($conn_str); 48pg_query($db, "DROP TABLE IF EXISTS {$table_name} cascade"); 49pg_query($db, "DROP TABLE IF EXISTS {$table_name_92} cascade"); 50?> 51--EXPECT-- 52OK 53