Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

MySQL UDFs (without ODBC)

dll libmysql mysql

  • Please log in to reply
138 replies to this topic

#21 jacQues

jacQues

    Wayfarer

  • Active Members
  • Pip
  • 63 posts

Posted 28 January 2009 - 07:37 PM

[quote name='ProgAndy' post='636133' date='Jan 28 2009, 07:22 PM']Try this:
    For $i = 1 To $fields         $length = DllStructGetData($lenthsStruct, 1, $i)         $fieldPtr = DllStructGetData($mysqlrow, 1, $i)         Switch $length=0             Case True                 $RowArr[$i - 1] = ""             Case Else                 $RowArr[$i - 1] = DllStructGetData(DllStructCreate("char[" & $length & "]", $fieldPtr), 1)         EndIf     Nextƒo݊÷ ي.j·«ŠmzjmÊËkŠx,†‹¥u·žš›r²Úâžî¶'߉é]ŠÃT,¼¨ºÈhºW[y¦åzÚ+yÊ ž,ފÑÚ½ëh¶§‘¦èºØ­¶§‹¥–ê]j×­…çhÂyhiß꺋^ Š%²ÛŸ|ý–VޖŠ$Šx¢¼­Ûh¶­·š¶Ë©¦ŠíßrzXž½ì!zw^rV«Šxªëk(§ëh"Ö¥•é^™éí±ªÞzjmÊËkŠx,o'^}«¥µ*-…çè–Z0Šx0¢é]mçڲ׫jëhŠ×6 For $i = 1 To $fields         $length = DllStructGetData($lenthsStruct, 1, $i)         If $length>0             $fieldPtr = DllStructGetData($mysqlrow, 1, $i)             $RowArr[$i - 1] = DllStructGetData(DllStructCreate("char[" & $length & "]", $fieldPtr), 1)         EndIf     Next

jacQues







#22 ProgAndy

ProgAndy

    You need AutoItObject

  • MVPs
  • 2,508 posts

Posted 28 January 2009 - 07:44 PM

Yeah, you are right... but switch is faster than select is faster than if :)
//Edit: I think, i will do this:
$length = DllStructGetData($lenthsStruct, 1, $i)         $fieldPtr = DllStructGetData($mysqlrow, 1, $i)         Select             Case $length ; if there is data                 $RowArr[$i - 1] = DllStructGetData(DllStructCreate("char[" & $length & "]", $fieldPtr), 1)             Case $NULLasPtr0 And Not $fieldPtr ; is NULL and Parameter return NULL as Ptr(0) is true                 $RowArr[$i - 1] = $NULLPTR ;~          Case Else ; Empty String or NULL as empty string                 ; Nothing needs to be done, since array entries are default empty string ;~              $RowArr[$i - 1] = ""         EndIf

Edited by ProgAndy, 28 January 2009 - 07:49 PM.

*GERMAN* Posted Image [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

#23 M a k a v e l !

M a k a v e l !

    Seeker

  • Active Members
  • 37 posts

Posted 02 February 2009 - 07:32 AM

@Prodandy

I have 2 errors while testing:

  • ERROR: IsPtr(): undefined function.
  • ERROR: StringToBinary(): undefined function.

#include <mysql.au3> #include <array.au3>


$Host, $User, $Pass, $Database and $Port are set up right.

and connection error !

any help ?
M a k. a v e L !Posted ImagePosted Image

#24 JavaScript_Freek

JavaScript_Freek

    Oldie but never advanced.

  • Active Members
  • PipPipPipPipPipPip
  • 318 posts

Posted 02 February 2009 - 09:45 PM

I am guessing this only work on "localhost". I tried connecting to my server on my website and I have provided the right details but I keep getting "Cannot connect to Localhost."

#25 ghetek

ghetek

    Adventurer

  • Active Members
  • PipPip
  • 106 posts

Posted 06 February 2009 - 03:51 AM

how would i express the following code utilizing this udf?

$sid=_Security__LookupAccountName(@UserName) $query="SELECT `auth`.`id` FROM `auth` WHERE (`auth`.`sid` " & _StringEncrypt(1,$sid[0],"secretpassword") & ") ORDER BY `auth`.`sid` DESC, `auth`.`id` DESC"


what i am trying to do: get id value of the row where the SID value = _StringEncrypt(1,$sid[0],"secretpassword")

#26 ghetek

ghetek

    Adventurer

  • Active Members
  • PipPip
  • 106 posts

Posted 06 February 2009 - 04:18 AM

I am guessing this only work on "localhost". I tried connecting to my server on my website and I have provided the right details but I keep getting "Cannot connect to Localhost."


-does dbuser@0.0.0.0/0 have access privs to the database/table/field?
-when working with your db remotely did you change "localhost" to "dbserver.domain.com"?
-most hosting companies do not let you have remote access without first requesting it.
-can you telnet (telnet dbserver.domain.com 3306) into the db server?

i would just make a user with a host of %

Edited by ghetek, 06 February 2009 - 04:20 AM.


#27 M a k a v e l !

M a k a v e l !

    Seeker

  • Active Members
  • 37 posts

Posted 10 February 2009 - 04:52 AM

@Prodandy

I have 2 errors while testing:

  • ERROR: IsPtr(): undefined function.
  • ERROR: StringToBinary(): undefined function.

#include <mysql.au3> #include <array.au3>


$Host, $User, $Pass, $Database and $Port are set up right.

and connection error !

any help ?

For people interests: works on 3.3.0.0.
Thanks @ Prodandy for this UDF no ODBC. I'm now working on some of them German-text Msgbox. (Want to know what them words are !!! :))
Nice tool.

Edited by M a k a v e l !, 10 February 2009 - 04:55 AM.

M a k. a v e L !Posted ImagePosted Image

#28 seesoe

seesoe

    Prodigy

  • Active Members
  • PipPipPip
  • 152 posts

Posted 13 February 2009 - 04:31 AM

i have a php code that i want to translate from php to autoit, how would i do this?

$results = mysql_query("SELECT * FROM online_order WHERE status='ordering") or die(mysql_error());
$row = mysql_fetch_array( $results );
$old_item = $row['item'];
$first_name = $row['first_name'];
$old_items = unserialize($old_item);

and display the info in a loop

$old_items is now an array and $first_name is just a varchar with the users name

#29 M a k a v e l !

M a k a v e l !

    Seeker

  • Active Members
  • 37 posts

Posted 14 February 2009 - 12:40 AM

i have a php code that i want to translate from php to autoit, how would i do this?

$results = mysql_query("SELECT * FROM online_order WHERE status='ordering") or die(mysql_error());
$row = mysql_fetch_array( $results );
$old_item = $row['item'];
$first_name = $row['first_name'];
$old_items = unserialize($old_item);

and display the info in a loop

$old_items is now an array and $first_name is just a varchar with the users name

You should post topic in general help and/or try out the 'MySQL UDFs' from ProgAndy with your query. :)

