cieciwa
Joined: 09 Aug 2005 Posts: 33 Location: Cracov, Poland
|
Posted: Tue Jul 03, 2007 10:06 Post subject: I'm stupid or so ??? |
|
|
Hi, I try to use continual time in my module.
I create in mysql table for this - in OnModeuleLoad:
Code: |
SQLExecDirect("DESCRIBE world_time;");
int iResult = SQLFetch();
DEBUG("Result of world_time: " + IntToString(iResult));
if (iResult != SQL_SUCCESS){
DEBUG("datatable not exist. creating ...");
SQLExecDirect("create table world_time ("+
" hour integer not NULL, "+
" day integer not NULL, "+
" month integer not NULL, "+
"year integer not NULL"+
");" );
sQuery="insert into world_time (hour, day, month, year) VALUE (0,1,6,1300);";
SQLExecDirect(sQuery);
if (iResult != SQL_SUCCESS){
DEBUG("bad datatime insert");
}
} else {
sQuery="SELECT hour,day,month,year FROM world_time;";
SQLExecDirect(sQuery);
DEBUG("[world_time]:" + sQuery);
if (SQLFetch() == SQL_SUCCESS){
SetCalendar(StringToInt(SQLGetData(4)),StringToInt(SQLGetData(3)),StringToInt(SQLGetData(2)));
SetTime(StringToInt(SQLGetData(1)),0,0,0);
} else {
DEBUG("[Time]Time not set - using default.");
SetCalendar(1300,6,1);
SetTime(0,0,0,0);
}
}
|
in OnHeartBeat I update time table like this:
Code: |
string sQuery="UPDATE world_time SET hour="+IntToString(GetTimeHour())+" ,day="+IntToString(GetCalendarDay())+",
month="+IntToString(GetCalendarMonth())+" ,year="+IntToString(GetCalendarYear())+" ;";
DEBUG(sQuery);
SQLExecDirect(sQuery);
if (SQLFetch() == SQL_SUCCESS){
DEBUG("[OnHeartBeat] Time updated");
} else {
DEBUG("[OnHeartBeat] Time not updated");
}
}
|
And in log I have:
Code: |
[DEBUG]UPDATE world_time SET hour=9 ,day=4, month=6 ,year=1372 ;
[DEBUG][OnHeartBeat] Time not updated
[DEBUG]UPDATE world_time SET hour=9 ,day=4, month=6 ,year=1372 ;
[DEBUG][OnHeartBeat] Time not updated
|
BUT !!!
in base is:
Code: |
mysql> select * from world_time;
+------+-----+-------+------+
| hour | day | month | year |
+------+-----+-------+------+
| 9 | 4 | 6 | 1372 |
+------+-----+-------+------+
1 row in set (0.00 sec)
|
I don't understand this ... |
|