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

Description

This section contains module classes API description.

Classes

class

MysqlConnection

Description

MySQL connection class, base version

Instance properties

constructor

MysqlConnection.new

    • new MysqlConnection()

Creates new MysqlConnection object

instance method

MysqlConnection#affectedRowsSync

    • MysqlConnection#affectedRowsSync()
      • Integer

Gets number of affected rows in previous operation

instance method

MysqlConnection#autoCommitSync

    • MysqlConnection#autoCommitSync(mode)
      • Boolean
    • mode
      • Boolean
    • Mode flag

Sets autocommit mode

instance method

MysqlConnection#changeUserSync

    • 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

    • MysqlConnection#closeSync()

Closes database connection

instance method

MysqlConnection#commitSync

    • MysqlConnection#commitSync()
      • Boolean

Commits the current transaction

instance method

MysqlConnection#connect

    • 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

    • MysqlConnection#connectedSync()
      • Boolean

Returns current connected status

instance method

MysqlConnection#connectSync

    • 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

    • MysqlConnection#debugSync(message)
    • message
      • String
    • Debug message

Performs debug logging

instance method

MysqlConnection#dumpDebugInfoSync

    • MysqlConnection#dumpDebugInfoSync()
      • Boolean

Dump debugging information into the log

instance method

MysqlConnection#errnoSync

    • MysqlConnection#errnoSync()
      • Integer

Returns the last error code

instance method

MysqlConnection#errorSync

    • MysqlConnection#errorSync()
      • String

Returns the last error message

instance method

MysqlConnection#escapeSync

    • 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

    • MysqlConnection#fieldCountSync()
      • Integer

Returns the number of columns for the most recent query

instance method

MysqlConnection#getCharsetNameSync

    • MysqlConnection#getCharsetNameSync()
      • String

Returns a character set name

instance method

MysqlConnection#getCharsetSync

    • MysqlConnection#getCharsetSync()
      • Object

Returns a character set object

instance method

MysqlConnection#getClientInfoSync

    • MysqlConnection#getClientInfoSync()
      • Object

Returns the MySQL client version and information

instance method

MysqlConnection#getInfoStringSync

    • MysqlConnection#getInfoStringSync()
      • String

Retrieves information about the most recently executed query

instance method

MysqlConnection#getInfoSync

    • MysqlConnection#getInfoSync()
      • Object

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

instance method

MysqlConnection#getWarningsSync

    • MysqlConnection#getWarningsSync()
      • Array

Gets result of SHOW WARNINGS

instance method

MysqlConnection#initStatementSync

Initializes a statement and returns it

instance method

MysqlConnection#initSync

    • MysqlConnection#initSync()
      • Boolean

Initializes MysqlConnection

instance method

MysqlConnection#lastInsertIdSync

    • MysqlConnection#lastInsertIdSync()
      • Integer

Returns the auto generated id used in the last query

instance method

MysqlConnection#multiMoreResultsSync

    • MysqlConnection#multiMoreResultsSync()
      • Boolean

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

instance method

MysqlConnection#multiNextResultSync

    • MysqlConnection#multiNextResultSync()
      • Boolean

Prepare next result from multi query

instance method

MysqlConnection#multiRealQuerySync

    • MysqlConnection#multiRealQuerySync(query)
      • Boolean
    • query
      • String
    • Query

Performs a multi query on the database

instance method

MysqlConnection#pingSync

    • MysqlConnection#pingSync()
      • Boolean

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

instance method

MysqlConnection#query

    • 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

    • 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

    • 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

    • MysqlConnection#realQuerySync()
      • Boolean
    • query
      • String
    • Query

Executes an SQL query

instance method

MysqlConnection#rollbackSync

    • MysqlConnection#rollbackSync()
      • Boolean

Rolls back current transaction

instance method

MysqlConnection#selectDbSync

    • MysqlConnection#selectDbSync(database)
      • Boolean
    • database
      • String
    • Database to use

Selects the default database for database queries

instance method

MysqlConnection#setCharsetSync

    • MysqlConnection#setCharsetSync()
      • Boolean
    • charset
      • String
    • Charset

Sets the default client character set

instance method