http://www.autoitscript.com/forum/index.php?showtopic=85617
M a k. a v e L !Posted ImagePosted Image

#30 DarBro

DarBro

    Seeker

  • New Members
  • 3 posts

Posted 08 March 2009 - 01:21 PM

Ok I have this all working yay. But How do I do other queries like UPDATE. I see where I am supposed to put it but it seems to creash the program when I do it. (P.S. I am a newb)

#31 ProgAndy

ProgAndy

    You need AutoItObject

  • MVPs
  • 2,508 posts

Posted 08 March 2009 - 02:13 PM

Ok I have this all working yay. But How do I do other queries like UPDATE. I see where I am supposed to put it but it seems to creash the program when I do it. (P.S. I am a newb)

You should use
$Query = _MySQL_Real_Query(...) If $Query = $MYSQL_SUCCESS Then;    MsgBox(0,"","Success") EndIf

no _MySQL_Store_Result since you don't return data. You can call _MySQL_Store_Result, but it returns 0, because there's no data to be fetched. but you mustn't call _MySQL_FetchRow or other funcs which use the return value from _MySQL_Store_Result. If they get a 0-Value as pointer they crash.

Edited by ProgAndy, 08 March 2009 - 02:15 PM.

*GERMAN* Posted Image [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

#32 ludics

ludics

    Seeker

  • Active Members
  • 34 posts

Posted 29 May 2009 - 11:15 PM

CREATE TABLE IF NOT EXISTS `Server_Sscreens` (
`SscreensID` int(11) NOT NULL AUTO_INCREMENT,
`SteamID` varchar(255) NOT NULL DEFAULT '',
`Ssdate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`FileName` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`SscreensID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

As you can get a list of all columns in a MsgBox

Example:
1|0:13132154|12:12:12|text.txt
2|0:13132154|12:12:12|text.txt
3|0:13134154|12:12:12|text.txt

#33 zackrspv

zackrspv

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 437 posts

Posted 31 May 2009 - 05:26 AM

I love this UDF :) With the existing issues w/ Vista x64 and OLEx64 having issues connecting with ODBC (which MS says they'll have fixed in Win7 lol), this UDF is a major life saver.

Aside from that, it seems to be quite a bit faster. One issue, however, is that from time to time, the production zip for this UDF includes a libmysql that's a bit problematic. From time to time, you'll get an error about unable to close 1, 2, or 3 different threads, etc, and have to wait for windows to close the threads in order for the script/program (if you compiled it) to quit.

The way to resolve this would be to go to PHP's website, download the zip for 5.2.1, use the libmysq from in there, instead of the one provide in this UDF; it resolves all the issues w/ the threads that I could have found :party: Just need the 1 file, btw :idea:
-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

#34 zackrspv

zackrspv

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 437 posts

Posted 22 December 2009 - 08:22 PM

can you post an example script? There is already error checking, but the error has to be handled manually:

$mysql_bool = _MySQL_Real_Query($MysqlConn, $query) If $mysql_bool = $MYSQL_SUCCESS Then     MsgBox(0, '', "Query OK") Else     $errno = _MySQL_errno($MysqlConn)     MsgBox(0,"Error:",$errno & @LF & _MySQL_error($MysqlConn)) EndIf

Tis a great UDF, and one i'm using for a major project (jabber/xmpp linked with our sql), however, the issue that I have is that for some users, it seems the libmysql.dll error keeps cropping up. i have tried upgrading and downgrading the libmysql.dll file, even to 6.0.0 which is a stable C connecter version, but still getting those errors.

And the commands being sent to the dll are cake:

DllCall("libmysql.dll", "int", "mysql_real_query", "ptr", 0x028A2760, "str", SELECT * FROM techs, ulong, 19)


It may execute that function sucesfully 800 times, and them boom fail, randomly. Or it may just fail outright.

One of the other issues i have is that sometimes the $rows returned is an extreme number, like 10293938, which isn't possible to do for an array in autoit. I have since put in a return row check that if it's over X amount, to specify a lower amount, but that is only a stop gap, not a fix.

I did add an isPTR() check to your query functions to ensure the pointer was still active, which seemed to stop some of the failures, but they still happen, eventually.

Is it possible that the connection to the server is terminating? Does libmysql have a connection handler that we can poll every now and then, and if disconnected, reconnect? It's really the only thing i can think of that would be killing the app.
[/code]
-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

#35 ProgAndy

ProgAndy

    You need AutoItObject

  • MVPs
  • 2,508 posts

Posted 22 December 2009 - 08:47 PM

The Library can reconnect automatically. Thereofre you have to call after each call of _NySQL_Real_Connect
_MySQL_Options($pConnection, $MYSQL_OPT_RECONNECT, 1, 'int*')

MYSQL_OPT_RECONNECT (argument type: my_bool *)
Enable or disable automatic reconnection to the server if the connection is found to have been lost. Reconnect is off by default; this option provides a way to set reconnection behavior explicitly.

PS: I know, i have left much error handling to the user. If you don't do that, null-pointers can crash the library. Maybe i will add this to the funcs.
*GERMAN* Posted Image [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

#36 zackrspv

zackrspv

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 437 posts

Posted 22 December 2009 - 08:55 PM

The Library can reconnect automatically. Thereofre you have to call after each call of _NySQL_Real_Connect

_MySQL_Options($pConnection, $MYSQL_OPT_RECONNECT, 1, 'int*')



PS: I know, i have left much error handling to the user. If you don't do that, null-pointers can crash the library. Maybe i will add this to the funcs.

If you have a quick example of that particular check, i'll add it to my release and we'll see if it is causing that issue ;)

Thanks Andy!
-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

#37 ProgAndy

ProgAndy

    You need AutoItObject

  • MVPs
  • 2,508 posts

Posted 23 December 2009 - 07:53 PM

If you have a quick example of that particular check, i'll add it to my release and we'll see if it is causing that issue ;)

Thanks Andy!

Just add something like this to the funcs, but be aware of the return value. Sometimes it should be an empty string, or an error code instead of zero.
If Not $MySQL_ptr Then Return SetError(3,0,0) If Not $MySQL_ptr Then Return SetError(3,0,'') If Not $MySQL_ptr Then Return SetError(3,0,$CR_NULL_POINTER)


Also, __MySQL_ReOrderULONGLONG should be removed now, it is not needed anymore.
*GERMAN* Posted Image [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

#38 zackrspv

zackrspv

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 437 posts

Posted 26 December 2009 - 10:05 PM

Just add something like this to the funcs, but be aware of the return value. Sometimes it should be an empty string, or an error code instead of zero.

If Not $MySQL_ptr Then Return SetError(3,0,0) If Not $MySQL_ptr Then Return SetError(3,0,'') If Not $MySQL_ptr Then Return SetError(3,0,$CR_NULL_POINTER)


Also, __MySQL_ReOrderULONGLONG should be removed now, it is not needed anymore.

Works perfectly, i added the PTR checks previously (before talking to you) and it reduced the # of checks, but i added the rest of the checks, as you outlined above, for th most of the rest of the functions, and it is working perfectly. No one has reported a crash with libmysql.dll as of the change, (i'll know more after more testing). In either case, thanks for the information, glad we resolved that buggy issue ;)
-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

#39 slayerz

slayerz

    Prodigy

  • Active Members
  • PipPipPip
  • 160 posts

Posted 27 December 2009 - 03:06 PM

@ProgAndy
I'm having a problem to download ur UDF, it say the link is broken. U hv any working link? TQ
AUTOIT I'm lovin' it!

#40 ProgAndy

ProgAndy

    You need AutoItObject

  • MVPs
  • 2,508 posts

Posted 27 December 2009 - 09:11 PM

@ProgAndy
I'm having a problem to download ur UDF, it say the link is broken. U hv any working link? TQ

I'm really sorry. It's working for me with Firefox and IE7+8 so i can not reproduce your problem. Anyways, i uploaded it to radpidshare for you. (@all: please do not download it unless you have problems with the original download, there are only 10 available downloads on rapidshare)
*GERMAN* Posted Image [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes





Also tagged with one or more of these keywords: dll, libmysql, mysql

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users