3 @version v5.20.19 13-Dec-2020
4 @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
5 @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
7 First cut at the Netezza Driver by Josh Eldridge joshuae74#hotmail.com
8 Based on the previous postgres drivers.
9 http://www.netezza.com/
10 Major Additions/Changes:
11 MetaDatabasesSQL, MetaTablesSQL, MetaColumnsSQL
12 Note: You have to have admin privileges to access the system tables
13 Removed non-working keys code (Netezza has no concept of keys)
14 Fixed the way data types and lengths are returned in MetaColumns()
15 as well as added the default lengths for certain types
16 Updated public variables for Netezza
17 Still need to remove blob functions, as Netezza doesn't suppport blob
19 // security - hide paths
20 if (!defined('ADODB_DIR')) die();
22 include_once(ADODB_DIR.'/drivers/adodb-postgres64.inc.php');
24 class ADODB_netezza extends ADODB_postgres64 {
25 var $databaseType = 'netezza';
26 var $dataProvider = 'netezza';
27 var $hasInsertID = false;
28 var $_resultid = false;
29 var $concat_operator='||';
30 var $random = 'random';
31 var $metaDatabasesSQL = "select objname from _v_object_data where objtype='database' order by 1";
32 var $metaTablesSQL = "select objname from _v_object_data where objtype='table' order by 1";
33 var $isoDates = true; // accepts dates in ISO format
34 var $sysDate = "CURRENT_DATE";
35 var $sysTimeStamp = "CURRENT_TIMESTAMP";
36 var $blobEncodeType = 'C';
37 var $metaColumnsSQL = "SELECT attname, atttype FROM _v_relation_column_def WHERE name = '%s' AND attnum > 0 ORDER BY attnum";
38 var $metaColumnsSQL1 = "SELECT attname, atttype FROM _v_relation_column_def WHERE name = '%s' AND attnum > 0 ORDER BY attnum";
39 // netezza doesn't have keys. it does have distributions, so maybe this is
40 // something that can be pulled from the system tables
42 var $hasAffectedRows = true;
44 var $true = 't'; // string that represents TRUE for a database
45 var $false = 'f'; // string that represents FALSE for a database
46 var $fmtDate = "'Y-m-d'"; // used by DBDate() as the default date format used by the database
47 var $fmtTimeStamp = "'Y-m-d G:i:s'"; // used by DBTimeStamp as the default timestamp fmt.
48 var $ansiOuter = true;
49 var $autoRollback = true; // apparently pgsql does not autorollback properly before 4.3.4
50 // http://bugs.php.net/bug.php?id=25404
53 function __construct()
58 function MetaColumns($table,$upper=true)
61 // Changed this function to support Netezza which has no concept of keys
62 // could posisbly work on other things from the system table later.
64 global $ADODB_FETCH_MODE;
66 $table = strtolower($table);
68 $save = $ADODB_FETCH_MODE;
69 $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
70 if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
72 $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table,$table));
73 if (isset($savem)) $this->SetFetchMode($savem);
74 $ADODB_FETCH_MODE = $save;
76 if ($rs === false) return false;
80 $fld = new ADOFieldObject();
81 $fld->name = $rs->fields[0];
83 // since we're returning type and length as one string,
84 // split them out here.
86 if ($first = strstr($rs->fields[1], "(")) {
87 $fld->max_length = trim($first, "()");
89 $fld->max_length = -1;
92 if ($first = strpos($rs->fields[1], "(")) {
93 $fld->type = substr($rs->fields[1], 0, $first);
95 $fld->type = $rs->fields[1];
101 $fld->max_length = 1;
104 $fld->max_length = 2;
109 $fld->max_length = 4;
114 $fld->max_length = 8;
117 case "time with time zone":
118 $fld->max_length = 12;
122 if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld;
123 else $retarr[($upper) ? strtoupper($fld->name) : $fld->name] = $fld;
135 /*--------------------------------------------------------------------------------------
136 Class Name: Recordset
137 --------------------------------------------------------------------------------------*/
139 class ADORecordSet_netezza extends ADORecordSet_postgres64
141 var $databaseType = "netezza";
144 function __construct($queryID,$mode=false)
146 parent::__construct($queryID,$mode);
149 // _initrs modified to disable blob handling
152 global $ADODB_COUNTRECS;
153 $this->_numOfRows = ($ADODB_COUNTRECS)? @pg_num_rows($this->_queryID):-1;
154 $this->_numOfFields = @pg_num_fields($this->_queryID);