I have a database table with a timestamp field, like so:
DROP TABLE IF EXISTS `starstable`.`student_task
`;
CREATE TABLE `starstable`.`student_task
` (
`studentTaskId` int(9) unsigned NOT NULL auto_increment,
`taskId` int(9) unsigned NOT NULL,
`objectId` bigint(20) unsigned NOT NULL,
`variable1` int(9) unsigned default NULL,
`variable2` int(9) unsigned default NULL,
`finished` tinyint(1) default NULL,
`startTaskDate` timestamp NOT NULL default CURRENT_TIMESTAMP,
`finishTaskDate` timestamp NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`studentTaskId`,`taskId`,
`objectId`
),
KEY `FK_STUDENT_TASK_OBJECTS` USING BTREE (`objectId`),
KEY `FK_STUDENT_TASK_TASK` USING BTREE (`taskId`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
The problem I am having is with inserting a value in field startTaskDate. I've tried to do it like so:
void DBTaskProvider::saveTask(c
onst ObjectID& objectID, const TaskGameStruct* const playerTask, const ActionType& actionType)
{
try
{
time_t finishDate = playerTask->finishedDate;
time_t startDate = playerTask->startDate;
querySQL
<< "CALL GDB_INSERT_STUDENT_TASK("
<< playerTask->taskID << ","
<< playerTask->objectID << ","
<< playerTask->varOne << ","
<< playerTask->varTwo << ","
<< playerTask->finished << ", "
<< "'" << mysqlpp::escape << mysqlpp::DateTime(startDat
e) << "', "
<< "'" << mysqlpp::escape << mysqlpp::Date(finishYear, finishMonth, finishDay) << "')";
// Execute the insert statement.
querySQL.use();
}
but I get the following error:
error LNK2019: unresolved external symbol "public: __thiscall mysqlpp::DateTime::DateTim
e(__int64)
" (??0DateTime@mysqlpp@@QAE@
_J@Z) referenced in function "public: void __thiscall Star::DBTaskProvider::save
Task(int const &,class Star::TaskGameStruct const * const,enum
Does anybody know what the problem is? Also, what is a good way to insert a value into a TIMESTAMP field using C++ and mysqlpp?
Start Free Trial