mIRC Home    About    Download    Register    News    Help

Print Thread
Page 2 of 2 1 2
Re: MySQL #106929 14/02/05 03:38 AM
Joined: Feb 2005
Posts: 8
R
remco25 Offline
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
R
Joined: Feb 2005
Posts: 8
Hammer: that's some pretty impressive code, I like the mysql.dll style much better though (easier :P), but I am probably forced to use this as my mIRC crashes with the dll's smirk

Quote:
Faulting application mirc.exe, version 6.1.6.0, faulting module ntdll.dll, version 5.1.2600.2180, fault address 0x00011404.

I've tried like 4 diff mysql installations and about 3 versions of the mysql.dll/lib_mysql.dll for mIRC.
It doesn't immediately crash, just after 5-30 minutes... also when scripts do a lot MYSQL commands.
Any idea(s)?

Also, does the com connection to the database stay alive till you close it or does it close after some time like with the dll's.

Thanks in advance,

Remco

Last edited by remco25; 14/02/05 03:41 AM.
Re: MySQL #106930 14/02/05 04:52 PM
Joined: Dec 2002
Posts: 1,321
H
Hammer Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
Sorry, I have no idea about the dlls .. I don't use any dlls at all.

As for your other question, your $com object stays open until you comclose it (or you close mIRC). This means that if you're going to be hitting the database with any regularity whatsoever, it's best to leave it open until you don't need it anymore, then close it (and any other objects you've created that use it). If you wanted to, you could open the connection on START and close it on EXIT. Creating the objects and getting everything connected is fairly slow, whereas using them once they are open/connected is not anywhere near as slow.


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
Re: MySQL #106931 14/02/05 05:34 PM
Joined: Feb 2005
Posts: 8
R
remco25 Offline
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
R
Joined: Feb 2005
Posts: 8
In one of your examples you used the com thingy "Collect" that collected 1 field is there also a command for a whole row? like FetchRow with the usual mysq.dll...

Is there any readme for using com and MYSQL? I'm quite lost in all the commands :tongue:

I've joined Dalnet btw, if you got some time on IRC it might be easier heh

Re: MySQL #106932 15/02/05 12:16 AM
Joined: Feb 2005
Posts: 8
R
remco25 Offline
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
R
Joined: Feb 2005
Posts: 8
it also seems I have to open a new Object for every SELECT or other sql query I do.. is it supposed to be like that?

Re: MySQL #106933 16/02/05 01:55 PM
Joined: Dec 2002
Posts: 1,321
H
Hammer Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
Yes, you have to have a different recordset object for each recordset returned to you; how else would you differentiate between them?

The Collect method is a simple method of retrieving the fields numerically when you know how many fields you want and in what order they are going to appear. It is 0-based, so your first field will be 0, your last field will be N-1, where N is the number of fields you requested. This is like PHP's if ($row = mysql_fetch_row($rs)), after which you would use $row[0] to reference the row.

The ADODB.Recordset object's .MoveNext method functions the same way performing another mysql_fetch_row() would; it moves the recordset pointer to the next record.

VBScript:

While Not rs.EOF
  • ' Do something with the current record, like retrieving its values, changing them, updating them, etc.
    rs.MoveNext
WEnd

PHP:

