original_string: public function describeTable($tableName, $schemaName = null)
      {
          // this is still a work in progress
  
          $sql= "SELECT DISTINCT t.owner, t.tabname, c.colname, c.colno, c.coltype,
                 d.default, c.collength, t.tabid
                 FROM syscolumns c
                 JOIN systables t ON c.tabid = t.tabid
                 LEFT JOIN sysdefaults d ON c.tabid = d.tabid AND c.colno = d.colno
                 WHERE "
                  . $this->_adapter->quoteInto('UPPER(t.tabname) = UPPER(?)', $tableName);
          if ($schemaName) {
              $sql .= $this->_adapter->quoteInto(' AND UPPER(t.owner) = UPPER(?)', $schemaName);
          }
          $sql .= " ORDER BY c.colno";
  
          $desc = array();
          $stmt = $this->_adapter->query($sql);
  
          $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;
          $length         = 6;
          $tabid          = 7;
  
          $primaryCols = null;
  
          foreach ($result as $key => $row) {
              $primary = false;
              $primaryPosition = null;
  
              if (!$primaryCols) {
                  $primaryCols = $this->_getPrimaryInfo($row[$tabid]);
              }
  
              if (array_key_exists($row[$colno], $primaryCols)) {
                  $primary = true;
                  $primaryPosition = $primaryCols[$row[$colno]];
              }
  
              $identity = false;
              if ($row[$typename] == 6 + 256 ||
                  $row[$typename] == 18 + 256) {
                  $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],
                  'DATA_TYPE'         => $this->_getDataType($row[$typename]),
                  'DEFAULT'           => $row[$default],
                  'NULLABLE'          => (bool) !($row[$typename] - 256 >= 0),
                  'LENGTH'            => $row[$length],
                  'SCALE'             => ($row[$typename] == 5 ? $row[$length]&255 : 0),
                  'PRECISION'         => ($row[$typename] == 5 ? (int)($row[$length]/256) : 0),
                  'UNSIGNED'          => false,
                  'PRIMARY'           => $primary,
                  'PRIMARY_POSITION'  => $primaryPosition,
                  'IDENTITY'          => $identity
              );
          }
  
          return $desc;
      }
code: public function describeTable($tableName, $schemaName = null)
      {
          // this is still a work in progress
  
          $sql= "SELECT DISTINCT t.owner, t.tabname, c.colname, c.colno, c.coltype,
                 d.default, c.collength, t.tabid
                 FROM syscolumns c
                 JOIN systables t ON c.tabid = t.tabid
                 LEFT JOIN sysdefaults d ON c.tabid = d.tabid AND c.colno = d.colno
                 WHERE "
                  . $this->_adapter->quoteInto('UPPER(t.tabname) = UPPER(?)', $tableName);
          if ($schemaName) {
              $sql .= $this->_adapter->quoteInto(' AND UPPER(t.owner) = UPPER(?)', $schemaName);
          }
          $sql .= " ORDER BY c.colno";
  
          $desc = array();
          $stmt = $this->_adapter->query($sql);
  
          $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;
          $length         = 6;
          $tabid          = 7;
  
          $primaryCols = null;
  
          foreach ($result as $key => $row) {
              $primary = false;
              $primaryPosition = null;
  
              if (!$primaryCols) {
                  $primaryCols = $this->_getPrimaryInfo($row[$tabid]);
              }
  
              if (array_key_exists($row[$colno], $primaryCols)) {
                  $primary = true;
                  $primaryPosition = $primaryCols[$row[$colno]];
              }
  
              $identity = false;
              if ($row[$typename] == 6 + 256 ||
                  $row[$typename] == 18 + 256) {
                  $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],
                  'DATA_TYPE'         => $this->_getDataType($row[$typename]),
                  'DEFAULT'           => $row[$default],
                  'NULLABLE'          => (bool) !($row[$typename] - 256 >= 0),
                  'LENGTH'            => $row[$length],
                  'SCALE'             => ($row[$typename] == 5 ? $row[$length]&255 : 0),
                  'PRECISION'         => ($row[$typename] == 5 ? (int)($row[$length]/256) : 0),
                  'UNSIGNED'          => false,
                  'PRIMARY'           => $primary,
                  'PRIMARY_POSITION'  => $primaryPosition,
                  'IDENTITY'          => $identity
              );
          }
  
          return $desc;
      }
code_tokens: public function describeTable ( $ tableName , $ schemaName = null ) { // this is still a work in progress $ sql = "SELECT DISTINCT t.owner, t.tabname, c.colname, c.colno, c.coltype,
                 d.default, c.collength, t.tabid
                 FROM syscolumns c
                 JOIN systables t ON c.tabid = t.tabid
                 LEFT JOIN sysdefaults d ON c.tabid = d.tabid AND c.colno = d.colno
                 WHERE " . $ this -> _adapter -> quoteInto ( 'UPPER(t.tabname) = UPPER(?)' , $ tableName ) ; if ( $ schemaName ) { $ sql .= $ this -> _adapter -> quoteInto ( ' AND UPPER(t.owner) = UPPER(?)' , $ schemaName ) ; } $ sql .= " ORDER BY c.colno" ; $ desc = array ( ) ; $ stmt = $ this -> _adapter -> query ( $ sql ) ; $ 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 ; $ length = 6 ; $ tabid = 7 ; $ primaryCols = null ; foreach ( $ result as $ key => $ row ) { $ primary = false ; $ primaryPosition = null ; if ( ! $ primaryCols ) { $ primaryCols = $ this -> _getPrimaryInfo ( $ row [ $ tabid ] ) ; } if ( array_key_exists ( $ row [ $ colno ] , $ primaryCols ) ) { $ primary = true ; $ primaryPosition = $ primaryCols [ $ row [ $ colno ] ] ; } $ identity = false ; if ( $ row [ $ typename ] == 6 + 256 || $ row [ $ typename ] == 18 + 256 ) { $ 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 ] , 'DATA_TYPE' => $ this -> _getDataType ( $ row [ $ typename ] ) , 'DEFAULT' => $ row [ $ default ] , 'NULLABLE' => ( bool ) ! ( $ row [ $ typename ] - 256 >= 0 ) , 'LENGTH' => $ row [ $ length ] , 'SCALE' => ( $ row [ $ typename ] == 5 ? $ row [ $ length ] & 255 : 0 ) , 'PRECISION' => ( $ row [ $ typename ] == 5 ? ( int ) ( $ row [ $ length ] / 256 ) : 0 ) , 'UNSIGNED' => false , 'PRIMARY' => $ primary , 'PRIMARY_POSITION' => $ primaryPosition , 'IDENTITY' => $ identity ) ; } return $ desc ; }
docstring: IDS catalog lookup for describe table
  
  @param string $tableName
  @param string $schemaName OPTIONAL
  @return array
docstring_tokens: IDS catalog lookup for describe table