src/api/php in the
SQL-relay source distribution
setup PHP_directory SQL_relay_directory, where:
PHP_directory - directory of PHP source
SQL_relay_directory- directory where SQL_relay is installed
make to build sql_relay.so
make clean
The example script:
int sqlrc_alloc(string server, int port, string user, string password,
int retrytime, int tries)
Initiates a connection to "server" on "port" and authenticates with "user" and "password". Failed connections will be retried for "tries" times on interval "retrytime" or on for a default number of times on a default interval if left unspecified.
void sqlrc_free(int sqlrcref)
Disconnects and terminates the session if it hasn't been terminated already.
int sqlrc_sendQuery(int sqlrcref, string query)
sends "query" and gets a return set. Returns TRUE on success and FALSE on failure.
int sqlrc_sendFinalQuery(int sqlrcref, string query)
sends "query", gets a return set and ends the session. Returns TRUE on success and FALSE on failure.
int sqlrc_sendFileQuery(int sqlrcref, string path, string filename)
Sends the query in file "path"/"filename" and gets a return set. Returns TRUE on success and FALSE on failure.
int sqlrc_sendFinalFileQuery(int sqlrcref, string path,
string filename);
sends the query in file "path"/"filename" , gets a return set and ends the session. Returns TRUE on success and FALSE on failure.
string sqlrc_sendCachedQuery(int sqlrcref, int ttl, string query)
Sends "query" and gets a return set. The return set is cached and returned string is the cache filename.
string sqlrc_sendCachedFinalQuery(int sqlrcref, int ttl, string query)
Sends "query", gets a return set and ends the session. The return set is cached and returned string is the cache filename.
string sqlrc_sendCachedFileQuery(int sqlrcref, int ttl,
string path, string filename)
Sends the query in file "path"/"filename" and gets a return set. The return set is cached and returned string is the cache filename.
string sqlrc_sendCachedFinalFileQuery(int sqlrcref, int ttl,
string path, string filename)
Sends the query in file "path"/"filename" with substitutions, gets a return set and ends the session. The return set is cached and "cachefilename" is allocated and set to the cache filename.
int sqlrc_openCachedResultSet(int sqlrcref, string filename)
Opens a cached result set as if a query that would have generated it had been executed. Returns TRUE on success and FALSE on failure.
void sqlrc_endSession(int sqlrcref)
terminates the session
int sqlrc_colCount(int sqlrcref)
returns the number of columns in the current return set
int sqlrc_rowCount(int sqlrcref)
returns the number of rows in the current return set
string sqlrc_errorMessage(int sqlrcref)
If a query failed and generated an error, the error message is available here. If the query succeeded then this method returns FALSE
string sqlrc_getFieldByIndex(int sqlrcref, int row, int col)
string sqlrc_getFieldByName(int sqlrcref, int row, string col)
returns a string with value of the specified row and column
array sqlrc_getRow(int sqlrcref, int row)
returns the array of the values of the specified row
array sqlrc_getColumnNames(int sqlrcref)
returns the array of the column names of the current return set
string sqlrc_getColumnName(int sqlrcref, int col)
returns the name of the specified column
string sqlrc_getColumnTypeByIndex(int sqlrcref, int col)
string sqlrc_getColumnTypeByName(int sqlrcref, string col)
returns the type of the specified column
int sqlrc_getColumnLengthByIndex(int sqlrcref, int col)
int sqlrc_getColumnLengthByName(int sqlrcref, string col)
returns the length of the specified column.
void sqlrc_debugOn(int sqlrcref)
Causes verbose debugging information to be sent to standard output. Another way to do this is to start a query with "-- debug\n".
void sqlrc_debugOff(int sqlrcref)
turns debugging off
int sqlrc_getDebug(sqlrc sqlrcref);
returns FALSE if debugging is off and TRUE if debugging is on
Adam Kroielnicki
adasz@wp.pl