3 V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my). All rights reserved.
5 First cut at the Netezza Driver by Josh Eldridge joshuae74#hotmail.com
6 Based on the previous postgres drivers.
7 http://www.netezza.com/
8 Major Additions/Changes:
9 MetaDatabasesSQL, MetaTablesSQL, MetaColumnsSQL
10 Note: You have to have admin privileges to access the system tables
11 Removed non-working keys code (Netezza has no concept of keys)
12 Fixed the way data types and lengths are returned in MetaColumns()
13 as well as added the default lengths for certain types
14 Updated public variables for Netezza
15 Still need to remove blob functions, as Netezza doesn't suppport blob
19 include_once(ADODB_DIR . '/drivers/adodb-postgres64.inc.php');
21 class ADODB_netezza extends ADODB_postgres64
23 var $databaseType = 'netezza';
24 var $dataProvider = 'netezza';
25 var $hasInsertID = false;
26 var $_resultid = false;
27 var $concat_operator = '||';
28 var $random = 'random';
29 var $upperCase = 'upper';
30 var $metaDatabasesSQL = "select objname from _v_object_data where objtype='database' order by 1";
31 var $metaTablesSQL = "select objname from _v_object_data where objtype='table' order by 1";
32 var $isoDates = true; // accepts dates in ISO format
33 var $sysDate = "CURRENT_DATE";
34 var $sysTimeStamp = "CURRENT_TIMESTAMP";
35 var $blobEncodeType = 'C';
36 var $metaColumnsSQL = "SELECT attname, atttype FROM _v_relation_column_def WHERE name = '%s' AND attnum > 0 ORDER BY attnum";
37 var $metaColumnsSQL1 = "SELECT attname, atttype FROM _v_relation_column_def WHERE name = '%s' AND attnum > 0 ORDER BY attnum";
38 // netezza doesn't have keys. it does have distributions, so maybe this is
39 // something that can be pulled from the system tables
41 var $hasAffectedRows = true;
43 var $true = 't'; // string that represents TRUE for a database
44 var $false = 'f'; // string that represents FALSE for a database
45 var $fmtDate = "'Y-m-d'"; // used by DBDate() as the default date format used by the database
46 var $fmtTimeStamp = "'Y-m-d G:i:s'"; // used by DBTimeStamp as the default timestamp fmt.
47 var $ansiOuter = true;
48 var $autoRollback = true; // apparently pgsql does not autorollback properly before 4.3.4
49 // http://bugs.php.net/bug.php?id=25404
51 function ADODB_netezza()
56 function &MetaColumns($table, $upper = true)
59 // Changed this function to support Netezza which has no concept of keys
60 // could posisbly work on other things from the system table later.
62 global $ADODB_FETCH_MODE;
64 $table = strtolower($table);
66 $save = $ADODB_FETCH_MODE;
67 $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
68 if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
70 $rs =& $this->Execute(sprintf($this->metaColumnsSQL, $table, $table));
71 if (isset($savem)) $this->SetFetchMode($savem);
72 $ADODB_FETCH_MODE = $save;
74 if ($rs === false) return false;
78 $fld = new ADOFieldObject();
79 $fld->name = $rs->fields[0];
81 // since we're returning type and length as one string,
82 // split them out here.
84 if ($first = strstr($rs->fields[1], "(")) {
85 $fld->max_length = trim($first, "()");
87 $fld->max_length = -1;
90 if ($first = strpos($rs->fields[1], "(")) {
91 $fld->type = substr($rs->fields[1], 0, $first);
93 $fld->type = $rs->fields[1];
102 $fld->max_length = 2;
107 $fld->max_length = 4;
112 $fld->max_length = 8;
115 case "time with time zone":
116 $fld->max_length = 12;
120 if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld;
121 else $retarr[($upper) ? strtoupper($fld->name) : $fld->name] = $fld;
132 /*--------------------------------------------------------------------------------------
133 Class Name: Recordset
134 --------------------------------------------------------------------------------------*/
136 class ADORecordSet_netezza extends ADORecordSet_postgres64
138 var $databaseType = "netezza";
141 function ADORecordSet_netezza($queryID, $mode = false)
143 if ($mode === false) {
144 global $ADODB_FETCH_MODE;
145 $mode = $ADODB_FETCH_MODE;
148 case ADODB_FETCH_NUM:
149 $this->fetchMode = PGSQL_NUM;
151 case ADODB_FETCH_ASSOC:
152 $this->fetchMode = PGSQL_ASSOC;
155 case ADODB_FETCH_DEFAULT:
156 case ADODB_FETCH_BOTH:
157 $this->fetchMode = PGSQL_BOTH;
160 $this->ADORecordSet($queryID);
163 // _initrs modified to disable blob handling
166 global $ADODB_COUNTRECS;
167 $this->_numOfRows = ($ADODB_COUNTRECS) ? @pg_numrows($this->_queryID) : -1;
168 $this->_numOfFields = @pg_numfields($this->_queryID);