# Mysql
# Classes
-
数据库链接对象
-
mysql数据库访问对象
# Functions
-
初始化全局MySql对象
connect(transaction) ⇒
Connection连接数据库
-
连接数据库并开启事务。
query(sql, logsql) ⇒
any连接数据库,执行一次SQL查询,并自动释放连接。
page(sql, page, size) ⇒
any连接数据库,执行一次分页查询,并自动释放连接。
# Connection
数据库链接对象
Kind: global class
# connection.query(sql, logsql) ⇒ any
执行一次sql查询
Kind: instance method of Connection Returns: any - 查询结果集
| Param | Type | Default | Description |
|---|---|---|---|
| sql | string | SQL语句 | |
| logsql | boolean | true | 是否打印SQL语句 |
# connection.page(sql, page, size) ⇒ any
执行一次分页查询
Kind: instance method of Connection Returns: any - 查询结果集
| Param | Type | Description |
|---|---|---|
| sql | string | SQL语句 |
| page | number | 当前页码,从1开始。 |
| size | number | 每页的数据条数 |
# connection.transaction()
开启事务
Kind: instance method of Connection
# connection.commit()
提交事务
Kind: instance method of Connection
# connection.rollback()
回滚事务
Kind: instance method of Connection
# connection.release()
释放连接
Kind: instance method of Connection
# MySql
mysql数据库访问对象
Kind: global class
# mySql.init()
构造器
Kind: instance method of MySql
# mySql.connect(transaction) ⇒ Connection
连接数据库
Kind: instance method of MySql Returns: Connection - 数据库连接对象
| Param | Type | Default | Description |
|---|---|---|---|
| transaction | boolean | false | 开启事务 |
# mySql.transaction()
连接数据库并开启事务。
Kind: instance method of MySql
# mySql.query(sql, logsql) ⇒ any
连接数据库,执行一次SQL查询,并自动释放连接。
Kind: instance method of MySql Returns: any - 查询结果集
| Param | Type | Default | Description |
|---|---|---|---|
| sql | string | SQL语句 | |
| logsql | boolean | true | 是否打印SQL语句 |
# mySql.page(sql, page, size) ⇒ any
连接数据库,执行一次分页查询,并自动释放连接。
Kind: instance method of MySql Returns: any - 查询结果集
| Param | Type | Description |
|---|---|---|
| sql | string | SQL语句 |
| page | number | 当前页码,从1开始。 |
| size | number | 每页的数据条数 |
# init()
初始化全局MySql对象
# connect(transaction) ⇒ Connection
连接数据库
Kind: global function Returns: Connection - 数据库连接对象
| Param | Type | Description |
|---|---|---|
| transaction | boolean | 开启事务 |
# transaction()
连接数据库并开启事务。
# query(sql, logsql) ⇒ any
连接数据库,执行一次SQL查询,并自动释放连接。
Kind: global function Returns: any - 查询结果集
| Param | Type | Description |
|---|---|---|
| sql | string | SQL语句 |
| logsql | boolean | 是否打印SQL语句 |
# page(sql, page, size) ⇒ any
连接数据库,执行一次分页查询,并自动释放连接。
Kind: global function Returns: any - 查询结果集
| Param | Type | Description |
|---|---|---|
| sql | string | SQL语句 |
| page | number | 当前页码,从1开始。 |
| size | number | 每页的数据条数 |