c++/MQDB/MappedQuery.cpp
/******************************************* 
  fetch_multiple

  Description: General purpose template function for fetching an array of instance
               of this class(subclass) using the create(row_map, database) method to convert
               a row of data into an object.
  Arg (1)    : $database (MQDB::Database)
  Arg (2)    : $sql (string of SQL statement with place holders)
  Arg (3...) : optional parameters to map to the placehodlers within the SQL
  Returntype : array of all instances of this Class (subclass) which match the query
  Exceptions : none
  Caller     : subclasses (not public methods)
  Example    : 
                  sub fetch_all_by_value {
                      my $class = shift;
                      my $db = shift;
                      my $name = shift;
                      my $sql = "SELECT * FROM symbol WHERE sym_value=?";
                      return $class->fetch_multiple($db, $sql, $name);
                  }

*******************************************/
fetch_multiple
Description: General purpose template function for fetching an array of instance
of this class(subclass) using the create(row_map, database) method to convert
a row of data into an object.
fetch_multiple Description : General purpose template function for fetching an array of instance of this class ( subclass ) using the create ( row_map database ) method to convert a row of data into an object .
vector<DBObject*> 
MQDB::fetch_multiple(DBObject* (*createFunc)(map<string, dynadata> &row_map, Database* db), 
                     Database *db, const char* sql, const char* fmt, ...)
{
  va_list                 ap;
  map<string, dynadata>   row_map;
  vector<DBObject*>       result;
  DBObject                *obj;
  void                    *stmt;
  if(db == NULL) { return result; }
  va_start(ap, fmt);
  stmt = db->prepare_fetch_sql(sql, fmt, ap);
  va_end(ap);
  while(db->fetch_next_row_map(stmt, row_map)) {
    obj = createFunc(row_map, db);
    if(obj != NULL) { result.push_back(obj); }
  }
  return result;
}
vector < DBObject * > MQDB :: fetch_multiple ( DBObject * ( * createFunc ) ( map < string , dynadata > & row_map , Database * db ) , Database * db , const char * sql , const char * fmt , ... ) { va_list ap ; map < string , dynadata > row_map ; vector < DBObject * > result ; DBObject * obj ; void * stmt ; if ( db == NULL ) { return result ; } va_start ( ap , fmt ) ; stmt = db -> prepare_fetch_sql ( sql , fmt , ap ) ; va_end ( ap ) ; while ( db -> fetch_next_row_map ( stmt , row_map ) ) { obj = createFunc ( row_map , db ) ; if ( obj != NULL ) { result . push_back ( obj ) ; } } return result ; }
fetch_multiple
Description: General purpose template function for fetching an array of instance
of this class(subclass) using the create(row_map, database) method to convert
a row of data into an object.
fetch_multiple Description : General purpose template function for fetching an array of instance of this class ( subclass ) using the create ( row_map database ) method to convert a row of data into an object .
//if(!(db->get_connection)) { printf STDERR "error with connection on query %s", sql; return result; }