while ($row = mysql_fetch_row($rs)) {
  • /* Do something with the current record, like retrieving its values, changing them, updating them, etc.
}

mIRC:

while (!$com(rs, EOF, 2)) {
  • ; Do something with the current record, like retrieving its values, changing them, updating them, etc.
    !.echo -q $com(rs, MoveNext, 1)
}


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
Re: MySQL #106934 16/07/05 04:02 AM
Joined: Dec 2002
Posts: 14
N
namnori Offline
Pikka bird
Offline
Pikka bird
N
Joined: Dec 2002
Posts: 14
Well I don't really know mySQL, PHP, com objects, or ADO, but I hacked together a !seen script anyways based on Hammer's work. I'm not sure why it works, but it works pretty well!

While I was trying to figure out how Hammer's code worked, I made some more goodies that might help others.

Here's a snippet...
Code:
  var %obj
  var %SQL = SELECT FirstName, LastName, Gender FROM Nicks WHERE nickname = ' $+ $1 $+ ';
  var %result = $mysql_query(%SQL,%DB), %success = $gettok(%result,1,32), %obj = $gettok(%result,2,32)
  if (%success) {
    echo %Success.Color -a * Opened MySQL QUERY connection: %SQL
    echo -a Returned: $mysql_fetch_field(%obj,1) $mysql_fetch_field(%obj,2) $mysql_fetch_field(%obj,3) 
    SQLcomclose %obj
  }
  else {
    echo %Failure.Color -a * Couldn't connect to MySQL for QUERY: %SQL
  }

That came from rewriting his 1st, simpler code, with his revised code. %DB is also the same as MySQL.Database or MySQL.Database.$ticks depending on where you copy paste.

And custom alias:
Code:
 
; NOT zero based, 1st column is column 1
ALIAS mysql_fetch_field {
  if ($com($$1, Collect, 2, i4, $calc($$2 - 1))) { return $com($$1).result  }
  else {
    ; ERROR: NO FIELD--OUT OF BOUNDS?
    return
  }
}
 


Now I'm trying to figure out how to get it to return stuff in a format I like. It's been returning integer data like "15" as "15.000000"

I tried different variable types: i1, i2, i4, ui1, ui2, ui4, int, uint, r4, r8, cy, date, decimal, bool, bstr, variant, dispatch, unknown, error (found in mIRC help for com objects) but nothing yet.

I know you didn't want to write a tutorial, but I've been trying to find documentation, especially on the syntax, with little luck.

[edit]I've found the MSDN reference, but it's just help me learn a lot more, but not how why it returns funny numbers.

Last edited by namnori; 16/07/05 04:44 AM.
Re: MySQL #106935 18/07/05 01:25 AM
Joined: Dec 2002
Posts: 14
N
namnori Offline
Pikka bird
Offline
Pikka bird
N
Joined: Dec 2002
Posts: 14
Upon working further with my code, there seems to be a memory leak.

I traced it to $mysql_command and to a smaller degree... $mysql_query

I'm not sure if I'm just not using it right, but mIRC's memory usage swells to 700 megs in a day.

To test it, I wrote an alias that called portions of the code inside large loops. Everything else I tested, including other mysql and com object aliases worked fine.

Re: MySQL #106936 01/12/06 08:18 PM
Joined: Dec 2006
Posts: 2
L
ldcrew Offline
Bowl of petunias
Offline
Bowl of petunias
L
Joined: Dec 2006
Posts: 2
hey im having problems in how to use this mysql connection and add to db.

My intention is to save all text from certain nick in to db on my mysql and add ctime next to it.

Example in db how to be stored:

ctime - The1LineFromTheNick
ctime - The2LineFromTheNick
ctime - The3LineFromTheNick


This is how far i got: (not much i know frown )

Code:
 
menu channel {
  Relayer
  .On: set %relay on | echo -as RELAYER Turned 09ON
  .Off: unset %relay | echo -as RELAYER Turned 04OFF
}

on *:text:*:#ChannelToListenOn: {
  if ($network == NetworkToListenOn && $nick == NameToListenOn && %relay == on) {
    if ( $chr(91) isin $1 && $chr(93) isin $3) {
      if (SEARCH !isin $2 && GROUP !isin $2) {
        if (FIRST !isin $2 && LAST !isin $2) {
          [color:green] ;Need to remove color from %text [/color]
          var %text = $1-
          var %Connection.String = (DRIVER={MySQL ODBC 3.51 Driver};, SERVER=MySQL.MySite.com;, $&
            PORT=80;, DATABASE=myDatabase;, USER=myUsername;, PASSWORD=myPassword;, OPTION=3;)
        }
      }
    }
  }
}


i know the remote bit trigger just fine, its more about getting $ctime - %text (with stripped color) & mysql part to work

Any help would be appreciated laugh

Page 2 of 2 1 2