/**
  * Returns information about a table or a result set.
  *
  * WARNING: this method will probably not work because the mysqli_*()
  * functions it relies upon may not exist.
  *
  * @param object|string  $result  DB_result object from a query or a
  *                                string containing the name of a table
  * @param int            $mode    a valid tableInfo mode
  * @return array  an associative array with the information requested
  *                or an error object if something is wrong
  * @access public
  * @internal
  * @see DB_common::tableInfo()
  */
 function tableInfo($result, $mode = null)
 {
     if (isset($result->result)) {
         /*
          * Probably received a result object.
          * Extract the result resource identifier.
          */
         $id = $result->result;
         $got_string = false;
     } elseif (is_string($result)) {
         /*
          * Probably received a table name.
          * Create a result resource identifier.
          */
         $id = @mysqli_list_fields($this->dsn['database'], $result, $this->connection);
         $got_string = true;
     } else {
         /*
          * Probably received a result resource identifier.
          * Copy it.
          * Depricated.  Here for compatibility only.
          */
         $id = $result;
         $got_string = false;
     }
     if (!is_resource($id)) {
         return $this->mysqlRaiseError(DB_ERROR_NEED_MORE_DATA);
     }
     if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE) {
         $case_func = 'strtolower';
     } else {
         $case_func = 'strval';
     }
     $count = @mysqli_num_fields($id);
     // made this IF due to performance (one if is faster than $count if's)
     if (!$mode) {
         for ($i = 0; $i < $count; $i++) {
             $res[$i]['table'] = $case_func(@mysqli_field_table($id, $i));
             $res[$i]['name'] = $case_func(@mysqli_field_name($id, $i));
             $res[$i]['type'] = @mysqli_field_type($id, $i);
             $res[$i]['len'] = @mysqli_field_len($id, $i);
             $res[$i]['flags'] = @mysqli_field_flags($id, $i);
         }
     } else {
         // full
         $res['num_fields'] = $count;
         for ($i = 0; $i < $count; $i++) {
             $res[$i]['table'] = $case_func(@mysqli_field_table($id, $i));
             $res[$i]['name'] = $case_func(@mysqli_field_name($id, $i));
             $res[$i]['type'] = @mysqli_field_type($id, $i);
             $res[$i]['len'] = @mysqli_field_len($id, $i);
             $res[$i]['flags'] = @mysqli_field_flags($id, $i);
             if ($mode & DB_TABLEINFO_ORDER) {
                 $res['order'][$res[$i]['name']] = $i;
             }
             if ($mode & DB_TABLEINFO_ORDERTABLE) {
                 $res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i;
             }
         }
     }
     // free the result only if we were called on a table
     if ($got_string) {
         @mysqli_free_result($id);
     }
     return $res;
 }
 function &FetchField($fieldOffset = -1)
 {
     if ($fieldOffset != -1) {
         $o = @mysqli_fetch_field($this->_queryID, $fieldOffset);
         $f = @mysqli_field_flags($this->_queryID, $fieldOffset);
         $o->max_length = @mysqli_field_len($this->_queryID, $fieldOffset);
         // suggested by: Jim Nicholson (jnich#att.com)
         //$o->max_length = -1; // mysql returns the max length less spaces -- so it is unrealiable
         $o->binary = strpos($f, 'binary') !== false;
     } else {
         if ($fieldOffset == -1) {
             /*	The $fieldOffset argument is not provided thus its -1 	*/
             $o = @mysqli_fetch_field($this->_queryID);
             $o->max_length = @mysqli_field_len($this->_queryID);
             // suggested by: Jim Nicholson (jnich#att.com)
             //$o->max_length = -1; // mysql returns the max length less spaces -- so it is unrealiable
         }
     }
     return $o;
 }