搜尋

USING

You can use the module by loading it in your PHP script and calling SQL Relay functions.

For example:

dl("sql_relay.so");$con=sqlrcon_alloc("adasz",9000,"","user1","password1",0,1);$cur=sqlrcur_alloc($con);sqlrcur_sendQuery($cur,"select table_name from user_tables");sqlrcon_endSession($con);for ($i=0; $i<sqlrcur_rowCount($cur); $i++){  printf("%s\n",sqlrcur_getField($cur,$i,"table_name"));}sqlrcur_free($cur);sqlrcon_free($con);

An alternative to running dl(sql_relay.so) is to put a line like:

extension=sql_relay.so

In your php.ini file. Doing this will improve performance as the library isn't loaded and unloaded each time a script runs, but only once when the web-server is started.

FUNCTIONS int sqlrcon_alloc(string server, int port, string socket, string user, string password, int retrytime, int tries)

Initiates a connection to "server" on "port" or to the unix "socket" on the local machine and authenticates with "user" and "password". Failed connections will be retried for "tries" times on interval "retrytime". If "tries" is 0 then retries will continue forever. If "retrytime" is 0 then retries will be attempted on a default interval.

If the "socket" parameter is nether NULL nor "" then an attempt will be made to connect through it before attempting to connect to "server" on "port". If it is NULL or "" then no attempt will be made to connect through the socket.*/

 

void sqlrcon_free(int sqlrconref)

Disconnects and terminates the session if it hasn't been terminated already.

 

void sqlrcon_setTimeout(int timeoutsec, int timeoutusec)

Sets the server connect timeout in seconds and milliseconds. Setting either parameter to -1 disables the timeout.

 

void sqlrcon_endSession(int sqlrconref)

terminates the session

 

void sqlrcon_suspendSession(int sqlrconref)

Disconnects this client from the current session but leaves the session open so that another client can connect to it using sqlrcon_resumeSession().

 

int sqlrcon_getConnectionPort(int sqlrconref)

Returns the inet port that the client is communicating over. This parameter may be passed to another client for use in the sqlrcon_resumeSession() command. Note: the value returned by this function is only valid after a call to sqlrcur_suspendSession().

 

string sqlrcon_getConnectionSocket(int sqlrconref)

Returns the unix socket that the client is communicating over. This parameter may be passed to another client for use in the sqlrcon_resumeSession() command. Note: the value returned by this function is only valid after a call to sqlrcur_suspendSession().

 

int sqlrcon_resumeSession(int sqlrconref, int port, string socket)

Resumes a session previously left open using sqlrcon_suspendSession(). Returns 1 on success and 0 on failure.

 

int sqlrcon_ping(int sqlrconref)

Returns 1 if the database is up and 0 if it's down.

 

string sqlrcon_identify(int sqlrconref)

Returns the type of database: oracle8, postgresql, mysql, etc.

 

string sqlrcon_dbVersion(int sqlrconref)

Returns the version of the database

 

string sqlrcon_serverVersion(int sqlrconref)

Returns the version of the SQL Relay server software

 

string sqlrcon_clientVersion(int sqlrconref)

Returns the version of the SQL Relay client software

 

string sqlrcon_bindFormat(int sqlrconref)

Returns a string representing the format of the bind variables used in the db.

 

int sqlrcon_autoCommitOn(int sqlrconref)

Instructs the database to perform a commit after every successful query.

 

int sqlrcon_autoCommitOff(int sqlrconref)

Instructs the database to wait for the client to tell it when to commit.

 

int sqlrcon_commit(int sqlrconref)

Issues a commit. Returns 1 if the commit succeeded, 0 if it failed and -1 if an error occurred.

 

int sqlrcon_rollback(int sqlrconref)

Issues a rollback. Returns 1 if the rollback succeeded, 0 if it failed and -1 if an error occurred.

 

void sqlrcon_debugOn(int sqlrconref)

Causes verbose debugging information to be sent to standard output. Another way to do this is to start a query with "-- debug\n".

 

void sqlrcon_debugOff(int sqlrconref)

turns debugging off

 

int sqlrcon_getDebug(int sqlrconref)

returns FALSE if debugging is off and TRUE if debugging is on

 

int sqlrcur_alloc(int sqlrconref) void sqlrcur_free(int sqlrcur) void sqlrcur_setResultSetBufferSize(int sqlrcurref, int rows)

