Zikula 1.0.1
[ class tree: Zikula 1.0.1 ] [ index: Zikula 1.0.1 ] [ all elements ]

Source for file adodb-netezza.inc.php

Documentation is available at adodb-netezza.inc.php

  1. <?php
  2. /*
  3.   V4.97 22 Jan 2008  (c) 2000-2008 John Lim (jlim#natsoft.com.my). All rights reserved.
  4.  
  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
  16. */
  17. // security - hide paths
  18. if (!defined('ADODB_DIR')) die();
  19.  
  20. include_once(ADODB_DIR.'/drivers/adodb-postgres64.inc.php');
  21.  
  22. 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 $metaDatabasesSQL = "select objname from _v_object_data where objtype='database' order by 1";
  30.     var $metaTablesSQL = "select objname from _v_object_data where objtype='table' order by 1";
  31.     var $isoDates = true// accepts dates in ISO format
  32.     var $sysDate = "CURRENT_DATE";
  33.     var $sysTimeStamp = "CURRENT_TIMESTAMP";
  34.     var $blobEncodeType = 'C';
  35.     var $metaColumnsSQL = "SELECT attname, atttype FROM _v_relation_column_def WHERE name = '%s' AND attnum > 0 ORDER BY attnum";
  36.     var $metaColumnsSQL1 = "SELECT attname, atttype FROM _v_relation_column_def WHERE name = '%s' AND attnum > 0 ORDER BY attnum";
  37.     // netezza doesn't have keys. it does have distributions, so maybe this is 
  38.     // something that can be pulled from the system tables
  39.     var $metaKeySQL = "";
  40.     var $hasAffectedRows = true;
  41.     var $hasLimit = true;    
  42.     var $true = 't';        // string that represents TRUE for a database
  43.     var $false = 'f';        // string that represents FALSE for a database
  44.     var $fmtDate = "'Y-m-d'";    // used by DBDate() as the default date format used by the database
  45.     var $fmtTimeStamp = "'Y-m-d G:i:s'"// used by DBTimeStamp as the default timestamp fmt.
  46.     var $ansiOuter = true;
  47.     var $autoRollback = true// apparently pgsql does not autorollback properly before 4.3.4
  48.                             // http://bugs.php.net/bug.php?id=25404
  49.  
  50.                             
  51.     function ADODB_netezza(
  52.     {
  53.     
  54.     }
  55.     
  56.     function &MetaColumns($table,$upper=true
  57.     {
  58.     
  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.
  61.     
  62.     global $ADODB_FETCH_MODE;
  63.     
  64.         $table strtolower($table);
  65.  
  66.         $save $ADODB_FETCH_MODE;
  67.         $ADODB_FETCH_MODE ADODB_FETCH_NUM;
  68.         if ($this->fetchMode !== false$savem $this->SetFetchMode(false);
  69.         
  70.         $rs =$this->Execute(sprintf($this->metaColumnsSQL,$table,$table));
  71.         if (isset($savem)) $this->SetFetchMode($savem);
  72.         $ADODB_FETCH_MODE $save;
  73.         
  74.         if ($rs === falsereturn false;
  75.  
  76.         $retarr array();
  77.         while (!$rs->EOF{     
  78.             $fld new ADOFieldObject();
  79.             $fld->name $rs->fields[0];
  80.             
  81.             // since we're returning type and length as one string, 
  82.             // split them out here.
  83.             
  84.             if ($first strstr($rs->fields[1]"(")) {
  85.              $fld->max_length trim($first"()");
  86.             else {
  87.              $fld->max_length = -1;
  88.             }
  89.         
  90.             if ($first strpos($rs->fields[1]"(")) {
  91.              $fld->type substr($rs->fields[1]0$first);
  92.             else {
  93.              $fld->type $rs->fields[1];
  94.             }
  95.             
  96.             switch ($fld->type{
  97.              case "byteint":
  98.              case "boolean":
  99.              $fld->max_length 1;
  100.              break;
  101.              case "smallint":
  102.              $fld->max_length 2;
  103.              break;
  104.              case "integer":
  105.              case "numeric":
  106.              case "date":
  107.              $fld->max_length 4;
  108.              break;
  109.              case "bigint":
  110.              case "time":
  111.              case "timestamp":
  112.              $fld->max_length 8;
  113.              break;
  114.              case "timetz":
  115.              case "time with time zone":
  116.              $fld->max_length 12;
  117.              break;
  118.             }
  119.             
  120.             if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM$retarr[$fld;    
  121.             else $retarr[($upperstrtoupper($fld->name$fld->name$fld;
  122.             
  123.             $rs->MoveNext();
  124.         }
  125.         $rs->Close();
  126.         return $retarr;    
  127.         
  128.     }
  129.  
  130.         
  131. }
  132.     
  133. /*--------------------------------------------------------------------------------------
  134.      Class Name: Recordset
  135. --------------------------------------------------------------------------------------*/
  136.  
  137. {
  138.     var $databaseType = "netezza";
  139.     var $canSeek = true;
  140.     
  141.     function ADORecordSet_netezza($queryID,$mode=false
  142.     {
  143.         if ($mode === false
  144.             global $ADODB_FETCH_MODE;
  145.             $mode $ADODB_FETCH_MODE;
  146.         }
  147.         switch ($mode)
  148.         {
  149.         case ADODB_FETCH_NUM$this->fetchMode = PGSQL_NUMbreak;
  150.         case ADODB_FETCH_ASSOC:$this->fetchMode = PGSQL_ASSOCbreak;
  151.         
  152.         case ADODB_FETCH_DEFAULT:
  153.         case ADODB_FETCH_BOTH:
  154.         default$this->fetchMode = PGSQL_BOTHbreak;
  155.         }
  156.         $this->adodbFetchMode $mode;
  157.         $this->ADORecordSet($queryID);
  158.     }
  159.     
  160.     // _initrs modified to disable blob handling
  161.     function _initrs()
  162.     {
  163.     global $ADODB_COUNTRECS;
  164.         $this->_numOfRows = ($ADODB_COUNTRECS)@pg_numrows($this->_queryID):-1;
  165.         $this->_numOfFields = @pg_numfields($this->_queryID);
  166.     }
  167.  
  168. }
  169. ?>

Documentation generated on Fri, 18 Jul 2008 21:40:23 +0200 by phpDocumentor 1.4.1