Results 1 to 4 of 4

Thread: A patch to improve clanDatabase

  1. #1
    Lesser Knight
    Join Date
    Mar 2009
    Posts
    54

    Default A patch to improve clanDatabase

    The aim of this patch is to improve both CL_DBReader and CL_DBCommand by reducing index and type management on the user end.

    two functions were added to CL_DBReader to simplify data retrieval:
    - get_column_value(int index) const;
    - get_column_value(const CL_StringRef &name) const;

    BEFORE:
    Code:
                item.id = reader.get_column_int(reader.get_name_index("id")); // verbose and hard to read
                item.title = reader.get_column_string(reader.get_name_index("title"));
                item.year = reader.get_column_int(reader.get_name_index("year"));
    
                int foo = reader.get_column_int(1);
                CL_String bar = reader.get_column_string(2);
    AFTER:
    Code:
                item.id = reader.get_column_value("id"); // no type or index to remember!
                item.title = reader.get_column_value("title");
                item.year = reader.get_column_value("year");
    
                int foo = reader.get_column_value(1); // access data by index for unknown column name
                CL_String bar = reader.get_column_value(2);
    Two more functions were added to CL_DBCommand:
    - set_input_parameter(int index, ValueType value);
    - set_input_parameter(const CL_StringRef &name, ValueType value);

    BEFORE
    Code:
    sql->create_command("insert into show_example (show_id, name) values (?1, :name)")
    cmd.set_input_parameter_int(1, id); // set input parameter by index
    cmd.set_input_parameter_string(cmd.get_input_parameter_column(":name"), name); // set input parameter by named parameter
    Code:
    sql->create_command("insert into show_example (show_id, name) values (?1, :name)")
    cmd.set_input_parameter(1, id); // set input parameter by index
    cmd.set_input_parameter(":name", name); // set input parameter by named parameter
    The new functions in this patch were inspired by the clanNetGame API.
    Attached Files Attached Files

  2. #2
    Lesser Knight
    Join Date
    Mar 2009
    Posts
    54

    Default

    bump.........

  3. #3
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    oops! I missed that patch, I'll do it tomorrow unless someone beats me to it

  4. #4
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    Patch applied to 2.2 and 2.3 SVN

    Many Thanks

Similar Threads

  1. Patch: Broken 3D example(s)
    By rebecca.palmer in forum Official ClanLib SDK Forums
    Replies: 5
    Last Post: 10-05-2010, 12:15 PM
  2. Small patch
    By Jonanin in forum Official ClanLib SDK Forums
    Replies: 1
    Last Post: 01-04-2010, 09:18 AM
  3. CL 0.8 Canvas patch, get-rid-of-warnings patch
    By Trigve in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 09-30-2007, 11:08 PM
  4. Sprite patch for 0.8
    By Trigve in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 07-19-2007, 12:41 AM
  5. opengl_window_provider_wgl patch
    By Trigve in forum Official ClanLib SDK Forums
    Replies: 1
    Last Post: 06-26-2007, 10:33 AM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •