Fork me on GitHub

### Sections

- #### classes

  This section contains module classes API description.

- #### exports

  This section contains module exports, available when you call `require('mysql-libmysqlclient')`.

section

## Classes section

View source

### Description

This section contains module classes API description.

### Classes

- #### MysqlConnection

  MySQL connection class, base version

- #### MysqlConnectionHighlevel

  MySQL connection with only high-level methods

- #### MysqlConnectionQueued

  MySQL connection with queries queue

- #### MysqlResult

  MySQL results class

- #### MysqlStatement

  MySQL prepared statement class

class

## MysqlConnection

View source

### Description

MySQL connection class, base version

### Subclasses

- MysqlConnectionQueued

### Constructor

- new MysqlConnection

### Instance methods

- affectedRowsSync
- autoCommitSync
- changeUserSync
- closeSync
- commitSync
- connect
- connectedSync
- connectSync
- debugSync
- dumpDebugInfoSync
- errnoSync
- errorSync
- escapeSync
- fieldCountSync
- getCharsetNameSync
- getCharsetSync
- getClientInfoSync
- getInfoStringSync
- getInfoSync
- getWarningsSync
- initStatementSync
- initSync
- lastInsertIdSync
- multiMoreResultsSync
- multiNextResultSync
- multiRealQuerySync
- pingSync
- query
- querySend
- realConnectSync
- realQuerySync
- rollbackSync
- selectDbSync
- setCharsetSync
- setOptionSync
- setSslSync
- sqlStateSync
- statSync
- storeResultSync
- threadIdSync
- threadSafeSync
- useResultSync
- warningCountSync

### Instance properties

- connectErrno
- connectError

Aliased as:

- MysqlLibmysqlclient.bindings.MysqlConnection

constructor

## MysqlConnection.new

View source

- - new MysqlConnection()

Creates new MysqlConnection object

instance method

## MysqlConnection#affectedRowsSync

View source

- - MysqlConnection#affectedRowsSync()
  - - Integer

Gets number of affected rows in previous operation

instance method

## MysqlConnection#autoCommitSync

View source

- - MysqlConnection#autoCommitSync(mode)
  - - Boolean

- - mode
  - - Boolean

  - Mode flag

Sets autocommit mode

instance method

## MysqlConnection#changeUserSync

View source

- - MysqlConnection#changeUserSync(user[, password][, database])
  - - Boolean

- - user
  - - String

  - Username

- - password
  - - String

  - Password

- - database
  - - String

  - Database to use

Changes the user and causes the database to become the default

instance method

## MysqlConnection#closeSync

View source

- - MysqlConnection#closeSync()

Closes database connection

instance method

## MysqlConnection#commitSync

View source

- - MysqlConnection#commitSync()
  - - Boolean

Commits the current transaction

instance method

## MysqlConnection#connect

View source

- - MysqlConnection#connect([hostname][, user][, password][, database][, port][, socket], callback)

- - hostname
  - - String

  - Hostname

- - user
  - - String

  - Username

- - password
  - - String

  - Password

- - database
  - - String

  - Database to use

- - port
  - - Integer

  - Connection port

- - socket
  - - String

  - Connection socket

- - callback
  - - Function

  - Callback function, gets (error)

Connects to the MySQL server

instance method

## MysqlConnection#connectedSync

View source

- - MysqlConnection#connectedSync()
  - - Boolean

Returns current connected status

instance method

## MysqlConnection#connectSync

View source

- - MysqlConnection#connectSync([hostname][, user][, password][, database][, port][, socket])
  - - Boolean

- - hostname
  - - String

  - Hostname

- - user
  - - String

  - Username

- - password
  - - String

  - Password

- - database
  - - String

  - Database to use

- - port
  - - Integer

  - Connection port

- - socket
  - - String

  - Connection socket

Connects to the MySQL server

instance method

## MysqlConnection#debugSync

View source

- - MysqlConnection#debugSync(message)

- - message
  - - String

  - Debug message

