import zend pgsql tests
We don't pass a single one because of Undefined function: pg_connect
Esse commit está contido em:
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
// create test table
|
||||
|
||||
include('config.inc');
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
if (!@pg_num_rows(@pg_query($db, "SELECT * FROM ".$table_name)))
|
||||
{
|
||||
@pg_query($db,$table_def); // Create table here
|
||||
for ($i=0; $i < $num_test_record; $i++) {
|
||||
pg_query($db,"INSERT INTO ".$table_name." VALUES ($i, 'ABC');");
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo pg_last_error()."\n";
|
||||
}
|
||||
|
||||
pg_close($db);
|
||||
|
||||
echo "OK";
|
||||
?>
|
||||
@@ -0,0 +1 @@
|
||||
OK
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
// connection function tests
|
||||
|
||||
include('config.inc');
|
||||
|
||||
$db = pg_pconnect($conn_str);
|
||||
var_dump($db);
|
||||
|
||||
if (pg_connection_status($db) != PGSQL_CONNECTION_OK)
|
||||
{
|
||||
echo "pg_connection_status() error\n";
|
||||
}
|
||||
if (!pg_connection_reset($db))
|
||||
{
|
||||
echo "pg_connection_reset() error\n";
|
||||
}
|
||||
if (pg_connection_busy($db))
|
||||
{
|
||||
echo "pg_connection_busy() error\n";
|
||||
}
|
||||
if (function_exists('pg_transaction_status')) {
|
||||
if (pg_transaction_status($db) != PGSQL_TRANSACTION_IDLE)
|
||||
{
|
||||
echo "pg_transaction_status() error\n";
|
||||
}
|
||||
}
|
||||
if (false === pg_host($db))
|
||||
{
|
||||
echo "pg_host() error\n";
|
||||
}
|
||||
if (!pg_dbname($db))
|
||||
{
|
||||
echo "pg_dbname() error\n";
|
||||
}
|
||||
if (!pg_port($db))
|
||||
{
|
||||
echo "pg_port() error\n";
|
||||
}
|
||||
if (pg_tty($db))
|
||||
{
|
||||
echo "pg_tty() error\n";
|
||||
}
|
||||
if (pg_options($db))
|
||||
{
|
||||
echo "pg_options() error\n";
|
||||
}
|
||||
|
||||
pg_close($db);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
@@ -0,0 +1,2 @@
|
||||
resource(%d) of type (pgsql link%s)
|
||||
===DONE===
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
include('config.inc');
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
|
||||
$result = pg_query($db, "SELECT * FROM ".$table_name.";");
|
||||
if (!($rows = pg_num_rows($result)))
|
||||
{
|
||||
echo "pg_num_row() error\n";
|
||||
}
|
||||
for ($i=0; $i < $rows; $i++)
|
||||
{
|
||||
pg_fetch_array($result, $i, PGSQL_NUM);
|
||||
}
|
||||
for ($i=0; $i < $rows; $i++)
|
||||
{
|
||||
pg_fetch_object($result);
|
||||
}
|
||||
for ($i=0; $i < $rows; $i++)
|
||||
{
|
||||
pg_fetch_row($result, $i);
|
||||
}
|
||||
for ($i=0; $i < $rows; $i++)
|
||||
{
|
||||
pg_fetch_result($result, $i, 0);
|
||||
}
|
||||
|
||||
pg_result_error($result);
|
||||
if (function_exists('pg_result_error_field')) {
|
||||
pg_result_error_field($result, PGSQL_DIAG_SEVERITY);
|
||||
pg_result_error_field($result, PGSQL_DIAG_SQLSTATE);
|
||||
pg_result_error_field($result, PGSQL_DIAG_MESSAGE_PRIMARY);
|
||||
pg_result_error_field($result, PGSQL_DIAG_MESSAGE_DETAIL);
|
||||
pg_result_error_field($result, PGSQL_DIAG_MESSAGE_HINT);
|
||||
pg_result_error_field($result, PGSQL_DIAG_STATEMENT_POSITION);
|
||||
if (defined('PGSQL_DIAG_INTERNAL_POSITION'))
|
||||
{
|
||||
pg_result_error_field($result, PGSQL_DIAG_INTERNAL_POSITION);
|
||||
}
|
||||
if (defined('PGSQL_DIAG_INTERNAL_QUERY'))
|
||||
{
|
||||
pg_result_error_field($result, PGSQL_DIAG_INTERNAL_QUERY);
|
||||
}
|
||||
pg_result_error_field($result, PGSQL_DIAG_CONTEXT);
|
||||
pg_result_error_field($result, PGSQL_DIAG_SOURCE_FILE);
|
||||
pg_result_error_field($result, PGSQL_DIAG_SOURCE_LINE);
|
||||
pg_result_error_field($result, PGSQL_DIAG_SOURCE_FUNCTION);
|
||||
}
|
||||
pg_num_rows(pg_query($db, "SELECT * FROM ".$table_name.";"));
|
||||
pg_num_fields(pg_query($db, "SELECT * FROM ".$table_name.";"));
|
||||
pg_field_name($result, 0);
|
||||
pg_field_num($result, $field_name);
|
||||
pg_field_size($result, 0);
|
||||
pg_field_type($result, 0);
|
||||
pg_field_prtlen($result, 0);
|
||||
pg_field_is_null($result, 0);
|
||||
|
||||
$result = pg_query($db, "INSERT INTO ".$table_name." VALUES (9999, 'ABC');");
|
||||
pg_last_oid($result);
|
||||
|
||||
pg_free_result($result);
|
||||
pg_close($db);
|
||||
|
||||
echo "OK";
|
||||
?>
|
||||
@@ -0,0 +1 @@
|
||||
OK
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
include('config.inc');
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
|
||||
if (!pg_send_query($db, "SELECT * FROM ".$table_name.";")) {
|
||||
echo "pg_send_query() error\n";
|
||||
}
|
||||
while(pg_connection_busy($db)); // busy wait: intended
|
||||
if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) {
|
||||
echo "pg_connection_status() error\n";
|
||||
}
|
||||
if (!($result = pg_get_result($db)))
|
||||
{
|
||||
echo "pg_get_result() error\n";
|
||||
}
|
||||
|
||||
if (!($rows = pg_num_rows($result))) {
|
||||
echo "pg_num_rows() error\n";
|
||||
}
|
||||
for ($i=0; $i < $rows; $i++)
|
||||
{
|
||||
pg_fetch_array($result, $i, PGSQL_NUM);
|
||||
}
|
||||
for ($i=0; $i < $rows; $i++)
|
||||
{
|
||||
pg_fetch_object($result);
|
||||
}
|
||||
for ($i=0; $i < $rows; $i++)
|
||||
{
|
||||
pg_fetch_row($result, $i);
|
||||
}
|
||||
for ($i=0; $i < $rows; $i++)
|
||||
{
|
||||
pg_fetch_result($result, $i, 0);
|
||||
}
|
||||
|
||||
pg_num_rows(pg_query($db, "SELECT * FROM ".$table_name.";"));
|
||||
pg_num_fields(pg_query($db, "SELECT * FROM ".$table_name.";"));
|
||||
pg_field_name($result, 0);
|
||||
pg_field_num($result, $field_name);
|
||||
pg_field_size($result, 0);
|
||||
pg_field_type($result, 0);
|
||||
pg_field_prtlen($result, 0);
|
||||
pg_field_is_null($result, 0);
|
||||
|
||||
if (!pg_send_query($db, "INSERT INTO ".$table_name." VALUES (8888, 'GGG');"))
|
||||
{
|
||||
echo "pg_send_query() error\n";
|
||||
}
|
||||
|
||||
pg_last_oid($result);
|
||||
pg_free_result($result);
|
||||
|
||||
|
||||
echo "OK";
|
||||
?>
|
||||
@@ -0,0 +1 @@
|
||||
OK
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
include('config.inc');
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
|
||||
echo "create/write/close LO\n";
|
||||
pg_exec ($db, "begin");
|
||||
$oid = pg_lo_create ($db);
|
||||
if (!$oid) echo ("pg_lo_create() error\n");
|
||||
$handle = pg_lo_open ($db, $oid, "w");
|
||||
if (!$handle) echo ("pg_lo_open() error\n");
|
||||
pg_lo_write ($handle, "large object data\n");
|
||||
pg_lo_close ($handle);
|
||||
pg_exec ($db, "commit");
|
||||
|
||||
echo "open/read/tell/seek/close LO\n";
|
||||
pg_exec ($db, "begin");
|
||||
$handle = pg_lo_open ($db, $oid, "w");
|
||||
pg_lo_read($handle, 100);
|
||||
pg_lo_tell($handle);
|
||||
pg_lo_seek($handle, 2);
|
||||
pg_lo_close($handle);
|
||||
pg_exec ($db, "commit");
|
||||
|
||||
echo "open/read_all/close LO\n";
|
||||
pg_exec ($db, "begin");
|
||||
$handle = pg_lo_open ($db, $oid, "w");
|
||||
pg_lo_read_all($handle);
|
||||
if (pg_last_error()) echo "pg_lo_read_all() error\n".pg_last_error();
|
||||
pg_lo_close($handle);
|
||||
pg_exec ($db, "commit");
|
||||
|
||||
echo "unlink LO\n";
|
||||
pg_exec ($db, "begin");
|
||||
pg_lo_unlink($db, $oid) or print("pg_lo_unlink() error 1\n");
|
||||
pg_exec ($db, "commit");
|
||||
|
||||
// more pg_lo_unlink() tests
|
||||
echo "Test without connection\n";
|
||||
pg_exec ($db, "begin");
|
||||
$oid = pg_lo_create ($db) or print("pg_lo_create() error\n");
|
||||
pg_lo_unlink($oid) or print("pg_lo_unlink() error 2\n");
|
||||
pg_exec ($db, "commit");
|
||||
|
||||
echo "Test with string oid value\n";
|
||||
pg_exec ($db, "begin");
|
||||
$oid = pg_lo_create ($db) or print("pg_lo_create() error\n");
|
||||
pg_lo_unlink($db, (string)$oid) or print("pg_lo_unlink() error 3\n");
|
||||
pg_exec ($db, "commit");
|
||||
|
||||
echo "import/export LO\n";
|
||||
$path = dirname(__FILE__) . '/';
|
||||
pg_query($db, 'begin');
|
||||
$oid = pg_lo_import($db, $path . 'php.gif');
|
||||
pg_query($db, 'commit');
|
||||
pg_query($db, 'begin');
|
||||
@unlink($path . 'php.gif.exported');
|
||||
pg_lo_export($oid, $path . 'php.gif.exported', $db);
|
||||
if (!file_exists($path . 'php.gif.exported')) {
|
||||
echo "Export failed\n";
|
||||
}
|
||||
@unlink($path . 'php.gif.exported');
|
||||
pg_query($db, 'commit');
|
||||
|
||||
echo "OK";
|
||||
?>
|
||||
@@ -0,0 +1,9 @@
|
||||
create/write/close LO
|
||||
open/read/tell/seek/close LO
|
||||
open/read_all/close LO
|
||||
large object data
|
||||
unlink LO
|
||||
Test without connection
|
||||
Test with string oid value
|
||||
import/export LO
|
||||
OK
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
include('config.inc');
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
|
||||
$rows = pg_copy_to($db, $table_name);
|
||||
|
||||
pg_query($db, "DELETE FROM $table_name");
|
||||
|
||||
pg_copy_from($db, $table_name, $rows);
|
||||
|
||||
echo "OK";
|
||||
|
||||
?>
|
||||
@@ -0,0 +1 @@
|
||||
OK
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
// optional functions
|
||||
|
||||
include('config.inc');
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
$enc = pg_client_encoding($db);
|
||||
|
||||
pg_set_client_encoding($db, $enc);
|
||||
|
||||
if (function_exists('pg_set_error_verbosity')) {
|
||||
pg_set_error_verbosity(PGSQL_ERRORS_TERSE);
|
||||
pg_set_error_verbosity(PGSQL_ERRORS_DEFAULT);
|
||||
pg_set_error_verbosity(PGSQL_ERRORS_VERBOSE);
|
||||
}
|
||||
echo "OK";
|
||||
?>
|
||||
@@ -0,0 +1 @@
|
||||
OK
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
include 'config.inc';
|
||||
define('FILE_NAME', dirname(__FILE__) . '/php.gif');
|
||||
|
||||
// pg_escape_string() test
|
||||
$before = "ABC\\ABC\'";
|
||||
$expect = "ABC\\\\ABC\\'";
|
||||
$expect2 = "ABC\\\\ABC\\\\''"; //the way escape string differs from PostgreSQL 9.0
|
||||
$after = pg_escape_string($before);
|
||||
if ($expect === $after || $expect2 === $after) {
|
||||
echo "pg_escape_string() is Ok\n";
|
||||
}
|
||||
else {
|
||||
echo "pg_escape_string() is NOT Ok\n";
|
||||
var_dump($before);
|
||||
var_dump($after);
|
||||
var_dump($expect);
|
||||
}
|
||||
|
||||
// pg_escape_bytea() test
|
||||
$before = "ABC\\ABC";
|
||||
$expect = "ABC\\\\\\\\ABC";
|
||||
$after = pg_escape_bytea($before);
|
||||
if ($expect === $after) {
|
||||
echo "pg_escape_bytea() is Ok\n";
|
||||
}
|
||||
else {
|
||||
echo "pg_escape_byte() is NOT Ok\n";
|
||||
var_dump($before);
|
||||
var_dump($after);
|
||||
var_dump($expect);
|
||||
}
|
||||
|
||||
// Test using database
|
||||
$data = file_get_contents(FILE_NAME);
|
||||
$db = pg_connect($conn_str);
|
||||
|
||||
// Insert binary to DB
|
||||
$escaped_data = pg_escape_bytea($data);
|
||||
pg_query("DELETE FROM ".$table_name." WHERE num = -9999;");
|
||||
$sql = "INSERT INTO ".$table_name." (num, bin) VALUES (-9999, CAST ('".$escaped_data."' AS BYTEA));";
|
||||
pg_query($db, $sql);
|
||||
|
||||
// Retrieve binary from DB
|
||||
$sql = "SELECT bin::bytea FROM ".$table_name." WHERE num = -9999";
|
||||
$result = pg_query($db, $sql);
|
||||
$row = pg_fetch_array($result, 0, PGSQL_ASSOC);
|
||||
|
||||
if ($data === pg_unescape_bytea($row['bin'])) {
|
||||
echo "pg_escape_bytea() actually works with database\n";
|
||||
}
|
||||
else {
|
||||
echo "pg_escape_bytea() is broken\n";
|
||||
}
|
||||
|
||||
// pg_escape_literal/pg_escape_identifier
|
||||
$before = "ABC\\ABC\'";
|
||||
$expect = " E'ABC\\\\ABC\\\\'''";
|
||||
$after = pg_escape_literal($before);
|
||||
if ($expect === $after) {
|
||||
echo "pg_escape_literal() is Ok\n";
|
||||
}
|
||||
else {
|
||||
echo "pg_escape_literal() is NOT Ok\n";
|
||||
var_dump($before);
|
||||
var_dump($after);
|
||||
var_dump($expect);
|
||||
}
|
||||
|
||||
$before = "ABC\\ABC\'";
|
||||
$expect = "\"ABC\ABC\'\"";
|
||||
$after = pg_escape_identifier($before);
|
||||
if ($expect === $after) {
|
||||
echo "pg_escape_identifier() is Ok\n";
|
||||
}
|
||||
else {
|
||||
echo "pg_escape_identifier() is NOT Ok\n";
|
||||
var_dump($before);
|
||||
var_dump($after);
|
||||
var_dump($expect);
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,5 @@
|
||||
pg_escape_string() is Ok
|
||||
pg_escape_bytea() is Ok
|
||||
pg_escape_bytea() actually works with database
|
||||
pg_escape_literal() is Ok
|
||||
pg_escape_identifier() is Ok
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
error_reporting(E_ALL);
|
||||
|
||||
include 'config.inc';
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
|
||||
$fields = array('num'=>'1234', 'str'=>'AAA', 'bin'=>'BBB');
|
||||
$converted = pg_convert($db, $table_name, $fields);
|
||||
|
||||
var_dump($converted);
|
||||
?>
|
||||
@@ -0,0 +1,8 @@
|
||||
array(3) {
|
||||
["num"]=>
|
||||
string(4) "1234"
|
||||
["str"]=>
|
||||
string(5) "'AAA'"
|
||||
["bin"]=>
|
||||
string(5) "'BBB'"
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
error_reporting(E_ALL);
|
||||
|
||||
include 'config.inc';
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
|
||||
$fields = array('num'=>'1234', 'str'=>'AAA', 'bin'=>'BBB');
|
||||
$converted = pg_convert($db, $table_name, $fields);
|
||||
|
||||
var_dump($converted);
|
||||
?>
|
||||
@@ -0,0 +1,8 @@
|
||||
array(3) {
|
||||
["num"]=>
|
||||
string(4) "1234"
|
||||
["str"]=>
|
||||
string(5) "'AAA'"
|
||||
["bin"]=>
|
||||
string(11) "'\\x424242'"
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
error_reporting(E_ALL);
|
||||
|
||||
include 'config.inc';
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
|
||||
$meta = pg_meta_data($db, $table_name);
|
||||
|
||||
var_dump($meta);
|
||||
?>
|
||||
@@ -0,0 +1,47 @@
|
||||
array(3) {
|
||||
["num"]=>
|
||||
array(6) {
|
||||
["num"]=>
|
||||
int(1)
|
||||
["type"]=>
|
||||
string(4) "int4"
|
||||
["len"]=>
|
||||
int(4)
|
||||
["not null"]=>
|
||||
bool(false)
|
||||
["has default"]=>
|
||||
bool(false)
|
||||
["array dims"]=>
|
||||
int(0)
|
||||
}
|
||||
["str"]=>
|
||||
array(6) {
|
||||
["num"]=>
|
||||
int(2)
|
||||
["type"]=>
|
||||
string(4) "text"
|
||||
["len"]=>
|
||||
int(-1)
|
||||
["not null"]=>
|
||||
bool(false)
|
||||
["has default"]=>
|
||||
bool(false)
|
||||
["array dims"]=>
|
||||
int(0)
|
||||
}
|
||||
["bin"]=>
|
||||
array(6) {
|
||||
["num"]=>
|
||||
int(3)
|
||||
["type"]=>
|
||||
string(5) "bytea"
|
||||
["len"]=>
|
||||
int(-1)
|
||||
["not null"]=>
|
||||
bool(false)
|
||||
["has default"]=>
|
||||
bool(false)
|
||||
["array dims"]=>
|
||||
int(0)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
error_reporting(E_ALL);
|
||||
|
||||
include 'config.inc';
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
$fields = array('num'=>'1234', 'str'=>'AAA', 'bin'=>'BBB');
|
||||
|
||||
pg_insert($db, $table_name, $fields) or print "Error in test 1\n";
|
||||
echo pg_insert($db, $table_name, $fields, PGSQL_DML_STRING)."\n";
|
||||
|
||||
echo "Ok\n";
|
||||
?>
|
||||
@@ -0,0 +1,2 @@
|
||||
INSERT INTO php_pgsql_test (num,str,bin) VALUES (1234,'AAA','BBB');
|
||||
Ok
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
error_reporting(E_ALL);
|
||||
|
||||
include 'config.inc';
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
$fields = array('num'=>'1234', 'str'=>'AAA', 'bin'=>'BBB');
|
||||
|
||||
pg_insert($db, $table_name, $fields) or print "Error in test 1\n";
|
||||
echo pg_insert($db, $table_name, $fields, PGSQL_DML_STRING)."\n";
|
||||
|
||||
echo "Ok\n";
|
||||
?>
|
||||
@@ -0,0 +1,2 @@
|
||||
INSERT INTO php_pgsql_test (num,str,bin) VALUES (1234,'AAA','\\x424242');
|
||||
Ok
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
error_reporting(E_ALL);
|
||||
|
||||
include 'config.inc';
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
$fields = array('num'=>'1234', 'str'=>'ABC', 'bin'=>'XYZ');
|
||||
$ids = array('num'=>'1234');
|
||||
|
||||
$res = pg_select($db, $table_name, $ids) or print "Error\n";
|
||||
var_dump($res);
|
||||
echo pg_select($db, $table_name, $ids, PGSQL_DML_STRING)."\n";
|
||||
echo "Ok\n";
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,13 @@
|
||||
array(1) {
|
||||
[0]=>
|
||||
array(3) {
|
||||
["num"]=>
|
||||
string(4) "1234"
|
||||
["str"]=>
|
||||
string(3) "AAA"
|
||||
["bin"]=>
|
||||
string(3) "BBB"
|
||||
}
|
||||
}
|
||||
SELECT * FROM php_pgsql_test WHERE num=1234;
|
||||
Ok
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
error_reporting(E_ALL);
|
||||
|
||||
include 'config.inc';
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
$fields = array('num'=>'1234', 'str'=>'ABC', 'bin'=>'XYZ');
|
||||
$ids = array('num'=>'1234');
|
||||
|
||||
$res = pg_select($db, $table_name, $ids) or print "Error\n";
|
||||
var_dump($res);
|
||||
echo pg_select($db, $table_name, $ids, PGSQL_DML_STRING)."\n";
|
||||
echo "Ok\n";
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,13 @@
|
||||
array(1) {
|
||||
[0]=>
|
||||
array(3) {
|
||||
["num"]=>
|
||||
string(4) "1234"
|
||||
["str"]=>
|
||||
string(3) "AAA"
|
||||
["bin"]=>
|
||||
string(8) "\x424242"
|
||||
}
|
||||
}
|
||||
SELECT * FROM php_pgsql_test WHERE num=1234;
|
||||
Ok
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
error_reporting(E_ALL);
|
||||
|
||||
include 'config.inc';
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
$fields = array('num'=>'1234', 'str'=>'ABC', 'bin'=>'XYZ');
|
||||
$ids = array('num'=>'1234');
|
||||
|
||||
pg_update($db, $table_name, $fields, $ids) or print "Error in test 1\n";
|
||||
echo pg_update($db, $table_name, $fields, $ids, PGSQL_DML_STRING)."\n";
|
||||
|
||||
echo "Ok\n";
|
||||
?>
|
||||
@@ -0,0 +1,2 @@
|
||||
UPDATE php_pgsql_test SET num=1234,str='ABC',bin='XYZ' WHERE num=1234;
|
||||
Ok
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
error_reporting(E_ALL);
|
||||
|
||||
include 'config.inc';
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
$fields = array('num'=>'1234', 'str'=>'ABC', 'bin'=>'XYZ');
|
||||
$ids = array('num'=>'1234');
|
||||
|
||||
pg_update($db, $table_name, $fields, $ids) or print "Error in test 1\n";
|
||||
echo pg_update($db, $table_name, $fields, $ids, PGSQL_DML_STRING)."\n";
|
||||
|
||||
echo "Ok\n";
|
||||
?>
|
||||
@@ -0,0 +1,2 @@
|
||||
UPDATE php_pgsql_test SET num=1234,str='ABC',bin='\\x58595a' WHERE num=1234;
|
||||
Ok
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
error_reporting(E_ALL);
|
||||
|
||||
include 'config.inc';
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
|
||||
$fields = array('num'=>'1234', 'str'=>'XXX', 'bin'=>'YYY');
|
||||
$ids = array('num'=>'1234');
|
||||
if (!pg_delete($db, $table_name, $ids)) {
|
||||
echo "Error\n";
|
||||
}
|
||||
else {
|
||||
echo "Ok\n";
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1 @@
|
||||
Ok
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
include 'config.inc';
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
|
||||
$sql = "SELECT * FROM ".$table_name." WHERE num = -2";
|
||||
$result = pg_query($db, "BEGIN;END");
|
||||
|
||||
echo pg_result_status($result)."\n";
|
||||
echo pg_result_status($result, PGSQL_STATUS_STRING)."\n";
|
||||
?>
|
||||
@@ -0,0 +1,2 @@
|
||||
1
|
||||
COMMIT
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
error_reporting(E_ALL);
|
||||
|
||||
include 'config.inc';
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
|
||||
$sql = "SELECT * FROM $table_name";
|
||||
$result = pg_query($db, $sql) or die('Cannot qeury db');
|
||||
$rows = pg_num_rows($result);
|
||||
|
||||
var_dump(pg_result_seek($result, 1));
|
||||
var_dump(pg_fetch_object($result));
|
||||
var_dump(pg_fetch_array($result, 1));
|
||||
var_dump(pg_fetch_row($result, 1));
|
||||
var_dump(pg_fetch_assoc($result, 1));
|
||||
var_dump(pg_result_seek($result, 0));
|
||||
|
||||
echo "Ok\n";
|
||||
?>
|
||||
@@ -0,0 +1,41 @@
|
||||
bool(true)
|
||||
object(stdClass)#1 (3) {
|
||||
["num"]=>
|
||||
string(1) "1"
|
||||
["str"]=>
|
||||
string(3) "ABC"
|
||||
["bin"]=>
|
||||
NULL
|
||||
}
|
||||
array(6) {
|
||||
[0]=>
|
||||
string(1) "1"
|
||||
["num"]=>
|
||||
string(1) "1"
|
||||
[1]=>
|
||||
string(3) "ABC"
|
||||
["str"]=>
|
||||
string(3) "ABC"
|
||||
[2]=>
|
||||
NULL
|
||||
["bin"]=>
|
||||
NULL
|
||||
}
|
||||
array(3) {
|
||||
[0]=>
|
||||
string(1) "1"
|
||||
[1]=>
|
||||
string(3) "ABC"
|
||||
[2]=>
|
||||
NULL
|
||||
}
|
||||
array(3) {
|
||||
["num"]=>
|
||||
string(1) "1"
|
||||
["str"]=>
|
||||
string(3) "ABC"
|
||||
["bin"]=>
|
||||
NULL
|
||||
}
|
||||
bool(true)
|
||||
Ok
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
// optional functions
|
||||
|
||||
include('config.inc');
|
||||
|
||||
$image = file_get_contents(dirname(__FILE__) . '/php.gif');
|
||||
$esc_image = pg_escape_bytea($image);
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
pg_query($db, 'INSERT INTO '.$table_name.' (num, bin) VALUES (9876, \''.$esc_image.'\');');
|
||||
$result = pg_query($db, 'SELECT * FROM '.$table_name.' WHERE num = 9876');
|
||||
$rows = pg_fetch_all($result);
|
||||
$unesc_image = pg_unescape_bytea($rows[0]['bin']);
|
||||
|
||||
if ($unesc_image !== $image) {
|
||||
echo "NG";
|
||||
}
|
||||
else {
|
||||
echo "OK";
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1 @@
|
||||
OK
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
// optional functions
|
||||
|
||||
include('config.inc');
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
var_dump(pg_ping($db));
|
||||
?>
|
||||
@@ -0,0 +1 @@
|
||||
bool(true)
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
// optional functions
|
||||
|
||||
include('config.inc');
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
$pid = pg_get_pid($db);
|
||||
|
||||
is_integer($pid) ? print 'OK' : print 'NG';
|
||||
?>
|
||||
@@ -0,0 +1 @@
|
||||
OK
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
// optional functions
|
||||
|
||||
include('config.inc');
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
pg_query($db, 'LISTEN test_msg');
|
||||
pg_query($db, 'NOTIFY test_msg');
|
||||
|
||||
$msg = pg_get_notify($db);
|
||||
|
||||
isset($msg['message'],$msg['pid']) ? print 'OK' : print 'NG';
|
||||
?>
|
||||
@@ -0,0 +1 @@
|
||||
OK
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
error_reporting(E_ALL);
|
||||
|
||||
include 'config.inc';
|
||||
|
||||
class test_class {
|
||||
function __construct($arg1, $arg2) {
|
||||
echo __METHOD__ . "($arg1,$arg2)\n";
|
||||
}
|
||||
}
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
|
||||
$sql = "SELECT * FROM $table_name WHERE num = 0";
|
||||
$result = pg_query($db, $sql) or die('Cannot qeury db');
|
||||
$rows = pg_num_rows($result);
|
||||
|
||||
var_dump(pg_fetch_object($result, NULL, 'test_class', array(1, 2)));
|
||||
|
||||
echo "Ok\n";
|
||||
?>
|
||||
@@ -0,0 +1,10 @@
|
||||
test_class::__construct(1,2)
|
||||
object(test_class)#1 (3) {
|
||||
["num"]=>
|
||||
string(1) "0"
|
||||
["str"]=>
|
||||
string(3) "ABC"
|
||||
["bin"]=>
|
||||
NULL
|
||||
}
|
||||
Ok
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
include('config.inc');
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
|
||||
$version = pg_version($db);
|
||||
if ($version['protocol'] >= 3) {
|
||||
$result = pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100));
|
||||
if (!($rows = pg_num_rows($result)))
|
||||
{
|
||||
echo "pg_num_row() error\n";
|
||||
}
|
||||
for ($i=0; $i < $rows; $i++)
|
||||
{
|
||||
pg_fetch_array($result, $i, PGSQL_NUM);
|
||||
}
|
||||
for ($i=0; $i < $rows; $i++)
|
||||
{
|
||||
pg_fetch_object($result);
|
||||
}
|
||||
for ($i=0; $i < $rows; $i++)
|
||||
{
|
||||
pg_fetch_row($result, $i);
|
||||
}
|
||||
for ($i=0; $i < $rows; $i++)
|
||||
{
|
||||
pg_fetch_result($result, $i, 0);
|
||||
}
|
||||
|
||||
pg_result_error($result);
|
||||
pg_num_rows(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100)));
|
||||
pg_num_fields(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100)));
|
||||
pg_field_name($result, 0);
|
||||
pg_field_num($result, $field_name);
|
||||
pg_field_size($result, 0);
|
||||
pg_field_type($result, 0);
|
||||
pg_field_prtlen($result, 0);
|
||||
pg_field_is_null($result, 0);
|
||||
|
||||
$result = pg_query_params($db, "INSERT INTO ".$table_name." VALUES (\$1, \$2);", array(9999, "A'BC"));
|
||||
pg_last_oid($result);
|
||||
|
||||
pg_free_result($result);
|
||||
}
|
||||
pg_close($db);
|
||||
|
||||
echo "OK";
|
||||
?>
|
||||
@@ -0,0 +1 @@
|
||||
OK
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
include('config.inc');
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
|
||||
$version = pg_version($db);
|
||||
if ($version['protocol'] >= 3) {
|
||||
$result = pg_prepare($db, "php_test", "SELECT * FROM ".$table_name." WHERE num > \$1;");
|
||||
pg_result_error($result);
|
||||
pg_free_result($result);
|
||||
$result = pg_execute($db, "php_test", array(100));
|
||||
if (!($rows = pg_num_rows($result)))
|
||||
{
|
||||
echo "pg_num_row() error\n";
|
||||
}
|
||||
for ($i=0; $i < $rows; $i++)
|
||||
{
|
||||
pg_fetch_array($result, $i, PGSQL_NUM);
|
||||
}
|
||||
for ($i=0; $i < $rows; $i++)
|
||||
{
|
||||
pg_fetch_object($result);
|
||||
}
|
||||
for ($i=0; $i < $rows; $i++)
|
||||
{
|
||||
pg_fetch_row($result, $i);
|
||||
}
|
||||
for ($i=0; $i < $rows; $i++)
|
||||
{
|
||||
pg_fetch_result($result, $i, 0);
|
||||
}
|
||||
|
||||
pg_result_error($result);
|
||||
pg_num_rows(pg_execute($db, "php_test", array(100)));
|
||||
pg_num_fields(pg_execute($db, "php_test", array(100)));
|
||||
pg_field_name($result, 0);
|
||||
pg_field_num($result, $field_name);
|
||||
pg_field_size($result, 0);
|
||||
pg_field_type($result, 0);
|
||||
pg_field_prtlen($result, 0);
|
||||
pg_field_is_null($result, 0);
|
||||
|
||||
$result = pg_prepare($db, "php_test2", "INSERT INTO ".$table_name." VALUES (\$1, \$2);");
|
||||
pg_result_error($result);
|
||||
pg_free_result($result);
|
||||
$result = pg_execute($db, "php_test2", array(9999, "A'BC"));
|
||||
pg_last_oid($result);
|
||||
|
||||
pg_free_result($result);
|
||||
}
|
||||
pg_close($db);
|
||||
|
||||
echo "OK";
|
||||
?>
|
||||
@@ -0,0 +1 @@
|
||||
OK
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
include('config.inc');
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
|
||||
$version = pg_version($db);
|
||||
if ($version['protocol'] >= 3) {
|
||||
if (!pg_send_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100))) {
|
||||
echo "pg_send_query_params() error\n";
|
||||
}
|
||||
while(pg_connection_busy($db)); // busy wait: intended
|
||||
if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) {
|
||||
echo "pg_connection_status() error\n";
|
||||
}
|
||||
if (!($result = pg_get_result($db)))
|
||||
{
|
||||
echo "pg_get_result() error\n";
|
||||
}
|
||||
if (!($rows = pg_num_rows($result))) {
|
||||
echo "pg_num_rows() error\n";
|
||||
}
|
||||
for ($i=0; $i < $rows; $i++)
|
||||
{
|
||||
pg_fetch_array($result, $i, PGSQL_NUM);
|
||||
}
|
||||
for ($i=0; $i < $rows; $i++)
|
||||
{
|
||||
pg_fetch_object($result);
|
||||
}
|
||||
for ($i=0; $i < $rows; $i++)
|
||||
{
|
||||
pg_fetch_row($result, $i);
|
||||
}
|
||||
for ($i=0; $i < $rows; $i++)
|
||||
{
|
||||
pg_fetch_result($result, $i, 0);
|
||||
}
|
||||
|
||||
pg_num_rows(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100)));
|
||||
pg_num_fields(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100)));
|
||||
pg_field_name($result, 0);
|
||||
pg_field_num($result, $field_name);
|
||||
pg_field_size($result, 0);
|
||||
pg_field_type($result, 0);
|
||||
pg_field_prtlen($result, 0);
|
||||
pg_field_is_null($result, 0);
|
||||
|
||||
if (!pg_send_query_params($db, "INSERT INTO ".$table_name." VALUES (\$1, \$2);", array(9999, "A'BC")))
|
||||
{
|
||||
echo "pg_send_query_params() error\n";
|
||||
}
|
||||
|
||||
pg_last_oid($result);
|
||||
pg_free_result($result);
|
||||
}
|
||||
pg_close($db);
|
||||
|
||||
echo "OK";
|
||||
?>
|
||||
@@ -0,0 +1 @@
|
||||
OK
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
include('config.inc');
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
|
||||
$version = pg_version($db);
|
||||
if ($version['protocol'] >= 3) {
|
||||
if (!pg_send_prepare($db, 'php_test', "SELECT * FROM ".$table_name." WHERE num > \$1;")) {
|
||||
echo "pg_send_prepare() error\n";
|
||||
}
|
||||
while(pg_connection_busy($db)); // busy wait: intended
|
||||
if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) {
|
||||
echo "pg_connection_status() error\n";
|
||||
}
|
||||
if (!($result = pg_get_result($db)))
|
||||
{
|
||||
echo "pg_get_result() error\n";
|
||||
}
|
||||
pg_free_result($result);
|
||||
|
||||
if (!pg_send_execute($db, 'php_test', array(100))) {
|
||||
echo "pg_send_execute() error\n";
|
||||
}
|
||||
while(pg_connection_busy($db)); // busy wait: intended
|
||||
if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) {
|
||||
echo "pg_connection_status() error\n";
|
||||
}
|
||||
if (!($result = pg_get_result($db)))
|
||||
{
|
||||
echo "pg_get_result() error\n";
|
||||
}
|
||||
|
||||
if (!($rows = pg_num_rows($result))) {
|
||||
echo "pg_num_rows() error\n";
|
||||
}
|
||||
for ($i=0; $i < $rows; $i++)
|
||||
{
|
||||
pg_fetch_array($result, $i, PGSQL_NUM);
|
||||
}
|
||||
for ($i=0; $i < $rows; $i++)
|
||||
{
|
||||
pg_fetch_object($result);
|
||||
}
|
||||
for ($i=0; $i < $rows; $i++)
|
||||
{
|
||||
pg_fetch_row($result, $i);
|
||||
}
|
||||
for ($i=0; $i < $rows; $i++)
|
||||
{
|
||||
pg_fetch_result($result, $i, 0);
|
||||
}
|
||||
|
||||
pg_num_rows(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100)));
|
||||
pg_num_fields(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100)));
|
||||
pg_field_name($result, 0);
|
||||
pg_field_num($result, $field_name);
|
||||
pg_field_size($result, 0);
|
||||
pg_field_type($result, 0);
|
||||
pg_field_prtlen($result, 0);
|
||||
pg_field_is_null($result, 0);
|
||||
|
||||
if (!pg_send_prepare($db, "php_test2", "INSERT INTO ".$table_name." VALUES (\$1, \$2);"))
|
||||
{
|
||||
echo "pg_send_prepare() error\n";
|
||||
}
|
||||
while(pg_connection_busy($db)); // busy wait: intended
|
||||
if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) {
|
||||
echo "pg_connection_status() error\n";
|
||||
}
|
||||
if (!($result = pg_get_result($db)))
|
||||
{
|
||||
echo "pg_get_result() error\n";
|
||||
}
|
||||
pg_free_result($result);
|
||||
|
||||
if (!pg_send_execute($db, "php_test2", array(9999, "A'BC")))
|
||||
{
|
||||
echo "pg_send_execute() error\n";
|
||||
}
|
||||
while(pg_connection_busy($db)); // busy wait: intended
|
||||
if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) {
|
||||
echo "pg_connection_status() error\n";
|
||||
}
|
||||
if (!($result = pg_get_result($db)))
|
||||
{
|
||||
echo "pg_get_result() error\n";
|
||||
}
|
||||
|
||||
pg_last_oid($result);
|
||||
pg_free_result($result);
|
||||
}
|
||||
pg_close($db);
|
||||
|
||||
echo "OK";
|
||||
?>
|
||||
@@ -0,0 +1 @@
|
||||
OK
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
include('config.inc');
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
|
||||
echo "create LO from int\n";
|
||||
pg_exec ($db, "begin");
|
||||
$oid = pg_lo_create ($db, 21000);
|
||||
if (!$oid) echo ("pg_lo_create() error\n");
|
||||
if ($oid != 21000) echo ("pg_lo_create() wrong id\n");
|
||||
pg_lo_unlink ($db, $oid);
|
||||
pg_exec ($db, "commit");
|
||||
|
||||
echo "create LO from string\n";
|
||||
pg_exec ($db, "begin");
|
||||
$oid = pg_lo_create ($db, "21001");
|
||||
if (!$oid) echo ("pg_lo_create() error\n");
|
||||
if ($oid != 21001) echo ("pg_lo_create() wrong id\n");
|
||||
pg_lo_unlink ($db, $oid);
|
||||
pg_exec ($db, "commit");
|
||||
|
||||
echo "create LO using default connection\n";
|
||||
pg_exec ("begin");
|
||||
$oid = pg_lo_create (21002);
|
||||
if (!$oid) echo ("pg_lo_create() error\n");
|
||||
if ($oid != 21002) echo ("pg_lo_create() wrong id\n");
|
||||
pg_lo_unlink ($oid);
|
||||
pg_exec ("commit");
|
||||
|
||||
echo "OK";
|
||||
?>
|
||||
@@ -0,0 +1,4 @@
|
||||
create LO from int
|
||||
create LO from string
|
||||
create LO using default connection
|
||||
OK
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
include('config.inc');
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
|
||||
echo "import LO from int\n";
|
||||
pg_exec($db, 'begin');
|
||||
$oid = pg_lo_import($db, __FILE__, 21003);
|
||||
if (!$oid) echo ("pg_lo_import() error\n");
|
||||
if ($oid != 21003) echo ("pg_lo_import() wrong id\n");
|
||||
pg_lo_unlink ($db, $oid);
|
||||
pg_exec($db, 'commit');
|
||||
|
||||
echo "import LO from string\n";
|
||||
pg_exec($db, 'begin');
|
||||
$oid = pg_lo_import($db, __FILE__, "21004");
|
||||
if (!$oid) echo ("pg_lo_import() error\n");
|
||||
if ($oid != 21004) echo ("pg_lo_import() wrong id\n");
|
||||
pg_lo_unlink ($db, $oid);
|
||||
pg_exec($db, 'commit');
|
||||
|
||||
echo "import LO using default connection\n";
|
||||
pg_exec('begin');
|
||||
$oid = pg_lo_import($db, __FILE__, 21005);
|
||||
if (!$oid) echo ("pg_lo_import() error\n");
|
||||
if ($oid != 21005) echo ("pg_lo_import() wrong id\n");
|
||||
pg_lo_unlink ($oid);
|
||||
pg_exec('commit');
|
||||
|
||||
|
||||
echo "OK";
|
||||
?>
|
||||
@@ -0,0 +1,4 @@
|
||||
import LO from int
|
||||
import LO from string
|
||||
import LO using default connection
|
||||
OK
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
require_once('config.inc');
|
||||
|
||||
$dbh = @pg_connect($conn_str);
|
||||
if (!$dbh) {
|
||||
die ("Could not connect to the server");
|
||||
}
|
||||
pg_close($dbh);
|
||||
|
||||
require_once(dirname(__FILE__).'/../../dba/tests/test.inc');
|
||||
require_once(dirname(__FILE__).'/../../dba/tests/dba_handler.inc');
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,30 @@
|
||||
database handler: %s
|
||||
3NYNYY
|
||||
Content String 2
|
||||
Content 2 replaced
|
||||
Read during write:%sallowed
|
||||
Content 2 replaced 2nd time
|
||||
The 6th value
|
||||
array(3) {
|
||||
["key number 6"]=>
|
||||
string(13) "The 6th value"
|
||||
["key2"]=>
|
||||
string(27) "Content 2 replaced 2nd time"
|
||||
["key5"]=>
|
||||
string(23) "The last content string"
|
||||
}
|
||||
--NO-LOCK--
|
||||
3NYNYY
|
||||
Content String 2
|
||||
Content 2 replaced
|
||||
Read during write: not allowed
|
||||
Content 2 replaced 2nd time
|
||||
The 6th value
|
||||
array(3) {
|
||||
["key number 6"]=>
|
||||
string(13) "The 6th value"
|
||||
["key2"]=>
|
||||
string(27) "Content 2 replaced 2nd time"
|
||||
["key5"]=>
|
||||
string(23) "The last content string"
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
require_once('config.inc');
|
||||
|
||||
$dbh = @pg_connect($conn_str);
|
||||
if (!$dbh) {
|
||||
die ("Could not connect to the server");
|
||||
}
|
||||
|
||||
@pg_query("DROP SEQUENCE id_id_seq");
|
||||
@pg_query("DROP TABLE id");
|
||||
pg_query("CREATE TABLE id (id SERIAL, t INT)");
|
||||
|
||||
for ($i=0; $i<4; $i++) {
|
||||
pg_query("INSERT INTO id (t) VALUES ($i)");
|
||||
}
|
||||
|
||||
class Id
|
||||
{
|
||||
public $id;
|
||||
|
||||
public function getId()
|
||||
{
|
||||
global $dbh;
|
||||
|
||||
$q = pg_query($dbh, "SELECT id FROM id");
|
||||
print_r(pg_fetch_array($q));
|
||||
print_r(pg_fetch_array($q));
|
||||
$id = pg_fetch_object($q);
|
||||
var_dump($id);
|
||||
return $id->id;
|
||||
}
|
||||
}
|
||||
|
||||
$id = new Id();
|
||||
var_dump($id->getId());
|
||||
|
||||
pg_close($dbh);
|
||||
|
||||
echo "Done\n";
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,16 @@
|
||||
Array
|
||||
(
|
||||
[0] => 1
|
||||
[id] => 1
|
||||
)
|
||||
Array
|
||||
(
|
||||
[0] => 2
|
||||
[id] => 2
|
||||
)
|
||||
object(stdClass)#%d (1) {
|
||||
["id"]=>
|
||||
string(1) "3"
|
||||
}
|
||||
string(1) "3"
|
||||
Done
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
require_once(dirname(__FILE__) . '/config.inc');
|
||||
|
||||
$dbh = @pg_connect($conn_str);
|
||||
if (!$dbh) {
|
||||
die ("Could not connect to the server");
|
||||
}
|
||||
|
||||
@pg_query("DROP TABLE id");
|
||||
pg_query("CREATE TABLE id (id INT)");
|
||||
|
||||
for ($i=0; $i<4; $i++) {
|
||||
pg_query("INSERT INTO id (id) VALUES ($i)");
|
||||
}
|
||||
|
||||
function xi_fetch_array($res, $type = PGSQL_ASSOC) {
|
||||
$a = pg_fetch_array($res, NULL, $type) ;
|
||||
return $a ;
|
||||
}
|
||||
|
||||
$res = pg_query("SELECT * FROM id");
|
||||
$i = 0; // endless-loop protection
|
||||
while($row = xi_fetch_array($res)) {
|
||||
print_r($row);
|
||||
if ($i++ > 4) {
|
||||
echo "ENDLESS-LOOP";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
pg_close($dbh);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
@@ -0,0 +1,17 @@
|
||||
Array
|
||||
(
|
||||
[id] => 0
|
||||
)
|
||||
Array
|
||||
(
|
||||
[id] => 1
|
||||
)
|
||||
Array
|
||||
(
|
||||
[id] => 2
|
||||
)
|
||||
Array
|
||||
(
|
||||
[id] => 3
|
||||
)
|
||||
===DONE===
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
require_once('config.inc');
|
||||
require_once('lcmess.inc');
|
||||
|
||||
$dbh = @pg_connect($conn_str);
|
||||
if (!$dbh) {
|
||||
die ("Could not connect to the server");
|
||||
}
|
||||
|
||||
_set_lc_messages();
|
||||
|
||||
$res = pg_query($dbh, "CREATE OR REPLACE FUNCTION test_notice() RETURNS boolean AS '
|
||||
begin
|
||||
RAISE NOTICE ''11111'';
|
||||
return ''f'';
|
||||
end;
|
||||
' LANGUAGE plpgsql;");
|
||||
|
||||
|
||||
$res = pg_query($dbh, 'SELECT test_notice()');
|
||||
$row = pg_fetch_row($res, 0);
|
||||
var_dump($row);
|
||||
pg_free_result($res);
|
||||
if ($row[0] == 'f')
|
||||
{
|
||||
var_dump(pg_last_notice($dbh));
|
||||
}
|
||||
|
||||
pg_close($dbh);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
@@ -0,0 +1,6 @@
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(1) "f"
|
||||
}
|
||||
string(14) "NOTICE: 11111"
|
||||
===DONE===
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
require_once('config.inc');
|
||||
require_once('lcmess.inc');
|
||||
|
||||
define('dbh', pg_connect($conn_str));
|
||||
if (!dbh) {
|
||||
die ("Could not connect to the server");
|
||||
}
|
||||
|
||||
_set_lc_messages();
|
||||
|
||||
$res = pg_query(dbh, "CREATE OR REPLACE FUNCTION test_notice() RETURNS boolean AS '
|
||||
begin
|
||||
RAISE NOTICE ''11111'';
|
||||
return ''f'';
|
||||
end;
|
||||
' LANGUAGE plpgsql;");
|
||||
|
||||
function tester() {
|
||||
$res = pg_query(dbh, 'SELECT test_notice()');
|
||||
$row = pg_fetch_row($res, 0);
|
||||
var_dump($row);
|
||||
pg_free_result($res);
|
||||
if ($row[0] == 'f')
|
||||
{
|
||||
var_dump(pg_last_notice(dbh));
|
||||
}
|
||||
}
|
||||
tester();
|
||||
|
||||
pg_close(dbh);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
@@ -0,0 +1,6 @@
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(1) "f"
|
||||
}
|
||||
string(14) "NOTICE: 11111"
|
||||
===DONE===
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
require_once('config.inc');
|
||||
|
||||
$dbh = @pg_connect($conn_str);
|
||||
if (!$dbh) {
|
||||
die ('Could not connect to the server');
|
||||
}
|
||||
|
||||
$tracefile = dirname(__FILE__) . '/trace.tmp';
|
||||
|
||||
@unlink($tracefile);
|
||||
var_dump(file_exists($tracefile));
|
||||
|
||||
pg_trace($tracefile, 'w', $dbh);
|
||||
$res = pg_query($dbh, 'select 1');
|
||||
var_dump($res);
|
||||
pg_close($dbh);
|
||||
|
||||
$found = 0;
|
||||
function search_trace_file($line)
|
||||
{
|
||||
if (strpos($line, '"select 1"') !== false || strpos($line, "'select 1'") !== false) {
|
||||
$GLOBALS['found']++;
|
||||
}
|
||||
}
|
||||
|
||||
$trace = file($tracefile);
|
||||
array_walk($trace, 'search_trace_file');
|
||||
var_dump($found > 0);
|
||||
var_dump(file_exists($tracefile));
|
||||
|
||||
?>
|
||||
===DONE===<?php unlink($tracefile); ?>
|
||||
@@ -0,0 +1,5 @@
|
||||
bool(false)
|
||||
resource(%d) of type (pgsql result)
|
||||
bool(true)
|
||||
bool(true)
|
||||
===DONE===
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
require_once('config.inc');
|
||||
|
||||
$dbh = @pg_connect($conn_str);
|
||||
if (!$dbh) {
|
||||
die ("Could not connect to the server");
|
||||
}
|
||||
|
||||
pg_query("CREATE TABLE php_test (id SERIAL, tm timestamp NOT NULL)");
|
||||
|
||||
$values = array('tm' => 'now()');
|
||||
pg_insert($dbh, 'php_test', $values);
|
||||
|
||||
$ids = array('id' => 1);
|
||||
pg_update($dbh, 'php_test', $values, $ids);
|
||||
|
||||
pg_query($dbh, "DROP TABLE php_test");
|
||||
pg_close($dbh);
|
||||
?>
|
||||
===DONE===
|
||||
@@ -0,0 +1 @@
|
||||
===DONE===
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
require_once('config.inc');
|
||||
|
||||
$dbh = @pg_connect($conn_str);
|
||||
if (!$dbh) {
|
||||
die ("Could not connect to the server");
|
||||
}
|
||||
|
||||
pg_query("CREATE TABLE php_test (id SERIAL PRIMARY KEY, time TIMESTAMP NOT NULL DEFAULT now())");
|
||||
|
||||
pg_insert($dbh, 'php_test', array());
|
||||
|
||||
var_dump(pg_fetch_assoc(pg_query("SELECT * FROM php_test")));
|
||||
|
||||
pg_query($dbh, "DROP TABLE php_test");
|
||||
pg_close($dbh);
|
||||
?>
|
||||
===DONE===
|
||||
@@ -0,0 +1,7 @@
|
||||
array(2) {
|
||||
["id"]=>
|
||||
string(%d) "%d"
|
||||
["time"]=>
|
||||
string(%d) "%s"
|
||||
}
|
||||
===DONE===
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
include('config.inc');
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
$result = pg_exec("SELECT * FROM ".$table_name);
|
||||
pg_numrows($result);
|
||||
pg_numfields($result);
|
||||
pg_fieldname($result, 0);
|
||||
pg_fieldsize($result, 0);
|
||||
pg_fieldtype($result, 0);
|
||||
pg_fieldprtlen($result, 0);
|
||||
pg_fieldisnull($result, 0);
|
||||
|
||||
pg_result($result,0,0);
|
||||
$result = pg_exec("INSERT INTO ".$table_name." VALUES (7777, 'KKK')");
|
||||
$oid = pg_getlastoid($result);
|
||||
pg_freeresult($result);
|
||||
pg_errormessage();
|
||||
$result = pg_exec("UPDATE ".$table_name." SET str = 'QQQ' WHERE str like 'RGD';");
|
||||
pg_cmdtuples($result);
|
||||
|
||||
|
||||
|
||||
echo "OK";
|
||||
?>
|
||||
@@ -0,0 +1 @@
|
||||
OK
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
// drop test table
|
||||
|
||||
include('config.inc');
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
pg_query($db, "DROP TABLE ".$table_name);
|
||||
|
||||
echo "OK";
|
||||
|
||||
?>
|
||||
@@ -0,0 +1 @@
|
||||
OK
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
include 'config.inc';
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
|
||||
@pg_query('DROP TABLE test_bug');
|
||||
|
||||
pg_query('CREATE TABLE test_bug (binfield byteA) ;');
|
||||
pg_query("INSERT INTO test_bug VALUES (decode('0103AA000812','hex'))");
|
||||
|
||||
|
||||
$data = pg_query("SELECT binfield FROM test_bug");
|
||||
$res = pg_fetch_result($data,0);
|
||||
var_dump($res);
|
||||
var_dump(bin2hex(pg_unescape_bytea($res)));
|
||||
|
||||
$sql = "BEGIN; DECLARE mycursor BINARY CURSOR FOR SELECT binfield FROM test_bug; FETCH ALL IN mycursor;";
|
||||
|
||||
$data = pg_query($sql);
|
||||
$res = pg_fetch_result($data,0);
|
||||
|
||||
var_dump(strlen($res));
|
||||
var_dump(bin2hex($res));
|
||||
|
||||
pg_close($db);
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
pg_query('DROP TABLE test_bug');
|
||||
pg_close($db);
|
||||
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,4 @@
|
||||
string(24) "\001\003\252\000\010\022"
|
||||
string(12) "0103aa000812"
|
||||
int(6)
|
||||
string(12) "0103aa000812"
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
include 'config.inc';
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
|
||||
@pg_query('DROP TABLE test_bug');
|
||||
|
||||
pg_query('CREATE TABLE test_bug (binfield byteA) ;');
|
||||
pg_query("INSERT INTO test_bug VALUES (decode('0103AA000812','hex'))");
|
||||
|
||||
|
||||
$data = pg_query("SELECT binfield FROM test_bug");
|
||||
$res = pg_fetch_result($data,0);
|
||||
var_dump($res);
|
||||
var_dump(bin2hex(pg_unescape_bytea($res)));
|
||||
|
||||
$sql = "BEGIN; DECLARE mycursor BINARY CURSOR FOR SELECT binfield FROM test_bug; FETCH ALL IN mycursor;";
|
||||
|
||||
$data = pg_query($sql);
|
||||
$res = pg_fetch_result($data,0);
|
||||
|
||||
var_dump(strlen($res));
|
||||
var_dump(bin2hex($res));
|
||||
|
||||
pg_close($db);
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
pg_query('DROP TABLE test_bug');
|
||||
pg_close($db);
|
||||
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,4 @@
|
||||
string(14) "\x0103aa000812"
|
||||
string(12) "0103aa000812"
|
||||
int(6)
|
||||
string(12) "0103aa000812"
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
require_once('config.inc');
|
||||
|
||||
$dbh = pg_connect($conn_str);
|
||||
$tbl_name = 'test_47199';
|
||||
@pg_query("DROP TABLE $tbl_name");
|
||||
pg_query("CREATE TABLE $tbl_name (null_field INT, not_null_field INT NOT NULL)");
|
||||
|
||||
pg_insert($dbh, $tbl_name, array('null_field' => null, 'not_null_field' => 1));
|
||||
pg_insert($dbh, $tbl_name, array('null_field' => null, 'not_null_field' => 2));
|
||||
|
||||
var_dump(pg_fetch_all(pg_query('SELECT * FROM '. $tbl_name)));
|
||||
|
||||
$query = pg_delete($dbh, $tbl_name, array('null_field' => NULL,'not_null_field' => 2), PGSQL_DML_STRING|PGSQL_DML_EXEC);
|
||||
|
||||
echo $query, "\n";
|
||||
|
||||
$query = pg_update($dbh, $tbl_name, array('null_field' => NULL, 'not_null_field' => 0), array('not_null_field' => 1, 'null_field' => ''), PGSQL_DML_STRING|PGSQL_DML_EXEC);
|
||||
|
||||
echo $query, "\n";
|
||||
|
||||
var_dump(pg_fetch_all(pg_query('SELECT * FROM '. $tbl_name)));
|
||||
|
||||
@pg_query("DROP TABLE $tbl_name");
|
||||
pg_close($dbh);
|
||||
|
||||
echo PHP_EOL."Done".PHP_EOL;
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,29 @@
|
||||
array(2) {
|
||||
[0]=>
|
||||
array(2) {
|
||||
["null_field"]=>
|
||||
NULL
|
||||
["not_null_field"]=>
|
||||
string(1) "1"
|
||||
}
|
||||
[1]=>
|
||||
array(2) {
|
||||
["null_field"]=>
|
||||
NULL
|
||||
["not_null_field"]=>
|
||||
string(1) "2"
|
||||
}
|
||||
}
|
||||
DELETE FROM test_47199 WHERE null_field IS NULL AND not_null_field=2;
|
||||
UPDATE test_47199 SET null_field=NULL,not_null_field=0 WHERE not_null_field=1 AND null_field IS NULL;
|
||||
array(1) {
|
||||
[0]=>
|
||||
array(2) {
|
||||
["null_field"]=>
|
||||
NULL
|
||||
["not_null_field"]=>
|
||||
string(1) "0"
|
||||
}
|
||||
}
|
||||
|
||||
Done
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
include 'config.inc';
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
$result = pg_query("select 'a' union select 'b'");
|
||||
|
||||
var_dump(pg_fetch_array($result, -1));
|
||||
var_dump(pg_fetch_assoc($result, -1));
|
||||
var_dump(pg_fetch_object($result, -1));
|
||||
var_dump(pg_fetch_row($result, -1));
|
||||
|
||||
var_dump(pg_fetch_array($result, 0));
|
||||
var_dump(pg_fetch_assoc($result, 0));
|
||||
var_dump(pg_fetch_object($result, 0));
|
||||
var_dump(pg_fetch_row($result, 0));
|
||||
|
||||
pg_close($db);
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,26 @@
|
||||
HipHop Warning: %a
|
||||
bool(false)
|
||||
HipHop Warning: %a
|
||||
bool(false)
|
||||
HipHop Warning: %a
|
||||
bool(false)
|
||||
HipHop Warning: %a
|
||||
bool(false)
|
||||
array(2) {
|
||||
[0]=>
|
||||
string(1) "a"
|
||||
["?column?"]=>
|
||||
string(1) "a"
|
||||
}
|
||||
array(1) {
|
||||
["?column?"]=>
|
||||
string(1) "a"
|
||||
}
|
||||
object(stdClass)#1 (1) {
|
||||
["?column?"]=>
|
||||
string(1) "a"
|
||||
}
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(1) "a"
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
include('config.inc');
|
||||
|
||||
$conn = pg_connect($conn_str);
|
||||
|
||||
pg_query('CREATE SCHEMA phptests');
|
||||
|
||||
pg_query('CREATE TABLE foo (id INT, id2 INT)');
|
||||
pg_query('CREATE TABLE phptests.foo (id INT, id2 INT)');
|
||||
|
||||
pg_insert($conn, 'foo', array('id' => 1, 'id2' => 1));
|
||||
pg_insert($conn, 'foo', array('id' => 1, 'id2' => 2));
|
||||
pg_insert($conn, 'foo', array('id' => 1, 'id2' => 2));
|
||||
pg_insert($conn, 'foo', array('id' => 3, 'id2' => 3));
|
||||
|
||||
pg_insert($conn, 'phptests.foo', array('id' => 1, 'id2' => 1));
|
||||
pg_insert($conn, 'phptests.foo', array('id' => 1, 'id2' => 2));
|
||||
pg_insert($conn, 'phptests.foo', array('id' => 2, 'id2' => 3));
|
||||
pg_insert($conn, 'phptests.foo', array('id' => 2, 'id2' => 3));
|
||||
|
||||
pg_delete($conn, 'foo', array('id' => 1, 'id2' => 0));
|
||||
pg_delete($conn, 'foo', array('id' => 1, 'id2' => 2));
|
||||
var_dump(pg_delete($conn, 'foo', array('id' => 1, 'id2' => 2), PGSQL_DML_STRING));
|
||||
|
||||
pg_delete($conn, 'phptests.foo', array('id' => 2, 'id2' => 1));
|
||||
pg_delete($conn, 'phptests.foo', array('id' => 2, 'id2' => 3));
|
||||
var_dump(pg_delete($conn, 'phptests.foo', array('id' => 2, 'id2' => 3), PGSQL_DML_STRING));
|
||||
|
||||
var_dump(pg_fetch_all(pg_query('SELECT * FROM foo')));
|
||||
var_dump(pg_fetch_all(pg_query('SELECT * FROM phptests.foo')));
|
||||
|
||||
/* Inexistent */
|
||||
pg_delete($conn, 'bar', array('id' => 1, 'id2' => 2));
|
||||
var_dump(pg_delete($conn, 'bar', array('id' => 1, 'id2' => 2), PGSQL_DML_STRING));
|
||||
|
||||
pg_query('DROP TABLE foo');
|
||||
pg_query('DROP TABLE phptests.foo');
|
||||
pg_query('DROP SCHEMA phptests');
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,37 @@
|
||||
string(37) "DELETE FROM foo WHERE id=1 AND id2=2;"
|
||||
string(46) "DELETE FROM phptests.foo WHERE id=2 AND id2=3;"
|
||||
array(2) {
|
||||
[0]=>
|
||||
array(2) {
|
||||
["id"]=>
|
||||
string(1) "1"
|
||||
["id2"]=>
|
||||
string(1) "1"
|
||||
}
|
||||
[1]=>
|
||||
array(2) {
|
||||
["id"]=>
|
||||
string(1) "3"
|
||||
["id2"]=>
|
||||
string(1) "3"
|
||||
}
|
||||
}
|
||||
array(2) {
|
||||
[0]=>
|
||||
array(2) {
|
||||
["id"]=>
|
||||
string(1) "1"
|
||||
["id2"]=>
|
||||
string(1) "1"
|
||||
}
|
||||
[1]=>
|
||||
array(2) {
|
||||
["id"]=>
|
||||
string(1) "1"
|
||||
["id2"]=>
|
||||
string(1) "2"
|
||||
}
|
||||
}
|
||||
HipHop Warning: %a
|
||||
HipHop Warning: %a
|
||||
bool(false)
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
include('config.inc');
|
||||
|
||||
$conn = pg_connect($conn_str);
|
||||
|
||||
pg_query('CREATE SCHEMA phptests');
|
||||
pg_query('CREATE TABLE phptests.foo (id INT, id2 INT)');
|
||||
|
||||
|
||||
pg_insert($conn, 'foo', array('id' => 1, 'id2' => 1));
|
||||
|
||||
pg_insert($conn, 'phptests.foo', array('id' => 1, 'id2' => 2));
|
||||
|
||||
var_dump(pg_insert($conn, 'phptests.foo', array('id' => 1, 'id2' => 2), PGSQL_DML_STRING));
|
||||
|
||||
var_dump(pg_select($conn, 'phptests.foo', array('id' => 1)));
|
||||
|
||||
pg_query('DROP TABLE phptests.foo');
|
||||
pg_query('DROP SCHEMA phptests');
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,11 @@
|
||||
HipHop Warning: %a
|
||||
string(47) "INSERT INTO phptests.foo (id,id2) VALUES (1,2);"
|
||||
array(1) {
|
||||
[0]=>
|
||||
array(2) {
|
||||
["id"]=>
|
||||
string(1) "1"
|
||||
["id2"]=>
|
||||
string(1) "2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
include('config.inc');
|
||||
|
||||
$conn = pg_connect($conn_str);
|
||||
|
||||
pg_query('CREATE SCHEMA phptests');
|
||||
|
||||
pg_query('CREATE TABLE phptests.foo (id INT, id2 INT)');
|
||||
|
||||
pg_query('CREATE TABLE foo (id INT, id3 INT)');
|
||||
|
||||
|
||||
var_dump(pg_meta_data($conn, 'foo'));
|
||||
var_dump(pg_meta_data($conn, 'phptests.foo'));
|
||||
|
||||
|
||||
pg_query('DROP TABLE foo');
|
||||
pg_query('DROP TABLE phptests.foo');
|
||||
pg_query('DROP SCHEMA phptests');
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,64 @@
|
||||
array(2) {
|
||||
["id"]=>
|
||||
array(6) {
|
||||
["num"]=>
|
||||
int(1)
|
||||
["type"]=>
|
||||
string(4) "int4"
|
||||
["len"]=>
|
||||
int(4)
|
||||
["not null"]=>
|
||||
bool(false)
|
||||
["has default"]=>
|
||||
bool(false)
|
||||
["array dims"]=>
|
||||
int(0)
|
||||
}
|
||||
["id3"]=>
|
||||
array(6) {
|
||||
["num"]=>
|
||||
int(2)
|
||||
["type"]=>
|
||||
string(4) "int4"
|
||||
["len"]=>
|
||||
int(4)
|
||||
["not null"]=>
|
||||
bool(false)
|
||||
["has default"]=>
|
||||
bool(false)
|
||||
["array dims"]=>
|
||||
int(0)
|
||||
}
|
||||
}
|
||||
array(2) {
|
||||
["id"]=>
|
||||
array(6) {
|
||||
["num"]=>
|
||||
int(1)
|
||||
["type"]=>
|
||||
string(4) "int4"
|
||||
["len"]=>
|
||||
int(4)
|
||||
["not null"]=>
|
||||
bool(false)
|
||||
["has default"]=>
|
||||
bool(false)
|
||||
["array dims"]=>
|
||||
int(0)
|
||||
}
|
||||
["id2"]=>
|
||||
array(6) {
|
||||
["num"]=>
|
||||
int(2)
|
||||
["type"]=>
|
||||
string(4) "int4"
|
||||
["len"]=>
|
||||
int(4)
|
||||
["not null"]=>
|
||||
bool(false)
|
||||
["has default"]=>
|
||||
bool(false)
|
||||
["array dims"]=>
|
||||
int(0)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
include('config.inc');
|
||||
|
||||
$conn = pg_connect($conn_str);
|
||||
|
||||
pg_query('CREATE SCHEMA phptests');
|
||||
|
||||
pg_query('CREATE TABLE phptests.foo (id INT, id2 INT)');
|
||||
pg_query('INSERT INTO phptests.foo VALUES (1,2)');
|
||||
pg_query('INSERT INTO phptests.foo VALUES (2,3)');
|
||||
|
||||
pg_query('CREATE TABLE phptests.bar (id4 INT, id3 INT)');
|
||||
pg_query('INSERT INTO phptests.bar VALUES (4,5)');
|
||||
pg_query('INSERT INTO phptests.bar VALUES (6,7)');
|
||||
|
||||
/* Inexistent table */
|
||||
var_dump(pg_select($conn, 'foo', array('id' => 1)));
|
||||
|
||||
/* Existent column */
|
||||
var_dump(pg_select($conn, 'phptests.foo', array('id' => 1)));
|
||||
|
||||
/* Testing with inexistent column */
|
||||
var_dump(pg_select($conn, 'phptests.bar', array('id' => 1)));
|
||||
|
||||
/* Existent column */
|
||||
var_dump(pg_select($conn, 'phptests.bar', array('id4' => 4)));
|
||||
|
||||
|
||||
pg_query('DROP TABLE phptests.foo');
|
||||
pg_query('DROP TABLE phptests.bar');
|
||||
pg_query('DROP SCHEMA phptests');
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,22 @@
|
||||
HipHop Warning: %a
|
||||
bool(false)
|
||||
array(1) {
|
||||
[0]=>
|
||||
array(2) {
|
||||
["id"]=>
|
||||
string(1) "1"
|
||||
["id2"]=>
|
||||
string(1) "2"
|
||||
}
|
||||
}
|
||||
HipHop Notice: %a
|
||||
bool(false)
|
||||
array(1) {
|
||||
[0]=>
|
||||
array(2) {
|
||||
["id4"]=>
|
||||
string(1) "4"
|
||||
["id3"]=>
|
||||
string(1) "5"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
include('config.inc');
|
||||
|
||||
$conn = pg_connect($conn_str);
|
||||
|
||||
pg_query('CREATE SCHEMA phptests');
|
||||
|
||||
pg_query('CREATE TABLE foo (id INT, id2 INT)');
|
||||
pg_query('CREATE TABLE phptests.foo (id INT, id2 INT)');
|
||||
|
||||
|
||||
pg_insert($conn, 'foo', array('id' => 1, 'id2' => 1));
|
||||
pg_insert($conn, 'phptests.foo', array('id' => 1, 'id2' => 2));
|
||||
|
||||
pg_update($conn, 'foo', array('id' => 10), array('id' => 1));
|
||||
var_dump(pg_update($conn, 'foo', array('id' => 10), array('id' => 1), PGSQL_DML_STRING));
|
||||
|
||||
pg_update($conn, 'phptests.foo', array('id' => 100), array('id2' => 2));
|
||||
var_dump(pg_update($conn, 'phptests.foo', array('id' => 100), array('id2' => 2), PGSQL_DML_STRING));
|
||||
|
||||
$rs = pg_query('SELECT * FROM foo UNION SELECT * FROM phptests.foo');
|
||||
while ($row = pg_fetch_assoc($rs)) {
|
||||
var_dump($row);
|
||||
}
|
||||
|
||||
pg_query('DROP TABLE foo');
|
||||
pg_query('DROP TABLE phptests.foo');
|
||||
pg_query('DROP SCHEMA phptests');
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,14 @@
|
||||
string(32) "UPDATE foo SET id=10 WHERE id=1;"
|
||||
string(43) "UPDATE phptests.foo SET id=100 WHERE id2=2;"
|
||||
array(2) {
|
||||
["id"]=>
|
||||
string(2) "10"
|
||||
["id2"]=>
|
||||
string(1) "1"
|
||||
}
|
||||
array(2) {
|
||||
["id"]=>
|
||||
string(3) "100"
|
||||
["id2"]=>
|
||||
string(1) "2"
|
||||
}
|
||||
Alguns arquivos não foram exibidos porque demasiados arquivos foram alterados neste diff Mostrar Mais
Referência em uma Nova Issue
Bloquear um usuário