php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #63656 PostgreSQL PDO methods like pgsqlCopyFromFile are undocumented
Submitted: 2012-11-30 12:06 UTC Modified: 2015-05-14 22:42 UTC
Votes:3
Avg. Score:4.3 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:1 (33.3%)
From: ch@php.net Assigned: salathe (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.4.9 OS:
Private report: No CVE-ID: None
 [2012-11-30 12:06 UTC] ch@php.net
Description:
------------
Several PostgreSQL specific PDO methods are not documented although they do work fine.

Although PDO aims to hide database specific features behind a common API, sometimes one simply wants to use certain features and for this reason they should not be hidden but rather documented (with a proper warning).

php5-5.4.4$ grep -B2 PHP_METHOD ext/pdo_pgsql/pgsql_driver.c

/* {{{ proto string PDO::pgsqlCopyFromArray(string $table_name , array $rows [, string $delimiter [, string $null_as ] [, string $fields])
   Returns true if the copy worked fine or false if error */
static PHP_METHOD(PDO, pgsqlCopyFromArray)
--
/* {{{ proto string PDO::pgsqlCopyFromFile(string $table_name , string $filename [, string $delimiter [, string $null_as ] [, string $fields])
   Returns true if the copy worked fine or false if error */
static PHP_METHOD(PDO, pgsqlCopyFromFile)
--
/* {{{ proto string PDO::pgsqlCopyToFile(string $table_name , $filename, [string $delimiter [, string $null_as [, string $fields]]])
   Returns true if the copy worked fine or false if error */
static PHP_METHOD(PDO, pgsqlCopyToFile)
--
/* {{{ proto string PDO::pgsqlCopyToArray(string $table_name , [string $delimiter [, string $null_as [, string $fields]]])
   Returns true if the copy worked fine or false if error */
static PHP_METHOD(PDO, pgsqlCopyToArray)
--
/* {{{ proto string PDO::pgsqlLOBCreate()
   Creates a new large object, returning its identifier.  Must be called inside a transaction. */
static PHP_METHOD(PDO, pgsqlLOBCreate)
--
/* {{{ proto resource PDO::pgsqlLOBOpen(string oid [, string mode = 'rb'])
   Opens an existing large object stream.  Must be called inside a transaction. */
static PHP_METHOD(PDO, pgsqlLOBOpen)
--
/* {{{ proto bool PDO::pgsqlLOBUnlink(string oid)
   Deletes the large object identified by oid.  Must be called inside a transaction. */
static PHP_METHOD(PDO, pgsqlLOBUnlink)



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-12-31 17:48 UTC] thomas dot mayer at 2bis10 dot de
Thank you so much for adding these functions.

This functionality is really needed to use the fast client-side COPY-behaviour of postgresql inside an existing pdo connection (which allows to reuse PDO's database transaction).

It took me hours to find out that PDO::pgsqlCopy* function exists in PDO. I think they are available since PHP 5.3.x and still not documented.
I just found some discussion here: http://www.serverphorums.com/read.php?7,151997,page=1

This really needs to be documented now.
 [2013-12-31 19:52 UTC] thomas dot mayer at 2bis10 dot de
Here's an example for reusing a doctrine connection (and db transaction) for the COPY via PDO:

$file = '/tmp/test.csv';
$this->manager->getConnection()->beginTransaction();
// ... do something in doctrine here
$pdo = $this->manager->getConnection()->getWrappedConnection();
$pdo->pgsqlCopyFromFile('testtable', $file, "\t", '', 'field1, field2');
$this->manager->getConnection()->commit();
 [2015-05-14 22:41 UTC] salathe@php.net
Automatic comment from SVN on behalf of salathe
Revision: http://svn.php.net/viewvc/?view=revision&revision=336777
Log: Document pdo_pgsql copy from/to file/array methods. Patch by Alexander N (doc bug #63656)
 [2015-05-14 22:42 UTC] salathe@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: salathe
 [2015-05-14 22:42 UTC] salathe@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 18:01:28 2024 UTC