The first script (draft of course) can take mySQL / postgreSQL / SQLite / VDB database.
and for the specified table
GENERATE CODE for Xojo, with command INSERT / UPDATE / SELECT
Using parameter you can specify if you want to use set of Bind() calls to bind values, or put them into SqlExecute() or SqlSelect() command.
For UPDATE command, script is able recognize PrimaryKey fields of a table, and put them into WHERE part instead of UPDATE SET part.
Bellow are examples of generated code for both these variants:
dim cmd as string = "UPDATE mantis_bug_file_table SET bug_id = ?, title = ?, description = ?, diskfile = ?, filename = ?, folder = ?, filesize = ?, file_type = ?, content = ?, date_added = ?, user_id = ? ) WHERE id = ?"
dim ps as PreparedSQLStatement = db.Prepare( cmd )
ps.BindType( 0, MySQLPreparedStatement.MYSQL_TYPE_LONG ) // bug_id
ps.BindType( 1, MySQLPreparedStatement.MYSQL_TYPE_STRING ) // title
ps.BindType( 2, MySQLPreparedStatement.MYSQL_TYPE_STRING ) // description
ps.BindType( 3, MySQLPreparedStatement.MYSQL_TYPE_STRING ) // diskfile
ps.BindType( 4, MySQLPreparedStatement.MYSQL_TYPE_STRING ) // filename
ps.BindType( 5, MySQLPreparedStatement.MYSQL_TYPE_STRING ) // folder
ps.BindType( 6, MySQLPreparedStatement.MYSQL_TYPE_LONG ) // filesize
ps.BindType( 7, MySQLPreparedStatement.MYSQL_TYPE_STRING ) // file_type
ps.BindType( 8, MySQLPreparedStatement.MYSQL_TYPE_BLOB ) // content
ps.BindType( 9, MySQLPreparedStatement.MYSQL_TYPE_LONG ) // date_added
ps.BindType( 10, MySQLPreparedStatement.MYSQL_TYPE_LONG ) // user_id
// WHERE part binding:
ps.BindType( 11, MySQLPreparedStatement.MYSQL_TYPE_LONG ) // id
ps.Bind( 0, int ) // bug_id
ps.Bind( 1, "" ) // title
ps.Bind( 2, "" ) // description
ps.Bind( 3, "" ) // diskfile
ps.Bind( 4, "" ) // filename
ps.Bind( 5, "" ) // folder
ps.Bind( 6, int ) // filesize
ps.Bind( 7, "" ) // file_type
ps.Bind( 8, blobstr ) // content
ps.Bind( 9, int ) // date_added
ps.Bind( 10, int ) // user_id
// WHERE part binding:
ps.Bind( 11, int ) // id
ps.SQLExecute()
dim cmd as string = "UPDATE mantis_bug_file_table SET bug_id = ?, title = ?, description = ?, diskfile = ?, filename = ?, folder = ?, filesize = ?, file_type = ?, content = ?, date_added = ?, user_id = ? ) WHERE id = ?"
dim ps as PreparedSQLStatement = db.Prepare( cmd )
ps.BindType( 0, MySQLPreparedStatement.MYSQL_TYPE_LONG ) // bug_id
ps.BindType( 1, MySQLPreparedStatement.MYSQL_TYPE_STRING ) // title
ps.BindType( 2, MySQLPreparedStatement.MYSQL_TYPE_STRING ) // description
ps.BindType( 3, MySQLPreparedStatement.MYSQL_TYPE_STRING ) // diskfile
ps.BindType( 4, MySQLPreparedStatement.MYSQL_TYPE_STRING ) // filename
ps.BindType( 5, MySQLPreparedStatement.MYSQL_TYPE_STRING ) // folder
ps.BindType( 6, MySQLPreparedStatement.MYSQL_TYPE_LONG ) // filesize
ps.BindType( 7, MySQLPreparedStatement.MYSQL_TYPE_STRING ) // file_type
ps.BindType( 8, MySQLPreparedStatement.MYSQL_TYPE_BLOB ) // content
ps.BindType( 9, MySQLPreparedStatement.MYSQL_TYPE_LONG ) // date_added
ps.BindType( 10, MySQLPreparedStatement.MYSQL_TYPE_LONG ) // user_id
// WHERE part binding:
ps.BindType( 11, MySQLPreparedStatement.MYSQL_TYPE_LONG ) // id
ps.SQLExecute( int, "", "", "", "", "", int, "", blobstr, int, int, int ) <====== REPLACE place-holders AND remove this comment