Performs debug logging

instance method

## MysqlConnection#dumpDebugInfoSync

View source

- - MysqlConnection#dumpDebugInfoSync()
  - - Boolean

Dump debugging information into the log

instance method

## MysqlConnection#errnoSync

View source

- - MysqlConnection#errnoSync()
  - - Integer

Returns the last error code

instance method

## MysqlConnection#errorSync

View source

- - MysqlConnection#errorSync()
  - - String

Returns the last error message

instance method

## MysqlConnection#escapeSync

View source

- - MysqlConnection#escapeSync(string)
  - - String

- - string
  - - String

  - String to escape

Escapes special characters in a string for use in an SQL statement, taking into account the current charset of the connection

instance method

## MysqlConnection#fieldCountSync

View source

- - MysqlConnection#fieldCountSync()
  - - Integer

Returns the number of columns for the most recent query

instance method

## MysqlConnection#getCharsetNameSync

View source

- - MysqlConnection#getCharsetNameSync()
  - - String

Returns a character set name

instance method

## MysqlConnection#getCharsetSync

View source

- - MysqlConnection#getCharsetSync()
  - - Object

Returns a character set object

instance method

## MysqlConnection#getClientInfoSync

View source

- - MysqlConnection#getClientInfoSync()
  - - Object

Returns the MySQL client version and information

instance method

## MysqlConnection#getInfoStringSync

View source

- - MysqlConnection#getInfoStringSync()
  - - String

Retrieves information about the most recently executed query

instance method

## MysqlConnection#getInfoSync

View source

- - MysqlConnection#getInfoSync()
  - - Object

Returns the MySQL client, server, host and protocol version and information

instance method

## MysqlConnection#getWarningsSync

View source

- - MysqlConnection#getWarningsSync()
  - - Array

Gets result of SHOW WARNINGS

instance method

## MysqlConnection#initStatementSync

View source

- - MysqlConnection#initStatementSync()
  - - MysqlStatement
    - Boolean

Initializes a statement and returns it

instance method

## MysqlConnection#initSync

View source

- - MysqlConnection#initSync()
  - - Boolean

Initializes MysqlConnection

instance method

## MysqlConnection#lastInsertIdSync

View source

- - MysqlConnection#lastInsertIdSync()
  - - Integer

Returns the auto generated id used in the last query

instance method

## MysqlConnection#multiMoreResultsSync

View source

- - MysqlConnection#multiMoreResultsSync()
  - - Boolean

Checks if there are any more query results from a multi query

instance method

## MysqlConnection#multiNextResultSync

View source

- - MysqlConnection#multiNextResultSync()
  - - Boolean

Prepare next result from multi query

instance method

## MysqlConnection#multiRealQuerySync

View source

- - MysqlConnection#multiRealQuerySync(query)
  - - Boolean

- - query
  - - String

  - Query

Performs a multi query on the database

instance method

## MysqlConnection#pingSync

View source

- - MysqlConnection#pingSync()
  - - Boolean

Pings a server connection, or tries to reconnect if the connection has gone down

instance method

## MysqlConnection#query

View source

- - MysqlConnection#query(query, callback)

- - query
  - - String

  - Query

- - callback
  - - Function

  - Callback function, gets (error, result)

Performs a query on the database. Uses mysql_real_query.

instance method

## MysqlConnection#querySend

View source

- - MysqlConnection#querySend(query, callback)

- - query
  - - String

  - Query

- - callback
  - - Function

  - Callback function, gets (errro, result)

Performs a query on the database. Uses mysql_send_query. / Handle MysqlConnection::QuerySend(const Arguments& args) { HandleScope scope;

REQ_STR_ARG(0, query); OPTIONAL_FUN_ARG(1, callback);

MysqlConnection *conn = OBJUNWRAP(args.Holder());

MYSQLCONN_MUSTBE_CONNECTED;

query_request *query_req = new query_request;

unsigned int query_len = static_cast(query.length()); query_req->query = new char[query_len + 1];

// Copy query from V8 var to buffer memcpy(query_req->query, *query, query_len); query_req->query[query_len] = '\0';

query_req->callback = Persistent::New(callback); query_req->conn = conn; conn->Ref();

// Send query mysql_send_query(conn->_conn, query_req->query, query_len + 1);

// Init IO watcher NODE_ADDON_SHIM_START_IO_WATCH(query_req, EV_After_QuerySend, conn->_conn->net.fd, EV_READ)

return Undefined(); }