Sets the number of rows of the result set to buffer at a time. 0 (the default) means buffer the entire result set.

 

int sqlrcur_getResultSetBufferSize(int sqlrcurref)

Returns the number of result set rows that will be buffered at a time or 0 for the entire result set.

 

void sqlrcur_dontGetColumnInfo(int sqlrcurref)

Tells the server not to send any column info (names, types, sizes). If you don't need that info, you should call this function to improve performance.

 

void sqlrcur_mixedCaseColumnNames(int sqlrcurref)

Columns names are returned in the same case as they are defined in the database. This is the default.

 

void sqlrcur_upperCaseColumnNames(int sqlrcurref)

Columns names are converted to upper case.

 

void sqlrcur_lowerCaseColumnNames(int sqlrcurref)

Columns names are converted to lower case.

 

void sqlrcur_getColumnInfo(int sqlrcurref)

Tells the server to send column info.

 

void sqlrcur_cacheToFile(int sqlrcurref, string filename)

Sets query caching on. Future queries will be cached to the file "filename". A default time-to-live of 10 minutes is also set. Note that once sqlrcur_cacheToFile() is called, the result sets of all future queries will be cached to that file until another call to sqlrcur_cacheToFile() changes which file to cache to or a call to sqlrcur_cacheOff() turns off caching.

 

void sqlrcur_setCacheTtl(int sqlrcurref, int ttl)

Sets the time-to-live for cached result sets. The sqlr-cachemanger will remove each cached result set "ttl" seconds after it's created.

 

string sqlrcur_getCacheFileName(int sqlrcurref)

Returns the name of the file containing the most recently cached result set.

 

void sqlrcur_cacheOff(int sqlrcurref)

Sets query caching off.

 

If you don't need to use substitution or bind variables in your queries, use these two functions.

 

int sqlrcur_sendQuery(int sqlrcurref, string query)

Sends "query" and gets a return set. Returns TRUE on success and FALSE on failure.

 

int sqlrcur_sendQueryWithLength(int sqlrcurref, string query, int length)

Sends "query" with length "length" and gets a result set. This function must be used if the query contains binary data.

 

int sqlrcur_sendFileQuery(int sqlrcurref, string path, string filename)

Sends the query in file "path"/"filename" and gets a return set. Returns TRUE on success and FALSE on failure.

 

If you need to use substitution or bind variables, in your queries use the following functions. See the API documentation for more information about substitution and bind variables.

 

void sqlrcur_prepareQuery(int sqlrcurref, string query)

Prepare to execute "query".

 

void sqlrcur_prepareQueryWithLength(int sqlrcurref, string query, int length)

Prepare to execute "query" with length "length". This function must be used if the query contains binary data.

 

void sqlrcur_prepareFileQuery(int sqlrcurref, string path, string filename)

Prepare to execute the contents of "path"/"filename".

 

void sqlrcur_substitution(int sqlrcurref, string variable, string value)
void sqlrcur_substitution(int sqlrcurref, string variable, long value)
void sqlrcur_substitution(int sqlrcurref, string variable, double value, short precision, short scale)

Define a substitution variable. Returns true if the substitution succeeded or false if the type of the data passed in wasn't a string, long or double or if precision and scale weren't passed in for a double.

 

void sqlrcur_clearBinds(int sqlrcurref)

Clear all bind variables.

 

void sqlrcur_countBindVariables(int sqlrcurref)

Parses the previously prepared query, counts the number of bind variables defined in it and returns that number.

 

void sqlrcur_inputBind(int sqlrcurref, string variable, string value)
void sqlrcur_inputBind(int sqlrcurref, string variable, long value)
void sqlrcur_inputBind(int sqlrcurref, string variable, double value, short precision, short scale)
void sqlrcur_inputBindBlob(int sqlrcurref, string variable, long length)
void sqlrcur_inputBindClob(int sqlrcurref, string variable, long length)

Define an input bind variable. Returns true if the bind succeeded or false if the type of the data passed in wasn't a string, long or double or if precision and scale weren't passed in for a double.

 

void sqlrcur_defineOutputBindString(int sqlrcurref, string variable, int length)

Define a string output bind variable. "length" bytes will be reserved to store the value.

 

void sqlrcur_defineOutputBindInteger(int sqlrcurref, string variable)

Define an integer output bind variable.

 

void sqlrcur_defineOutputBindDouble(int sqlrcurref, string variable)

