mysqli/Readme.md

58 lines
1.3 KiB
Markdown
Raw Permalink Normal View History

2017-02-28 18:27:38 +08:00
![module info](https://nodei.co/npm/mysqli.png?downloads=true&downloadRank=true&stars=true)
2021-08-23 19:25:20 +08:00
[中文说明](./Readme_CN.md)
2017-12-14 16:36:39 +08:00
# mysqli
2017-02-28 18:27:38 +08:00
2021-08-23 19:25:20 +08:00
> This module is based on the `node-mysql` module and converts the SQL syntax to the API similar to MongoDB. Some simple APIs is provided for commonly used additions, deletions, and changes, and xss injection, which is very friendly to novices.
2017-02-28 18:27:38 +08:00
2021-08-23 19:25:20 +08:00
## installation
2017-02-28 18:27:38 +08:00
```bash
2021-08-23 19:25:20 +08:00
# 3.x recommend
2018-05-29 19:02:33 +08:00
npm i mysqli
# or
npm i mysqli@3.x
2021-08-23 19:25:20 +08:00
# 2.x old version
2018-05-29 19:02:33 +08:00
npm i mysqli@2.x
2017-02-28 18:27:38 +08:00
```
2021-08-23 19:25:20 +08:00
## Quick Start
> One or more configurations can be passed in for instantiation. When there is only one database, the default is the `master library`; when there is more than one database service, the first one is automatically used as the `master library`, and the other `slave libraries`. so, `pay attention to the order` when using.
2017-02-28 18:27:38 +08:00
```javascript
let Mysqli = require('mysqli')
2021-08-23 19:25:20 +08:00
// one config
2017-02-28 18:27:38 +08:00
let conn = new Mysqli({
2021-08-23 19:25:20 +08:00
host: '', // IP/domain
post: 3306, //port, default 3306
user: '', // username
passwd: '', // password
charset: '', // CHARSET of database, default to utf8 【optional】
db: '' // the default database name 【optional】
2017-12-14 16:36:39 +08:00
})
2017-02-28 18:27:38 +08:00
2021-08-23 19:25:20 +08:00
// two or more configs
2017-02-28 18:27:38 +08:00
let conn = new Mysqli([
2017-12-14 16:36:39 +08:00
{
2021-08-23 19:25:20 +08:00
host: 'host1', //
...
2017-12-14 16:36:39 +08:00
},
{
2021-08-23 19:25:20 +08:00
host: 'host2', //
...
},
...
2017-12-14 16:36:39 +08:00
])
2017-02-28 18:27:38 +08:00
```
2021-08-23 19:25:20 +08:00
## Document
* [v3.x](docs/3.x.md)
2021-08-23 19:27:09 +08:00
* [v2.x](docs/2.x.md) 👎 Deprecated