MysqlConnection#setOptionSync

    • MysqlConnection#setOptionSync(key, value)
      • Boolean
    • key
      • Integer
    • Option key

    • value
      • Integer
      • String
    • Option value

Sets connection options

instance method

MysqlConnection#setSslSync

    • 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

    • MysqlConnection#sqlStateSync()
      • String

Returns the SQLSTATE error from previous MySQL operation

instance method

MysqlConnection#statSync

    • MysqlConnection#statSync()
      • String

Gets the current system status

instance method

MysqlConnection#storeResultSync

Transfers a result set from the last query

instance method

MysqlConnection#threadIdSync

    • MysqlConnection#threadIdSync()
      • Integer

Returns the thread ID for the current connection

instance method

MysqlConnection#threadSafeSync

    • MysqlConnection#threadSafeSync()
      • Boolean

Returns whether thread safety is given or not

instance method

MysqlConnection#useResultSync

Initiates a result set retrieval for the last query

instance method

MysqlConnection#warningCountSync

    • MysqlConnection#warningCountSync()
      • Integer

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

instance property

MysqlConnection#connectErrno

read-only
    • MysqlConnection#connectErrno
      • Integer

Gets last connect error number

instance property

MysqlConnection#connectError

read-only
    • MysqlConnection#connectError
      • String

Gets last connect error string

class

MysqlConnectionHighlevel

Description

MySQL connection with only high-level methods

Instance methods

instance method

MysqlConnectionHighlevel#query

    • 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

    • MysqlConnectionHighlevel#setQueryTypeSync(queryType)

Sets this._queryType

class

MysqlConnectionQueued

Description

MySQL connection with queries queue

Superclass

Instance methods

instance method

MysqlConnectionQueued#connect

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

Connects to the MySQL server

instance method

MysqlConnectionQueued#query

    • MysqlConnectionQueued#query(query[, callback])

Performs a query on the database

Uses mysql_real_query()

instance method

MysqlConnectionQueued#querySend

    • MysqlConnectionQueued#querySend(query[, callback])

Performs a query on the database

Uses mysql_send_query()

class

MysqlResult

Description

MySQL results class

Constructor

Instance properties

constructor

MysqlResult.new

internal
    • new MysqlResult()

Creates new MysqlResult object

instance method

MysqlResult#dataSeekSync

    • MysqlResult#dataSeekSync(offset)
    • offset
      • Integer
    • The field offset

Adjusts the result pointer to an arbitrary row in the result

instance method

MysqlResult#fetchAll

    • 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

    • MysqlResult#fetchAllSync([options])
      • Array
    • options
      • Boolean
      • Object
    • Fetch style options (optional)

Fetches all result rows as an array

instance method

MysqlResult#fetchArraySync

    • MysqlResult#fetchArraySync()
      • Array

Fetch a result row as an array

instance method

MysqlResult#fetchFieldDirectSync

    • 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

    • MysqlResult#fetchFieldsSync()
      • Array

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

instance method

MysqlResult#fetchFieldSync

    • MysqlResult#fetchFieldSync()
      • Object

Returns metadata of the next field in the result set

instance method

MysqlResult#fetchLengthsSync

    • MysqlResult#fetchLengthsSync()
      • Array

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

instance method

MysqlResult#fetchObjectSync

    • MysqlResult#fetchObjectSync()
      • Object

Fetch a result row as an object

instance method

MysqlResult#fieldSeekSync

    • MysqlResult#fieldSeekSync(fieldNumber)
    • fieldNumber
      • Integer
    • Field number (starts from 0)

Set result pointer to a specified field offset

instance method

MysqlResult#fieldTellSync

    • MysqlResult#fieldTellSync()
      • Integer

Returns the position of the field cursor

instance method

MysqlResult#freeSync

    • MysqlResult#freeSync()

Frees the memory associated with a result

instance method

MysqlResult#numRowsSync

    • MysqlResult#numRowsSync()
      • Integer

Gets the number of rows in a result

instance property

MysqlResult#fieldCount

read-only
    • MysqlResult#fieldCount
      • Integer
      • Undefined

Get the number of fields in a result

class

MysqlStatement

Description

MySQL prepared statement class

