Hi,
Does anyone have a code-example using "mysql_stmt_bind_param" that they wouldn't mind sharing, please?
I'm trying to use this statement on Windows XP 32-bit, using PB 5.11 and libmysql 6.1.0 (mysql c connector), both with and without Unicode enabled on the PB compiler.
The reason I'm asking is that whatever I do, the parameter bind appears to work (as a SELECT statement returns the correct records), but the return code is never zero (it actually is large enough to look like a memory address) and the error message is always blank.
Thanks in advance for any assistance.
Win32 - mysql_stmt_bind_param example
Win32 - mysql_stmt_bind_param example
If the temperature today was 0 degrees, how can it be twice as cold tomorrow?
- RichAlgeni
- Addict

- Posts: 935
- Joined: Wed Sep 22, 2010 1:50 am
- Location: Bradenton, FL
Re: Win32 - mysql_stmt_bind_param example
Haven't done what you've asked, but I'll throw this out to try and help:
Have you searching on that error code?
If you can't find it, are you compiling your PB program as 64 bit code? If you are and your return code is type '.i', try changing the return code to type '.l', then see if the return code is something you can look up?
Have you searching on that error code?
If you can't find it, are you compiling your PB program as 64 bit code? If you are and your return code is type '.i', try changing the return code to type '.l', then see if the return code is something you can look up?
Re: Win32 - mysql_stmt_bind_param example
Hi RichAlgeni,
Thanks for the reply; any help / suggestions are much appreciated. I'm running in a 32-bit environment; I don't have access to a 64-bit OS.
The statement "mysql_stmt_bind_param" is supposed to return zero for success, otherwise failure is indicated by a non-zero return code. The return code I receive varies, but is usually something in the form "33428480"; this looks more like a memory address instead of a failure code
The statement is documented here http://dev.mysql.com/doc/refman/5.6/en/ ... param.html.
What concerns me is that even though the return code is non-zero, any given SQL statement is executed correctly and returns the correct records. I could just ignore the return code and assume that it will always indicate failure (but work okay), but as an experienced developer, I know that would be a fatal mistake.
All searches I've made on the statement and possible return codes show nothing to indicate what may be going on. In fact, apart from information similar to that posted on the MySQL web-site, there appears to be very little information on the statement and it's use.
I'm currently going through all the Structure declarations to see if there is anything amiss with the definitions of the various MySQL structures, but anything appears possible at this stage... and I'm gradually going bald ripping my hair out
Thanks in advance.
Thanks for the reply; any help / suggestions are much appreciated. I'm running in a 32-bit environment; I don't have access to a 64-bit OS.
The statement "mysql_stmt_bind_param" is supposed to return zero for success, otherwise failure is indicated by a non-zero return code. The return code I receive varies, but is usually something in the form "33428480"; this looks more like a memory address instead of a failure code
The statement is documented here http://dev.mysql.com/doc/refman/5.6/en/ ... param.html.
What concerns me is that even though the return code is non-zero, any given SQL statement is executed correctly and returns the correct records. I could just ignore the return code and assume that it will always indicate failure (but work okay), but as an experienced developer, I know that would be a fatal mistake.
All searches I've made on the statement and possible return codes show nothing to indicate what may be going on. In fact, apart from information similar to that posted on the MySQL web-site, there appears to be very little information on the statement and it's use.
I'm currently going through all the Structure declarations to see if there is anything amiss with the definitions of the various MySQL structures, but anything appears possible at this stage... and I'm gradually going bald ripping my hair out
Thanks in advance.
If the temperature today was 0 degrees, how can it be twice as cold tomorrow?
Re: Win32 - mysql_stmt_bind_param example
I've discovered the problem...a catalogue of errors! 
The statement returns a "my_bool" value which is declared as "char" in the MySQL docs.
In my source code, the statement was declared as returning a "byte" (1 byte, -128 to +127); this should be an "ascii" (1 byte, 0 to +255).
Then, I was assigning the return code to an "integer" (4 bytes, -2147483648 to +2147483647), instead of another "ascii".
When I modify my code to reflect the above variable types, the return code is zero.
When I've tidied-up my code, I'll post it here for posterity.
The statement returns a "my_bool" value which is declared as "char" in the MySQL docs.
In my source code, the statement was declared as returning a "byte" (1 byte, -128 to +127); this should be an "ascii" (1 byte, 0 to +255).
Then, I was assigning the return code to an "integer" (4 bytes, -2147483648 to +2147483647), instead of another "ascii".
When I modify my code to reflect the above variable types, the return code is zero.
When I've tidied-up my code, I'll post it here for posterity.
If the temperature today was 0 degrees, how can it be twice as cold tomorrow?
Re: Win32 - mysql_stmt_bind_param example
As promised, below is the code I've been testing in isolation to understand how "mysql_stmt_bind_param" works. It is based on the code posted by infratec at http://www.purebasic.fr/english/viewtop ... t=libmysql.
All I've really done is added some more MySQL structures, and tried to adjust the existing structures to comply more with the MySQL C header files with regards to MySQL prepared statements. Please let me know if something is incorrect, and post it here for everyone to benefit.
I've added a sample "main" procedure at the end to show how I'm using the code. It will run in either Unicode or non-Unicode mode, and should be run with the Debugger to see any output. You will need to create a table on a MySQL database and modify the SQL statement in the code accordingly to get records, but that should not be an issue if you need to play with this code anyway
Don't forget to change the "db..." variables to your username, password, etc...
I'm working on a feature-rich and easy-to-use MySQL library incorporating as many coding approaches and bits of advice I've found within the PB forums (and outside of them) as possible. I will post this separately when it is complete, but it is an on-going project that will take me some time. The good thing is that it will be used in a "live" project, so should be reasonably well tested when I post the finished item.
I hope this helps someone work out how to use more of the features of MySQL, and its my small way of trying to return some of the help that I've received over the years from everyone else...I wish I could do more. If you can improve on this, please do and post for all of us to see and use. Many thanks.
All I've really done is added some more MySQL structures, and tried to adjust the existing structures to comply more with the MySQL C header files with regards to MySQL prepared statements. Please let me know if something is incorrect, and post it here for everyone to benefit.
I've added a sample "main" procedure at the end to show how I'm using the code. It will run in either Unicode or non-Unicode mode, and should be run with the Debugger to see any output. You will need to create a table on a MySQL database and modify the SQL statement in the code accordingly to get records, but that should not be an issue if you need to play with this code anyway
I'm working on a feature-rich and easy-to-use MySQL library incorporating as many coding approaches and bits of advice I've found within the PB forums (and outside of them) as possible. I will post this separately when it is complete, but it is an on-going project that will take me some time. The good thing is that it will be used in a "live" project, so should be reasonably well tested when I post the finished item.
I hope this helps someone work out how to use more of the features of MySQL, and its my small way of trying to return some of the help that I've received over the years from everyone else...I wish I could do more. If you can improve on this, please do and post for all of us to see and use. Many thanks.
Code: Select all
;
; MySQL.pbi V1.00
;
; a wrapper for MySQL 6.0.2
;
; by BKK
;
; Modified by Techie42, 12th June 2013
Enumeration
#MYSQL_OPT_CONNECT_TIMEOUT
#MYSQL_OPT_COMPRESS
#MYSQL_OPT_NAMED_PIPE
#MYSQL_INIT_COMMAND
#MYSQL_READ_DEFAULT_FILE
#MYSQL_READ_DEFAULT_GROUP
#MYSQL_SET_CHARSET_DIR
#MYSQL_SET_CHARSET_NAME
#MYSQL_OPT_LOCAL_INFILE
#MYSQL_OPT_PROTOCOL
#MYSQL_SHARED_MEMORY_BASE_NAME
#MYSQL_OPT_READ_TIMEOUT
#MYSQL_OPT_WRITE_TIMEOUT
#MYSQL_OPT_USE_RESULT
#MYSQL_OPT_USE_REMOTE_CONNECTION
#MYSQL_OPT_USE_EMBEDDED_CONNECTION
#MYSQL_OPT_GUESS_CONNECTION
#MYSQL_SET_CLIENT_IP
#MYSQL_SECURE_AUTH
#MYSQL_REPORT_DATA_TRUNCATION
#MYSQL_OPT_RECONNECT
#MYSQL_OPT_SSL_VERIFY_SERVER_CERT
EndEnumeration
Enumeration
#MYSQL_STATUS_READY
#MYSQL_STATUS_GET_RESULT
#MYSQL_STATUS_USE_RESULT
EndEnumeration
Enumeration
#MYSQL_PROTOCOL_DEFAULT
#MYSQL_PROTOCOL_TCP
#MYSQL_PROTOCOL_SOCKET
#MYSQL_PROTOCOL_PIPE
#MYSQL_PROTOCOL_MEMORY
EndEnumeration
Enumeration
#MYSQL_STMT_INIT_DONE = 1
#MYSQL_STMT_PREPARE_DONE
#MYSQL_STMT_EXECUTE_DONE
#MYSQL_STMT_FETCH_DONE
EndEnumeration
Enumeration
#STMT_ATTR_UPDATE_MAX_LENGTH
#STMT_ATTR_CURSOR_TYPE
#STMT_ATTR_PREFETCH_ROWS
EndEnumeration
#SCRAMBLE_LENGTH = 20
#SCRAMBLE_LENGTH_323 = 8
#SCRAMBLED_PASSWORD_CHAR_LENGTH = (#SCRAMBLE_LENGTH*2+1)
#SCRAMBLED_PASSWORD_CHAR_LENGTH_323 = (#SCRAMBLE_LENGTH_323*2)
#NOT_NULL_FLAG = 1 ; Field can't be NULL
#PRI_KEY_FLAG = 2 ; Field is part of a primary key
#UNIQUE_KEY_FLAG = 4 ; Field is part of a unique key
#MULTIPLE_KEY_FLAG = 8 ; Field is part of a key
#BLOB_FLAG = 16 ; Field is a blob
#UNSIGNED_FLAG = 32 ; Field is unsigned
#ZEROFILL_FLAG = 64 ; Field is zerofill
#BINARY_FLAG = 128 ; Field is binary
#ENUM_FLAG = 256 ; field is an enum
#AUTO_INCREMENT_FLAG = 512 ; field is a autoincrement field
#TIMESTAMP_FLAG = 1024 ; Field is a timestamp
#SET_FLAG = 2048 ; field is a set
#NO_DEFAULT_VALUE_FLAG = 4096 ; Field doesn't have default value
#N_UPDATE_NOW_FLAG = 8192 ; Field is set To NOW on UPDATE
#NUM_FLAG = 32768 ; Field is num (For clients)
#PART_KEY_FLAG = 16384 ; Intern; Part of some key
#GROUP_FLAG = 32768 ; Intern: Group field
#UNIQUE_FLAG = 65536 ; Intern: Used by sql_yacc
#BINCMP_FLAG = 131072 ; Intern: Used by sql_yacc
#GET_FIXED_FIELDS_FLAG = (1 << 18) ; Used To get fields in item tree
#FIELD_IN_PART_FUNC_FLAG = (1 << 19) ; Field part of partition func
#FIELD_IN_ADD_INDEX = (1<< 20) ; Intern: Field used in ADD INDEX
#FIELD_IS_RENAMED = (1<< 21) ; Intern: Field is being renamed
#FIELD_STORAGE_FLAGS = 22 ; Storage type: bit 22, 23 And 24
#COLUMN_FORMAT_FLAGS = 25 ; Column format: bit 25, 26 And 27
#REFRESH_GRANT = 1 ; Refresh grant tables
#REFRESH_LOG = 2 ; Start on new log file
#REFRESH_TABLES = 4 ; close all tables
#REFRESH_HOSTS = 8 ; Flush host cache
#REFRESH_STATUS = 16 ; Flush status variables
#REFRESH_THREADS = 32 ; Flush thread cache
#REFRESH_SLAVE = 64 ; Reset master info And restart slave thread
#REFRESH_MASTER = 128 ; Remove all bin logs in the index And truncate the index
#REFRESH_READ_LOCK = 16384 ; Lock tables For Read
#REFRESH_FAST = 32768 ; Intern flag
#REFRESH_QUERY_CACHE = 65536
#REFRESH_QUERY_CACHE_FREE = $20000 ; pack query cache
#REFRESH_DES_KEY_FILE = $40000
#REFRESH_USER_RESOURCES = $80000
#REFRESH_BACKUP_LOG = $200000
#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_PROTOCOL_41 = 512 ; New 4.1 protocol
#CLIENT_INTERACTIVE = 1024 ; This is an interactive client
#CLIENT_SSL = 2048 ; Switch To SSL after handshake
#CLIENT_IGNORE_SIGPIPE = 4096 ; IGNORE sigpipes
#CLIENT_TRANSACTIONS = 8192 ; Client knows about transactions
#CLIENT_RESERVED = 16384 ; Old flag For 4.1 protocol
#CLIENT_SECURE_CONNECTION = 32768 ; New 4.1 authentication
#CLIENT_MULTI_STATEMENTS = (1 << 16) ; Enable/disable multi-stmt support
#CLIENT_MULTI_RESULTS = (1 << 17) ; Enable/disable multi-results
#CLIENT_PS_MULTI_RESULTS = (1 << 18) ; Multi-results in PS-protocol
#CLIENT_SSL_VERIFY_SERVER_CERT = (1 << 30)
#CLIENT_REMEMBER_OPTIONS = (1 << 31)
#SERVER_STATUS_IN_TRANS = 1 ; Transaction has started
#SERVER_STATUS_AUTOCOMMIT = 2 ; Server in auto_commit mode
#SERVER_MORE_RESULTS_EXISTS = 8 ; Multi query - Next query exists
#SERVER_QUERY_NO_GOOD_INDEX_USED = 16
#SERVER_QUERY_NO_INDEX_USED = 32
#SERVER_STATUS_CURSOR_EXISTS = 64
#SERVER_STATUS_LAST_ROW_SENT = 128
#SERVER_STATUS_DB_DROPPED = 256 ; A database was dropped
#SERVER_STATUS_NO_BACKSLASH_ESCAPES = 512
#SERVER_STATUS_METADATA_CHANGED = 1024
#SERVER_QUERY_WAS_SLOW = 2048
#SERVER_PS_OUT_PARAMS = 4096
Enumeration
#MYSQL_TYPE_DECIMAL
#MYSQL_TYPE_TINY
#MYSQL_TYPE_SHORT
#MYSQL_TYPE_LONG
#MYSQL_TYPE_FLOAT
#MYSQL_TYPE_DOUBLE
#MYSQL_TYPE_NULL
#MYSQL_TYPE_TIMESTAMP
#MYSQL_TYPE_LONGLONG
#MYSQL_TYPE_INT24
#MYSQL_TYPE_DATE
#MYSQL_TYPE_TIME
#MYSQL_TYPE_DATETIME
#MYSQL_TYPE_YEAR
#MYSQL_TYPE_NEWDATE
#MYSQL_TYPE_VARCHAR
#MYSQL_TYPE_BIT
#MYSQL_TYPE_NEWDECIMAL = 246
#MYSQL_TYPE_ENUM = 247
#MYSQL_TYPE_SET = 248
#MYSQL_TYPE_TINY_BLOB = 249
#MYSQL_TYPE_MEDIUM_BLOB = 250
#MYSQL_TYPE_LONG_BLOB = 251
#MYSQL_TYPE_BLOB = 252
#MYSQL_TYPE_VAR_STRING = 253
#MYSQL_TYPE_STRING = 254
#MYSQL_TYPE_GEOMETRY = 255
#MAX_NO_FIELD_TYPES ; Should always be last
EndEnumeration
#MYSQL_SHUTDOWN_KILLABLE_CONNECT = (1 << 0)
#MYSQL_SHUTDOWN_KILLABLE_TRANS = (1 << 1)
#MYSQL_SHUTDOWN_KILLABLE_LOCK_TABLE = (1 << 2)
#MYSQL_SHUTDOWN_KILLABLE_UPDATE = (1 << 3)
Enumeration
#SHUTDOWN_DEFAULT = 0
#SHUTDOWN_WAIT_CONNECTIONS = #MYSQL_SHUTDOWN_KILLABLE_CONNECT
#SHUTDOWN_WAIT_TRANSACTIONS = #MYSQL_SHUTDOWN_KILLABLE_TRANS
#SHUTDOWN_WAIT_UPDATES = #MYSQL_SHUTDOWN_KILLABLE_UPDATE
#SHUTDOWN_WAIT_ALL_BUFFERS = (#MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1)
#SHUTDOWN_WAIT_CRITICAL_BUFFERS = (#MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1) + 1
#KILL_QUERY = 254
#KILL_CONNECTION = 255
EndEnumeration
Enumeration
#CURSOR_TYPE_NO_CURSOR = 0
#CURSOR_TYPE_READ_ONLY = 1
#CURSOR_TYPE_FOR_UPDATE = 2
#CURSOR_TYPE_SCROLLABLE = 4
EndEnumeration
Enumeration
#MYSQL_OPTION_MULTI_STATEMENTS_ON
#MYSQL_OPTION_MULTI_STATEMENTS_OFF
EndEnumeration
#MYSYS_ERRMSG_SIZE = 512
#HOSTNAME_LENGTH = 60
#SYSTEM_CHARSET_MBMAXLEN = 4
#NAME_CHAR_LEN = 64
#USERNAME_CHAR_LENGTH = 16
#NAME_LEN = (#NAME_CHAR_LEN * #SYSTEM_CHARSET_MBMAXLEN)
#USERNAME_LENGTH = (#USERNAME_CHAR_LENGTH * #SYSTEM_CHARSET_MBMAXLEN)
#SERVER_VERSION_LENGTH = 60
#SQLSTATE_LENGTH = 5
#MYSQL_ERRMSG_SIZE = 512
Structure st_used_mem
*next.Integer
left.i
size.i
EndStructure
Structure st_mem_root
*free.st_used_mem
*used.st_used_mem
*pre_alloc.st_used_mem
min_malloc.i
block_num.i
first_block_usage.i
*error_handler.Integer
EndStructure
Structure st_net
*vio.Integer
*buff.Ascii
*buff_end.Ascii
*write_pos.Ascii
*read_pos.Ascii
fd.i
remain_in_buf.l
length.l
buf_length.l
where_b.l
max_packet.l
max_packet_size.l
pkt_nr.i
compress_pkt_nr.i
write_timeout.i
read_timeout.i
retry_count.i
fcntl.i
*return_status.Integer
reading_or_writing.a
unused1.b
unused2.b
compress.b
unused3.b
; further unused declarations not required ... see mysql_com.h
EndStructure
Structure mysql_field
name.s ; Name of column
org_name.s ; Original column name, if an alias
table.s ; Table of column if column was a field
org_table.s ; Org table name, if table was an alias
db.s ; Database for table
catalog.s ; Catalog for table
def.s ; Default value (set by mysql_list_fields)
length.l ; Width of column (create length)
max_length.l ; Max width for selected set
name_length.i ;
org_name_length.i ;
table_length.i ;
org_table_length.i ;
db_length.i ;
catalog_length.i ;
def_length.i ;
flags.i ; Div flags
decimals.i ; Number of decimals in field
charsetnr.i ; Character set
type.i ; Type of field. See mysql_com.h for types
*extension ;
EndStructure
Structure mysql_rows
*NextRow.Integer ; list of rows
*Data.Integer ;
length.l ;
EndStructure
Structure mysql_data
*Data.mysql_rows ;
*embedded_info.Integer ;
alloc.st_mem_root ;
rows.q ;
fields.i ;
*extension.Integer ;
EndStructure
Structure mysql_options
connect_timeout.i
read_timeout.i
write_timeout.i
port.i
protocol.i
client_flag.l
host.s
user.s
password.s
unix_socket.s
db.s
*init_commands
my_cnf_file.s
my_cnf_group.s
charset_dir.s
charset_name.s
ssl_key.s
ssl_cert.s
ssl_ca.s
ssl_capath.s
ssl_cipher.s
shared_memory_base_name.s
max_allowed_packet.l
use_ssl.b
compress.b
named_pipe.b
unused1.b
unused2.b
unused3.b
unused4.b
methods_to_use.i
client_ip.s
secure_auth.b
report_data_truncation.b
*local_infile_init
*local_infile_read
*local_infile_end
*local_infile_error
*local_infile_userdata
*extension
EndStructure
Structure mysql
net.st_net ; Communication parameters
*connector_fd.Ascii ; ConnectorFd for SSL
*host.Integer
*user.Integer
*passwd.Integer
*unix_socket.Integer
*server_version.Integer
*host_info.Integer
*info.Integer
*db.Integer
*charset
*fields.mysql_field ;
field_alloc.st_mem_root ;
affected_rows.q ;
insert_id.q ; id if insert on table with NEXTNR
extra_info.q ; Not used
thread_id.l ; Id for connection in server
packet_length.l ;
port.i ;
client_flag.l
server_capabilities.l ;
protocol_version.i ;
field_count.i ;
server_status.i ;
server_language.i ;
warning_count.i ;
options.mysql_options
status.i
free_me.b ; If free in mysql_close
reconnect.b ; set to 1 if automatic reconnect
scramble.a[#SCRAMBLE_LENGTH + 1] ;
unused1.b
*unused2
*unused3
*unused4
*unused5
*stmts.Integer ; list of all statements
*methods.st_mysql_methods
*thd;
*unbuffered_fetch_owner.Integer
*info_buffer.Integer;
*extension;
EndStructure
Structure character_set
number.i ; character set number
state.i ; character set state
csname.s ; collation name
name.s ; character set name
comment.s ; comment
dir.s ; character set directory
mbminlen.i ; min. length for multibyte strings
mbmaxlen.i ; max. length for multibyte strings
EndStructure
Structure mysql_res
row_count.q
*fields.mysql_field
*Datas.mysql_data
*data_cursor.mysql_rows
*lengths.Long ; column lengths of current row
*handle.mysql ; for unbuffered reads
*methods.mysql_methods ;
*row ; If unbuffered read
*current_row ; buffer to current row
*field_alloc ;
field_count.i
current_field.i ;
eof.b ; Used by mysql_fetch_row
unbuffered_fetch_cancelled.b ;
*extension
EndStructure
Structure mysql_parameter
*p_max_allowed_packet.Long
*p_net_buffer_length.Long
*extension
EndStructure
Structure mysql_bind
*length.Long ; output length pointer
*is_null.Ascii ; Pointer to null indicator
*buffer.Integer ; buffer to get/put data
*error.Ascii
*row_ptr.Ascii ; for the current data position
*store_param_func.Integer
*fetch_result.Integer
*skip_result.Integer
buffer_length.l ;
offset.l ; offset position for char/binary fetch
length_value.l ; Used if length is 0
param_number.i ; For null count and error messages
pack_length.i ; Internal length for packed data
buffer_type.i ; buffer type
error_value.a ; used if error is 0
is_unsigned.a ; set if integer type is unsigned
long_data_used.a ; If used with mysql_send_long_data
is_null_value.a ; Used if is_null is 0
*extension.Integer ;
EndStructure
Structure mysql_stmt
mem_root.st_mem_root
*List.Integer ; list to keep track of all stmts
*mysql.mysql ; connection handle
*params.mysql_bind ; input parameters
*bind.mysql_bind ; output parameters
*fields.mysql_field ; result set metadata
result.mysql_data ; cached result set
*data_cursor.mysql_rows ; current row in cached result
*read_row_func
affected_rows.q ;
insert_id.q ; copy of mysql->insert_id
stmt_id.l ; Id for prepared statement
flags.l ; i.e. type of cursor To open
prefetch_rows.l ; number of rows per one COM_FETCH
server_status.i ;
last_errno.i ; error code
param_count.i ; input parameter count
field_count.i ; number of columns in result set
state.i ; statement state
last_error.s[#MYSQL_ERRMSG_SIZE] ; error message
sqlstate.s[#SQLSTATE_LENGTH + 1] ;
send_types_to_server.b ;
bind_param_done.b ; input buffers were supplied
bind_result_done.a ; output buffers were supplied
unbuffered_fetch_cancelled.b ;
update_max_length.b ;
*extension ;
EndStructure
Structure mysql_methods
*read_query_result
*advanced_command
*read_rows
*use_result
*fetch_lengths
*flush_use_result
*list_fields
*read_prepare_result
*stmt_execute
*read_binary_rows
*unbuffered_fetch
*free_embedded_thd
*read_statistics
*next_result
*read_change_user_result
*read_rows_from_cursor
EndStructure
Global mysql_lib
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Windows
Global mysql_filename$ = "libmysql.dll"
Macro OSPrototype
Prototype
EndMacro
CompilerCase #PB_OS_Linux
Global mysql_filename$ = "libmysql.so.1"
Macro OSPrototype
PrototypeC
EndMacro
CompilerCase #PB_OS_MacOS
Global mysql_filename$ = "libmysql.so.1"
Macro OSPrototype
PrototypeC
EndMacro
CompilerEndSelect
CompilerIf #PB_Compiler_Unicode
OSPrototype.q Proto_mysql_affected_rows(*mysql)
OSPrototype.b Proto_mysql_autocommit(*mysql, auto_mode.b)
OSPrototype.b Proto_mysql_change_user(*mysql, user.p-utf8, passwd.p-utf8, db.p-utf8)
OSPrototype.i Proto_mysql_character_set_name(*mysql)
OSPrototype.i Proto_mysql_close(*mysql)
OSPrototype.b Proto_mysql_commit(*mysql)
OSPrototype Proto_mysql_data_seek(*result, offset.q)
OSPrototype Proto_mysql_debug(debugstr.p-utf8)
OSPrototype.i Proto_mysql_dump_debug_info(*mysql)
OSPrototype.b Proto_mysql_embedded()
OSPrototype.b Proto_mysql_eof(*result)
OSPrototype.i Proto_mysql_errno(*mysql)
OSPrototype.s Proto_mysql_error(*mysql)
OSPrototype.l Proto_mysql_escape_string(tostr.p-utf8, fromstr.p-utf8, from_length.l)
OSPrototype.i Proto_mysql_fetch_field(*result)
OSPrototype.i Proto_mysql_fetch_field_direct(*result, fieldnr.i)
OSPrototype.i Proto_mysql_fetch_fields(*result)
OSPrototype.i Proto_mysql_fetch_lengths(*result)
OSPrototype.i Proto_mysql_fetch_row(*result)
OSPrototype.i Proto_mysql_field_count(*mysql)
OSPrototype.i Proto_mysql_field_seek(*result, offset.i)
OSPrototype.i Proto_mysql_field_tell(*result)
OSPrototype Proto_mysql_free_result(*result)
OSPrototype Proto_mysql_get_character_set_info(*mysql, *charset)
OSPrototype.i Proto_mysql_get_client_info()
OSPrototype.l Proto_mysql_get_client_version()
OSPrototype.i Proto_mysql_get_host_info(*mysql)
OSPrototype.i Proto_mysql_get_parameters()
OSPrototype.i Proto_mysql_get_proto_info(*mysql)
OSPrototype.i Proto_mysql_get_server_info(*mysql)
OSPrototype.l Proto_mysql_get_server_version(*mysql)
OSPrototype.i Proto_mysql_get_ssl_cipher(*mysql)
OSPrototype.l Proto_mysql_hex_string(tostr.s, fromstr.p-utf8, fromlen.l)
OSPrototype.i Proto_mysql_info(*mysql)
OSPrototype.i Proto_mysql_init(*mysql)
OSPrototype.q Proto_mysql_insert_id(*mysql)
OSPrototype.i Proto_mysql_kill(*mysql, pid.l)
OSPrototype.i Proto_mysql_list_dbs(*mysql, wild.p-utf8)
OSPrototype.i Proto_mysql_list_fields(*mysql, table.p-utf8, wild.p-utf8)
OSPrototype.i Proto_mysql_list_processes(*mysql)
OSPrototype.i Proto_mysql_list_tables(*mysql, wild.p-utf8)
OSPrototype.b Proto_mysql_more_results(*mysql)
OSPrototype.i Proto_mysql_next_result(*mysql)
OSPrototype.i Proto_mysql_num_fields(*result)
OSPrototype.q Proto_mysql_num_rows(*result)
OSPrototype.i Proto_mysql_options(*mysql, option.i, arg.p-utf8)
OSPrototype.i Proto_mysql_ping(*mysql)
OSPrototype.i Proto_mysql_query(*mysql, q.p-utf8)
OSPrototype.b Proto_mysql_read_query_result(*mysql)
OSPrototype.i Proto_mysql_real_connect(*mysql, host.p-utf8, user.p-utf8, passwd.p-utf8, db.p-utf8, port.i, unix_socket.p-utf8, clientflag.l)
OSPrototype.l Proto_mysql_real_escape_string(*mysql, tostr.p-utf8, fromstr.p-utf8, length.l)
OSPrototype.i Proto_mysql_real_query(*mysql, q.p-utf8, length.l)
OSPrototype.i Proto_mysql_refresh(*mysql, refresh_options.i)
OSPrototype.b Proto_mysql_rollback(*mysql)
OSPrototype.i Proto_mysql_row_seek(*result, *offset)
OSPrototype.i Proto_mysql_row_tell(*result)
OSPrototype.i Proto_mysql_select_db(*mysql, db.p-utf8)
OSPrototype.i Proto_mysql_send_query(*mysql, q.p-utf8, length.l)
OSPrototype Proto_mysql_server_end()
OSPrototype.i Proto_mysql_server_init(argc.i, *argv, *groups)
OSPrototype.i Proto_mysql_set_character_set(*mysql, csname.p-utf8)
OSPrototype Proto_mysql_set_local_infile_default(*mysql)
OSPrototype.i Proto_mysql_set_local_infile_handler(*mysql, *local_infile_init, *local_infile_read, *local_infile_end, *local_infile_error)
OSPrototype.i Proto_mysql_set_server_option(*mysql, option.i)
OSPrototype.i Proto_mysql_shutdown(*mysql, shutdown_level.i)
OSPrototype.i Proto_mysql_sqlstate(*mysql)
OSPrototype.b Proto_mysql_ssl_set(*mysql, key.p-utf8, cert.p-utf8, ca.p-utf8, capath.p-utf8, cipher.p-utf8)
OSPrototype.i Proto_mysql_stat(*mysql)
OSPrototype.q Proto_mysql_stmt_affected_rows(*stmt)
OSPrototype.b Proto_mysql_stmt_attr_get(*stmt, attr_type.i, *attr)
OSPrototype.b Proto_mysql_stmt_attr_set(*stmt, attr_type.i, *attr)
OSPrototype.a Proto_mysql_stmt_bind_param(*stmt, *bnd)
OSPrototype.b Proto_mysql_stmt_bind_result(*stmt, *bnd)
OSPrototype.b Proto_mysql_stmt_close(*stmt)
OSPrototype Proto_mysql_stmt_data_seek(*stmt, offset.q)
OSPrototype.i Proto_mysql_stmt_errno(*stmt)
OSPrototype.i Proto_mysql_stmt_error(*stmt)
OSPrototype.i Proto_mysql_stmt_execute(*stmt)
OSPrototype.i Proto_mysql_stmt_fetch(*stmt)
OSPrototype.i Proto_mysql_stmt_fetch_column(*stmt, *bind_arg, column.i, offset.l)
OSPrototype.i Proto_mysql_stmt_field_count(*stmt)
OSPrototype.b Proto_mysql_stmt_free_result(*stmt)
OSPrototype.i Proto_mysql_stmt_init(*stmt)
OSPrototype.q Proto_mysql_stmt_insert_id(*stmt)
OSPrototype.i Proto_mysql_stmt_next_result(*stmt)
OSPrototype.q Proto_mysql_stmt_num_rows(*stmt)
OSPrototype.l Proto_mysql_stmt_param_count(*stmt)
OSPrototype.i Proto_mysql_stmt_param_metadata(*stmt)
OSPrototype.i Proto_mysql_stmt_prepare(*stmt, query.p-utf8, length.l)
OSPrototype.b Proto_mysql_stmt_reset(*stmt)
OSPrototype.i Proto_mysql_stmt_result_metadata(*stmt)
OSPrototype.i Proto_mysql_stmt_row_seek(*stmt, *offset)
OSPrototype.i Proto_mysql_stmt_row_tell(*stmt)
OSPrototype.b Proto_mysql_stmt_send_long_data(*stmt, param_number.i, DataStr.p-utf8, length.l)
OSPrototype.i Proto_mysql_stmt_sqlstate(*stmt)
OSPrototype.i Proto_mysql_stmt_store_result(*stmt)
OSPrototype.i Proto_mysql_store_result(*mysql)
OSPrototype Proto_mysql_thread_end()
OSPrototype.l Proto_mysql_thread_id(*mysql)
OSPrototype.b Proto_mysql_thread_init()
OSPrototype.i Proto_mysql_thread_safe()
OSPrototype.i Proto_mysql_use_result(*mysql)
OSPrototype.i Proto_mysql_warning_count(*mysql)
CompilerElse
OSPrototype.q Proto_mysql_affected_rows(*mysql)
OSPrototype.b Proto_mysql_autocommit(*mysql, auto_mode.b)
OSPrototype.b Proto_mysql_change_user(*mysql, user.s, passwd.s, db.s)
OSPrototype.i Proto_mysql_character_set_name(*mysql)
OSPrototype.i Proto_mysql_close(*mysql)
OSPrototype.b Proto_mysql_commit(*mysql)
OSPrototype Proto_mysql_data_seek(*result, offset.q)
OSPrototype Proto_mysql_debug(debugstr.s)
OSPrototype.i Proto_mysql_dump_debug_info(*mysql)
OSPrototype.b Proto_mysql_embedded()
OSPrototype.b Proto_mysql_eof(*result)
OSPrototype.i Proto_mysql_errno(*mysql)
OSPrototype.s Proto_mysql_error(*mysql)
OSPrototype.l Proto_mysql_escape_string(tostr.s, fromstr.s, from_length.l)
OSPrototype.i Proto_mysql_fetch_field(*result)
OSPrototype.i Proto_mysql_fetch_field_direct(*result, fieldnr.i)
OSPrototype.i Proto_mysql_fetch_fields(*result)
OSPrototype.i Proto_mysql_fetch_lengths(*result)
OSPrototype.i Proto_mysql_fetch_row(*result)
OSPrototype.i Proto_mysql_field_count(*mysql)
OSPrototype.i Proto_mysql_field_seek(*result, offset.i)
OSPrototype.i Proto_mysql_field_tell(*result)
OSPrototype Proto_mysql_free_result(*result)
OSPrototype Proto_mysql_get_character_set_info(*mysql, *charset)
OSPrototype.s Proto_mysql_get_client_info()
OSPrototype.l Proto_mysql_get_client_version()
OSPrototype.s Proto_mysql_get_host_info(*mysql)
OSPrototype.i Proto_mysql_get_parameters()
OSPrototype.i Proto_mysql_get_proto_info(*mysql)
OSPrototype.s Proto_mysql_get_server_info(*mysql)
OSPrototype.l Proto_mysql_get_server_version(*mysql)
OSPrototype.s Proto_mysql_get_ssl_cipher(*mysql)
OSPrototype.l Proto_mysql_hex_string(tostr.s, fromstr.s, fromlen.l)
OSPrototype.s Proto_mysql_info(*mysql)
OSPrototype.i Proto_mysql_init(*mysql)
OSPrototype.q Proto_mysql_insert_id(*mysql)
OSPrototype.i Proto_mysql_kill(*mysql, pid.l)
OSPrototype.i Proto_mysql_list_dbs(*mysql, wild.s)
OSPrototype.i Proto_mysql_list_fields(*mysql, table.s, wild.s)
OSPrototype.i Proto_mysql_list_processes(*mysql)
OSPrototype.i Proto_mysql_list_tables(*mysql, wild.s)
OSPrototype.b Proto_mysql_more_results(*mysql)
OSPrototype.i Proto_mysql_next_result(*mysql)
OSPrototype.i Proto_mysql_num_fields(*result)
OSPrototype.q Proto_mysql_num_rows(*result)
OSPrototype.i Proto_mysql_options(*mysql, option.i, arg.s)
OSPrototype.i Proto_mysql_ping(*mysql)
OSPrototype.i Proto_mysql_query(*mysql, q.s)
OSPrototype.b Proto_mysql_read_query_result(*mysql)
OSPrototype.i Proto_mysql_real_connect(*mysql, host.s, user.s, passwd.s, db.s, port.i, unix_socket.s, clientflag.l)
OSPrototype.l Proto_mysql_real_escape_string(*mysql, tostr.s, fromstr.s, length.l)
OSPrototype.i Proto_mysql_real_query(*mysql, q.s, length.l)
OSPrototype.i Proto_mysql_refresh(*mysql, refresh_options.i)
OSPrototype.b Proto_mysql_rollback(*mysql)
OSPrototype.i Proto_mysql_row_seek(*result, *offset)
OSPrototype.i Proto_mysql_row_tell(*result)
OSPrototype.i Proto_mysql_select_db(*mysql, db.s)
OSPrototype.i Proto_mysql_send_query(*mysql, q.s, length.l)
OSPrototype Proto_mysql_server_end()
OSPrototype.i Proto_mysql_server_init(argc.i, *argv, *groups)
OSPrototype.i Proto_mysql_set_character_set(*mysql, csname.s)
OSPrototype Proto_mysql_set_local_infile_default(*mysql)
OSPrototype.i Proto_mysql_set_local_infile_handler(*mysql, *local_infile_init, *local_infile_read, *local_infile_end, *local_infile_error)
OSPrototype.i Proto_mysql_set_server_option(*mysql, option.i)
OSPrototype.i Proto_mysql_shutdown(*mysql, shutdown_level.i)
OSPrototype.s Proto_mysql_sqlstate(*mysql)
OSPrototype.b Proto_mysql_ssl_set(*mysql, key.s, cert.s, ca.s, capath.s, cipher.s)
OSPrototype.s Proto_mysql_stat(*mysql)
OSPrototype.q Proto_mysql_stmt_affected_rows(*stmt)
OSPrototype.b Proto_mysql_stmt_attr_get(*stmt, attr_type.i, *attr)
OSPrototype.b Proto_mysql_stmt_attr_set(*stmt, attr_type.i, *attr)
OSPrototype.a Proto_mysql_stmt_bind_param(*stmt, *bnd)
OSPrototype.b Proto_mysql_stmt_bind_result(*stmt, *bnd)
OSPrototype.b Proto_mysql_stmt_close(*stmt)
OSPrototype Proto_mysql_stmt_data_seek(*stmt, offset.q)
OSPrototype.i Proto_mysql_stmt_errno(*stmt)
OSPrototype.s Proto_mysql_stmt_error(*stmt)
OSPrototype.i Proto_mysql_stmt_execute(*stmt)
OSPrototype.i Proto_mysql_stmt_fetch(*stmt)
OSPrototype.i Proto_mysql_stmt_fetch_column(*stmt, *bind_arg, column.i, offset.l)
OSPrototype.i Proto_mysql_stmt_field_count(*stmt)
OSPrototype.b Proto_mysql_stmt_free_result(*stmt)
OSPrototype.i Proto_mysql_stmt_init(*stmt)
OSPrototype.q Proto_mysql_stmt_insert_id(*stmt)
OSPrototype.i Proto_mysql_stmt_next_result(*stmt)
OSPrototype.q Proto_mysql_stmt_num_rows(*stmt)
OSPrototype.l Proto_mysql_stmt_param_count(*stmt)
OSPrototype.i Proto_mysql_stmt_param_metadata(*stmt)
OSPrototype.i Proto_mysql_stmt_prepare(*stmt, query.s, length.l)
OSPrototype.b Proto_mysql_stmt_reset(*stmt)
OSPrototype.i Proto_mysql_stmt_result_metadata(*stmt)
OSPrototype.i Proto_mysql_stmt_row_seek(*stmt, *offset)
OSPrototype.i Proto_mysql_stmt_row_tell(*stmt)
OSPrototype.b Proto_mysql_stmt_send_long_data(*stmt, param_number.i, DataStr.s, length.l)
OSPrototype.i Proto_mysql_stmt_sqlstate(*stmt)
OSPrototype.i Proto_mysql_stmt_store_result(*stmt)
OSPrototype.i Proto_mysql_store_result(*mysql)
OSPrototype Proto_mysql_thread_end()
OSPrototype.l Proto_mysql_thread_id(*mysql)
OSPrototype.b Proto_mysql_thread_init()
OSPrototype.i Proto_mysql_thread_safe()
OSPrototype.i Proto_mysql_use_result(*mysql)
OSPrototype.i Proto_mysql_warning_count(*mysql)
CompilerEndIf
Global mysql_affected_rows.Proto_mysql_affected_rows
Global mysql_autocommit.Proto_mysql_autocommit
Global mysql_change_user.Proto_mysql_change_user
Global mysql_character_set_name.Proto_mysql_character_set_name
Global mysql_close.Proto_mysql_close
Global mysql_commit.Proto_mysql_commit
Global mysql_data_seek.Proto_mysql_data_seek
Global mysql_debug.Proto_mysql_debug
Global mysql_dump_debug_info.Proto_mysql_dump_debug_info
Global mysql_embedded.Proto_mysql_embedded
Global mysql_eof.Proto_mysql_eof
Global mysql_errno.Proto_mysql_errno
Global mysql_error.Proto_mysql_error
Global mysql_escape_string.Proto_mysql_escape_string
Global mysql_fetch_field.Proto_mysql_fetch_field
Global mysql_fetch_field_direct.Proto_mysql_fetch_field_direct
Global mysql_fetch_fields.Proto_mysql_fetch_fields
Global mysql_fetch_lengths.Proto_mysql_fetch_lengths
Global mysql_fetch_row.Proto_mysql_fetch_row
Global mysql_field_count.Proto_mysql_field_count
Global mysql_field_seek.Proto_mysql_field_seek
Global mysql_field_tell.Proto_mysql_field_tell
Global mysql_free_result.Proto_mysql_free_result
Global mysql_get_character_set_info.Proto_mysql_get_character_set_info
Global mysql_get_client_info.Proto_mysql_get_client_info
Global mysql_get_client_version.Proto_mysql_get_client_version
Global mysql_get_host_info.Proto_mysql_get_host_info
Global mysql_get_parameters.Proto_mysql_get_parameters
Global mysql_get_proto_info.Proto_mysql_get_proto_info
Global mysql_get_server_info.Proto_mysql_get_server_info
Global mysql_get_server_version.Proto_mysql_get_server_version
Global mysql_get_ssl_cipher.Proto_mysql_get_ssl_cipher
Global mysql_hex_string.Proto_mysql_hex_string
Global mysql_info.Proto_mysql_info
Global mysql_init.Proto_mysql_init
Global mysql_insert_id.Proto_mysql_insert_id
Global mysql_kill.Proto_mysql_kill
Global mysql_list_dbs.Proto_mysql_list_dbs
Global mysql_list_fields.Proto_mysql_list_fields
Global mysql_list_processes.Proto_mysql_list_processes
Global mysql_list_tables.Proto_mysql_list_tables
Global mysql_more_results.Proto_mysql_more_results
Global mysql_next_result.Proto_mysql_next_result
Global mysql_num_fields.Proto_mysql_num_fields
Global mysql_num_rows.Proto_mysql_num_rows
Global mysql_options.Proto_mysql_options
Global mysql_ping.Proto_mysql_ping
Global mysql_query.Proto_mysql_query
Global mysql_read_query_result.Proto_mysql_read_query_result
Global mysql_real_connect.Proto_mysql_real_connect
Global mysql_real_escape_string.Proto_mysql_real_escape_string
Global mysql_real_query.Proto_mysql_real_query
Global mysql_refresh.Proto_mysql_refresh
Global mysql_rollback.Proto_mysql_rollback
Global mysql_row_seek.Proto_mysql_row_seek
Global mysql_row_tell.Proto_mysql_row_tell
Global mysql_select_db.Proto_mysql_select_db
Global mysql_send_query.Proto_mysql_send_query
Global mysql_server_end.Proto_mysql_server_end
Global mysql_server_init.Proto_mysql_server_init
Global mysql_set_character_set.Proto_mysql_set_character_set
Global mysql_set_local_infile_default.Proto_mysql_set_local_infile_default
Global mysql_set_local_infile_handler.Proto_mysql_set_local_infile_handler
Global mysql_set_server_option.Proto_mysql_set_server_option
Global mysql_shutdown.Proto_mysql_shutdown
Global mysql_sqlstate.Proto_mysql_sqlstate
Global mysql_ssl_set.Proto_mysql_ssl_set
Global mysql_stat.Proto_mysql_stat
Global mysql_stmt_affected_rows.Proto_mysql_stmt_affected_rows
Global mysql_stmt_attr_get.Proto_mysql_stmt_attr_get
Global mysql_stmt_attr_set.Proto_mysql_stmt_attr_set
Global mysql_stmt_bind_param.Proto_mysql_stmt_bind_param
Global mysql_stmt_bind_result.Proto_mysql_stmt_bind_result
Global mysql_stmt_close.Proto_mysql_stmt_close
Global mysql_stmt_data_seek.Proto_mysql_stmt_data_seek
Global mysql_stmt_errno.Proto_mysql_stmt_errno
Global mysql_stmt_error.Proto_mysql_stmt_error
Global mysql_stmt_execute.Proto_mysql_stmt_execute
Global mysql_stmt_fetch.Proto_mysql_stmt_fetch
Global mysql_stmt_fetch_column.Proto_mysql_stmt_fetch_column
Global mysql_stmt_field_count.Proto_mysql_stmt_field_count
Global mysql_stmt_free_result.Proto_mysql_stmt_free_result
Global mysql_stmt_init.Proto_mysql_stmt_init
Global mysql_stmt_insert_id.Proto_mysql_stmt_insert_id
Global mysql_stmt_next_result.Proto_mysql_stmt_next_result
Global mysql_stmt_num_rows.Proto_mysql_stmt_num_rows
Global mysql_stmt_param_count.Proto_mysql_stmt_param_count
Global mysql_stmt_param_metadata.Proto_mysql_stmt_param_metadata
Global mysql_stmt_prepare.Proto_mysql_stmt_prepare
Global mysql_stmt_reset.Proto_mysql_stmt_reset
Global mysql_stmt_result_metadata.Proto_mysql_stmt_result_metadata
Global mysql_stmt_row_seek.Proto_mysql_stmt_row_seek
Global mysql_stmt_row_tell.Proto_mysql_stmt_row_tell
Global mysql_stmt_send_long_data.Proto_mysql_stmt_send_long_data
Global mysql_stmt_sqlstate.Proto_mysql_stmt_sqlstate
Global mysql_stmt_store_result.Proto_mysql_stmt_store_result
Global mysql_store_result.Proto_mysql_store_result
Global mysql_thread_end.Proto_mysql_thread_end
Global mysql_thread_id.Proto_mysql_thread_id
Global mysql_thread_init.Proto_mysql_thread_init
Global mysql_thread_safe.Proto_mysql_thread_safe
Global mysql_use_result.Proto_mysql_use_result
Global mysql_warning_count.Proto_mysql_warning_count
Procedure.i mysql_lib_init()
Protected Result
Result = #False
mysql_lib = OpenLibrary(#PB_Any, mysql_filename$)
If mysql_lib
mysql_affected_rows = GetFunction(mysql_lib, "mysql_affected_rows")
mysql_autocommit = GetFunction(mysql_lib, "mysql_autocommit")
mysql_change_user = GetFunction(mysql_lib, "mysql_change_user")
mysql_character_set_name = GetFunction(mysql_lib, "mysql_character_set_name")
mysql_close = GetFunction(mysql_lib, "mysql_close")
mysql_commit = GetFunction(mysql_lib, "mysql_commit")
mysql_data_seek = GetFunction(mysql_lib, "mysql_data_seek")
mysql_debug = GetFunction(mysql_lib, "mysql_debug")
mysql_dump_debug_info = GetFunction(mysql_lib, "mysql_dump_debug_info")
mysql_embedded = GetFunction(mysql_lib, "mysql_embedded")
mysql_eof = GetFunction(mysql_lib, "mysql_eof")
mysql_errno = GetFunction(mysql_lib, "mysql_errno")
mysql_error = GetFunction(mysql_lib, "mysql_error")
mysql_escape_string = GetFunction(mysql_lib, "mysql_escape_string")
mysql_fetch_field = GetFunction(mysql_lib, "mysql_fetch_field")
mysql_fetch_field_direct = GetFunction(mysql_lib, "mysql_fetch_field_direct")
mysql_fetch_fields = GetFunction(mysql_lib, "mysql_fetch_fields")
mysql_fetch_lengths = GetFunction(mysql_lib, "mysql_fetch_lengths")
mysql_fetch_row = GetFunction(mysql_lib, "mysql_fetch_row")
mysql_field_count = GetFunction(mysql_lib, "mysql_field_count")
mysql_field_seek = GetFunction(mysql_lib, "mysql_field_seek")
mysql_field_tell = GetFunction(mysql_lib, "mysql_field_tell")
mysql_free_result = GetFunction(mysql_lib, "mysql_free_result")
mysql_get_character_set_info = GetFunction(mysql_lib, "mysql_get_character_set_info")
mysql_get_client_info = GetFunction(mysql_lib, "mysql_get_client_info")
mysql_get_client_version = GetFunction(mysql_lib, "mysql_get_client_version")
mysql_get_host_info = GetFunction(mysql_lib, "mysql_get_host_info")
mysql_get_parameters = GetFunction(mysql_lib, "mysql_get_parameters")
mysql_get_proto_info = GetFunction(mysql_lib, "mysql_get_proto_info")
mysql_get_server_info = GetFunction(mysql_lib, "mysql_get_server_info")
mysql_get_server_version = GetFunction(mysql_lib, "mysql_get_server_version")
mysql_get_ssl_cipher = GetFunction(mysql_lib, "mysql_get_ssl_cipher")
mysql_hex_string = GetFunction(mysql_lib, "mysql_hex_string")
mysql_info = GetFunction(mysql_lib, "mysql_info")
mysql_init = GetFunction(mysql_lib, "mysql_init")
mysql_insert_id = GetFunction(mysql_lib, "mysql_insert_id")
mysql_kill = GetFunction(mysql_lib, "mysql_kill")
mysql_list_dbs = GetFunction(mysql_lib, "mysql_list_dbs")
mysql_list_fields = GetFunction(mysql_lib, "mysql_list_fields")
mysql_list_processes = GetFunction(mysql_lib, "mysql_list_processes")
mysql_list_tables = GetFunction(mysql_lib, "mysql_list_tables")
mysql_more_results = GetFunction(mysql_lib, "mysql_more_results")
mysql_next_result = GetFunction(mysql_lib, "mysql_next_result")
mysql_num_fields = GetFunction(mysql_lib, "mysql_num_fields")
mysql_num_rows = GetFunction(mysql_lib, "mysql_num_rows")
mysql_options = GetFunction(mysql_lib, "mysql_options")
mysql_ping = GetFunction(mysql_lib, "mysql_ping")
mysql_query = GetFunction(mysql_lib, "mysql_query")
mysql_read_query_result = GetFunction(mysql_lib, "mysql_read_query_result")
mysql_real_connect = GetFunction(mysql_lib, "mysql_real_connect")
mysql_real_escape_string = GetFunction(mysql_lib, "mysql_real_escape_string")
mysql_real_query = GetFunction(mysql_lib, "mysql_real_query")
mysql_refresh = GetFunction(mysql_lib, "mysql_refresh")
mysql_rollback = GetFunction(mysql_lib, "mysql_rollback")
mysql_row_seek = GetFunction(mysql_lib, "mysql_row_seek")
mysql_row_tell = GetFunction(mysql_lib, "mysql_row_tell")
mysql_select_db = GetFunction(mysql_lib, "mysql_select_db")
mysql_send_query = GetFunction(mysql_lib, "mysql_send_query")
mysql_server_end = GetFunction(mysql_lib, "mysql_server_end")
mysql_server_init = GetFunction(mysql_lib, "mysql_server_init")
mysql_set_character_set = GetFunction(mysql_lib, "mysql_set_character_set")
mysql_set_local_infile_default = GetFunction(mysql_lib, "mysql_set_local_infile_default")
mysql_set_local_infile_handler = GetFunction(mysql_lib, "mysql_set_local_infile_handler")
mysql_set_server_option = GetFunction(mysql_lib, "mysql_set_server_option")
mysql_shutdown = GetFunction(mysql_lib, "mysql_shutdown")
mysql_sqlstate = GetFunction(mysql_lib, "mysql_sqlstate")
mysql_ssl_set = GetFunction(mysql_lib, "mysql_ssl_set")
mysql_stat = GetFunction(mysql_lib, "mysql_stat")
mysql_stmt_affected_rows = GetFunction(mysql_lib, "mysql_stmt_affected_rows")
mysql_stmt_attr_get = GetFunction(mysql_lib, "mysql_stmt_attr_get")
mysql_stmt_attr_set = GetFunction(mysql_lib, "mysql_stmt_attr_set")
mysql_stmt_bind_param = GetFunction(mysql_lib, "mysql_stmt_bind_param")
mysql_stmt_bind_result = GetFunction(mysql_lib, "mysql_stmt_bind_result")
mysql_stmt_close = GetFunction(mysql_lib, "mysql_stmt_close")
mysql_stmt_data_seek = GetFunction(mysql_lib, "mysql_stmt_data_seek")
mysql_stmt_errno = GetFunction(mysql_lib, "mysql_stmt_errno")
mysql_stmt_error = GetFunction(mysql_lib, "mysql_stmt_error")
mysql_stmt_execute = GetFunction(mysql_lib, "mysql_stmt_execute")
mysql_stmt_fetch = GetFunction(mysql_lib, "mysql_stmt_fetch")
mysql_stmt_fetch_column = GetFunction(mysql_lib, "mysql_stmt_fetch_column")
mysql_stmt_field_count = GetFunction(mysql_lib, "mysql_stmt_field_count")
mysql_stmt_free_result = GetFunction(mysql_lib, "mysql_stmt_free_result")
mysql_stmt_init = GetFunction(mysql_lib, "mysql_stmt_init")
mysql_stmt_insert_id = GetFunction(mysql_lib, "mysql_stmt_insert_id")
mysql_stmt_next_result = GetFunction(mysql_lib, "mysql_stmt_next_result")
mysql_stmt_num_rows = GetFunction(mysql_lib, "mysql_stmt_num_rows")
mysql_stmt_param_count = GetFunction(mysql_lib, "mysql_stmt_param_count")
mysql_stmt_param_metadata = GetFunction(mysql_lib, "mysql_stmt_param_metadata")
mysql_stmt_prepare = GetFunction(mysql_lib, "mysql_stmt_prepare")
mysql_stmt_reset = GetFunction(mysql_lib, "mysql_stmt_reset")
mysql_stmt_result_metadata = GetFunction(mysql_lib, "mysql_stmt_result_metadata")
mysql_stmt_row_seek = GetFunction(mysql_lib, "mysql_stmt_row_seek")
mysql_stmt_row_tell = GetFunction(mysql_lib, "mysql_stmt_row_tell")
mysql_stmt_send_long_data = GetFunction(mysql_lib, "mysql_stmt_send_long_data")
mysql_stmt_sqlstate = GetFunction(mysql_lib, "mysql_stmt_sqlstate")
mysql_stmt_store_result = GetFunction(mysql_lib, "mysql_stmt_store_result")
mysql_store_result = GetFunction(mysql_lib, "mysql_store_result")
mysql_thread_end = GetFunction(mysql_lib, "mysql_thread_end")
mysql_thread_id = GetFunction(mysql_lib, "mysql_thread_id")
mysql_thread_init = GetFunction(mysql_lib, "mysql_thread_init")
mysql_thread_safe = GetFunction(mysql_lib, "mysql_thread_safe")
mysql_use_result = GetFunction(mysql_lib, "mysql_use_result")
mysql_warning_count = GetFunction(mysql_lib, "mysql_warning_count")
Result = #True
EndIf
ProcedureReturn Result
EndProcedure
Procedure mysql_lib_free()
If IsLibrary(mysql_lib) : CloseLibrary(mysql_lib) : EndIf
mysql_lib = 0
EndProcedure
EnableExplicit
Procedure main()
Protected dbHost.s
Protected dbName.s
Protected dbUser.s
Protected dbPwd.s
Protected dbPort.i
Protected sql.s
Protected *mysql.mysql
Protected *mysqlStmt.mysql_stmt
Protected *mysqlMeta.mysql_res
Protected res.i
Protected res2.a
Protected statusParm.i
Protected lengthResult.i
Protected Dim result.mysql_bind(4)
Protected Dim param.mysql_bind(1)
If ( InitNetwork() )
dbHost = "<database server location>"
dbUser = "<username>"
dbPwd = "<password>"
dbName = "<database name>"
dbPort = 3306
If ( mysql_lib_init() )
Debug "OKAY : mysql_lib_init"
*mysql = mysql_init( #Null )
If ( *mySql )
Debug "OKAY : mysql_init"
If ( mysql_real_connect( *mysql, dbHost, dbUser, dbPwd, dbName, dbPort, #NULL$, #CLIENT_COMPRESS ) )
Debug "OKAY : mysql_real_connect"
; We want one field "sizeName" returned from the query ... and we will choose records where the "status" field equals 1
sql = "SELECT sizeName FROM ImageSizes WHERE ( status = ? )"
*mysqlStmt = mysql_stmt_init( *mysql )
If ( *mysqlStmt )
Debug "OKAY : mysql_stmt_init"
If ( mysql_stmt_prepare( *mysqlStmt, sql, Len( sql ) ) = 0 )
Debug "OKAY : mysql_stmt_prepare"
param(0)\buffer_type = #MYSQL_TYPE_LONG
param(0)\buffer = @statusParm
statusParm = 1 ; Only return records where the "status" field equals 1
res2 = mysql_stmt_bind_param( *mysqlStmt, param() )
If ( res2 = 0 )
Debug "OKAY : mysql_stmt_bind_param"
EndIf
*mysqlMeta = mysql_stmt_result_metadata( *mysqlStmt )
If ( *mysqlMeta )
Debug "OKAY : mysql_stmt_result_metadata"
If ( mysql_stmt_execute( *mysqlStmt ) = 0 )
Debug "OKAY : mysql_stmt_execute"
result(0)\buffer_type = #MYSQL_TYPE_STRING
result(0)\buffer = AllocateMemory( 512 )
result(0)\buffer_length = 512
result(0)\is_null = 0
result(0)\length = @lengthResult
lengthResult = 0 ; this variable will contain the length of the first field value (string) for each loop below
If ( mysql_stmt_bind_result( *mysqlStmt, result() ) = 0 )
Debug "OKAY : mysql_stmt_bind_result"
While ( mysql_stmt_fetch( *mysqlStmt ) = 0 )
If #PB_Compiler_Unicode
Debug "row : " + PeekS( result(0)\buffer, lengthResult, #PB_UTF8 ) + " , " + Str( lengthResult )
Else
Debug "row : " + PeekS( result(0)\buffer ) + " , " + Str( lengthResult )
EndIf
Wend
EndIf
FreeMemory( result(0)\buffer )
EndIf
mysql_free_result( *mysqlMeta )
EndIf
EndIf
mysql_stmt_close( *mysqlStmt )
EndIf
Else
Debug "cannot open database"
EndIf
mySql_close( *mysql )
Else
Debug "cannot initialise mysql"
EndIf
mysql_lib_free()
EndIf
EndIf
EndProcedure
main()
If the temperature today was 0 degrees, how can it be twice as cold tomorrow?
- RichAlgeni
- Addict

- Posts: 935
- Joined: Wed Sep 22, 2010 1:50 am
- Location: Bradenton, FL
Re: Win32 - mysql_stmt_bind_param example
Nicely done Techie!
Look forward to seeing more of your code soon!
Rich
Look forward to seeing more of your code soon!
Rich