Define a double precision floating point output bind variable.

 

void sqlrcur_defineOutputBindBlob(int sqlrcurref, string variable)

Define a BLOB output bind variable.

 

void sqlrcur_defineOutputBindClob(int sqlrcurref, string variable)

Define a CLOB output bind variable.

 

void sqlrcur_defineOutputBindCursor(int sqlrcurref, string variable)

Define a cursor output bind variable.

 

void sqlrcur_validateBinds(int sqlrcurref)

If you are binding to any variables that might not actually be in your query, call this to ensure that the database won't try to bind them unless they really are in the query.

 

void sqlrcur_validBind(int sqlrcurref, string variable)

Returns true if "variable" was a valid bind variable of the query.

 

int sqlrcur_executeQuery(int sqlrcurref)

Execute the query that was previously prepared and bound.

 

int sqlrcur_fetchFromBindCursor(int sqlrcurref)

Fetch from a cursor that was returned as an output bind variable.

 

int sqlrcur_getOutputBindString(int sqlrcurref, string variable)

Get the value stored in a previously defined output bind variable.

 

int sqlrcur_getOutputBindBlob(int sqlrcurref, string variable)

Get the value stored in a previously defined output bind variable.

 

int sqlrcur_getOutputBindClob(int sqlrcurref, string variable)

Get the value stored in a previously defined output bind variable.

 

int sqlrcur_getOutputBindInteger(int sqlrcurref, string variable)

Get the value stored in a previously defined output bind variable.

 

int sqlrcur_getOutputBindDouble(int sqlrcurref, string variable)

Get the value stored in a previously defined output bind variable.

 

int sqlrcur_getOutputBindLength(int sqlrcurref, string variable)

Get the length of the value stored in a previously defined output bind variable.

 

int sqlrcur_getOutputBindCursor(int sqlrcurref, string variable)

Get the cursor associated with a previously defined output bind variable.

 

