TYPO3 CMS  TYPO3_7-6
adodb-netezza.inc.php
Go to the documentation of this file.
1 <?php
2 /*
3  @version v5.20.3 01-Jan-2016
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
6 
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
18 */
19 // security - hide paths
20 if (!defined('ADODB_DIR')) die();
21 
22 include_once(ADODB_DIR.'/drivers/adodb-postgres64.inc.php');
23 
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
41  var $metaKeySQL = "";
42  var $hasAffectedRows = true;
43  var $hasLimit = 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
51 
52 
53  function __construct()
54  {
55 
56  }
57 
58  function MetaColumns($table,$upper=true)
59  {
60 
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.
63 
64  global $ADODB_FETCH_MODE;
65 
66  $table = strtolower($table);
67 
68  $save = $ADODB_FETCH_MODE;
69  $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
70  if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
71 
72  $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table,$table));
73  if (isset($savem)) $this->SetFetchMode($savem);
74  $ADODB_FETCH_MODE = $save;
75 
76  if ($rs === false) return false;
77 
78  $retarr = array();
79  while (!$rs->EOF) {
80  $fld = new ADOFieldObject();
81  $fld->name = $rs->fields[0];
82 
83  // since we're returning type and length as one string,
84  // split them out here.
85 
86  if ($first = strstr($rs->fields[1], "(")) {
87  $fld->max_length = trim($first, "()");
88  } else {
89  $fld->max_length = -1;
90  }
91 
92  if ($first = strpos($rs->fields[1], "(")) {
93  $fld->type = substr($rs->fields[1], 0, $first);
94  } else {
95  $fld->type = $rs->fields[1];
96  }
97 
98  switch ($fld->type) {
99  case "byteint":
100  case "boolean":
101  $fld->max_length = 1;
102  break;
103  case "smallint":
104  $fld->max_length = 2;
105  break;
106  case "integer":
107  case "numeric":
108  case "date":
109  $fld->max_length = 4;
110  break;
111  case "bigint":
112  case "time":
113  case "timestamp":
114  $fld->max_length = 8;
115  break;
116  case "timetz":
117  case "time with time zone":
118  $fld->max_length = 12;
119  break;
120  }
121 
122  if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld;
123  else $retarr[($upper) ? strtoupper($fld->name) : $fld->name] = $fld;
124 
125  $rs->MoveNext();
126  }
127  $rs->Close();
128  return $retarr;
129 
130  }
131 
132 
133 }
134 
135 /*--------------------------------------------------------------------------------------
136  Class Name: Recordset
137 --------------------------------------------------------------------------------------*/
138 
140 {
141  var $databaseType = "netezza";
142  var $canSeek = true;
143 
144  function __construct($queryID,$mode=false)
145  {
146  parent::__construct($queryID,$mode);
147  }
148 
149  // _initrs modified to disable blob handling
150  function _initrs()
151  {
152  global $ADODB_COUNTRECS;
153  $this->_numOfRows = ($ADODB_COUNTRECS)? @pg_num_rows($this->_queryID):-1;
154  $this->_numOfFields = @pg_num_fields($this->_queryID);
155  }
156 
157 }
if(isset($_REQUEST['nrows'])) else $rs
Definition: server.php:94
MetaColumns($table, $upper=true)
__construct($queryID, $mode=false)