original_string: public function describeTable($tableName, $schemaName = null)
      {
          $sql = "SELECT DISTINCT c.tabschema, c.tabname, c.colname, c.colno,
                  c.typename, c.default, c.nulls, c.length, c.scale,
                  c.identity, tc.type AS tabconsttype, k.colseq
                  FROM syscat.columns c
                  LEFT JOIN (syscat.keycoluse k JOIN syscat.tabconst tc
                   ON (k.tabschema = tc.tabschema
                     AND k.tabname = tc.tabname
                     AND tc.type = 'P'))
                   ON (c.tabschema = k.tabschema
                   AND c.tabname = k.tabname
                   AND c.colname = k.colname)
              WHERE "
              . $this->_adapter->quoteInto('UPPER(c.tabname) = UPPER(?)', $tableName);
          if ($schemaName) {
              $sql .= $this->_adapter->quoteInto(' AND UPPER(c.tabschema) = UPPER(?)', $schemaName);
          }
          $sql .= " ORDER BY c.colno";
  
          $desc = array();
          $stmt = $this->_adapter->query($sql);
  
          /**
           * To avoid case issues, fetch using FETCH_NUM
           */
          $result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
  
          /**
           * The ordering of columns is defined by the query so we can map
           * to variables to improve readability
           */
          $tabschema      = 0;
          $tabname        = 1;
          $colname        = 2;
          $colno          = 3;
          $typename       = 4;
          $default        = 5;
          $nulls          = 6;
          $length         = 7;
          $scale          = 8;
          $identityCol    = 9;
          $tabconstype    = 10;
          $colseq         = 11;
  
          foreach ($result as $key => $row) {
              list ($primary, $primaryPosition, $identity) = array(false, null, false);
              if ($row[$tabconstype] == 'P') {
                  $primary = true;
                  $primaryPosition = $row[$colseq];
              }
              /**
               * In IBM DB2, an column can be IDENTITY
               * even if it is not part of the PRIMARY KEY.
               */
              if ($row[$identityCol] == 'Y') {
                  $identity = true;
              }
  
              $desc[$this->_adapter->foldCase($row[$colname])] = array(
              'SCHEMA_NAME'      => $this->_adapter->foldCase($row[$tabschema]),
              'TABLE_NAME'       => $this->_adapter->foldCase($row[$tabname]),
              'COLUMN_NAME'      => $this->_adapter->foldCase($row[$colname]),
              'COLUMN_POSITION'  => $row[$colno]+1,
              'DATA_TYPE'        => $row[$typename],
              'DEFAULT'          => $row[$default],
              'NULLABLE'         => (bool) ($row[$nulls] == 'Y'),
              'LENGTH'           => $row[$length],
              'SCALE'            => $row[$scale],
              'PRECISION'        => ($row[$typename] == 'DECIMAL' ? $row[$length] : 0),
              'UNSIGNED'         => false,
              'PRIMARY'          => $primary,
              'PRIMARY_POSITION' => $primaryPosition,
              'IDENTITY'         => $identity
              );
          }
  
          return $desc;
      }
code: public function describeTable($tableName, $schemaName = null)
      {
          $sql = "SELECT DISTINCT c.tabschema, c.tabname, c.colname, c.colno,
                  c.typename, c.default, c.nulls, c.length, c.scale,
                  c.identity, tc.type AS tabconsttype, k.colseq
                  FROM syscat.columns c
                  LEFT JOIN (syscat.keycoluse k JOIN syscat.tabconst tc
                   ON (k.tabschema = tc.tabschema
                     AND k.tabname = tc.tabname
                     AND tc.type = 'P'))
                   ON (c.tabschema = k.tabschema
                   AND c.tabname = k.tabname
                   AND c.colname = k.colname)
              WHERE "
              . $this->_adapter->quoteInto('UPPER(c.tabname) = UPPER(?)', $tableName);
          if ($schemaName) {
              $sql .= $this->_adapter->quoteInto(' AND UPPER(c.tabschema) = UPPER(?)', $schemaName);
          }
          $sql .= " ORDER BY c.colno";
  
          $desc = array();
          $stmt = $this->_adapter->query($sql);
  
          /**
           * To avoid case issues, fetch using FETCH_NUM
           */
          $result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
  
          /**
           * The ordering of columns is defined by the query so we can map
           * to variables to improve readability
           */
          $tabschema      = 0;
          $tabname        = 1;
          $colname        = 2;
          $colno          = 3;
          $typename       = 4;
          $default        = 5;
          $nulls          = 6;
          $length         = 7;
          $scale          = 8;
          $identityCol    = 9;
          $tabconstype    = 10;
          $colseq         = 11;
  
          foreach ($result as $key => $row) {
              list ($primary, $primaryPosition, $identity) = array(false, null, false);
              if ($row[$tabconstype] == 'P') {
                  $primary = true;
                  $primaryPosition = $row[$colseq];
              }
              /**
               * In IBM DB2, an column can be IDENTITY
               * even if it is not part of the PRIMARY KEY.
               */
              if ($row[$identityCol] == 'Y') {
                  $identity = true;
              }
  
              $desc[$this->_adapter->foldCase($row[$colname])] = array(
              'SCHEMA_NAME'      => $this->_adapter->foldCase($row[$tabschema]),
              'TABLE_NAME'       => $this->_adapter->foldCase($row[$tabname]),
              'COLUMN_NAME'      => $this->_adapter->foldCase($row[$colname]),
              'COLUMN_POSITION'  => $row[$colno]+1,
              'DATA_TYPE'        => $row[$typename],
              'DEFAULT'          => $row[$default],
              'NULLABLE'         => (bool) ($row[$nulls] == 'Y'),
              'LENGTH'           => $row[$length],
              'SCALE'            => $row[$scale],
              'PRECISION'        => ($row[$typename] == 'DECIMAL' ? $row[$length] : 0),
              'UNSIGNED'         => false,
              'PRIMARY'          => $primary,
              'PRIMARY_POSITION' => $primaryPosition,
              'IDENTITY'         => $identity
              );
          }
  
          return $desc;
      }