int sqlrcur_openCachedResultSet(int sqlrcurref, 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.

 

int sqlrcur_colCount(int sqlrcurref)

returns the number of columns in the current return set

 

int sqlrcur_rowCount(int sqlrcurref)

returns the number of rows in the current return set

 

int sqlrcur_totalRows(int sqlrcurref)

Returns the total number of rows that will be returned in the result set. Not all databases support this call. Don't use it for applications which are designed to be portable across databases. -1 is returned by databases which don't support this option.

 

int sqlrcur_affectedRows(int sqlrcurref)

Returns the number of rows that were updated, inserted or deleted by the query. Not all databases support this call. Don't use it for applications which are designed to be portable across databases. -1 is returned by databases which don't support this option.

 

int sqlrcur_firstRowIndex(int sqlrcurref)

Returns the index of the first buffered row. This is useful when buffering only part of the result set at a time.

 

int sqlrcur_endOfResultSet(int sqlrcurref)

Returns 0 if part of the result set is still pending on the server and 1 if not. This function can only return 0 if setResultSetBufferSize() has been called with a parameter other than 0.

 

string sqlrcur_errorMessage(int sqlrcurref)

If a query failed and generated an error, the error message is available here. If the query succeeded then this function returns FALSE

 

string sqlrcur_getNullsAsEmptyStrings(int sqlrcurref)

Tells the client to return NULL fields and output bind variables as empty strings. This is the default.

 

string sqlrcur_getNullsAsNulls(int sqlrcurref)

Tells the client to return NULL fields and output bind variables as NULL's.

 

string sqlrcur_getField(int sqlrcurref, int row, int col)

returns a string with value of the specified row and column

 

string sqlrcur_getFieldLength(int sqlrcurref, int row, int col)

returns the length of the specified row and column

 

array sqlrcur_getRow(int sqlrcurref, int row)

returns an indexed array of the values of the specified row

 

array sqlrcur_getRowLengths(int sqlrcurref, int row)

returns an indexed array of the lengths of the specified row

 

array sqlrcur_getRowAssoc(int sqlrcurref, int row)

returns an associative array of the values of the specified row

 

array sqlrcur_getRowLengthsAssoc(int sqlrcurref, int row)

returns an associative array of the lengths of the specified row

 

array sqlrcur_getColumnNames(int sqlrcurref)

returns the array of the column names of the current return set

 

string sqlrcur_getColumnName(int sqlrcurref, int col)

returns the name of the specified column

 

string sqlrcur_getColumnType(int sqlrcurref, string col)
string sqlrcur_getColumnType(int sqlrcurref, int col)

returns the type of the specified column

 

int sqlrcur_getColumnLength(int sqlrcurref, string col)
int sqlrcur_getColumnLength(int sqlrcurref, int col)

returns the length of the specified column.

 

int sqlrcur_getColumnPrecision(int sqlrcurref, string col);
int sqlrcur_getColumnPrecision(int sqlrcurref, int col);

Returns the precision of the specified column. Precision is the total number of digits in a number. eg: 123.45 has a precision of 5. For non-numeric types, it's the number of characters in the string.

 

int sqlrcur_getColumnScale(int sqlrcurref, string col);
int sqlrcur_getColumnScale(int sqlrcurref, int col);

Returns the scale of the specified column. Scale is the total number of digits to the right of the decimal point in a number. eg: 123.45 has a scale of 2.

 

int sqlrcur_getColumnIsNullable(int sqlrcurref, string col);
int sqlrcur_getColumnIsNullable(int sqlrcurref, int col);

Returns 1 if the specified column can contain nulls and 0 otherwise.

 

int sqlrcur_getColumnIsPrimaryKey(int sqlrcurref, string col);
int sqlrcur_getColumnIsPrimaryKey(int sqlrcurref, int col);

Returns 1 if the specified column is a primary key and 0 otherwise.

 

int sqlrcur_getColumnIsUnique(int sqlrcurref, string col);
int sqlrcur_getColumnIsUnique(int sqlrcurref, int col);

Returns 1 if the specified column is unique and 0 otherwise.

 

int sqlrcur_getColumnIsPartOfKey(int sqlrcurref, string col);
int sqlrcur_getColumnIsPartOfKey(int sqlrcurref, int col);

Returns 1 if the specified column is part of a composite key and 0 otherwise.

 

int sqlrcur_getColumnIsUnsigned(int sqlrcurref, string col);
int sqlrcur_getColumnIsUnsigned(int sqlrcurref, int col);

Returns 1 if the specified column is an unsigned number and 0 otherwise.

 

int sqlrcur_getColumnIsZeroFilled(int sqlrcurref, string col);
int sqlrcur_getColumnIsZeroFilled(int sqlrcurref, int col);

Returns 1 if the specified column was created with the zero-fill flag and 0 otherwise.

 

int sqlrcur_getColumnIsBinary(int sqlrcurref, string col);
int sqlrcur_getColumnIsBinary(int sqlrcurref, int col);

Returns 1 if the specified column contains binary data and 0 otherwise.

 

int sqlrcur_getColumnIsAutoIncrement(int sqlrcurref, string col);
int sqlrcur_getColumnIsAutoIncrement(int sqlrcurref, int col);

Returns 1 if the specified column auto-increments and 0 otherwise.

 

int sqlrcur_getLongest(int sqlrcurref, string col)
int sqlrcur_getLongest(int sqlrcurref, int col)

Returns the length of the longest field in the specified column.

 

void sqlrcur_suspendResultSet(int sqlrcurref)

Tells the server to leave this result set open when the connection calls suspendSession() so that another connection can connect to it using resumeResultSet() after it calls resumeSession().

 

int sqlrcur_getResultSetId(int sqlrcurref)

Returns the internal ID of this result set. This parameter may be passed to another statement for use in the resumeResultSet() function. Note: the value returned by this function is only valid after a call to sqlrcur_suspendResultSet().

 

void sqlrcur_resumeResultSet(int sqlrcurref, int id)

Resumes a result set previously left open using suspendSession(). Returns 1 on success and 0 on failure.

 

void sqlrcur_resumeCachedResultSet(int sqlrcurref, int id, string filename)

Resumes a result set previously left open using suspendSession() and continues caching the result set to "filename". Returns 1 on success and 0 on failure.

 

AUTHOR Adam Kropielnicki
adasz@wp.pl
陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
超越炒作:評估當今PHP的角色超越炒作:評估當今PHP的角色Apr 12, 2025 am 12:17 AM

PHP在現代編程中仍然是一個強大且廣泛使用的工具,尤其在web開發領域。 1)PHP易用且與數據庫集成無縫,是許多開發者的首選。 2)它支持動態內容生成和麵向對象編程,適合快速創建和維護網站。 3)PHP的性能可以通過緩存和優化數據庫查詢來提升,其廣泛的社區和豐富生態系統使其在當今技術棧中仍具重要地位。

