Koha's DB interfacing in C4 is very procedural and full of repetitive code for basic table operations. We haven't enforced a strict naming convention, or an argument style, so the result is predictably confusing. The arguments are frequently recognized by position, so you have to remember which is which, and how many, like: GetItem(undef,$barcode) GetItem($itemnumber,undef,1)
C4::Table manipulates table data in a completely OO way, with the same argument style regardless of which table is being accessed. There is no reason that we should have to code a new Get_XXX_by_YYY function or add a new positional argument to existing Get_XXX functions every time we want to be able to query efficiently against a given field. We should be able to do that from the start. For example: use C4::Table; my $table = C4::Table->new('items'); my $set1 = $table->select({barcode => $barcode}); my $set2 = $table->select({itemnumber => $itemnumber}); Please note that this is not designed as a substitute for true DBI abstraction (like DBIx::Class) or other more sophisticated OO layers. It doesn't build composite objects from multiple JOIN statements or that kind of thing. But it does make all Koha table data immediately available to API queries with comparison (=, >, <, >=, <=) to any field, sortable +/- by any field, and LIMITable to a given value. I'll sending the small proof-of-concept patch for a C4::Table with an example test script (a good place to start). This approach is still experimental, so it does not supplant any production code. Please review and feedback. --Joe Atzberger, LibLime
_______________________________________________ Koha-devel mailing list Koha-devel@lists.koha.org http://lists.koha.org/mailman/listinfo/koha-devel