1 |
efrain |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* ADOdb PostgreSQL 8 driver
|
|
|
4 |
*
|
|
|
5 |
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
|
|
|
6 |
*
|
|
|
7 |
* @package ADOdb
|
|
|
8 |
* @link https://adodb.org Project's web site and documentation
|
|
|
9 |
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
|
|
|
10 |
*
|
|
|
11 |
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
|
|
|
12 |
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
|
|
|
13 |
* any later version. This means you can use it in proprietary products.
|
|
|
14 |
* See the LICENSE.md file distributed with this source code for details.
|
|
|
15 |
* @license BSD-3-Clause
|
|
|
16 |
* @license LGPL-2.1-or-later
|
|
|
17 |
*
|
|
|
18 |
* @copyright 2000-2013 John Lim
|
|
|
19 |
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
|
|
|
20 |
*/
|
|
|
21 |
|
|
|
22 |
// security - hide paths
|
|
|
23 |
if (!defined('ADODB_DIR')) die();
|
|
|
24 |
|
|
|
25 |
include_once(ADODB_DIR."/drivers/adodb-postgres7.inc.php");
|
|
|
26 |
|
|
|
27 |
class ADODB_postgres8 extends ADODB_postgres7
|
|
|
28 |
{
|
|
|
29 |
var $databaseType = 'postgres8';
|
|
|
30 |
|
|
|
31 |
// From PostgreSQL 8.0 onwards, the adsrc column used in earlier versions to
|
|
|
32 |
// retrieve the default value is obsolete and should not be used (see #562).
|
|
|
33 |
var $metaDefaultsSQL = "SELECT d.adnum as num, pg_get_expr(d.adbin, d.adrelid) as def
|
|
|
34 |
FROM pg_attrdef d, pg_class c
|
|
|
35 |
WHERE d.adrelid=c.oid AND c.relname='%s'
|
|
|
36 |
ORDER BY d.adnum";
|
|
|
37 |
|
|
|
38 |
/**
|
|
|
39 |
* Retrieve last inserted ID
|
|
|
40 |
* Don't use OIDs, since as per {@link http://php.net/function.pg-last-oid php manual }
|
|
|
41 |
* they won't be there in Postgres 8.1
|
|
|
42 |
* (and they're not what the application wants back, anyway).
|
|
|
43 |
* @param string $table
|
|
|
44 |
* @param string $column
|
|
|
45 |
* @return int last inserted ID for given table/column, or the most recently
|
|
|
46 |
* returned one if $table or $column are empty
|
|
|
47 |
*/
|
|
|
48 |
protected function _insertID( $table = '', $column = '' )
|
|
|
49 |
{
|
|
|
50 |
global $ADODB_GETONE_EOF;
|
|
|
51 |
|
|
|
52 |
$sql = empty($table) || empty($column)
|
|
|
53 |
? 'SELECT lastval()'
|
|
|
54 |
: "SELECT currval(pg_get_serial_sequence('$table', '$column'))";
|
|
|
55 |
|
|
|
56 |
// Squelch "ERROR: lastval is not yet defined in this session" (see #978)
|
|
|
57 |
$result = @$this->GetOne($sql);
|
|
|
58 |
if ($result === false || $result == $ADODB_GETONE_EOF) {
|
|
|
59 |
if ($this->debug) {
|
|
|
60 |
ADOConnection::outp(__FUNCTION__ . "() failed : " . $this->errorMsg());
|
|
|
61 |
}
|
|
|
62 |
return false;
|
|
|
63 |
}
|
|
|
64 |
return $result;
|
|
|
65 |
}
|
|
|
66 |
}
|
|
|
67 |
|
|
|
68 |
class ADORecordSet_postgres8 extends ADORecordSet_postgres7
|
|
|
69 |
{
|
|
|
70 |
var $databaseType = "postgres8";
|
|
|
71 |
}
|
|
|
72 |
|
|
|
73 |
class ADORecordSet_assoc_postgres8 extends ADORecordSet_assoc_postgres7
|
|
|
74 |
{
|
|
|
75 |
var $databaseType = "postgres8";
|
|
|
76 |
}
|