mirror of
https://github.com/danog/ext-pq.git
synced 2024-11-30 04:19:49 +01:00
pq\Types, pq\LOB
- added pq\Types instead of Connection->types - added pq\LOB
This commit is contained in:
parent
6bfbeb8ffc
commit
d4f2435f5b
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,6 +1,6 @@
|
||||
|
||||
# /
|
||||
/*~
|
||||
*~
|
||||
/*.tgz
|
||||
/.deps
|
||||
/*.lo
|
||||
|
3
TODO
3
TODO
@ -1,6 +1,5 @@
|
||||
* parse arrays out of PQgetvalue
|
||||
* listenAsync & notifyAsync
|
||||
* LOBs
|
||||
* COPY
|
||||
* transaction savepoints
|
||||
* transaction snapshots
|
||||
@ -8,7 +7,9 @@
|
||||
* pq\Event\Result\Destroy,
|
||||
* pq\Event\Connection\Destroy
|
||||
|
||||
* bound columns/variables
|
||||
* fetchInto/fetchCtor?
|
||||
* unlisten?
|
||||
* pq\Result->__clone through PQcopyResult?
|
||||
* LOB stream wrapper
|
||||
* LOB convenience import/export over php streams
|
||||
|
801
src/php_pq.c
801
src/php_pq.c
File diff suppressed because it is too large
Load Diff
@ -9,7 +9,8 @@ echo "Test\n";
|
||||
include "_setup.inc";
|
||||
|
||||
$c = new pq\Connection(PQ_DSN);
|
||||
$c->execParamsAsync("SELECT \$1,\$2::int4", array(1,2), array($c->types->byName->int4->oid), function ($res) {
|
||||
$t = new pq\Types($c);
|
||||
$c->execParamsAsync("SELECT \$1,\$2::int4", array(1,2), array($t["int4"]->oid), function ($res) {
|
||||
var_dump($res);
|
||||
});
|
||||
do {
|
||||
|
@ -21,7 +21,8 @@ function complete($s) {
|
||||
}
|
||||
|
||||
$c = new pq\Connection(PQ_DSN);
|
||||
$s = $c->prepareAsync("test", "SELECT \$1,\$2::int4", array($c->types->byName->int4->oid));
|
||||
$t = new pq\Types($c);
|
||||
$s = $c->prepareAsync("test", "SELECT \$1,\$2::int4", array($t["int4"]->oid));
|
||||
|
||||
complete($s);
|
||||
|
||||
|
@ -8,7 +8,8 @@ echo "Test\n";
|
||||
include "_setup.inc";
|
||||
|
||||
$c = new pq\Connection(PQ_DSN);
|
||||
$s = $c->prepare("test1", "SELECT \$1",array($c->types->byName->text->oid));
|
||||
$t = new pq\Types($c);
|
||||
$s = $c->prepare("test1", "SELECT \$1",array($t["text"]->oid));
|
||||
$r = $s->exec(array("fooo"));
|
||||
|
||||
printf("%s\n", $r->errorMessage);
|
||||
|
33
tests/lob001.phpt
Normal file
33
tests/lob001.phpt
Normal file
@ -0,0 +1,33 @@
|
||||
--TEST--
|
||||
large objects
|
||||
--SKIPIF--
|
||||
<? php include "_skipif.inc"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
echo "Test\n";
|
||||
|
||||
include "_setup.inc";
|
||||
|
||||
$c = new pq\Connection(PQ_DSN);
|
||||
$t = $c->startTransaction();
|
||||
|
||||
$lob = $t->createLOB();
|
||||
$lob->write(file_get_contents(__FILE__));
|
||||
var_dump($lob->tell());
|
||||
$lob->seek(0, SEEK_SET);
|
||||
$dat = $lob->read(filesize(__FILE__));
|
||||
var_dump(hash("md5", $dat));
|
||||
var_dump(hash_file("md5", __FILE__));
|
||||
$lob->truncate(5);
|
||||
$lob = new pq\Lob($t, $lob->oid);
|
||||
var_dump($lob->read(123));
|
||||
?>
|
||||
DONE
|
||||
--EXPECT--
|
||||
Test
|
||||
int(416)
|
||||
string(32) "d422937493386635bd56b9a9885e7614"
|
||||
string(32) "d422937493386635bd56b9a9885e7614"
|
||||
string(5) "<?php"
|
||||
DONE
|
||||
|
@ -12,7 +12,7 @@ $s = $c->prepare("test1", "SELECT NOW() - \$1");
|
||||
$r = $s->exec(array("2012-12-12 12:12:12"));
|
||||
$d = $s->desc();
|
||||
|
||||
printf("%s\n", $c->types->byOid->{$d[0]}->typname);
|
||||
printf("%s\n", (new pq\Types($c))[$d[0]]->typname);
|
||||
|
||||
?>
|
||||
DONE
|
||||
|
@ -14,7 +14,7 @@ new pq\Event($c, pq\Event::NOTICE, function($c, $notice) {
|
||||
});
|
||||
$t = new pq\Transaction($c);
|
||||
$c->exec("DROP TABLE IF EXISTS test; CREATE TABLE test (id serial, data text)");
|
||||
$s = $c->prepare("test_insert", "INSERT INTO test (data) VALUES (\$1)", array($c->types->byName->text->oid));
|
||||
$s = $c->prepare("test_insert", "INSERT INTO test (data) VALUES (\$1)", array((new pq\Types($c))["text"]->oid));
|
||||
$s->exec(array("a"));
|
||||
$s->exec(array("b"));
|
||||
$s->exec(array("c"));
|
||||
|
Loading…
Reference in New Issue
Block a user