logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
I'm stupid or so ???

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules
View previous topic :: View next topic  
Author Message
cieciwa



Joined: 09 Aug 2005
Posts: 33
Location: Cracov, Poland

PostPosted: Tue Jul 03, 2007 10:06    Post subject: I'm stupid or so ??? Reply with quote

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 ...
Back to top
View user's profile Send private message Send e-mail
Gryphyn



Joined: 20 Jan 2005
Posts: 431

PostPosted: Tue Jul 03, 2007 10:38    Post subject: Reply with quote

An UPDATE does not produce a result set.
The SQLFetch() fails because of this.

-check the value of GetEffectedRows() after the update, this will tell you how many rows were updated.

Cheers
Gryphyn
Back to top
View user's profile Send private message
cieciwa



Joined: 09 Aug 2005
Posts: 33
Location: Cracov, Poland

PostPosted: Tue Jul 03, 2007 10:52    Post subject: Reply with quote

Where is GetEffectedRows()??
Back to top
View user's profile Send private message Send e-mail
Gryphyn



Joined: 20 Jan 2005
Posts: 431

PostPosted: Tue Jul 03, 2007 23:39    Post subject: Reply with quote

cieciwa wrote:
Where is GetEffectedRows()??

You should have this in your nwnx_sql script.

look for SQLGetAffectedRows() (trust me to spell it wrong Embarassed )

Cheers
Gryphyn
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group