Public Member Functions | Protected Member Functions | Protected Attributes

mysqlpl::SqlRecord Class Reference

a record to hold return columns for a given statement More...

Collaboration diagram for mysqlpl::SqlRecord:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 this (SqlStatement stmt)
int get_column_count ()
 version (MYSQLPL_PREP_STMT)
ColumnType get_column_type (int idx)
ColumnType get_column_type (in char[] col_name)
void print_columns (Stream o)
void print_values (Stream o)
 version (XMLSTORAGE)

Protected Member Functions

int * find_column (in char[] col_name)
int get_column_idx (in char[] col_name)

Protected Attributes

SqlStatement _stmt
ColumnDataVector _columns
int[char[]] _name_map

Detailed Description

a record to hold return columns for a given statement

Definition at line 771 of file mysqlpl.d.


Constructor & Destructor Documentation

mysqlpl::SqlRecord::this ( SqlStatement  stmt ) [inline]

Definition at line 773 of file mysqlpl.d.

References get_column_count(), and mysqlpl::version().

    {
        _stmt = stmt;

        int column_cnt = stmt.get_column_count();

        _columns = new ColumnDataVector(column_cnt);

        MYSQL_FIELD* fields = mysqlpl_fetch_fields(stmt.get_meta_res());

        foreach(ColumnData col; _columns) {
            col._type.init(fields);

            fields = mysqlpl_next_field(fields);

          version(MYSQLPL_PREP_STMT) {
            col._column = new SqlVariant(col._type._data_type);
          }
        }

        //_name_map.clear();
    }

Here is the call graph for this function:


Member Function Documentation

int* mysqlpl::SqlRecord::find_column ( in char[]  col_name ) [inline, protected]

Definition at line 886 of file mysqlpl.d.

    {
         // initialize column name map
        if (!_name_map) {
            int idx = 0;

            foreach(col; _columns)
                _name_map[toupper(col._type._name)] = idx++;
        }

        return toupper(col_name) in _name_map;
    }
int mysqlpl::SqlRecord::get_column_count (  ) [inline]

Definition at line 796 of file mysqlpl.d.

Referenced by this().

    {
        return _columns.length;
    }

Here is the caller graph for this function:

int mysqlpl::SqlRecord::get_column_idx ( in char[]  col_name ) [inline, protected]

Definition at line 899 of file mysqlpl.d.

    {
        int* found = find_column(col_name);

        if (found)
            return *found;
        else {
            throw new MSqlException("column not found");
            //return -1;
        }
    }
ColumnType mysqlpl::SqlRecord::get_column_type ( in char[]  col_name ) [inline]

Definition at line 825 of file mysqlpl.d.

    {
        int* found = find_column(col_name);

        if (found)
            return _columns[*found]._type;
        else {
            throw new MSqlException("column not found");
            return null;
        }
    }
ColumnType mysqlpl::SqlRecord::get_column_type ( int  idx ) [inline]

Definition at line 820 of file mysqlpl.d.

    {
        return _columns[idx]._type;
    }
void mysqlpl::SqlRecord::print_columns ( Stream  o ) [inline]

Definition at line 837 of file mysqlpl.d.

References mysqlpl::ColumnType::_name, mysqlpl::ColumnType::_table_name, and mysqlpl::ColumnType::get_type_str().

    {
        foreach(col; _columns) {
            ColumnType type = col._type;

            if (type._table_name.length)
                o.writeString(type._table_name ~ '.');

            o.writeString(type._name ~ ": " ~ type.get_type_str() ~ '\n');
        }

        o.write('\n');
    }

Here is the call graph for this function:

void mysqlpl::SqlRecord::print_values ( Stream  o ) [inline]

Definition at line 851 of file mysqlpl.d.

References mysqlpl::ColumnType::_name, and mysqlpl::version().

    {
      version(XMLSTORAGE) {
        foreach(col; _columns) {
            ColumnType type = col._type;

    //      if (type._table_name.length)
    //          o.writeString(type._table_name ~ ".");

            o.writeString(type._name ~ "=" ~ col._column.str() ~ '\n');
        }
      } else {
        int i = 0;

        foreach(col; _columns) {
            ColumnType type = col._type;

    //      if (type._table_name)
    //          o.writeString(type._table_name ~ ".");

            o.writeString(type._name ~ "=" ~ _stmt().get_string(i++) ~ '\n');
        }
      }
    }

Here is the call graph for this function:

mysqlpl::SqlRecord::version ( MYSQLPL_PREP_STMT   ) [inline]

Definition at line 801 of file mysqlpl.d.

                             {
    SqlVariant get_column(int idx)
    {
        return _columns[idx]._column;
    }

    SqlVariant get_column(in char[] col_name)
    {
        int* found = find_column(col_name);

        if (found)
            return _columns[*found]._column;
        else {
            throw new MSqlException("column not found");
            return null;
        }
    }
  }
mysqlpl::SqlRecord::version ( XMLSTORAGE   ) [inline]

Definition at line 876 of file mysqlpl.d.

                      {
    void dump_values(XMLStorage.XMLPos o);
  }

Member Data Documentation

ColumnDataVector mysqlpl::SqlRecord::_columns [protected]

Definition at line 882 of file mysqlpl.d.

int [char[]] mysqlpl::SqlRecord::_name_map [protected]

Definition at line 884 of file mysqlpl.d.

Definition at line 881 of file mysqlpl.d.


The documentation for this class was generated from the following file: