1--TEST-- 2PostgreSQL pg_convert() and JSON/Array 3--EXTENSIONS-- 4pgsql 5--SKIPIF-- 6<?php 7include("inc/skipif.inc"); 8skip_server_version('9.2'); 9?> 10--FILE-- 11<?php 12error_reporting(E_ALL); 13 14include 'inc/config.inc'; 15$table_name_92 = "table_10pg_convert_json_array_92"; 16 17$db = pg_connect($conn_str); 18pg_query($db, "CREATE TABLE {$table_name_92} (textary text[], jsn json)"); 19 20$fields = array( 21 'textary'=>'{"meeting", "lunch", "training", "presentation"}', 22 'jsn'=>'{"f1":1,"f2":"foo"}', 23); 24$converted = pg_convert($db, $table_name_92, $fields); 25var_dump($converted); 26 27if (!pg_insert($db, $table_name_92, $fields)) { 28 echo "Error\n"; 29} else { 30 echo "OK\n"; 31} 32 33?> 34--CLEAN-- 35<?php 36include('inc/config.inc'); 37$table_name_92 = "table_10pg_convert_json_array_92"; 38 39$db = pg_connect($conn_str); 40pg_query($db, "DROP TABLE IF EXISTS {$table_name_92}"); 41?> 42--EXPECT-- 43array(2) { 44 [""textary""]=> 45 string(51) "E'{"meeting", "lunch", "training", "presentation"}'" 46 [""jsn""]=> 47 string(22) "E'{"f1":1,"f2":"foo"}'" 48} 49OK 50