Database Method(s)

Functions provided to interact with SQL database(s). It currently supports MySql, PostgreSql and Sqlite. Database settings are retrieved from the INI file identified by the section name.


      db_create (string inisection);
        - connects to the database
        - the inisection contains the database connection parameters
        - returns a database handle used for succeeding function calls

      db_bind (long handle, string bindvalue);
        - binds a variable to a SQL parameter
        - handle is the database handle returned by db_create
        - bindvalue is the value to bind
        - returns true on success, false otherwise

      db_select (long handle, string sqlselect);
        - executes a SQL select statement
        - handle is the database handle returned by db_create
        - sqlselect is the SQL query
        - returns true on success, false otherwise

      db_update (long handle, string sqlupdate);
        - executes a SQL UPDATE, INSERT or DELETE
        - handle is the database handle returned by db_create
        - sqlupdate is the SQL query
        - returns true on success, false otherwise

      db_bind_reset (long handle);
        - resets the bind variable list
        - handle is the database handle returned by db_create
        - returns true on success, false otherwise

      db_next (long handle);
        - move to the next selected record in the result set
        - handle is the database handle returned by db_create
        - returns true on success, false otherwise

      db_field (long handle, string name, string defaultvalue);
        - retrieves a field value from the current row
        - handle is the database handle returned by db_create
        - name is the database field name
        - defaultvalue us the default in case the field value is null
        - returns true on success, false otherwise

      db_eof (long handle);
        - checks if the end of the result set has been reached
        - handle is the database handle returned by db_create
        - returns true on success, false otherwise

      db_bind_reset (long handle);
        - resets the bind variable list
        - handle is the database handle returned by db_create
        - returns true on success, false otherwise

      db_reset (long handle);
        - resets the database, clears the result set or rollsback transaction(s)
        - handle is the database handle returned by db_create
        - returns true on success, false otherwise

      db_commit (long handle);
        - commits database changes
        - handle is the database handle returned by db_create
        - returns true on success, false otherwise

      db_rollback (long handle);
        - cancels the database changes
        - handle is the database handle returned by db_create
        - returns true on success, false otherwise
    

db_result - returns a formatted string containing the entire result set

Argument Type Description
handle Number The database handle returned by db_create
format Number Result Set Format Type:
dbcsv (), dbjson (), dbquery ()

These functions return a numeric representation of the format desired for SQL query results. dbcsv () indicates a comma delimitted string, dbjson () a JSON formatted string and dbquery () for an HTML parameter string.
Optional: json name String The name of the root JSON node. Default is "data"
Optional: json additional info Boolean True if additional data will be appended to the output string. Otherwise, the terminating closing brace will be included in the output.
Optional: json append Boolean True if the format request is being appended to an existing JSON string. Otherwise, the starting brace will be included in the output.
Return Value Type Description
formatted output String A formatted string containing the result set