com.caucho.quercus.lib.db
Class Mysqli

java.lang.Object
  extended by com.caucho.quercus.lib.db.JdbcConnectionResource
      extended by com.caucho.quercus.lib.db.Mysqli
All Implemented Interfaces:
EnvCleanup
Direct Known Subclasses:
MysqliResource

public class Mysqli
extends JdbcConnectionResource

mysqli object oriented API facade


Nested Class Summary
static class Mysqli.LastSqlType
           
 
Nested classes/interfaces inherited from class com.caucho.quercus.lib.db.JdbcConnectionResource
JdbcConnectionResource.SqlParseToken
 
Field Summary
protected static java.lang.String DRIVER
           
 
Fields inherited from class com.caucho.quercus.lib.db.JdbcConnectionResource
_conn, _driver, _flags, _host, _port, _socket, _sqlParseToken, _url, ENCODING
 
Constructor Summary
protected Mysqli(Env env)
           
  Mysqli(Env env, StringValue host, StringValue user, StringValue password, java.lang.String db, int port, StringValue socket)
          This is the constructor for the mysqli class.
 
Method Summary
 int affected_rows()
          returns the number of affected rows.
 boolean autocommit(boolean isAutoCommit)
          sets the autocommit mode
 boolean change_user(java.lang.String user, java.lang.String password, java.lang.String db)
          Changes the user and database
 StringValue character_set_name(Env env)
          Returns the client encoding.
 StringValue client_encoding(Env env)
          Alias for character_set_name
 boolean close(Env env)
          Closes the connection.
protected  ConnectionEntry connectImpl(Env env, java.lang.String host, java.lang.String userName, java.lang.String password, java.lang.String dbname, int port, java.lang.String socket, int flags, java.lang.String driver, java.lang.String url, boolean isNewLink)
          Connects to the underlying database.
protected  JdbcResultResource createResult(Env env, java.sql.Statement stmt, java.sql.ResultSet rs)
          Creates a database-specific result.
 int errno()
          Returns the error code for the most recent function call
 StringValue escape_string(StringValue str)
          Escapes the string
 int field_count()
          Returns the number of columns in the last query.
 Value get_dbname(Env env)
          Returns the database name.
 StringValue get_host_info(Env env)
          Returns the host information.
 StringValue get_host_name(Env env)
          Returns the host name.
 int get_port_number()
          Returns the port number.
 int get_proto_info()
          Returns the protocol information.
 StringValue get_server_info(Env env)
          Returns the server information.
 int get_server_version()
          Returns the server information.
 int getaffected_rows()
          Quercus function to get the field 'affected_rows'.
 StringValue getclient_info(Env env)
          Quercus function to get the field 'client_info'.
 int getclient_version(Env env)
          Quercus function to get the field 'client_version'.
 int geterrno()
          Quercus function to get the field 'errno'.
 StringValue geterror(Env env)
          Quercus function to get the field 'error'.
 int getfield_count()
          Quercus function to get the field 'field_count'.
 StringValue gethost_info(Env env)
          Quercus function to get the field 'host_info'.
 Value getinfo(Env env)
          Quercus function to get the field 'info'.
 Value getinsert_id(Env env)
          Quercus function to get the field 'insert_id'.
 int getprotocol_version()
          Quercus function to get the field 'protocol_version'.
 StringValue getserver_info(Env env)
          Quercus function to get the field 'server_info'.
 int getserver_version()
          Quercus function to get the field 'server_version'.
 StringValue getsqlstate(Env env)
          Quercus function to get the field 'sqlstate'.
 Value getthread_id(Env env)
          Quercus function to get the field 'thread_id'.
protected static java.lang.String getUrl(java.lang.String host, int port, java.lang.String dbname, java.lang.String encoding, boolean useInteractive, boolean useCompression, boolean useSsl)
           
 int getwarning_count(Env env)
          Quercus function to get the field 'warning_count'.
 Value insert_id(Env env)
          returns ID generated for an AUTO_INCREMENT column by the previous INSERT query on success, 0 if the previous query does not generate an AUTO_INCREMENT value, or FALSE if no MySQL connection was established
 boolean isLastSqlDescribe()
           
 boolean kill(Env env, int threadId)
          Kills the given mysql thread id.
 JdbcResultResource list_dbs()
           
protected  MysqliResult metaQuery(Env env, java.lang.String sql, java.lang.String catalog)
          Used by the various mysqli functions to query the database for metadata about the resultset which is not in ResultSetMetaData.
 boolean more_results()
          Check for more results in a multi-query
 boolean multi_query(Env env, StringValue query)
          executes one or multiple queries which are concatenated by a semicolon.
 boolean next_result()
          prepares next result set from a previous call to mysqli_multi_query
 boolean options(int option, Value value)
          Sets a mysqli option.
 MysqliStatement prepare(Env env, StringValue query)
          returns a prepared statement or null on error.
 Value query(Env env, StringValue sqlV, int resultMode)
          Executes a query.
 boolean real_connect(Env env, StringValue host, StringValue userName, StringValue password, StringValue dbname, int port, StringValue socket, int flags)
          Connects to the underlying database.
 StringValue real_escape_string(StringValue str)
          Escapes the string
 boolean real_query(Env env, StringValue query)
          Execute an single query against the database whose result can then be retrieved or stored using the mysqli_store_result() or mysqli_use_result() functions.
protected  Value realQuery(Env env, java.lang.String sql)
          Intercept Mysql specific query before sending to JDBC driver to handle any special cases.
 boolean rollback()
          Rolls the current transaction back.
 boolean select_db(java.lang.String db)
          Selects the underlying database/catalog to use.
 boolean set_charset(java.lang.String charset)
          Sets the character set
 boolean set_opt(int option, Value value)
          Sets a mysqli option
 void setPersistent()
           
 StringValue sqlstate(Env env)
          Returns the SQLSTATE error
 Value stat(Env env)
          returns a string with the status of the connection or FALSE if error
 MysqliStatement stmt_init(Env env)
          returns a statement for use with mysqli_stmt_prepare
 JdbcResultResource store_result(Env env)
          Transfers the result set from the last query on the database connection represented by conn.
 boolean thread_safe()
          Returns true for thread_safe
 java.lang.String toString()
          Converts to a string.
 JdbcResultResource use_result(Env env)
          Transfers the result set from the last query on the database connection represented by conn.
 int warning_count(Env env)
          returns the number of warnings from the last query in the connection object.
 
Methods inherited from class com.caucho.quercus.lib.db.JdbcConnectionResource
cleanup, clearErrors, closeStatement, commit, connectInternal, error, getAffectedRows, getCatalog, getCatalogs, getCharacterSetName, getClientEncoding, getClientInfo, getConnection, getDbName, getDriver, getEnv, getErrorCode, getErrorMessage, getFieldCount, getHost, getHostInfo, getJavaConnection, getPassword, getPort, getResultResource, getServerInfo, getTableMetaData, getUrl, getURL, getUserName, getWarnings, isConnected, isSeekable, keepResourceValues, keepStatementOpen, parseSqlToken, ping, realEscapeString, saveErrors, setAffectedRows, setAutoCommit, setCatalog, setClientEncoding, setResultResource, setWarnings, toObject, validateConnection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DRIVER

protected static final java.lang.String DRIVER
See Also:
Constant Field Values
Constructor Detail

Mysqli

public Mysqli(Env env,
              StringValue host,
              StringValue user,
              StringValue password,
              java.lang.String db,
              int port,
              StringValue socket)
This is the constructor for the mysqli class. It can be invoked by PHP or and by Java code.


Mysqli

protected Mysqli(Env env)
Method Detail

isLastSqlDescribe

public boolean isLastSqlDescribe()

connectImpl

protected ConnectionEntry connectImpl(Env env,
                                      java.lang.String host,
                                      java.lang.String userName,
                                      java.lang.String password,
                                      java.lang.String dbname,
                                      int port,
                                      java.lang.String socket,
                                      int flags,
                                      java.lang.String driver,
                                      java.lang.String url,
                                      boolean isNewLink)
Connects to the underlying database.

Specified by:
connectImpl in class JdbcConnectionResource

getUrl

protected static java.lang.String getUrl(java.lang.String host,
                                         int port,
                                         java.lang.String dbname,
                                         java.lang.String encoding,
                                         boolean useInteractive,
                                         boolean useCompression,
                                         boolean useSsl)

getaffected_rows

public int getaffected_rows()
Quercus function to get the field 'affected_rows'.


affected_rows

public int affected_rows()
returns the number of affected rows.


autocommit

public boolean autocommit(boolean isAutoCommit)
sets the autocommit mode


change_user

public boolean change_user(java.lang.String user,
                           java.lang.String password,
                           java.lang.String db)
Changes the user and database

Parameters:
user - the new user
password - the new password
db - the new database

character_set_name

public StringValue character_set_name(Env env)
Returns the client encoding. XXX: stubbed out. has to be revised once we figure out what to do with character encoding


client_encoding

public StringValue client_encoding(Env env)
Alias for character_set_name


geterrno

public int geterrno()
Quercus function to get the field 'errno'.


errno

public int errno()
Returns the error code for the most recent function call


geterror

public StringValue geterror(Env env)
Quercus function to get the field 'error'.


escape_string

public StringValue escape_string(StringValue str)
Escapes the string


getclient_info

public StringValue getclient_info(Env env)
Quercus function to get the field 'client_info'.


getclient_version

public int getclient_version(Env env)
Quercus function to get the field 'client_version'.


get_dbname

public Value get_dbname(Env env)
Returns the database name.


gethost_info

public StringValue gethost_info(Env env)
Quercus function to get the field 'host_info'.


get_host_info

public StringValue get_host_info(Env env)
Returns the host information.


get_host_name

public StringValue get_host_name(Env env)
Returns the host name.


getinfo

public Value getinfo(Env env)
Quercus function to get the field 'info'.


get_port_number

public int get_port_number()
Returns the port number.


getprotocol_version

