Automatically generated installer lang files
[moodle.git] / lib / adodb / drivers / adodb-netezza.inc.php
blobdc7c58e428c141f9764d02af13f015edccb9cf03
1 <?php
2 /**
3 * Netezza Driver
5 * @link https://www.ibm.com/products/netezza
6 * Based on the previous postgres drivers. Major Additions/Changes:
7 * - MetaDatabasesSQL, MetaTablesSQL, MetaColumnsSQL
8 * Note: You have to have admin privileges to access the system tables
9 * - Removed non-working keys code (Netezza has no concept of keys)
10 * - Fixed the way data types and lengths are returned in MetaColumns()
11 * as well as added the default lengths for certain types
12 * - Updated public variables for Netezza
13 * TODO: Still need to remove blob functions, as Netezza doesn't support blob
15 * This file is part of ADOdb, a Database Abstraction Layer library for PHP.
17 * @package ADOdb
18 * @link https://adodb.org Project's web site and documentation
19 * @link https://github.com/ADOdb/ADOdb Source code and issue tracker
21 * The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
22 * and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
23 * any later version. This means you can use it in proprietary products.
24 * See the LICENSE.md file distributed with this source code for details.
25 * @license BSD-3-Clause
26 * @license LGPL-2.1-or-later
28 * @copyright 2000-2013 John Lim
29 * @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
30 * @author Josh Eldridge <joshuae74@hotmail.com>
33 // security - hide paths
34 if (!defined('ADODB_DIR')) die();
36 include_once(ADODB_DIR.'/drivers/adodb-postgres64.inc.php');
38 class ADODB_netezza extends ADODB_postgres64 {
39 var $databaseType = 'netezza';
40 var $dataProvider = 'netezza';
41 var $hasInsertID = false;
42 var $_resultid = false;
43 var $concat_operator='||';
44 var $random = 'random';
45 var $metaDatabasesSQL = "select objname from _v_object_data where objtype='database' order by 1";
46 var $metaTablesSQL = "select objname from _v_object_data where objtype='table' order by 1";
47 var $isoDates = true; // accepts dates in ISO format
48 var $sysDate = "CURRENT_DATE";
49 var $sysTimeStamp = "CURRENT_TIMESTAMP";
50 var $blobEncodeType = 'C';
51 var $metaColumnsSQL = "SELECT attname, atttype FROM _v_relation_column_def WHERE name = '%s' AND attnum > 0 ORDER BY attnum";
52 var $metaColumnsSQL1 = "SELECT attname, atttype FROM _v_relation_column_def WHERE name = '%s' AND attnum > 0 ORDER BY attnum";
53 // netezza doesn't have keys. it does have distributions, so maybe this is
54 // something that can be pulled from the system tables
55 var $metaKeySQL = "";
56 var $hasAffectedRows = true;
57 var $hasLimit = true;
58 var $true = 't'; // string that represents TRUE for a database
59 var $false = 'f'; // string that represents FALSE for a database
60 var $fmtDate = "'Y-m-d'"; // used by DBDate() as the default date format used by the database
61 var $fmtTimeStamp = "'Y-m-d G:i:s'"; // used by DBTimeStamp as the default timestamp fmt.
62 var $ansiOuter = true;
63 var $autoRollback = true; // apparently pgsql does not autorollback properly before 4.3.4
64 // http://bugs.php.net/bug.php?id=25404
67 function MetaColumns($table,$upper=true)
70 // Changed this function to support Netezza which has no concept of keys
71 // could posisbly work on other things from the system table later.
73 global $ADODB_FETCH_MODE;
75 $table = strtolower($table);
77 $save = $ADODB_FETCH_MODE;
78 $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
79 if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
81 $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table,$table));
82 if (isset($savem)) $this->SetFetchMode($savem);
83 $ADODB_FETCH_MODE = $save;
85 if ($rs === false) return false;
87 $retarr = array();
88 while (!$rs->EOF) {
89 $fld = new ADOFieldObject();
90 $fld->name = $rs->fields[0];
92 // since we're returning type and length as one string,
93 // split them out here.
95 if ($first = strstr($rs->fields[1], "(")) {
96 $fld->max_length = trim($first, "()");
97 } else {
98 $fld->max_length = -1;
101 if ($first = strpos($rs->fields[1], "(")) {
102 $fld->type = substr($rs->fields[1], 0, $first);
103 } else {
104 $fld->type = $rs->fields[1];
107 switch ($fld->type) {
108 case "byteint":
109 case "boolean":
110 $fld->max_length = 1;
111 break;
112 case "smallint":
113 $fld->max_length = 2;
114 break;
115 case "integer":
116 case "numeric":
117 case "date":
118 $fld->max_length = 4;
119 break;
120 case "bigint":
121 case "time":
122 case "timestamp":
123 $fld->max_length = 8;
124 break;
125 case "timetz":
126 case "time with time zone":
127 $fld->max_length = 12;
128 break;
131 if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld;
132 else $retarr[($upper) ? strtoupper($fld->name) : $fld->name] = $fld;
134 $rs->MoveNext();
136 $rs->Close();
137 return $retarr;
144 /*--------------------------------------------------------------------------------------
145 Class Name: Recordset
146 --------------------------------------------------------------------------------------*/
148 class ADORecordSet_netezza extends ADORecordSet_postgres64
150 var $databaseType = "netezza";
151 var $canSeek = true;
153 // _initrs modified to disable blob handling
154 function _initrs()
156 global $ADODB_COUNTRECS;
157 $this->_numOfRows = ($ADODB_COUNTRECS)? @pg_num_rows($this->_queryID):-1;
158 $this->_numOfFields = @pg_num_fields($this->_queryID);