com.caucho.quercus.lib.db
Class MysqliStatement

java.lang.Object
  extended by com.caucho.quercus.lib.db.JdbcStatementResource
      extended by com.caucho.quercus.lib.db.MysqliStatement

public class MysqliStatement
extends JdbcStatementResource

mysqli object oriented API facade


Method Summary
 int affected_rows(Env env)
          Returns the total number of rows changed, deleted, or inserted by the last executed statement.
 boolean bind_param(Env env, StringValue types, Value[] params)
          Binds variables to a prepared statement as parameters.
 boolean bind_result(Env env, Value[] outParams)
          Binds variables to a prepared statement for result storage.
 boolean close(Env env)
          Closes a prepared statement.
 Value data_seek(Env env, int offset)
          Seeks to an arbitrary row in statement result set.
 int errno()
          Returns the error code for the most recent statement call.
 StringValue error(Env env)
          Returns a string description for last statement error
 boolean execute(Env env)
          Executes a prepared Query.
 Value fetch(Env env)
          Fetch results from a prepared statement into the bound variables.
 int field_count(Env env)
          Returns the number of columns in the last query.
 void free_result(Env env)
          Frees the associated result.
 int getaffected_rows(Env env)
          Quercus function to get the field 'affected_rows'.
 int geterrno()
          Quercus function to get the field 'errno'.
 StringValue geterror(Env env)
          Quercus function to get the field 'error'.
 int getfield_count(Env env)
          Quercus function to get the field 'field_count'.
 Value getinsert_id(Env env)
          Quercus function to get the field 'insert_id'.
 Value getnum_rows(Env env)
          Quercus function to get the field 'num_rows'.
 int getparam_count(Env env)
          Quercus function to get the field 'param_count'.
 StringValue getsqlstate(Env env)
          Quercus function to get the field 'sqlstate'.
 Value insert_id(Env env)
           
 Value num_rows(Env env)
          Returns the number of rows in the result.
 int param_count(Env env)
          Returns the number of parameter markers for this statement.
 boolean prepare(Env env, StringValue query)
          Prepare a SQL statement for execution.
 boolean reset(Env env)
          Resets the statement.
 MysqliResult result_metadata(Env env)
          mysqli_stmt_result_metadata seems to be some initial step towards getting metadata from a resultset created by a SELECT run by a prepared statement.
 boolean send_long_data(Env env, int paramNumber, java.lang.String data)
          Send data in blocks.
 StringValue sqlstate(Env env)
          Returns SQLSTATE error from previous statement operation.
 boolean store_result(Env env)
          Saves the result as buffered.
 
Methods inherited from class com.caucho.quercus.lib.db.JdbcStatementResource
bindParams, bindResults, close, dataSeek, errorCode, errorMessage, executeStatement, freeResult, getFieldCount, getJavaConnection, getMetaData, getNumRows, getParam, getParamLength, getPreparedStatement, getResultMetadata, getResultSet, getStatementType, paramCount, prepareStatement, setObject, setPreparedStatement, setResultSet, toString, validateConnection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getaffected_rows

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


affected_rows

public int affected_rows(Env env)
Returns the total number of rows changed, deleted, or inserted by the last executed statement.

Parameters:
env - the PHP executing environment
Returns:
an integer greater than zero indicates the number of rows affected or retrieved. Zero indicates that no records were updated for an UPDATE/DELETE statement, no rows matched the WHERE clause in the query or that no query has yet been executed. -1 indicates that the query has returned an error.

bind_param

public boolean bind_param(Env env,
                          StringValue types,
                          Value[] params)
Binds variables to a prepared statement as parameters.

Parameters:
env - the PHP executing environment
types - string of i,d,s,b (ie: "idds")
params - array of values (probably Vars)
Returns:
true on success or false on failure

bind_result

public boolean bind_result(Env env,
                           Value[] outParams)
Binds variables to a prepared statement for result storage.

Parameters:
env - the PHP executing environment
outParams - the output variables
Returns:
true on success or false on failure

close

public boolean close(Env env)
Closes a prepared statement.

