Documentation TYPO3 par Ameos

adodb-netezza.inc.php

00001 <?php
00002 /*
00003   V4.93 10 Oct 2006  (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved.
00004  
00005   First cut at the Netezza Driver by Josh Eldridge joshuae74#hotmail.com
00006  Based on the previous postgres drivers.
00007  http://www.netezza.com/
00008  Major Additions/Changes:
00009     MetaDatabasesSQL, MetaTablesSQL, MetaColumnsSQL
00010     Note: You have to have admin privileges to access the system tables
00011     Removed non-working keys code (Netezza has no concept of keys)
00012     Fixed the way data types and lengths are returned in MetaColumns()
00013     as well as added the default lengths for certain types
00014     Updated public variables for Netezza
00015     Still need to remove blob functions, as Netezza doesn't suppport blob
00016 */
00017 // security - hide paths
00018 if (!defined('ADODB_DIR')) die();
00019 
00020 include_once(ADODB_DIR.'/drivers/adodb-postgres64.inc.php');
00021 
00022 class ADODB_netezza extends ADODB_postgres64 {
00023     var $databaseType = 'netezza';      
00024         var $dataProvider = 'netezza';
00025         var $hasInsertID = false;
00026         var $_resultid = false;
00027         var $concat_operator='||';
00028         var $random = 'random';
00029         var $metaDatabasesSQL = "select objname from _v_object_data where objtype='database' order by 1";
00030     var $metaTablesSQL = "select objname from _v_object_data where objtype='table' order by 1";
00031         var $isoDates = true; // accepts dates in ISO format
00032         var $sysDate = "CURRENT_DATE";
00033         var $sysTimeStamp = "CURRENT_TIMESTAMP";
00034         var $blobEncodeType = 'C';
00035         var $metaColumnsSQL = "SELECT attname, atttype FROM _v_relation_column_def WHERE name = '%s' AND attnum > 0 ORDER BY attnum";
00036         var $metaColumnsSQL1 = "SELECT attname, atttype FROM _v_relation_column_def WHERE name = '%s' AND attnum > 0 ORDER BY attnum";
00037         // netezza doesn't have keys. it does have distributions, so maybe this is 
00038         // something that can be pulled from the system tables
00039         var $metaKeySQL = "";
00040         var $hasAffectedRows = true;
00041         var $hasLimit = true;   
00042         var $true = 't';                // string that represents TRUE for a database
00043         var $false = 'f';               // string that represents FALSE for a database
00044         var $fmtDate = "'Y-m-d'";       // used by DBDate() as the default date format used by the database
00045         var $fmtTimeStamp = "'Y-m-d G:i:s'"; // used by DBTimeStamp as the default timestamp fmt.
00046         var $ansiOuter = true;
00047         var $autoRollback = true; // apparently pgsql does not autorollback properly before 4.3.4
00048                                                         // http://bugs.php.net/bug.php?id=25404
00049 
00050                                                         
00051         function ADODB_netezza() 
00052         {
00053         
00054         }
00055         
00056         function &MetaColumns($table,$upper=true) 
00057         {
00058         
00059         // Changed this function to support Netezza which has no concept of keys
00060         // could posisbly work on other things from the system table later.
00061         
00062         global $ADODB_FETCH_MODE;
00063         
00064                 $table = strtolower($table);
00065 
00066                 $save = $ADODB_FETCH_MODE;
00067                 $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
00068                 if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
00069                 
00070                 $rs =& $this->Execute(sprintf($this->metaColumnsSQL,$table,$table));
00071                 if (isset($savem)) $this->SetFetchMode($savem);
00072                 $ADODB_FETCH_MODE = $save;
00073                 
00074                 if ($rs === false) return false;
00075 
00076                 $retarr = array();
00077                 while (!$rs->EOF) {     
00078                         $fld = new ADOFieldObject();
00079                         $fld->name = $rs->fields[0];
00080                         
00081                         // since we're returning type and length as one string, 
00082                         // split them out here.
00083                         
00084                         if ($first = strstr($rs->fields[1], "(")) {
00085                          $fld->max_length = trim($first, "()");
00086                         } else {
00087                          $fld->max_length = -1;
00088                         }
00089                 
00090                         if ($first = strpos($rs->fields[1], "(")) {
00091                          $fld->type = substr($rs->fields[1], 0, $first);
00092                         } else {
00093                          $fld->type = $rs->fields[1];
00094                         }
00095                         
00096                         switch ($fld->type) {
00097                          case "byteint":
00098                          case "boolean":
00099                          $fld->max_length = 1;
00100                          break;
00101                          case "smallint":
00102                          $fld->max_length = 2;
00103                          break;
00104                          case "integer":
00105                          case "numeric":
00106                          case "date":
00107                          $fld->max_length = 4;
00108                          break;
00109                          case "bigint":
00110                          case "time":
00111                          case "timestamp":
00112                          $fld->max_length = 8;
00113                          break;
00114                          case "timetz":
00115                          case "time with time zone":
00116                          $fld->max_length = 12;
00117                          break;
00118                         }
00119                         
00120                         if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld;     
00121                         else $retarr[($upper) ? strtoupper($fld->name) : $fld->name] = $fld;
00122                         
00123                         $rs->MoveNext();
00124                 }
00125                 $rs->Close();
00126                 return $retarr; 
00127                 
00128         }
00129 
00130                 
00131 }
00132         
00133 /*--------------------------------------------------------------------------------------
00134          Class Name: Recordset
00135 --------------------------------------------------------------------------------------*/
00136 
00137 class ADORecordSet_netezza extends ADORecordSet_postgres64
00138 {
00139         var $databaseType = "netezza";
00140         var $canSeek = true;
00141         
00142         function ADORecordSet_netezza($queryID,$mode=false) 
00143         {
00144                 if ($mode === false) { 
00145                         global $ADODB_FETCH_MODE;
00146                         $mode = $ADODB_FETCH_MODE;
00147                 }
00148                 switch ($mode)
00149                 {
00150                 case ADODB_FETCH_NUM: $this->fetchMode = PGSQL_NUM; break;
00151                 case ADODB_FETCH_ASSOC:$this->fetchMode = PGSQL_ASSOC; break;
00152                 
00153                 case ADODB_FETCH_DEFAULT:
00154                 case ADODB_FETCH_BOTH:
00155                 default: $this->fetchMode = PGSQL_BOTH; break;
00156                 }
00157                 $this->adodbFetchMode = $mode;
00158                 $this->ADORecordSet($queryID);
00159         }
00160         
00161         // _initrs modified to disable blob handling
00162         function _initrs()
00163         {
00164         global $ADODB_COUNTRECS;
00165                 $this->_numOfRows = ($ADODB_COUNTRECS)? @pg_numrows($this->_queryID):-1;
00166                 $this->_numOfFields = @pg_numfields($this->_queryID);
00167         }
00168 
00169 }
00170 ?>


Généré par Les experts TYPO3 avec  doxygen 1.4.6