PHP中的弱參考是什麼?什麼時候有用?PHP中的弱參考是什麼?什麼時候有用?Apr 12, 2025 am 12:13 AM

在PHP中,弱引用是通過WeakReference類實現的,不會阻止垃圾回收器回收對象。弱引用適用於緩存系統和事件監聽器等場景,需注意其不能保證對象存活,且垃圾回收可能延遲。

解釋PHP中的__ Invoke Magic方法。解釋PHP中的__ Invoke Magic方法。Apr 12, 2025 am 12:07 AM

\_\_invoke方法允許對象像函數一樣被調用。 1.定義\_\_invoke方法使對象可被調用。 2.使用$obj(...)語法時,PHP會執行\_\_invoke方法。 3.適用於日誌記錄和計算器等場景,提高代碼靈活性和可讀性。

解釋PHP 8.1中的纖維以進行並發。解釋PHP 8.1中的纖維以進行並發。Apr 12, 2025 am 12:05 AM

Fibers在PHP8.1中引入,提升了並發處理能力。 1)Fibers是一種輕量級的並發模型,類似於協程。 2)它們允許開發者手動控制任務的執行流,適合處理I/O密集型任務。 3)使用Fibers可以編寫更高效、響應性更強的代碼。

PHP社區:資源,支持和發展PHP社區:資源,支持和發展Apr 12, 2025 am 12:04 AM

PHP社區提供了豐富的資源和支持,幫助開發者成長。 1)資源包括官方文檔、教程、博客和開源項目如Laravel和Symfony。 2)支持可以通過StackOverflow、Reddit和Slack頻道獲得。 3)開發動態可以通過關注RFC了解。 4)融入社區可以通過積極參與、貢獻代碼和學習分享來實現。

PHP與Python:了解差異PHP與Python:了解差異Apr 11, 2025 am 12:15 AM

PHP和Python各有優勢,選擇應基於項目需求。 1.PHP適合web開發,語法簡單,執行效率高。 2.Python適用於數據科學和機器學習,語法簡潔,庫豐富。

php:死亡還是簡單地適應?php:死亡還是簡單地適應?Apr 11, 2025 am 12:13 AM

PHP不是在消亡,而是在不斷適應和進化。 1)PHP從1994年起經歷多次版本迭代,適應新技術趨勢。 2)目前廣泛應用於電子商務、內容管理系統等領域。 3)PHP8引入JIT編譯器等功能,提升性能和現代化。 4)使用OPcache和遵循PSR-12標準可優化性能和代碼質量。

PHP的未來:改編和創新PHP的未來:改編和創新Apr 11, 2025 am 12:01 AM

PHP的未來將通過適應新技術趨勢和引入創新特性來實現:1)適應云計算、容器化和微服務架構,支持Docker和Kubernetes;2)引入JIT編譯器和枚舉類型,提升性能和數據處理效率;3)持續優化性能和推廣最佳實踐。

See all articles

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

AI Hentai Generator

AI Hentai Generator

免費產生 AI 無盡。

熱門文章

R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
3 週前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳圖形設置
3 週前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您聽不到任何人,如何修復音頻
3 週前By尊渡假赌尊渡假赌尊渡假赌
WWE 2K25:如何解鎖Myrise中的所有內容
4 週前By尊渡假赌尊渡假赌尊渡假赌

熱工具

SublimeText3 Linux新版

SublimeText3 Linux新版

SublimeText3 Linux最新版

mPDF

mPDF

mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),

Atom編輯器mac版下載

Atom編輯器mac版下載

最受歡迎的的開源編輯器

DVWA

DVWA

Damn Vulnerable Web App (DVWA) 是一個PHP/MySQL的Web應用程序,非常容易受到攻擊。它的主要目標是成為安全專業人員在合法環境中測試自己的技能和工具的輔助工具,幫助Web開發人員更好地理解保護網路應用程式的過程,並幫助教師/學生在課堂環境中教授/學習Web應用程式安全性。 DVWA的目標是透過簡單直接的介面練習一些最常見的Web漏洞,難度各不相同。請注意,該軟體中

VSCode Windows 64位元 下載

VSCode Windows 64位元 下載

微軟推出的免費、功能強大的一款IDE編輯器