Parameters:
env - the PHP executing environment
Returns:
true on success or false on failure

data_seek

public Value data_seek(Env env,
                       int offset)
Seeks to an arbitrary row in statement result set.

Parameters:
env - the PHP executing environment
offset - row offset
Returns:
NULL on sucess or FALSE on failure

errno

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

Parameters:
env - the PHP executing environment
Returns:
the error code or zero if no error occurred

geterrno

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


error

public StringValue error(Env env)
Returns a string description for last statement error

Parameters:
env - the PHP executing environment
Returns:
a string that describes the error or an empty string if no error occurred.

geterror

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


execute

public boolean execute(Env env)
Executes a prepared Query. The statement has been prepared using mysqli_prepare.

Overrides:
execute in class JdbcStatementResource
Parameters:
env - the PHP executing environment
Returns:
true on success or false on failure

fetch

public Value fetch(Env env)
Fetch results from a prepared statement into the bound variables.

Overrides:
fetch in class JdbcStatementResource
Parameters:
env - the PHP executing environment
Returns:
true on success, false on failure or null if no more rows/data exists

free_result

public void free_result(Env env)
Frees the associated result.

Parameters:
env - the PHP executing environment

getnum_rows

public Value getnum_rows(Env env)
Quercus function to get the field 'num_rows'.


num_rows

public Value num_rows(Env env)
Returns the number of rows in the result.

Parameters:
env - the PHP executing environment
Returns:
the number of rows in the result set

getparam_count

public int getparam_count(Env env)
Quercus function to get the field 'param_count'.


param_count

public int param_count(Env env)
Returns the number of parameter markers for this statement.

Parameters:
env - the PHP executing environment
Returns:
the number of parameter markers for this statement

prepare

public boolean prepare(Env env,
                       StringValue query)
Prepare a SQL statement for execution.

Overrides:
prepare in class JdbcStatementResource
Parameters:
env - the PHP executing environment
query - SQL query
Returns:
true on success or false on failure

reset

public boolean reset(Env env)
Resets the statement.

Parameters:
env - the PHP executing environment
Returns:
true on success or false on failure

result_metadata

public MysqliResult result_metadata(Env env)
mysqli_stmt_result_metadata seems to be some initial step towards getting metadata from a resultset created by a SELECT run by a prepared statement. NB: the $field variable in the following 2 PHP scripts will be equivalent: $result = mysqli_query($link,"SELECT * FROM test"); $field = mysqli_fetch_field($result); AND $stmt = mysqli_prepare($link, "SELECT * FROM test"); mysqli_stmt_execute($stmt); $metaData = mysqli_stmt_result_metadata($stmt); $field = mysqli_fetch_field($metaData); So it seems that this function just provides a link into the resultset. The PHP documentation is clear that this function returns a mysqli_result with NO DATA. For simplicity, we return a mysqli_result with all the data. We check that mysqli_stmt_execute() has been run. From libmysql.c: This function should be used after mysql_stmt_execute(). ... Next steps you may want to make: - find out number of columns is result set by calling mysql_num_fields(res).... - fetch metadata for any column with mysql_fetch_field... So basically, this function seems to exist only to be a way to get at the metadata from a resultset generated by a prepared statement.

Parameters:
env - the PHP executing environment
Returns:
a result with meta data or false on failure

send_long_data

public boolean send_long_data(Env env,
                              int paramNumber,
                              java.lang.String data)
Send data in blocks.

Parameters:
env - the PHP executing environment
paramNumber - indicates which parameter to associate the data with
data - the data to be sent
Returns:
true on success or false on failure

getsqlstate

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


sqlstate

public StringValue sqlstate(Env env)
Returns SQLSTATE error from previous statement operation.

Parameters:
env - the PHP executing environment
Returns:
the SQLSTATE (5-characters string) for the last error. '00000' means no error

store_result

public boolean store_result(Env env)
Saves the result as buffered.

Parameters:
env - the PHP executing environment
Returns:
true on success or false on failure

getfield_count

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


field_count

public int field_count(Env env)
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)