All Classes Namespaces Functions Variables Groups Pages
MysqlSqlUtil Module

# MysqlSqlUtil Module Introduction

The MysqlSqlUtil module provides a high level API for working with MySQL database objects.

Usually this module is loaded on demand from the SqlUtil module, however to use this module directly, use `"%requires MysqlSqlUtil"` in your code.

All the public symbols in the module are defined in the MysqlSqlUtil namespace

Note
  This module requires the mysql binary module for communication with MySQL databases

# Schema Management on MySQL

## Type Mapping

Column types are mapped from Qore types as follows:

MySQL Column Type Mappings

Generic Type Name | Oracle Type Used
`float` | `double`
`number` | `decimal`
`string` | `varchar`
`date` | `datetime`
`binary` | `varbinary`
`bool` | `tinyint`
SqlUtil::BLOB | `mediumblob`
SqlUtil::CHAR | `char`
SqlUtil::CLOB | `mediumtext`
SqlUtil::NUMERIC | `decimal`
SqlUtil::VARCHAR | `varchar`

To use other types, use the `"native_type"` column description option with the native MySQL type name instead (under the `"driver"` and `"mysql"` keys for schemas supporting multiple databases).

## NOT NULL Constraints on MySQL

MySQL currently does not support firing "before insert" or "before update" triggers before constraints are checked, so in other databases where a trigger will set a default value for a column when a NULL is inserted, MySQL will raise an error if there is a NOT NULL constraint on the column.

# Release Notes

## MysqlSqlUtil v1.1

- corrected support for the `varbinary` type (bug 403)
- corrected support for the `binary` type (bug 524)
- `schema` member incorrectly set by AbstractDatasource::getUserName() instead of AbstractDatasource::getDBName() (bug 519)
- corrected support for datatypes `binary`, `char`, `varbinary`, `varchar`
- added support for `cop_cast` operator (feature 535)

## MysqlSqlUtil v1.0

- initial release