Announcement

Collapse
No announcement yet.

mysql

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #21
    Originally posted by Stuart McLachlan View Post
    Using the MySQL.ini linked earlier with the PTR definitions modified to BYVAL
    and libmySQL.dll 32 bit downloaded from the web. Stripped down still truncates retreived data at 36 characters!

    The only libmyql.dll I found to download standalone is ver 5.5.9.0 dated 12 march 2011, so that may be an issue?
    (Since located and tested 6.1.10.0 with same results)
    Looking at some old posts, it seems that the .inc file was for ver 4.0.
    I doubt that it is useful any more.

    To the OP - consider SQLTools or a different RDBMS

    I'm finished here, I've wasted far too much time on this one!

    Comment


    • #22
      Wish I'd found this 2009 post a lot earlier

      Originally posted by José Roca View Post
      I have ascertained that the TYPEs you're using are for MYSQL v. 4.0. The ones for the current version are very different. You will have trouble to access the members of the structures using these outdated definitions.

      Comment


      • #23
        I have created two programs. The first program has three fields per record and shows good results. The
        second program has thirteen fields per record and the results are not correct. There are also two small
        programs that create the databases and tables.

        I have also included the MySql.inc that Stuart pointed out.
        "If you're using the headers from here https://forum.powerbasic.com/forum/u...ders#post28754)"

        Code:
        'programData\mysql\mysql server 5.7\data is where database is found
        'program creates database with three fields in table.
        
        #COMPILE EXE
        
        
        #INCLUDE "MySQL.inc" ' header file - declares for MySQL
        
        FUNCTION PBMAIN() AS LONG
        
            DIM rs AS LONG
        
            LOCAL i AS LONG, nError AS LONG
            LOCAL sHost AS STRING, sUser AS STRING, sPassword AS STRING, sTemp AS STRING
            LOCAL sTableName AS STRING, sOrderField AS STRING,datarow AS LONG
            LOCAL sDbname AS ASCIIZ*255, selectdb AS ASCIIZ*255, selecttb AS ASCIIZ*1255
            LOCAL nField AS LONG,ptfield AS LONG,numrows AS LONG
        
            sHost       = "localhost"
            sUser       = "djthain1"
            sPassword   = "[email protected]"
        
            sDbname     = "bookkeeping6"
        
            sTableName  = "addrs"
        
        '***********************************************************
        'Init System
        
            IF mysql_init() THEN
                MSGBOX mySQL_Error(),16,"[Error] mysql_init"
                EXIT FUNCTION
            END IF
        
        '***********************************************************
        'Setup Options
        
            IF mysql_options( %MYSQL_OPT_LOCAL_INFILE, "local-infile=1" ) THEN
                MSGBOX mySQL_Error(),16,"[Error] mysql_options"
                EXIT FUNCTION
            END IF
        
        '***********************************************************
        'Connect to Server
        
            IF mySQL_Connect( sHost, sUser, sPassword, 0 ) THEN  '-- Connect to mySQL
                MSGBOX mySQL_Error(),16,"[Error] mySQL_Connect"
                EXIT FUNCTION
            END IF
        
        '***********************************************************  first run only then comment out ''
        'Create Database
        
            selectdb = "create database "+sdbname
            IF mySQL_Query( selectdb ) THEN                     '-- create DB
                MSGBOX mySQL_Error(),16,"[Error] mySQL_query"
                EXIT FUNCTION
            END IF
        
        '***********************************************************
        'Select the Database
        
            IF mySQL_Select_Db( sDbname ) THEN    '-- Select DB
                MSGBOX mySQL_Error(),16,"[Error] mySQL_Select_Db"
                EXIT FUNCTION
            END IF
        
        '~~~ Create a table in the current database ******************    first run only then comment out
            selecttb = "CREATE TABLE "+sTableName+ "(" + _
                "rcdno int unsigned auto_increment primary key," + _
                "primkey char(70)," + _
                "lastname char(35)," + _
                "firstname char(35))"
        
             mySQL_query(selecttb)
        
             mySQL_Free_Result()
        
        '***************************************************************
        
            MSGBOX mysql_info,,"Success"
        
            CALL mySQL_Close
        
        END FUNCTION
        Code:
        'program with three fields per record output
        
        #COMPILE EXE
        
        #INCLUDE "MySQL.inc" ' header file - declares for MySQL
        
        '------------------------------------------------------------------------------
        
        FUNCTION PBMAIN() AS LONG
        
            DIM primkey$(1)
            DIM lastname$(1)
            DIM firstname$(1)
            DIM addr1$(1)
            DIM addr2$(1)
            DIM cityst$(1)
            DIM zip$(1)
            DIM x AS LONG
            DIM y AS LONG
            DIM rcdnumber AS LONG
            DIM sTableName AS STRING
            DIM nError AS LONG
            DIM sHost AS STRING
            DIM sUser AS STRING
            DIM sPassword AS STRING
            DIM sDbname AS ASCIIZ*255
            DIM selectdb AS ASCIIZ*255
            DIM selecttb AS ASCIIZ*1255
        
            sHost       = "localhost"
            sUser       = "djthain1"
            sPassword   = "[email protected]"
        
            sDbname     = "bookkeeping6"
            sTableName  = "addrs"
        
        '***********************************************************
        'Init System
        
            IF mysql_init() THEN
                MSGBOX mySQL_Error(),16,"[Error] mysql_init"
                EXIT FUNCTION
            END IF
        
        '***********************************************************
        'Setup Options
        
            IF mysql_options( %MYSQL_OPT_LOCAL_INFILE, "local-infile=1" ) THEN
                MSGBOX mySQL_Error(),16,"[Error] mysql_options"
                EXIT FUNCTION
            END IF
        
        '***********************************************************
        'Connect to Server
        
            IF mySQL_Connect( sHost, sUser, sPassword, 0 ) THEN  '-- Connect to mySQL
                MSGBOX mySQL_Error(),16,"[Error] mySQL_Connect"
                EXIT FUNCTION
            END IF
        
        
        '***********************************************************
        'Select the Database
        
            IF mySQL_Select_Db( sDbname ) THEN    '-- Select DB
                MSGBOX mySQL_Error(),16,"[Error] mySQL_Select_Db"
                EXIT FUNCTION
            END IF
        
        '   LOCAL windowtitle AS ASCIIZ * 256
        
            primkey$="SMITHDARREN"
            lastname$="smith"
            firstname$="darrenx"
        
            mysql_query "insert into addrs (primkey,lastname,firstname) values ('"+ _
                primkey$+"','"+lastname$+"','"+firstname$+"')"
        
        
        
            IF mySQL_Query( "select * from " + sTableName ) THEN
                MSGBOX mySQL_Error(),16,"[Error] mySQL_Query"
                EXIT FUNCTION
            END IF
        
            rcdnumber = mySQL_Num_Rows
        
            REDIM primkey$(rcdnumber)
            REDIM lastname$(rcdnumber)
            REDIM firstname$(rcdnumber)
        
            DO WHILE (mysql_fetch_row())
        
                    primekey$ =mySQL_Data(2)     '"primkey",%snaddr)
                    lstname$ =mySQL_Data(3)      '"lastname",%snaddr)
                    fstname$ =mySQL_Data(4)      '"firstname",%snaddr)
        
                    INCR y&
        '            lstname$=RTRIM$(lstname$)
                    ARRAY INSERT primkey$(y&), primekey$
                    ARRAY INSERT lastname$(y&), lstname$
                    ARRAY INSERT firstname$(y&), fstname$
        
            LOOP
        
            FOR x = 1 TO rcdnumber
                MSGBOX primkey$(x)+" "+lastname$(x)+" "+firstname$(x)
            NEXT x
        
            mySQL_Free_Result()
        
            CALL mySQL_Close
        
            CLOSE
        
        
        END FUNCTION  ' PbMain
        Code:
        'programData\mysql\mysql server 5.7\data is where database is found
        
        'program that creates a database and table with thirteen fields
        
        #COMPILE EXE
        
        
        #INCLUDE "MySQL.inc" ' header file - declares for MySQL
        
        FUNCTION PBMAIN() AS LONG
        
            DIM rs AS LONG
        
            LOCAL i AS LONG, nError AS LONG
            LOCAL sHost AS STRING, sUser AS STRING, sPassword AS STRING, sTemp AS STRING
            LOCAL sTableName AS STRING, sOrderField AS STRING,datarow AS LONG
            LOCAL sDbname AS ASCIIZ*255, selectdb AS ASCIIZ*255, selecttb AS ASCIIZ*1255
            LOCAL nField AS LONG,ptfield AS LONG,numrows AS LONG
        
            sHost       = "localhost"
            sUser       = "djthain1"
            sPassword   = "[email protected]"
        
            sDbname     = "bookkeeping4"
        
            sTableName  = "addrs"
        
        '***********************************************************
        'Init System
        
            IF mysql_init() THEN
                MSGBOX mySQL_Error(),16,"[Error] mysql_init"
                EXIT FUNCTION
            END IF
        
        '***********************************************************
        'Setup Options
        
            IF mysql_options( %MYSQL_OPT_LOCAL_INFILE, "local-infile=1" ) THEN
                MSGBOX mySQL_Error(),16,"[Error] mysql_options"
                EXIT FUNCTION
            END IF
        
        '***********************************************************
        'Connect to Server
        
            IF mySQL_Connect( sHost, sUser, sPassword, 0 ) THEN  '-- Connect to mySQL
                MSGBOX mySQL_Error(),16,"[Error] mySQL_Connect"
                EXIT FUNCTION
            END IF
        
        '***********************************************************  first run only then comment out ''
        'Create Database
        
            selectdb = "create database "+sdbname
            IF mySQL_Query( selectdb ) THEN                     '-- create DB
                MSGBOX mySQL_Error(),16,"[Error] mySQL_query"
                EXIT FUNCTION
            END IF
        
        '***********************************************************
        'Select the Database
        
            IF mySQL_Select_Db( sDbname ) THEN    '-- Select DB
                MSGBOX mySQL_Error(),16,"[Error] mySQL_Select_Db"
                EXIT FUNCTION
            END IF
        
        '~~~ Create a table in the current database ******************    first run only then comment out
            selecttb = "CREATE TABLE "+sTableName+ "(" + _
                "rcdno int unsigned auto_increment primary key," + _
                "primkey char(70)," + _
                "lastname char(35)," + _
                "firstname char(35)," + _
                "addr1 char(35)," + _
                "addr2 char(35)," + _
                "cityst char(35)," + _
                "zip char(35)," + _
                "phone1 char(35)," + _
                "phone2 char(35)," + _
                "email1 char(45)," + _
                "email2 char(45)," + _
                "chk char(35))"
        
            mySQL_query(selecttb)
        
             mySQL_Free_Result()
        
        '***************************************************************
        
            MSGBOX mysql_info,,"Success"
        
            CALL mySQL_Close
        
        END FUNCTION
        Code:
        'program that outputs records with thirteen fields.
        #COMPILE EXE
        
        #INCLUDE "MySQL.inc" ' header file - declares for MySQL
        
        '------------------------------------------------------------------------------
        
        FUNCTION PBMAIN() AS LONG
        
            DIM primkey$(1)
            DIM lastname$(1)
            DIM firstname$(1)
            DIM addr1$(1)
            DIM addr2$(1)
            DIM cityst$(1)
            DIM zip$(1)
        
            DIM x AS LONG
            DIM y AS LONG
            DIM rcdnumber AS LONG
            DIM sTableName AS STRING
        
            DIM nError AS LONG
        
            DIM sHost AS STRING
            DIM sUser AS STRING
            DIM sPassword AS STRING
        
        
            DIM sDbname AS ASCIIZ*255
            DIM selectdb AS ASCIIZ*255
            DIM selecttb AS ASCIIZ*1255
        
        
            sHost       = "localhost"
            sUser       = "djthain1"
            sPassword   = "[email protected]"
        
            sDbname     = "bookkeeping4"
            sTableName  = "addrs"
        
        '***********************************************************
        'Init System
        
            IF mysql_init() THEN
                MSGBOX mySQL_Error(),16,"[Error] mysql_init"
                EXIT FUNCTION
            END IF
        
        '***********************************************************
        'Setup Options
        
            IF mysql_options( %MYSQL_OPT_LOCAL_INFILE, "local-infile=1" ) THEN
                MSGBOX mySQL_Error(),16,"[Error] mysql_options"
                EXIT FUNCTION
            END IF
        
        '***********************************************************
        'Connect to Server
        
            IF mySQL_Connect( sHost, sUser, sPassword, 0 ) THEN  '-- Connect to mySQL
                MSGBOX mySQL_Error(),16,"[Error] mySQL_Connect"
                EXIT FUNCTION
            END IF
        
        
        '***********************************************************
        'Select the Database
        
            IF mySQL_Select_Db( sDbname ) THEN    '-- Select DB
                MSGBOX mySQL_Error(),16,"[Error] mySQL_Select_Db"
                EXIT FUNCTION
            END IF
        
        '   LOCAL windowtitle AS ASCIIZ * 256
        
            primkey$="SMITHDARREN"
            lastname$="smith"
            firstname$="darrenw"
            addr1$="1722Apache"
            addr2$="apt 22"
            cityst$="smithville tx"
            zip$="44920"
            phone1$="3033437782"
            phone2$=" "
            email1$="[email protected]
            email2$=" "
            chk$=" "
        
        
            mysql_query "insert into addrs (primkey,lastname,firstname,addr1,addr2,cityst,zip,phone1,phone2,email1,email2,chk) values ('"+ _
                primkey$+"','"+lastname$+"','"+firstname$+"','"+addr1$+"','"+addr2$+"','"+cityst$+"','"+zip$+"','"+phone1$+ _
                "','"+phone2$+"','"+email1$+"','"+email2$+"','"+chk$+"')"
        
        
            IF mySQL_Query( "select * from " + sTableName ) THEN
                MSGBOX mySQL_Error(),16,"[Error] mySQL_Query"
                EXIT FUNCTION
            END IF
        
            rcdnumber = mySQL_Num_Rows
        
            REDIM primkey$(rcdnumber)
            REDIM lastname$(rcdnumber)
            REDIM firstname$(rcdnumber)
            REDIM addr1$(rcdnumber)
            REDIM addr2$(rcdnumber)
            REDIM cityst$(rcdnumber)
            REDIM zip$(rcdnumber)
        
            DO WHILE (mysql_fetch_row())
        
                    primekey$ =mySQL_Data(2)     '"primkey",%snaddr)
                    lstname$ =mySQL_Data(3)      '"lastname",%snaddr)
                    fstname$ =mySQL_Data(4)      '"firstname",%snaddr)
                    adrs1$ =mySQL_Data(5)       '"addr1",%snaddr)
                    adrs2$ =mySQL_Data(6)       '"addr2",%snaddr)
                    ctyst$ =mySQL_Data(7)        '"cityst",%snaddr)
                    zp$ =mySQL_Data(8)           '"zip",%snaddr)
                    phone1$ =mySQL_Data(9)
                    phone2$ =mySQL_Data(10)
                    email1$ =mySQL_Data(11)
                    email2$ =mySQL_Data(12)
                    chk$ =mySQL_Data(13)
        
                    INCR y&
                    lstname$=RTRIM$(lstname$)
                    ARRAY INSERT primkey$(y&), primekey$
                    ARRAY INSERT lastname$(y&), lstname$
                    ARRAY INSERT firstname$(y&), fstname$
                    ARRAY INSERT addr1$(y&), adrs1$
                    ARRAY INSERT addr2$(y&), adrs2$
                    ARRAY INSERT cityst$(y&), ctyst$
                    ARRAY INSERT zip$(y&), zp$
        
            LOOP
        
            FOR x = 1 TO rcdnumber
                MSGBOX primkey$(x)+" "+lastname$(x)+" "+firstname$(x)+" "+ addr1$(x)+" "+addr2$(x)+" "+cityst$(x)+" "+zip$(x)
        
            NEXT x
        
            mySQL_Free_Result()
        
            CALL mySQL_Close
        
            CLOSE
        
        
        END FUNCTION  ' PbMain
        Code:
        'MySql.inc
        '***************************************************************************************************************
        '
        ' Added to By Mike Trader - Oct 2002 (still incomplete)
        '
        ' For those who cannot/do not wish to use ODBE interface (SQL Tools) for MySQL
        ' Specifically included is the %MYSQL_OPT_LOCAL_INFILE to allow loading of
        ' data from a file directly into an SQL data base (MtSQL 4.0 and up) security switch
        ' (This ver still uses GLOBALs so is not useable for multiple calls or threaded calls)
        ' Added alot of comments for quick scanning of SQL functions
        ' Rewrote Error checking in mySQL_Query to include "file not found" (which has no error number!)
        ' mysql_affected_rows  - DECLARED with T_MYSQL PTR not T_MYSQL_RES PTR as per manual
        ' mysql_create_db  - function Added
        ' mysql_drop_db    - function Added (DELETEs the database)
        '
        '
        ' See the MySQL Manual (comes with MySQL), FUNCTION INDEX (at btm) for more info on these function calls
        '
        ' SQL server control Operational Concept for Newbies:
        ' Initialize SQL, Send Options, Connect to SQL server, Select a Database, use Query to send a Command,
        ' CHECK the stored results, Free the stored results ready for next Query.
        ' All the Commands are sent to the SQL server via the Query, the result of the Query is stored as a table
        ' of Rows and columns with info in them specific to the Query. It is your job to go thru it and pull it out!
        '
        '
        '
        '
        '
        ' (MOSTLY) Ported to PowerBASIC by Florent Heyworth - 17-Sep-2001 (incomplete)
        ' Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
        ' This library is free software; you can redistribute it and/or
        ' modify it under the terms of the GNU Library General Public
        ' License as published by the Free Software Foundation; either
        ' version 2 of the License, or (at your option) any later version.
        ' This library is distributed in the hope that it will be useful,
        ' but WITHOUT ANY WARRANTY; without even the implied warranty of
        ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
        ' Library General Public License for more details.
        ' You should have received a copy of the GNU Library General Public
        ' License along with this library; if not, write to the Free
        ' Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
        ' MA 02111-1307, USA */
        
        '***************************************************************************************************************
        'mysql_option enum
        %MYSQL_OPT_CONNECT_TIMEOUT  = 0
        %MYSQL_OPT_COMPRESS         = 1
        %MYSQL_OPT_NAMED_PIPE       = 2
        %MYSQL_INIT_COMMAND         = 3
        %MYSQL_READ_DEFAULT_FILE    = 4
        %MYSQL_READ_DEFAULT_GROUP   = 5
        %MYSQL_SET_CHARSET_DIR      = 6
        %MYSQL_SET_CHARSET_NAME     = 7
        %MYSQL_OPT_LOCAL_INFILE     = 8
        
        'mysql_status enum
        %MYSQL_STATUS_READY         = 0
        %MYSQL_STATUS_GET_RESULT    = 1
        %MYSQL_STATUS_USE_RESULT    = 2
        
        %MYSQL_ERRMSG_SIZE          = 200
        
        %CLIENT_LONG_PASSWORD       = 1         'new more secure passwords
        %CLIENT_FOUND_ROWS          = 2         'Found instead of affected rows
        %CLIENT_LONG_FLAG           = 4         'Get all column flags
        %CLIENT_CONNECT_WITH_DB     = 8         'One can specify db on connect
        %CLIENT_NO_SCHEMA           = 16        'Don't allow database.table.column
        %CLIENT_COMPRESS            = 32        'Can use compression protocol
        %CLIENT_ODBC                = 64        'Odbc client
        %CLIENT_LOCAL_FILES         = 128       'Can use LOAD DATA LOCAL
        %CLIENT_IGNORE_SPACE        = 256       'Ignore spaces before '('
        %CLIENT_CHANGE_USER         = 512       'Support the mysql_change_user()
        %CLIENT_INTERACTIVE         = 1024      'This is an interactive client%CLIENT_SSL = 2048                      'Switch to SSL after handshake
        %CLIENT_IGNORE_SIGPIPE      = 4096      'IGNORE sigpipes
        %CLIENT_TRANSACTIONS        = 8196      'Client knows about transactions
        
        'enum field types
        %FIELD_TYPE_DECIMAL         = 0
        %FIELD_TYPE_TINY            = 1
        %FIELD_TYPE_SHORT           = 2
        %FIELD_TYPE_LONG            = 3
        %FIELD_TYPE_FLOAT           = 4
        %FIELD_TYPE_DOUBLE          = 5
        %FIELD_TYPE_NULL            = 6
        %FIELD_TYPE_TIMESTAMP       = 7
        %FIELD_TYPE_LONGLONG        = 8
        %FIELD_TYPE_INT24           = 9
        %FIELD_TYPE_DATE            = 10
        %FIELD_TYPE_TIME            = 11
        %FIELD_TYPE_DATETIME        = 12
        %FIELD_TYPE_YEAR            = 13
        %FIELD_TYPE_NEWDATE         = 14
        %FIELD_TYPE_ENUM            = 247
        %FIELD_TYPE_SET             = 248
        %FIELD_TYPE_TINY_BLOB       = 249
        %FIELD_TYPE_MEDIUM_BLOB     = 250
        %FIELD_TYPE_LONG_BLOB       = 251
        %FIELD_TYPE_BLOB            = 252
        %FIELD_TYPE_VAR_STRING      = 253
        %FIELD_TYPE_STRING          = 254
        
        
        
        
        '***************************************************************************************************************
        TYPE T_USED_MEM '/* struct for once_alloc */
            ptNext AS T_USED_MEM PTR '/* Next block in use */
            dwLeft AS DWORD '/* memory left in block */
            dwSize AS DWORD '/* size of block */
        END TYPE
        
        TYPE T_MEM_ROOT
            ptFree AS T_USED_MEM PTR
            ptUsed AS T_USED_MEM PTR
            ptPreAlloc AS T_USED_MEM PTR
            dwMinMalloc AS DWORD
            dwBlockSize AS DWORD
        END TYPE
        
        TYPE T_MYSQL_OPTIONS
            dwConnectTimeout AS DWORD
            dwClientFlag AS DWORD
            bFlagCompress AS BYTE
            bFlagNamedPipe AS BYTE
            pszHost AS ASCIIZ PTR
            pszInitCommand AS ASCIIZ PTR
            pszUser AS ASCIIZ PTR
            pszPassword AS ASCIIZ PTR
            pszUnixSocket AS ASCIIZ PTR
            pszDb AS ASCIIZ PTR
            pszMyConfFile AS ASCIIZ PTR
            pszMyConfGroup AS ASCIIZ PTR
            pszCharsetDir AS ASCIIZ PTR
            pszCharsetName AS ASCIIZ PTR
            bFlagUseSSL AS BYTE             '/* if to use SSL or not */
            pszSSLKey AS ASCIIZ PTR         '/* PEM key file */
            pszSSLCert AS ASCIIZ PTR        '/* PEM cert file */
            pszSSLCa AS ASCIIZ PTR          '/* PEM CA file */
            pszSSLCaPath AS ASCIIZ PTR      '/* PEM directory of CA-s? */
        END TYPE
        
        TYPE T_NET
            dwVio AS DWORD
            lSock AS LONG
            lFcntl AS LONG
            pbBuf AS BYTE PTR
            pbBufEnd AS BYTE PTR
            pbWritePos AS BYTE PTR
            pbReadPos AS BYTE PTR
            szLastError AS ASCIIZ * %MYSQL_ERRMSG_SIZE
            lLastErrNo AS LONG
            lMaxPacket AS LONG
            lTimeOut AS LONG
            lPktNr AS LONG
            bError AS BYTE
            bFlagReturnErrNo AS BYTE
            bFlagCompress AS BYTE
            bFlagNoSendOk AS BYTE
            lRemainInBuf AS LONG
            lBufLength AS LONG
            lWhereb AS LONG
            plReturnStatus AS LONG PTR
            bReadingOrWriting AS BYTE
            bSaveChar AS BYTE
        END TYPE
        
        TYPE T_MYSQL_FIELD
            pszNAME AS ASCIIZ PTR           '/* Name of column */
            pszTable AS ASCIIZ PTR          '/* Table of column if column was a field */
            pszDefault AS ASCIIZ PTR        '/* Default value (set by mysql_list_fields) */
            lFieldType AS LONG              '/* Type of field. Se mysql_com.h for types */
            dwLength AS DWORD               '/* Width of column */
            dwMaxLength AS DWORD            '/* Max width of selected set */
            dwFlags AS DWORD                '/* Div flags */
            dwDecimals AS DWORD             '/* Number of decimals in field */
        END TYPE
        
        TYPE T_CHARSET_INFO
            dwNumber AS DWORD
            pszName AS ASCIIZ PTR
            pbCType AS BYTE PTR
            pbToLower AS BYTE PTR
            pbToUpper AS BYTE PTR
            pbSortOrder AS BYTE PTR
            dwStrxFrmMultiply AS DWORD
            pFuncStrColl AS DWORD
            pFuncStrxFrm AS DWORD
            pFuncStrnnColl AS DWORD
            pFuncStrnxFrm AS DWORD
            pbFuncLikeRange AS DWORD
            dwMbMaxLen AS DWORD
            pFuncIsMbChar AS DWORD
            pbFuncIsMbHead AS DWORD
            pMbCharLen AS DWORD
        END TYPE
        
        TYPE T_MYSQL
            tNet AS T_NET
            pszGptr AS ASCIIZ PTR
            pszHost AS ASCIIZ PTR
            pszUser AS ASCIIZ PTR
            pszPassword AS ASCIIZ PTR
            pszUnixSocket AS ASCIIZ PTR
            pszServerVersion AS ASCIIZ PTR
            pszHostInfo AS ASCIIZ PTR
            dwPort AS DWORD
            dwClientFlag AS DWORD
            dwServerCapabilities AS DWORD
            dwProtocolVersion AS DWORD
            dwFieldCount AS DWORD
            dwServerStatus AS DWORD
            dwThreadId AS DWORD
            qAffectedRows AS QUAD
            qInsertId AS QUAD
            qExtraInfo AS QUAD
            ptFields AS T_MYSQL_FIELD PTR
            tFieldAlloc AS T_MEM_ROOT
            bFlagFreeMe AS BYTE
            bFlagReconnect AS BYTE
            tOptions AS T_MYSQL_OPTIONS
            szScramble AS ASCIIZ * 9
            ptCharset AS T_CHARSET_INFO PTR
            dwServerLanguage AS DWORD
        END TYPE
        
        TYPE T_MYSQL_ROWS
            ptNext AS DWORD                         'list of rows
            pszData AS ASCIIZ PTR
        END TYPE
        
        TYPE T_MYSQL_DATA
            qRows AS QUAD
            dwFields AS DWORD
            ptData AS T_MYSQL_ROWS PTR
            tAlloc AS T_MEM_ROOT
        END TYPE
        
        TYPE T_MYSQL_RES
            qRowCount AS QUAD
            dwFieldCount AS DWORD
            dwCurrentField AS DWORD
            ptFields AS T_MYSQL_FIELD PTR
            ptData AS T_MYSQL_DATA PTR
            ptDataCursor AS T_MYSQL_ROWS PTR
            ptFieldAlloc AS T_MEM_ROOT                  '/* If unbuffered read */
            pszRow AS ASCIIZ PTR                        '/* array of strings */
            pszCurrentRow AS ASCIIZ PTR                 '/* column lengths of current row *
            pdwLength AS DWORD PTR                      '/* for unbuffered reads */
            tHandle AS T_MYSQL PTR                      '/* Used my mysql_fetch_row */
            bEof AS BYTE
        END TYPE
        
        
        
        
        
        '***************************************************************************************************************
        'connection management routines
        DECLARE SUB      pbmysql_close          LIB "libmySQL.DLL" ALIAS "mysql_close"        (BYVAL ptMYSQL  AS T_MYSQL PTR)
        DECLARE FUNCTION pbmysql_init           LIB "libmySQL.DLL" ALIAS "mysql_init"         (BYVAL ptMYSQL  AS T_MYSQL PTR) AS LONG
        DECLARE FUNCTION pbmysql_options        LIB "libmySQL.DLL" ALIAS "mysql_options"      (BYVAL ptMYSQL  AS T_MYSQL PTR, BYVAL lOption AS LONG,_
                                                                                                                      szArg AS ANY) AS LONG
        DECLARE FUNCTION pbmysql_ping           LIB "libmySQL.DLL" ALIAS "mysql_ping"         (BYVAL ptMYSQL  AS T_MYSQL PTR) AS LONG
        DECLARE FUNCTION pbmysql_real_connect   LIB "libmySQL.DLL" ALIAS "mysql_real_connect" (BYVAL ptMYSQL  AS T_MYSQL PTR, szHostName AS ASCIIZ,_
                                                                                             szUserName AS ASCIIZ, szPassword AS ASCIIZ,_
                                                                                               szDbName AS ASCIIZ, BYVAL lPortNum AS LONG,_
                                                                                           szSocketName AS ASCIIZ, BYVAL lFlags AS LONG) AS LONG
        'STATUS AND ERROR-reporting routines
        DECLARE FUNCTION pbmysql_errno          LIB "libmySQL.DLL" ALIAS "mysql_errno"        (BYVAL ptMYSQL  AS T_MYSQL PTR) AS LONG
        DECLARE FUNCTION pbmysql_error          LIB "libmySQL.DLL" ALIAS "mysql_error"        (BYVAL ptMYSQL  AS T_MYSQL PTR) AS LONG
        
        'QUERY CONTRUCTION and execution routines
        DECLARE FUNCTION pbmysql_query          LIB "libmySQL.DLL" ALIAS "mysql_query"        (BYVAL ptMYSQL  AS T_MYSQL PTR, sQueryString AS ASCIIZ) AS LONG
        DECLARE FUNCTION pbmysql_select_db      LIB "libmySQL.DLL" ALIAS "mysql_select_db"    (BYVAL ptMYSQL  AS T_MYSQL PTR, szDbName AS ASCIIZ) AS LONG
        DECLARE FUNCTION pbmysql_create_db      LIB "libmySQL.DLL" ALIAS "mysql_create_db"    (BYVAL ptMYSQL  AS T_MYSQL PTR, szDbName AS ASCIIZ) AS LONG
        DECLARE FUNCTION pbmysql_drop_db        LIB "libmySQL.DLL" ALIAS "mysql_drop_db"      (BYVAL ptMYSQL  AS T_MYSQL PTR, szDbName AS ASCIIZ) AS LONG
        
        'RESULT SET PROCessing routines
        DECLARE FUNCTION pbmysql_affected_rows  LIB "libmySQL.DLL" ALIAS "mysql_affected_rows"(BYVAL ptMYSQL  AS T_MYSQL PTR) AS LONG
        DECLARE SUB      pbmysql_data_seek      LIB "libmySQL.DLL" ALIAS "mysql_data_seek"    (BYVAL ptResult AS T_MYSQL_RES PTR, BYVAL Offset AS QUAD)
        DECLARE FUNCTION pbmysql_fetch_field_direct LIB "libmySQL.DLL" ALIAS "mysql_fetch_field_direct" (BYVAL ptResult AS T_MYSQL_RES PTR, _
                                                                                                         BYVAL lFieldNum AS LONG) AS LONG
        DECLARE FUNCTION pbmysql_fetch_lengths  LIB "libmySQL.DLL" ALIAS "mysql_fetch_lengths"(BYVAL ptResult AS T_MYSQL_RES PTR) AS LONG
        DECLARE FUNCTION pbmysql_fetch_row      LIB "libmySQL.DLL" ALIAS "mysql_fetch_row"    (BYVAL ptResult AS T_MYSQL_RES PTR ) AS LONG
        DECLARE FUNCTION pbmysql_field_count    LIB "libmySQL.DLL" ALIAS "mysql_field_count"  (BYVAL ptMYSQL  AS T_MYSQL PTR) AS LONG
        DECLARE SUB      pbmysql_free_result    LIB "libmySQL.DLL" ALIAS "mysql_free_result"  (BYVAL ptMYSQL  AS T_MYSQL PTR)
        DECLARE FUNCTION pbmysql_info           LIB "libmySQL.DLL" ALIAS "mysql_info"         (BYVAL ptMYSQL  AS T_MYSQL PTR) AS STRING
        DECLARE FUNCTION pbmysql_insert_id      LIB "libmySQL.DLL" ALIAS "mysql_insert_id"    (BYVAL ptMYSQL  AS T_MYSQL PTR) AS LONG
        DECLARE FUNCTION pbmysql_num_fields     LIB "libmySQL.DLL" ALIAS "mysql_num_fields"   (BYVAL ptResult AS T_MYSQL_RES PTR) AS LONG
        DECLARE FUNCTION pbmysql_num_rows       LIB "libmySQL.DLL" ALIAS "mysql_num_rows"     (BYVAL ptResult AS T_MYSQL_RES PTR ) AS LONG
        DECLARE FUNCTION pbmysql_store_result   LIB "libmySQL.DLL" ALIAS "mysql_store_result" (BYVAL ptMYSQL  AS T_MYSQL PTR) AS LONG
        DECLARE FUNCTION pbmysql_use_result     LIB "libmySQL.DLL" ALIAS "mysql_use_result"   (BYVAL ptMYSQL  AS T_MYSQL PTR) AS LONG
        
        
        '***************************************************************************************************************
        #IF NOT %DEF(%FALSE)
            %FALSE = 0
        #ENDIF
        
        #IF NOT %DEF(%TRUE)
            %TRUE = 1
        #ENDIF
        
        #IF NOT %DEF(%NULL)
            %NULL = 0
        #ENDIF
        
        SUB Tell( sMessage AS STRING )
            #IF %DEF(%PB_CC32)
                STDOUT "[INFO] " + sMessage
            #ELSE
                MSGBOX sMessage,64,"[INFO]"
            #ENDIF
        END SUB
        
        SUB Croak( sMessage AS STRING )
            #IF %DEF(%PB_CC32)
                STDOUT "[ERROR] " + sMessage
            #ELSE
                MSGBOX sMessage,16,"[ERROR]"
            #ENDIF
        END SUB
        
        '***************************************************************************************************************
        
            ' Not a good idea. Should be replaced with Local Vars in each function for thread compatability
            GLOBAL ptSqlStruct  AS T_MYSQL       PTR
            GLOBAL ptSqlHandle  AS T_MYSQL       PTR
            GLOBAL ptResult     AS T_MYSQL_RES   PTR
            GLOBAL ptField      AS T_MYSQL_FIELD PTR
            GLOBAL ptMySQL_Data AS T_MYSQL_DATA  PTR
            GLOBAL ptRow        AS        ASCIIZ PTR
        
        
        
        
        '***************************************************************************************************************
        FUNCTION GetFieldDesc( BYVAL lFieldType AS LONG ) AS STRING
        
            SELECT CASE lFieldType
                CASE %FIELD_TYPE_DECIMAL    : FUNCTION="TYPE_DECIMAL"
                CASE %FIELD_TYPE_TINY       : FUNCTION="TYPE_TINY"
                CASE %FIELD_TYPE_SHORT      : FUNCTION="TYPE_SHORT"
                CASE %FIELD_TYPE_LONG       : FUNCTION="TYPE_LONG"
                CASE %FIELD_TYPE_FLOAT      : FUNCTION="TYPE_FLOAT"
                CASE %FIELD_TYPE_DOUBLE     : FUNCTION="TYPE_DOUBLE"
                CASE %FIELD_TYPE_NULL       : FUNCTION="TYPE_NULL"
                CASE %FIELD_TYPE_TIMESTAMP  : FUNCTION="TYPE_TIMESTAMP"
                CASE %FIELD_TYPE_LONGLONG   : FUNCTION="TYPE_LONGLONG"
                CASE %FIELD_TYPE_INT24      : FUNCTION="TYPE_INT24"
                CASE %FIELD_TYPE_DATE       : FUNCTION="TYPE_DATE"
                CASE %FIELD_TYPE_TIME       : FUNCTION="TYPE_TIME"
                CASE %FIELD_TYPE_DATETIME   : FUNCTION="TYPE_DATETIME"
                CASE %FIELD_TYPE_YEAR       : FUNCTION="TYPE_YEAR"
                CASE %FIELD_TYPE_NEWDATE    : FUNCTION="TYPE_NEWDATE"
                CASE %FIELD_TYPE_ENUM       : FUNCTION="TYPE_ENUM"
                CASE %FIELD_TYPE_SET        : FUNCTION="TYPE_SET"
                CASE %FIELD_TYPE_TINY_BLOB  : FUNCTION="TYPE_TINY_BLOB"
                CASE %FIELD_TYPE_MEDIUM_BLOB: FUNCTION="TYPE_MEDIUM_BLOB"
                CASE %FIELD_TYPE_LONG_BLOB  : FUNCTION="TYPE_LONG_BLOB"
                CASE %FIELD_TYPE_BLOB       : FUNCTION="TYPE_BLOB"
                CASE %FIELD_TYPE_VAR_STRING : FUNCTION="TYPE_VAR_STRING"
                CASE %FIELD_TYPE_STRING     : FUNCTION="TYPE_STRING"
                CASE ELSE                   : FUNCTION="TYPE_UNKNOWN"
            END SELECT
        
        END FUNCTION
        
        
        '---------------------------------------------------------------------------------------------------------------
        ' This function needs to be called for each created thread to initialise thread specific variables.
        '---------------------------------------------------------------------------------------------------------------
        FUNCTION mysql_init() AS LONG
            ptSqlStruct = pbmysql_init( BYVAL ptSqlHandle ) ' returns An initialised MYSQL* handle.  NULL if insufficient memory
            IF ptSqlStruct = %NULL THEN FUNCTION = pbmysql_errno( BYVAL ptSqlStruct )
        END FUNCTION
        
        '---------------------------------------------------------------------------------------------------------------
        ' Connect to mySQL
        ' if nPort is set to 0 then use default port of 3306
        ' return error_no on error
        ' return 0 on success
        ' The value of host may be either a hostname or an IP address.  If host is NULL or the string "localhost",
        ' a connection to the local host is assumed. If the OS supports sockets (Unix) or named pipes (Windows),
        ' they are used instead of TCP/IP to connect to the server.
        '
        ' The user parameter contains the user's MySQL login ID.  If user is NULL, the current user is assumed.
        ' Under Unix, this is the current login NAME.  Under Windows ODBC, the current user NAME must be
        ' specified explicitly.  See ODBC administrator.
        '
        ' The passwd parameter contains the password for user.  If passwd is NULL, only entries in the user
        ' table for the user that have a blank (empty) password field will be checked for a match. This allows
        ' the database administrator to set up the MySQL privilege system in such a way that users get different
        ' privileges depending on whether or not they have specified a password.
        '
        ' db is the database name.  If db is not NULL, the connection will set the default database to this value.
        '
        ' If port is not 0, the value will be used as the port number for the TCP/IP connection.  Note that the
        ' host parameter determines the type of the connection.
        '
        ' The value of client_flag is usually 0, but can be set to a combination of the following flags in very special circumstances:
        '---------------------------------------------------------------------------------------------------------------
        FUNCTION mySql_Connect(BYVAL sHost AS STRING, sUser AS STRING, sPassword AS STRING, nPort AS LONG) AS LONG
        
            LOCAL ptrHost AS ASCIIZ PTR, ptrUser AS ASCIIZ PTR, ptrPassword AS ASCIIZ PTR, ptrPort AS LONG PTR
        
            IF nPort = 0 THEN nPort = 3306
        
            ptrHost     = STRPTR( sHost )
            ptrUser     = STRPTR( sUser )
            ptrPassword = STRPTR( sPassword )
            ptrPort     = VARPTR( nPort )
        
            ptSqlHandle = pbmysql_real_connect( BYVAL ptSqlStruct, @ptrHost, @ptrUser, @ptrPassword, BYVAL %NULL, @ptrPort, BYVAL %NULL, 0 )
        
            IF ptSqlHandle = %NULL THEN
                FUNCTION = pbmysql_errno( BYVAL ptSqlStruct )
                CALL pbmysql_close( BYVAL ptSqlStruct )
                EXIT FUNCTION
            END IF
        
            FUNCTION = 0 '@ptSqlHandle
        END FUNCTION
        
        '---------------------------------------------------------------------------------------------------------------
        ' You must call mysql_store_result() or mysql_use_result() for every query that successfully retrieves data
        ' (SELECT, SHOW, DESCRIBE, EXPLAIN).
        ' You don't have to call mysql_store_result() or mysql_use_result() for other queries, but it will not do any
        ' harm or cause any notable performance if you call mysql_store_result() in all cases.  You can detect if the
        ' query didn't have a result set by checking if mysql_store_result() returns 0 (more about this in manual).
        ' mysql_store_result() reads the entire result of a query to the client, allocates a MYSQL_RES structure,
        ' and places the result into this structure.
        ' Once you have called mysql_store_result() and got a result back that isn't a null pointer, you may call mysql_num_rows()
        ' to find out how many rows are in the result set.
        ' You can call mysql_fetch_row() to fetch rows from the result set, or mysql_row_seek() and mysql_row_tell() to obtain or
        ' set the current row position within the result set.
        ' You must call mysql_free_result() once you are done with the result set.
        '---------------------------------------------------------------------------------------------------------------
        FUNCTION mySQL_Store_Result() AS LONG
            ptResult = pbmysql_store_result( BYVAL ptSqlHandle ) ' returns MYSQL_RES result structure. NULL if an error occurred.
        END FUNCTION
        
        
        '---------------------------------------------------------------------------------------------------------------
        ' You must call mysql_store_result() or mysql_use_result() for every query that successfully retrieves data
        ' (SELECT, SHOW, DESCRIBE, EXPLAIN).
        ' mysql_use_result() initiates a result set retrieval but does not actually read the result set into the client like
        ' mysql_store_result() does.  Instead, each row must be retrieved individually by making calls to mysql_fetch_row().
        ' This reads the result of a query directly from the server without storing it in a temporary table or local buffer, which
        ' is somewhat faster and uses much less memory than mysql_store_result().  The client will only allocate memory for
        ' the current row and a communication buffer that may grow up to max_allowed_packet bytes.
        '---------------------------------------------------------------------------------------------------------------
        FUNCTION mysql_use_result() AS LONG
            ptResult = pbmysql_use_result( BYVAL ptSqlHandle ) ' returns MYSQL_RES result structure. NULL if an error occurred.
        END FUNCTION
        
        '---------------------------------------------------------------------------------------------------------------
        ' Return the last mySQL error number as a number
        ' For the connection specified by mysql, mysql_errno() returns the error code for the most recently invoked API function
        ' that can succeed or fail.  A return value of zero means that no error occurred. Client error message numbers are listed
        ' in the MySQL errmsg.h header file.  Server error message numbers are listed in mysqld_error.h. In the MySQL source
        ' distribution you can find a complete list of error messages and error numbers in the file Docs/mysqld_error.txt.
        '---------------------------------------------------------------------------------------------------------------
        FUNCTION mySql_ErrNo() AS LONG
            FUNCTION = pbmysql_errno( BYVAL ptSqlStruct ) ' Returns An error code value. Zero if no error occurred.
        END FUNCTION
        
        FUNCTION mySqlErrNo_Str() AS STRING
            FUNCTION = FORMAT$( pbmysql_errno( BYVAL ptSqlStruct )) ' Returns An error code STRING
        END FUNCTION
        
        FUNCTION mySql_Error() AS STRING
            FUNCTION = @ptSqlStruct.tNet.szLastError ' Return the description of last mySQL error as a string. Empty string = no error
        
        END FUNCTION
        
        '---------------------------------------------------------------------------------------------------------------
        ' Retrieves a string providing information about the most recently executed query, but only for some statements.
        ' For other statements, mysql_info() returns NULL. (see manual for details)
        '---------------------------------------------------------------------------------------------------------------
        FUNCTION mysql_info() AS STRING
            LOCAL zRes AS ASCIIZ * 255
            zRes = pbmysql_info( BYVAL ptSqlHandle )  ' A character string representing additional information about the
            FUNCTION = zRes
        END FUNCTION                                  ' most recently executed query.  NULL if no information is available for the query.
        
        
        
        '---------------------------------------------------------------------------------------------------------------
        ' Executes the SQL query pointed to by the null-terminated string query.  The query must consist of a single SQL statement.
        ' You should not add a terminating semicolon (   or \g to the statement.
        '---------------------------------------------------------------------------------------------------------------
        FUNCTION mySQL_Query(sQuery AS ASCIIZ) AS LONG
            LOCAL nRetval AS LONG, ErrNum AS LONG, ErrStr AS STRING
        
            CALL pbmysql_query( BYVAL ptSqlHandle, sQuery )  ' Zero if the query was successful. Non-zero if an error occurred.
            ErrNum = mySql_ErrNo
            ErrStr = mySql_Error
            IF ErrNum OR LEN(ErrStr) THEN  ' some errors are reported but not given a number !?
                IF ErrNum THEN FUNCTION = ErrNum ELSE FUNCTION = -1
                EXIT FUNCTION
            ELSE
                nRetval = mySQL_Store_Result()
            END IF
        END FUNCTION
        
        
        '---------------------------------------------------------------------------------------------------------------
        ' Select a mySQL database
        ' Causes the database specified by db to become the default (current) database on the connection specified by mysql.
        ' In subsequent queries, this database is the default for table references that do not include an explicit database specifier.
        '---------------------------------------------------------------------------------------------------------------
        FUNCTION mySQL_Select_Db( sDb AS ASCIIZ ) AS LONG
            FUNCTION = pbmysql_select_db( BYVAL ptSqlHandle, sDB ) ' Zero for success.  Non-zero if an error occurred.
        END FUNCTION
        
        
        '---------------------------------------------------------------------------------------------------------------
        ' Creates the database named by the db parameter.
        ' This function is deprecated.  It is preferable to use mysql_query() to issue a SQL CREATE DATABASE statement instead.
        '---------------------------------------------------------------------------------------------------------------
        FUNCTION mysql_create_db( sDb AS ASCIIZ ) AS LONG
            FUNCTION = pbmysql_create_db( BYVAL ptSqlHandle, sDB ) ' Zero for success.  Non-zero if an error occurred.
        END FUNCTION
        
        '---------------------------------------------------------------------------------------------------------------
        ' Drops (DELETES) the database named by the db parameter.
        ' This function is deprecated.  It is preferable to use mysql_query() to issue a SQL DROP DATABASE statement instead.
        ' DROP DATABASE drops all tables in the database and deletes the database.  If you do a DROP DATABASE on a
        ' symbolic linked database, both the link and the original database is deleted. Be VERY careful with this command!
        '---------------------------------------------------------------------------------------------------------------
        FUNCTION mysql_drop_db( sDb AS ASCIIZ ) AS LONG
            FUNCTION = pbmysql_drop_db( BYVAL ptSqlHandle, sDB ) ' Zero for success.  Non-zero if an error occurred.
        END FUNCTION
        
        
        
        '---------------------------------------------------------------------------------------------------------------
        ' Options
        ' %MYSQL_OPT_CONNECT_TIMEOUT  = 0
        ' %MYSQL_OPT_COMPRESS         = 1
        ' %MYSQL_OPT_NAMED_PIPE       = 2
        ' %MYSQL_INIT_COMMAND         = 3
        ' %MYSQL_READ_DEFAULT_FILE    = 4
        ' %MYSQL_READ_DEFAULT_GROUP   = 5
        ' %MYSQL_SET_CHARSET_DIR      = 6
        ' %MYSQL_SET_CHARSET_NAME     = 7
        ' %MYSQL_OPT_LOCAL_INFILE     = 8  security switch
        '
        ' mysql_options( %MYSQL_OPT_LOCAL_INFILE, "local-infile=1" )
        ' mysql_options( %MYSQL_READ_DEFAULT_GROUP, "odbc" )
        '---------------------------------------------------------------------------------------------------------------
        FUNCTION mysql_options( BYVAL lOpt AS LONG, sArg AS ASCIIZ ) AS LONG
           FUNCTION = pbmysql_options( BYVAL ptSqlStruct, lOpt, sArg ) ' Returns Zero for success. Non-zero if you used an unknown option
        END FUNCTION
        
        
        '---------------------------------------------------------------------------------------------------------------
        ' Returns the number of rows changed by the last UPDATE, deleted by the last DELETE or inserted by the last INSERT
        ' statement. May be called immediately after mysql_query() FOR UPDATE, DELETE, OR INSERT statements.
        ' FOR SELECT statements, mysql_affected_rows() works like mysql_num_rows().
        ' will show 0 for Table Delete
        '---------------------------------------------------------------------------------------------------------------
        FUNCTION mysql_affected_rows() AS LONG
            FUNCTION = pbmysql_affected_rows( BYVAL ptSqlHandle ) ' An integer > than zero indicates the number of rows affected or retrieved
        END FUNCTION
        
        
        
        
        
        '---------------------------------------------------------------------------------------------------------------
        ' Return the number of fields from a previous mySQL_Query
        ' Returns the number of columns for the most recent query on the connection. The normal use of this function is when
        ' mysql_store_result() returned NULL (and thus you have no result set pointer).  In this case, you can
        ' call mysql_field_count() to determine whether mysql_store_result() should have produced a non-empty result.
        ' This allows the client program to take proper action without knowing whether the query was a
        ' SELECT (or SELECT-like) statement.  see example in manual.
        '---------------------------------------------------------------------------------------------------------------
        FUNCTION mySQL_Field_Count() AS LONG
           FUNCTION = pbmysql_field_count( BYVAL ptSqlHandle ) ' Returns unsigned integer for the number of fields in a result set.
        END FUNCTION
        
        '---------------------------------------------------------------------------------------------------------------
        ' Return field info on the current RESULT set to ptField. - must provide the field number
        ' Returns the definition of one column of a result set as a MYSQL_FIELD structure. Call this function repeatedly
        ' to retrieve information about all columns in the result set.  mysql_fetch_field() returns NULL when no more fields are left.
        '---------------------------------------------------------------------------------------------------------------
        FUNCTION mySQL_Fetch_Field( BYVAL nField AS LONG ) AS LONG
            IF nField <> 0 THEN DECR nField
            FUNCTION = pbmySQL_Fetch_Field_Direct( BYVAL ptResult, nField )
        END FUNCTION
        
        '---------------------------------------------------------------------------------------------------------------
        ' Returns the number of columns (fields) in a RESULT set.
        '---------------------------------------------------------------------------------------------------------------
        FUNCTION mysql_num_fields() AS LONG
            FUNCTION = pbmysql_num_fields( BYVAL ptResult ) ' returns unsigned integer representing the num fields in a result set.
        END FUNCTION
        
        '---------------------------------------------------------------------------------------------------------------
        ' Return the number of rows in the RESULT set.
        ' The use of mysql_num_rows() depends on whether you use mysql_store_result() or mysql_use_result() to return the result set.
        ' If you use mysql_store_result(), mysql_num_rows() may be called immediately.  If you use mysql_use_result(),
        ' mysql_num_rows() will not return the correct value until all the rows in the result set have been retrieved.
        '---------------------------------------------------------------------------------------------------------------
        FUNCTION mySQL_Num_Rows() AS LONG
            FUNCTION = pbmysql_num_rows( BYVAL ptResult ) ' Returns The number of rows in the result set.
        END FUNCTION
        
        
        
        '---------------------------------------------------------------------------------------------------------------
        ' Seeks to an arbitrary row in a query RESULT set.  This requires that the result set structure contains the
        ' entire result of the query, so mysql_data_seek() may be used in conjunction only with mysql_store_result(),
        ' not with mysql_use_result().
        ' The offset should be a value IN the range FROM 0 TO mysql_num_rows(result)-1.
        '---------------------------------------------------------------------------------------------------------------
        SUB mysql_data_seek( Offset AS QUAD )
            CALL pbmysql_data_seek( BYVAL ptResult, Offset )
        END SUB
        
        '---------------------------------------------------------------------------------------------------------------
        ' Returns the lengths of the columns of the current row within a RESULT set.  If you plan to copy field values,
        ' this length information is also useful for optimisation, because you can avoid calling strlen().  In addition,
        ' if the result set contains binary data, you must use this function to determine the size of the data, because
        ' strlen() returns incorrect results for any field containing null characters.
        ' The length FOR empty columns AND FOR columns containing NULL values is zero.  TO see how TO distinguish these
        ' two cases, see the description FOR mysql_fetch_row().
        '---------------------------------------------------------------------------------------------------------------
        FUNCTION mysql_fetch_lengths() AS LONG
            FUNCTION = pbmysql_fetch_lengths( BYVAL ptResult )
        END FUNCTION
        
        '---------------------------------------------------------------------------------------------------------------
        ' Retrieves the next row of a RESULT set. When used after mysql_use_result(), mysql_fetch_row()
        ' returns NULL when there are no more rows TO retrieve OR IF an ERROR occurred.
        ' The number OF values IN the row is given by mysql_num_fields(result).  IF row holds the RETURN value FROM a
        ' CALL TO mysql_fetch_row(), pointers TO the values are accessed AS row[0] TO row[mysql_num_fields(result)-1].
        ' NULL values IN the row are indicated by NULL pointers.
        ' The lengths OF the field values IN the row may be obtained by calling mysql_fetch_lengths().  Empty fields
        ' AND fields containing NULL both have length 0; you can distinguish these by checking the POINTER FOR the
        ' field value.  IF the POINTER is NULL, the field is NULL; otherwise, the field is empty.
        '---------------------------------------------------------------------------------------------------------------
        FUNCTION mySQL_Fetch_Row() AS LONG
            ptMySQL_Data = pbmysql_fetch_row( BYVAL ptResult )
            IF ptMySQL_Data THEN FUNCTION = 1
        END FUNCTION
        
        
        FUNCTION mySQL_Data( BYVAL nField AS LONG ) AS STRING
            FUNCTION = PARSE$( @@ptMySQL_Data, CHR$(0), nField ) ' Return the field value from a mySQL_Fetch_Row given the field index
        END FUNCTION
        
        
        '---------------------------------------------------------------------------------------------------------------
        ' Frees the memory allocated for a RESULT set by mysql_store_result(), mysql_use_result(), mysql_list_dbs(), etc.
        ' When you are done with a result set, you must free the memory it uses by calling mysql_free_result().
        '---------------------------------------------------------------------------------------------------------------
        SUB mySQL_Free_Result()
            CALL pbmysql_free_result( BYVAL ptResult )
        END SUB
        
        
        '---------------------------------------------------------------------------------------------------------------
        ' Return the Auto incr value of the last record inserted with an auto incr field
        '---------------------------------------------------------------------------------------------------------------
        FUNCTION mySQL_Insert_Id() AS LONG
            FUNCTION = pbmysql_insert_id( BYVAL ptSqlHandle ) ' The value of AUTO_INCREMENT field updated by previous query.
        END FUNCTION  'Returns zero if no previous query on the connection or if query did not update an AUTO_INCREMENT value.
        
        
        '---------------------------------------------------------------------------------------------------------------
        ' Ping
        ' Checks whether the connection to the server is working. If it has gone down, an automatic reconnection is attempted.
        '---------------------------------------------------------------------------------------------------------------
        FUNCTION mySQL_Ping() AS LONG
            FUNCTION = pbmysql_ping( BYVAL ptSqlHandle )
        END FUNCTION
        
        '---------------------------------------------------------------------------------------------------------------
        ' Close
        ' Closes a previously opened connection.  mysql_close() also deallocates the connection handle pointed to by mysql if the
        ' handle was allocated automatically by mysql_init() or mysql_connect().
        '---------------------------------------------------------------------------------------------------------------
        SUB mySQL_Close()
             IF ptSqlHandle THEN CALL pbmysql_close( BYVAL ptSqlHandle )
        END SUB
        djthain

        Comment


        • #24
          Originally posted by david thain View Post
          I have created two programs. The first program has three fields per record and shows good results. The
          second program has thirteen fields per record and the results are not correct. There are also two small
          programs that create the databases and tables.
          See posts 21 and 22 above. You're very lucky that the first program worked.

          You cannot rely on anything working with that .inc file and AFAIK, there are no PB .inc files for any recent version of mySQL.
          You are wasting your time trying to use libmysql.dll in PB unless you are using a VERY old mySQL version.



          Added:

          Out of morbid curiosity I looked at your two programs.
          It's obvious why the first one worked and the second one didn't.
          The total length of the data returned per row for the first program was less than 36 characters.
          The total length of the data returned per row for the second program was more than36 characters.

          We have already established that those ver 4 headers used with a ver 5 or ver 6 DLL will only retrieve the first 36 characters for each row returned by a Select query.

          The T_MYSQL_RES structure used to store the query results has a totally different definition in Ver 5 and upwards - the same is true of many other definitions!
          Last edited by Stuart McLachlan; 9 Jul 2020, 06:55 PM.

          Comment


          • #25
            If you really want to do this, then you will need to download and install MySQL 4 from http://mysql.localhost.net.ar/downloads/mysql/4.1.html

            But note: that the last ver 4 is already 12 years old and unsupported.

            Comment

            Working...
            X