Instance properties

constructor

MysqlStatement.new

internal
    • new MysqlStatement()

Creates new MySQL prepared statement object

instance method

MysqlStatement#affectedRowsSync

    • MysqlStatement#affectedRowsSync()
      • Integer

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

instance method

MysqlStatement#attrGetSync

    • MysqlStatement#attrGetSync(attr)
      • Boolean
      • Integer
    • attr
      • Integer
    • Attribute id

Used to get the current value of a statement attribute

instance method

MysqlStatement#attrSetSync

    • 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

    • MysqlStatement#bindParamsSync(params)
      • Boolean
    • params
      • Array
    • Parameters values to bind

Binds variables to a prepared statement as parameters

instance method

MysqlStatement#closeSync

    • MysqlStatement#closeSync()
      • Boolean

Closes a prepared statement

instance method

MysqlStatement#dataSeekSync

    • MysqlStatement#dataSeekSync(offset)
    • offset
      • Integer
    • Offset value

Seeks to an arbitrary row in statement result set

instance method

MysqlStatement#errnoSync

    • MysqlStatement#errnoSync()
      • Integer

Returns the error code for the most recent statement call

instance method

MysqlStatement#errorSync

    • MysqlStatement#errorSync()
      • String

Returns a string description for last statement error

instance method

MysqlStatement#executeSync

    • MysqlStatement#executeSync()
      • Boolean

Executes a prepared query

instance method

MysqlStatement#fetchAllSync

    • MysqlStatement#fetchAllSync()
      • Object

Returns row data from statement result

instance method

MysqlStatement#fieldCountSync

    • MysqlStatement#fieldCountSync()
      • Integer

Returns the number of field in the given statement

instance method

MysqlStatement#freeResultSync

    • MysqlStatement#freeResultSync()
      • Boolean

Frees stored result memory for the given statement handle

instance method

MysqlStatement#lastInsertIdSync

    • MysqlStatement#lastInsertIdSync()
      • Integer

Get the ID generated from the previous INSERT operation

instance method

MysqlStatement#numRowsSync

    • MysqlStatement#numRowsSync()
      • Integer

Return the number of rows in statements result set

instance method

MysqlStatement#prepareSync

    • MysqlStatement#prepareSync(query)
      • Boolean
    • query
      • String
    • Query for prepare

Prepare statement by given query

instance method

MysqlStatement#resetSync

    • MysqlStatement#resetSync()
      • Boolean

Resets a prepared statement

instance method

MysqlStatement#resultMetadataSync

Returns result set metadata from a prepared statement

instance method

MysqlStatement#sendLongDataSync

    • 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

    • MysqlStatement#sqlStateSync()
      • String

Returns SQLSTATE error from previous statement operation

instance method

MysqlStatement#storeResultSync

    • MysqlStatement#storeResultSync()
      • Boolean

Transfers a result set from a prepared statement

instance property

MysqlStatement#paramCount

read-only
    • MysqlStatement#paramCount
      • Integer

Returns the number of parameter for the given statement

section

Exports section

Description

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

Namespaces

namespace

MysqlLibmysqlclient

Description

Asynchronous MySQL bindings for Node.js

Namespaces

namespace

MysqlLibmysqlclient.bindings

Description

mysql-libmysqlclient module bindings

class

MysqlLibmysqlclient.bindings.MysqlConnection

class

MysqlLibmysqlclient.bindings.MysqlResult

Alias of:
class

MysqlLibmysqlclient.bindings.MysqlStatement

class method

MysqlLibmysqlclient.createConnection

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

Creates connection to database

Asynchronous version

class method

MysqlLibmysqlclient.createConnectionHighlevel

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

Creates high-level connection to database

Asynchronous version

class method

MysqlLibmysqlclient.createConnectionHighlevelSync

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

Creates high-level connection to database

Synchronous version

class method

MysqlLibmysqlclient.createConnectionQueued

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

Creates queued connection to database

Asynchronous version

class method

MysqlLibmysqlclient.createConnectionQueuedSync

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

Creates queued connection to database

Synchronous version

class method

MysqlLibmysqlclient.createConnectionSync

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

Creates connection to database

Synchronous version