public int getprotocol_version()
Quercus function to get the field 'protocol_version'.


get_proto_info

public int get_proto_info()
Returns the protocol information.


getserver_info

public StringValue getserver_info(Env env)
Quercus function to get the field 'server_info'.


get_server_info

public StringValue get_server_info(Env env)
Returns the server information.


getserver_version

public int getserver_version()
Quercus function to get the field 'server_version'.


get_server_version

public int get_server_version()
Returns the server information.


getfield_count

public int getfield_count()
Quercus function to get the field 'field_count'.


field_count

public int field_count()
Returns the number of columns in the last query.


getinsert_id

public Value getinsert_id(Env env)
Quercus function to get the field 'insert_id'.


insert_id

public Value insert_id(Env env)
returns ID generated for an AUTO_INCREMENT column by the previous INSERT query on success, 0 if the previous query does not generate an AUTO_INCREMENT value, or FALSE if no MySQL connection was established


list_dbs

public JdbcResultResource list_dbs()

more_results

public boolean more_results()
Check for more results in a multi-query


multi_query

public boolean multi_query(Env env,
                           StringValue query)
executes one or multiple queries which are concatenated by a semicolon.


next_result

public boolean next_result()
prepares next result set from a previous call to mysqli_multi_query


options

public boolean options(int option,
                       Value value)
Sets a mysqli option.


query

public Value query(Env env,
                   StringValue sqlV,
                   int resultMode)
Executes a query.

Parameters:
env - the PHP executing environment
sql - the escaped query string (can contain escape sequences like `\n' and `\Z')
resultMode - ignored
Returns:
a JdbcResultResource, or null for failure

realQuery

protected Value realQuery(Env env,
                          java.lang.String sql)
Intercept Mysql specific query before sending to JDBC driver to handle any special cases.

Overrides:
realQuery in class JdbcConnectionResource

real_query

public boolean real_query(Env env,
                          StringValue query)
Execute an single query against the database whose result can then be retrieved or stored using the mysqli_store_result() or mysqli_use_result() functions.

Parameters:
env - the PHP executing environment
query - the escaped query string (can contain escape sequences like `\n' and `\Z')

prepare

public MysqliStatement prepare(Env env,
                               StringValue query)
returns a prepared statement or null on error.


real_connect

public boolean real_connect(Env env,
                            StringValue host,
                            StringValue userName,
                            StringValue password,
                            StringValue dbname,
                            int port,
                            StringValue socket,
                            int flags)
Connects to the underlying database.


real_escape_string

public StringValue real_escape_string(StringValue str)
Escapes the string


rollback

public boolean rollback()
Rolls the current transaction back.

Overrides:
rollback in class JdbcConnectionResource

select_db

public boolean select_db(java.lang.String db)
Selects the underlying database/catalog to use.

Parameters:
dbname - the name of the database to select.

set_charset

public boolean set_charset(java.lang.String charset)
Sets the character set


set_opt

public boolean set_opt(int option,
                       Value value)
Sets a mysqli option


getsqlstate

public StringValue getsqlstate(Env env)
Quercus function to get the field 'sqlstate'.


sqlstate

public StringValue sqlstate(Env env)
Returns the SQLSTATE error


stat

public Value stat(Env env)
returns a string with the status of the connection or FALSE if error


stmt_init

public MysqliStatement stmt_init(Env env)
returns a statement for use with mysqli_stmt_prepare


store_result

public JdbcResultResource store_result(Env env)
Transfers the result set from the last query on the database connection represented by conn. Used in conjunction with mysqli_multi_query


getthread_id

public Value getthread_id(Env env)
Quercus function to get the field 'thread_id'.


kill

public boolean kill(Env env,
                    int threadId)
Kills the given mysql thread id. Killing the connection is not the same as simply closing the connection. For example, table locks are released by a KILL.


thread_safe

public boolean thread_safe()
Returns true for thread_safe


use_result

public JdbcResultResource use_result(Env env)
Transfers the result set from the last query on the database connection represented by conn. Used in conjunction with mysqli_multi_query


getwarning_count

public int getwarning_count(Env env)
Quercus function to get the field 'warning_count'.


warning_count

public int warning_count(Env env)
returns the number of warnings from the last query in the connection object.

Returns:
number of warnings

createResult

protected JdbcResultResource createResult(Env env,
                                          java.sql.Statement stmt,
                                          java.sql.ResultSet rs)
Creates a database-specific result.

Overrides:
createResult in class JdbcConnectionResource

metaQuery

protected MysqliResult metaQuery(Env env,
                                 java.lang.String sql,
                                 java.lang.String catalog)
Used by the various mysqli functions to query the database for metadata about the resultset which is not in ResultSetMetaData. This function DOES NOT clear existing resultsets.


setPersistent

public void setPersistent()

close

public boolean close(Env env)
Description copied from class: JdbcConnectionResource
Closes the connection.

Overrides:
close in class JdbcConnectionResource

toString

public java.lang.String toString()
Converts to a string.

Overrides:
toString in class JdbcConnectionResource