#ifndef hAlbumIDProductIDDigitalTable #define hAlbumIDProductIDDigitalTable #include "PackedTable.h" struct _albumIDProductIDDigital { private: long _album_id; long _product_id; public: long album_id() { return _album_id; } long product_id() { return _product_id; } friend class AlbumIDProductIDDigitalTable; }; class AlbumIDProductIDDigitalTable : public PackedTableFlat { public: typedef struct _albumIDProductIDDigital tData; tData* getIndexedData(const long index) { return (tData*)this->_getIndexedData(index); } protected: enum Field { kFieldAlbumID, kFieldProductID }; PackedTable::SharedMemoryHandler _dataFileHandler; virtual DataFileHandler* _getDataFileHandler() { return &_dataFileHandler; } virtual long _dataFlatElementSize() { return sizeof(tData); } virtual const char* _maxIDQueryString() { return "SELECT MAX(album_id) FROM album"; } // In this context (where product_type_id == 3), asset_id IS album_id // virtual const char* _dataQueryString() { return "SELECT asset_id,product_id,product_type_id FROM product WHERE product_type_id = 3 ORDER BY asset_id"; } virtual void _readDataRow(MYSQL_ROW row) { // cast the data block to an array of the right type. // tData* array = (tData*)this->_dataFlatRAM; // First we need to determine the id, which will give us // the correct index into the array to store everything. // long albumID; PackedTable::_ParseLong(row[kFieldAlbumID], &albumID); long i = albumID; array[i]._album_id = albumID; PackedTable::_ParseLong(row[kFieldProductID], &(array[i]._product_id)); } }; #endif