VVVideoRepository::find
The find() member function of the class VVVideoRepository, takes a VVVideo instance as an argument, with only some of its fields filled in. It uses this partial VVVideo as a search criterion. The function returns the first video it finds that matches the field passed in. The source code of this member function follows, taken from the file vidrep.cpp.
VVVideo
VVVideoRepository::find(const VVVideo& aVideo) const //1
{
RWDBCriterion searchCriterion("0 = 0", 0, 0); //2
RWCString title = aVideo.title(); //3
if (!title.isNull()) //4
searchCriterion = searchCriterion &&
titleColumn_.like(title); //5
if (aVideo.id()) //6
searchCriterion = searchCriterion &&
idColumn_ == aVideo.id(); //7
if (aVideo.year()) //8
searchCriterion = searchCriterion &&
yearColumn_ == aVideo.year(); //9
RWCString category = aVideo.category(); //10
if (!category.isNull()) //11
searchCriterion = searchCriterion &&
categoryColumn_.like(category); //12
if (aVideo.quantity())
searchCriterion = searchCriterion &&
quantityColumn_ == aVideo.quantity(); //13
if (aVideo.numOnHand()) //14
searchCriterion = searchCriterion &&
numOnHandColumn_ == aVideo.numOnHand(); //15
RWCString synopsis = aVideo.synopsis(); //16
if (!synopsis.isNull()) //17
searchCriterion = searchCriterion &&
synopsisColumn_.like(synopsis); //18
RWDBSelector aSelector = aDB_.selector(searchCriterion); //19
aSelector << table_; //20
RWDBReader aReader = aSelector.reader(); //21
VVVideo theVideo; //22
if (aReader()) //23
aReader >> theVideo; //24
return theVideo; //25
NOTE: Do not confuse the RWCString::isNull method with NULL database values. The RWCString::isNull method returns true if the string is empty. However, some database vendors do not consider an empty string to be the same as a NULL value.