Jump to content

SQL woes


 Share

Recommended Posts

So I've spent the evening looking into the several MySQL UDFs across the forum, trying to understand how to use them, and I have failed horribly. Does anoybody know a good place to start? I'm just trying to do simple data storage and am only using the database at all for cross language compatibility.

Why cant there just be a simple function like

SendToDB( $value, $row, $cloumn, $table )
GetFromDB( $value, $row, $cloumn, $table )

All help appreciated :graduated:.

[center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw

Link to comment
Share on other sites

Why cant there just be a simple function like

There can be, you just need to allow for circumstances where the programmer does not require adding in optional clauses.

I've written PHP functions like this before, so I'll post the code when I get home. All you need to do is convert to AutoIt :graduated:

James

Link to comment
Share on other sites

For this simple DB purpose I recommend to use SQLite.

It's part of AutoIt and there are easy functions for working with DB data, see this example from Autoit's helppfile:

Good SQL help is here http://www.w3schools.com/sql/default.asp

#include <SQLite.au3>
#include <SQLite.dll.au3>

Local $aResult, $iRows, $iColumns, $iRval

_SQLite_Startup ()
If @error > 0 Then
    MsgBox(16, "SQLite Error", "SQLite.dll Can't be Loaded!")
    Exit - 1
EndIf
_SQLite_Open () ; Open a :memory: database
If @error > 0 Then
    MsgBox(16, "SQLite Error", "Can't Load Database!")
    Exit - 1
EndIf

;Example Table
;   Name        | Age
;   -----------------------
;   Alice       | 43
;   Bob         | 28
;   Cindy       | 21

If Not _SQLite_Exec (-1, "CREATE TEMP TABLE persons (Name, Age);") = $SQLITE_OK Then _
        MsgBox(16, "SQLite Error", _SQLite_ErrMsg ())
If Not _SQLite_Exec (-1, "INSERT INTO persons VALUES ('Alice','43');") = $SQLITE_OK Then _
        MsgBox(16, "SQLite Error", _SQLite_ErrMsg ())
If Not _SQLite_Exec (-1, "INSERT INTO persons VALUES ('Bob','28');") = $SQLITE_OK Then _
        MsgBox(16, "SQLite Error", _SQLite_ErrMsg ())
If Not _SQLite_Exec (-1, "INSERT INTO persons VALUES ('Cindy','21');") = $SQLITE_OK Then _
        MsgBox(16, "SQLite Error", _SQLite_ErrMsg ())

; Query
$iRval = _SQLite_GetTable2d (-1, "SELECT * FROM persons;", $aResult, $iRows, $iColumns)
If $iRval = $SQLITE_OK Then
    _SQLite_Display2DResult($aResult)

;~   $aResult looks like this:
;~  
;~   Name   Age 
;~   Alice  43 
 
;~   Bob    28  
;~   Cindy 21  
;~
;~    If the dimensions would be switched in _SQLite_GetTable2d the result would look like this:
;~  
;~   Name  Alice Bob  Cindy 
;~   Age   43   28   21 
   

Else
    MsgBox(16, "SQLite Error: " $iRval, _SQLite_ErrMsg ())
EndIf

_SQLite_Close ()
_SQLite_Shutdown ()
Edited by Zedna
Link to comment
Share on other sites

Im in the same boat, tried looking up using MySQL in autoit and it seems you need several addictional files and there is a big lack of help i.e. no helpfile or thread dead. Im just trying to have my 1500+ line script read a vaule from my webpages database.

muppet hands are so soft :)

Link to comment
Share on other sites

Hey guys, SqLite doesn't fit my purpose as it's local only. However I finally managed to figure out the mysql syntax. Thanks for the link zedna, it cleared alot of the fog from my eyes.

@russel

You interact with the mysql database through querys, which are like commands. Then you use another function to pull the result (depending on which UDF your using).

[center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...