/** MysqlConnection#querySync(query) -> MysqlResult - query (String): Query

Performs a query on the database.

instance method

## MysqlConnection#realConnectSync

View source

- - MysqlConnection#realConnectSync([hostname][, user][, password][, database][, port][, socket])
  - - Boolean

- - hostname
  - - String

  - Hostname

- - user
  - - String

  - Username

- - password
  - - String

  - Password

- - database
  - - String

  - Database to use

- - port
  - - Integer

  - Connection port

- - socket
  - - String

  - Connection socket

Open a new connection to the MySQL server

instance method

## MysqlConnection#realQuerySync

View source

- - MysqlConnection#realQuerySync()
  - - Boolean

- - query
  - - String

  - Query

Executes an SQL query

instance method

## MysqlConnection#rollbackSync

View source

- - MysqlConnection#rollbackSync()
  - - Boolean

Rolls back current transaction

instance method

## MysqlConnection#selectDbSync

View source

- - MysqlConnection#selectDbSync(database)
  - - Boolean

- - database
  - - String

  - Database to use

Selects the default database for database queries

instance method

## MysqlConnection#setCharsetSync

View source

- - MysqlConnection#setCharsetSync()
  - - Boolean

- - charset
  - - String

  - Charset

Sets the default client character set

instance method

## MysqlConnection#setOptionSync

View source

- - MysqlConnection#setOptionSync(key, value)
  - - Boolean

- - key
  - - Integer

  - Option key

- - value
  - - Integer
    - String

  - Option value

Sets connection options

instance method

## MysqlConnection#setSslSync

View source

- - MysqlConnection#setSslSync()

Sets SSL options Used for establishing secure connections

- key (String): Key file
- cert (String): Certificate file
- ca (String): Certificate authority file
- capath(String): CA certificates in PEM directory
- cipher (String): Allowable ciphers

instance method

## MysqlConnection#sqlStateSync

View source

- - MysqlConnection#sqlStateSync()
  - - String

Returns the SQLSTATE error from previous MySQL operation

instance method

## MysqlConnection#statSync

View source

- - MysqlConnection#statSync()
  - - String

Gets the current system status

instance method

## MysqlConnection#storeResultSync

View source

- - MysqlConnection#storeResultSync()
  - - MysqlResult

Transfers a result set from the last query

instance method

## MysqlConnection#threadIdSync

View source

- - MysqlConnection#threadIdSync()
  - - Integer

Returns the thread ID for the current connection

instance method

## MysqlConnection#threadSafeSync

View source

- - MysqlConnection#threadSafeSync()
  - - Boolean

Returns whether thread safety is given or not

instance method

## MysqlConnection#useResultSync

View source

- - MysqlConnection#useResultSync()
  - - MysqlResult

Initiates a result set retrieval for the last query

instance method

## MysqlConnection#warningCountSync

View source

- - MysqlConnection#warningCountSync()
  - - Integer

Returns the number of warnings from the last query for the given link

instance property

## MysqlConnection#connectErrno

View source
read-only

- - MysqlConnection#connectErrno
  - - Integer

Gets last connect error number

instance property

## MysqlConnection#connectError

View source
read-only

- - MysqlConnection#connectError
  - - String

Gets last connect error string

class

## MysqlConnectionHighlevel

View source

### Description

MySQL connection with only high-level methods

### Superclass

MysqlConnectionQueued

### Instance methods

- query
- setQueryTypeSync

instance method

## MysqlConnectionHighlevel#query

View source

- - MysqlConnectionHighlevel#query(query[, callback])

Performs a query on the database

Uses mysql_real_query() or mysql_send_query() depends on this._queryType

instance method

## MysqlConnectionHighlevel#setQueryTypeSync

View source

- - MysqlConnectionHighlevel#setQueryTypeSync(queryType)

Sets this._queryType

class

## MysqlConnectionQueued

View source

### Description

MySQL connection with queries queue

### Superclass

MysqlConnection

### Subclasses

- MysqlConnectionHighlevel

### Instance methods

- connect
- query
- querySend

instance method

## MysqlConnectionQueued#connect

View source

- - MysqlConnectionQueued#connect(hostname[, user][, password][, database][, port][, socket][, callback])

Connects to the MySQL server

instance method

## MysqlConnectionQueued#query

View source

- - MysqlConnectionQueued#query(query[, callback])

Performs a query on the database

Uses mysql_real_query()

instance method

## MysqlConnectionQueued#querySend

View source

- - MysqlConnectionQueued#querySend(query[, callback])

Performs a query on the database

Uses mysql_send_query()

class

## MysqlResult

View source

### Description

MySQL results class

### Constructor

- new MysqlResult

### Instance methods

- dataSeekSync
- fetchAll
- fetchAllSync
- fetchArraySync
- fetchFieldDirectSync
- fetchFieldsSync
- fetchFieldSync
- fetchLengthsSync
- fetchObjectSync
- fieldSeekSync
- fieldTellSync
- freeSync
- numRowsSync

### Instance properties

- fieldCount

Aliased as:

- MysqlLibmysqlclient.bindings.MysqlResult

constructor

## MysqlResult.new

View source
internal

- - new MysqlResult()

Creates new MysqlResult object

instance method

## MysqlResult#dataSeekSync

View source

- - MysqlResult#dataSeekSync(offset)

- - offset
  - - Integer

  - The field offset

Adjusts the result pointer to an arbitrary row in the result

instance method

## MysqlResult#fetchAll

View source

- - MysqlResult#fetchAll(callback)
- - MysqlResult#fetchAll(options, callback)

- - options
  - - Boolean
    - Object

  - Fetch style options (optional)

- - callback
  - - Function

  - Callback function, gets (error, rows)

Fetches all result rows as an array

instance method

## MysqlResult#fetchAllSync

View source

- - MysqlResult#fetchAllSync([options])
  - - Array

- - options
  - - Boolean
    - Object

  - Fetch style options (optional)

Fetches all result rows as an array

instance method

## MysqlResult#fetchArraySync

View source

- - MysqlResult#fetchArraySync()
  - - Array

Fetch a result row as an array

instance method

## MysqlResult#fetchFieldDirectSync

View source

- - MysqlResult#fetchFieldDirectSync(fieldNum)
  - - Object

- - fieldNum
  - - Integer

  - Field number (starts from 0)

Returns metadata of the arbitrary field in the result set

instance method

## MysqlResult#fetchFieldsSync

View source

- - MysqlResult#fetchFieldsSync()
  - - Array

Returns an array of objects representing the fields in a result set

instance method

## MysqlResult#fetchFieldSync

View source

- - MysqlResult#fetchFieldSync()
  - - Object

Returns metadata of the next field in the result set

instance method

## MysqlResult#fetchLengthsSync

View source

- - MysqlResult#fetchLengthsSync()
  - - Array

Returns the lengths of the columns of the current row in the result set

instance method

## MysqlResult#fetchObjectSync

View source

- - MysqlResult#fetchObjectSync()
  - - Object

Fetch a result row as an object

instance method

## MysqlResult#fieldSeekSync

View source

- - MysqlResult#fieldSeekSync(fieldNumber)

- - fieldNumber
  - - Integer

  - Field number (starts from 0)

Set result pointer to a specified field offset

instance method

## MysqlResult#fieldTellSync

View source

- - MysqlResult#fieldTellSync()
  - - Integer

Returns the position of the field cursor

instance method

## MysqlResult#freeSync

View source

- - MysqlResult#freeSync()

Frees the memory associated with a result

instance method

## MysqlResult#numRowsSync

View source

- - MysqlResult#numRowsSync()
  - - Integer

Gets the number of rows in a result

instance property

## MysqlResult#fieldCount

View source
read-only

- - MysqlResult#fieldCount
  - - Integer
    - Undefined

Get the number of fields in a result

class

## MysqlStatement

View source

### Description

MySQL prepared statement class

### Constructor

- new MysqlStatement

### Instance methods

- affectedRowsSync
- attrGetSync
- attrSetSync
- bindParamsSync
- closeSync
- dataSeekSync
- errnoSync
- errorSync
- executeSync
- fetchAllSync
- fieldCountSync
- freeResultSync
- lastInsertIdSync
- numRowsSync
- prepareSync
- resetSync
- resultMetadataSync
- sendLongDataSync
- sqlStateSync
- storeResultSync

### Instance properties

- paramCount

Aliased as:

- MysqlLibmysqlclient.bindings.MysqlStatement

constructor

## MysqlStatement.new

View source
internal

- - new MysqlStatement()

Creates new MySQL prepared statement object

instance method

## MysqlStatement#affectedRowsSync

View source

- - MysqlStatement#affectedRowsSync()
  - - Integer

Returns the total number of rows changed, deleted, or inserted by the last executed statement

instance method

## MysqlStatement#attrGetSync

View source

- - MysqlStatement#attrGetSync(attr)
  - - Boolean
    - Integer

- - attr
  - - Integer

  - Attribute id

Used to get the current value of a statement attribute

instance method

## MysqlStatement#attrSetSync

View source

- - MysqlStatement#attrSetSync(attr, value)
  - - Boolean

- - attr
  - - Integer

  - Attribute id

- - value
  - - Boolean
    - Integer

  - Attribute value

Set the value of statement attribute. Used to modify the behavior of a prepared statement

instance method

## MysqlStatement#bindParamsSync

View source

- - MysqlStatement#bindParamsSync(params)
  - - Boolean

- - params
  - - Array

  - Parameters values to bind

Binds variables to a prepared statement as parameters

instance method

## MysqlStatement#closeSync

View source

- - MysqlStatement#closeSync()
  - - Boolean

Closes a prepared statement

instance method

## MysqlStatement#dataSeekSync

View source

- - MysqlStatement#dataSeekSync(offset)

- - offset
  - - Integer

  - Offset value

Seeks to an arbitrary row in statement result set

instance method

## MysqlStatement#errnoSync

View source

- - MysqlStatement#errnoSync()
  - - Integer

Returns the error code for the most recent statement call

instance method

## MysqlStatement#errorSync

View source

- - MysqlStatement#errorSync()
  - - String

Returns a string description for last statement error

instance method

## MysqlStatement#executeSync

View source

- - MysqlStatement#executeSync()
  - - Boolean

Executes a prepared query

instance method

## MysqlStatement#fetchAllSync

View source

- - MysqlStatement#fetchAllSync()
  - - Object

Returns row data from statement result

instance method

## MysqlStatement#fieldCountSync

View source

- - MysqlStatement#fieldCountSync()
  - - Integer

Returns the number of field in the given statement

instance method

## MysqlStatement#freeResultSync

View source

- - MysqlStatement#freeResultSync()
  - - Boolean

Frees stored result memory for the given statement handle

instance method

## MysqlStatement#lastInsertIdSync

View source

- - MysqlStatement#lastInsertIdSync()
  - - Integer

Get the ID generated from the previous INSERT operation

instance method

## MysqlStatement#numRowsSync

View source

- - MysqlStatement#numRowsSync()
  - - Integer

Return the number of rows in statements result set

instance method

## MysqlStatement#prepareSync

View source

- - MysqlStatement#prepareSync(query)
  - - Boolean

- - query
  - - String

  - Query for prepare

Prepare statement by given query

instance method

## MysqlStatement#resetSync

View source

- - MysqlStatement#resetSync()
  - - Boolean

Resets a prepared statement

instance method

## MysqlStatement#resultMetadataSync

View source

- - MysqlStatement#resultMetadataSync()
  - - MysqlResult

Returns result set metadata from a prepared statement

instance method

## MysqlStatement#sendLongDataSync

View source

- - MysqlStatement#sendLongDataSync(parameterNumber, data)
  - - Boolean

- - parameterNumber
  - - Integer

  - Parameter number, beginning with 0

- - data
  - - String

  - Data

Send parameter data to the server in blocks (or "chunks")

instance method

## MysqlStatement#sqlStateSync

View source

- - MysqlStatement#sqlStateSync()
  - - String

Returns SQLSTATE error from previous statement operation

instance method

## MysqlStatement#storeResultSync

View source

- - MysqlStatement#storeResultSync()
  - - Boolean

Transfers a result set from a prepared statement

instance property

## MysqlStatement#paramCount

View source
read-only

- - MysqlStatement#paramCount
  - - Integer

Returns the number of parameter for the given statement

section

## Exports section

View source

### Description

This section contains module exports, available when you call `require('mysql-libmysqlclient')`.

### Namespaces

- #### MysqlLibmysqlclient

  Asynchronous MySQL bindings for Node.js

namespace

## MysqlLibmysqlclient

View source

### Description

Asynchronous MySQL bindings for Node.js

### Namespaces

- #### MysqlLibmysqlclient.bindings

  `mysql-libmysqlclient` module bindings

### Class methods

- createConnection
- createConnectionHighlevel
- createConnectionHighlevelSync
- createConnectionQueued
- createConnectionQueuedSync
- createConnectionSync

namespace

## MysqlLibmysqlclient.bindings

View source

### Description

`mysql-libmysqlclient` module bindings

### Classes

- #### MysqlLibmysqlclient.bindings.MysqlConnection

- #### MysqlLibmysqlclient.bindings.MysqlResult

- #### MysqlLibmysqlclient.bindings.MysqlStatement

class

## MysqlLibmysqlclient.bindings.MysqlConnection

View source
Alias of:

- MysqlConnection

class

## MysqlLibmysqlclient.bindings.MysqlResult

View source
Alias of:

- MysqlResult

class

## MysqlLibmysqlclient.bindings.MysqlStatement

View source
Alias of:

- MysqlStatement

class method

## MysqlLibmysqlclient.createConnection

View source

- - MysqlLibmysqlclient.createConnection(hostname[, user][, password][, database][, port][, socket][, callback])

Creates connection to database

Asynchronous version

class method

## MysqlLibmysqlclient.createConnectionHighlevel

View source

- - MysqlLibmysqlclient.createConnectionHighlevel(hostname[, user][, password][, database][, port][, socket][, callback])

Creates high-level connection to database

Asynchronous version

class method

## MysqlLibmysqlclient.createConnectionHighlevelSync

View source

- - MysqlLibmysqlclient.createConnectionHighlevelSync(hostname[, user][, password][, database][, port][, socket])
  - - MysqlConnectionHighlevel

Creates high-level connection to database

Synchronous version

class method

## MysqlLibmysqlclient.createConnectionQueued

View source

- - MysqlLibmysqlclient.createConnectionQueued(hostname[, user][, password][, database][, port][, socket][, callback])

Creates queued connection to database

Asynchronous version

class method

## MysqlLibmysqlclient.createConnectionQueuedSync

View source

- - MysqlLibmysqlclient.createConnectionQueuedSync(hostname[, user][, password][, database][, port][, socket])
  - - MysqlConnectionQueued

Creates queued connection to database

Synchronous version

class method

## MysqlLibmysqlclient.createConnectionSync

View source

- - MysqlLibmysqlclient.createConnectionSync(hostname[, user][, password][, database][, port][, socket])
  - - MysqlConnection

Creates connection to database

Synchronous version