code_tokens: public function describeTable ( $ tableName , $ schemaName = null ) { $ sql = "SELECT DISTINCT c.tabschema, c.tabname, c.colname, c.colno,
                  c.typename, c.default, c.nulls, c.length, c.scale,
                  c.identity, tc.type AS tabconsttype, k.colseq
                  FROM syscat.columns c
                  LEFT JOIN (syscat.keycoluse k JOIN syscat.tabconst tc
                   ON (k.tabschema = tc.tabschema
                     AND k.tabname = tc.tabname
                     AND tc.type = 'P'))
                   ON (c.tabschema = k.tabschema
                   AND c.tabname = k.tabname
                   AND c.colname = k.colname)
              WHERE " . $ this -> _adapter -> quoteInto ( 'UPPER(c.tabname) = UPPER(?)' , $ tableName ) ; if ( $ schemaName ) { $ sql .= $ this -> _adapter -> quoteInto ( ' AND UPPER(c.tabschema) = UPPER(?)' , $ schemaName ) ; } $ sql .= " ORDER BY c.colno" ; $ desc = array ( ) ; $ stmt = $ this -> _adapter -> query ( $ sql ) ; /**
           * To avoid case issues, fetch using FETCH_NUM
           */ $ result = $ stmt -> fetchAll ( Zend_Db :: FETCH_NUM ) ; /**
           * The ordering of columns is defined by the query so we can map
           * to variables to improve readability
           */ $ tabschema = 0 ; $ tabname = 1 ; $ colname = 2 ; $ colno = 3 ; $ typename = 4 ; $ default = 5 ; $ nulls = 6 ; $ length = 7 ; $ scale = 8 ; $ identityCol = 9 ; $ tabconstype = 10 ; $ colseq = 11 ; foreach ( $ result as $ key => $ row ) { list ( $ primary , $ primaryPosition , $ identity ) = array ( false , null , false ) ; if ( $ row [ $ tabconstype ] == 'P' ) { $ primary = true ; $ primaryPosition = $ row [ $ colseq ] ; } /**
               * In IBM DB2, an column can be IDENTITY
               * even if it is not part of the PRIMARY KEY.
               */ if ( $ row [ $ identityCol ] == 'Y' ) { $ identity = true ; } $ desc [ $ this -> _adapter -> foldCase ( $ row [ $ colname ] ) ] = array ( 'SCHEMA_NAME' => $ this -> _adapter -> foldCase ( $ row [ $ tabschema ] ) , 'TABLE_NAME' => $ this -> _adapter -> foldCase ( $ row [ $ tabname ] ) , 'COLUMN_NAME' => $ this -> _adapter -> foldCase ( $ row [ $ colname ] ) , 'COLUMN_POSITION' => $ row [ $ colno ] + 1 , 'DATA_TYPE' => $ row [ $ typename ] , 'DEFAULT' => $ row [ $ default ] , 'NULLABLE' => ( bool ) ( $ row [ $ nulls ] == 'Y' ) , 'LENGTH' => $ row [ $ length ] , 'SCALE' => $ row [ $ scale ] , 'PRECISION' => ( $ row [ $ typename ] == 'DECIMAL' ? $ row [ $ length ] : 0 ) , 'UNSIGNED' => false , 'PRIMARY' => $ primary , 'PRIMARY_POSITION' => $ primaryPosition , 'IDENTITY' => $ identity ) ; } return $ desc ; }
docstring: DB2 catalog lookup for describe table
  
  @param string $tableName
  @param string $schemaName OPTIONAL
  @return array
docstring_tokens: DB2 catalog lookup for describe table