PHP API
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.soIn 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

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

뜨거운 주제











PHP의 API가 예외 처리 및 재시도 메커니즘을 처리하는 방법 PHP에서 API는 다양한 특징과 기능을 제공하므로 많은 웹사이트와 애플리케이션의 핵심이 되었습니다. 그러나 API를 사용하다 보면 네트워크 연결 문제, 응답 시간 초과, 잘못된 요청 등 많은 문제에 직면하는 경우가 많습니다. 이 경우 애플리케이션의 신뢰성과 안정성을 보장하기 위해 예외 처리 및 재시도 메커니즘을 이해해야 합니다. 예외 처리 PHP에서 예외 처리는 보다 우아하고 읽기 쉬운 오류 처리입니다.

PHP Kuaishou API 인터페이스 개발 가이드: 비디오 다운로드 및 업로드 시스템 구축 방법 소개: 소셜 미디어의 급속한 발전으로 점점 더 많은 사람들이 자신의 삶의 순간을 인터넷에서 공유하고 싶어합니다. 그중에서도 짧은 영상 플랫폼은 계속해서 인기를 끌며 사람들이 자신의 삶과 오락을 기록하고 공유하는 중요한 수단이 되었습니다. PHP Kuaishou API 인터페이스는 개발자가 기능이 풍부한 비디오 다운로드 및 업로드 시스템을 구축하는 데 도움을 줄 수 있는 강력한 도구입니다. 이 기사에서는 PHP Kuaishou API 인터페이스를 사용하여 API를 개발하는 방법을 살펴보겠습니다.

PHP는 웹 개발에 널리 사용되는 매우 인기 있는 서버측 스크립팅 언어입니다. 웹 개발에서 API는 클라이언트와의 통신을 담당하는 매우 중요한 구성 요소입니다. 그 중에서도 API 성능과 효율성은 애플리케이션의 사용자 경험에 매우 중요합니다. 캐싱과 중복 데이터는 API 개발 중 두 가지 중요한 개념입니다. 이 기사에서는 API의 성능과 안정성을 향상시키기 위해 PHP에서 이를 처리하는 방법을 소개합니다. 1. 캐싱 개념 캐싱은 웹 애플리케이션에서 널리 사용되는 최적화 기술입니다.

PHP Kuaishou API 인터페이스를 통해 비디오 수집 및 공유가 실현될 수 있습니다. 모바일 인터넷 시대에 짧은 비디오는 사람들의 삶에 없어서는 안될 부분이 되었습니다. 중국의 주류 단편 비디오 소셜 플랫폼인 Kuaishou는 엄청난 사용자 기반을 보유하고 있습니다. 사용자 경험을 향상시키기 위해 PHP Kuaishou API 인터페이스를 통해 비디오 수집 및 공유 기능을 구현하여 사용자가 좋아하는 비디오를 보다 편리하게 관리하고 공유할 수 있도록 합니다. 1. Kuaishou API 사용 Kuaishou는 비디오 검색, 비디오 세부 정보, 비디오 수집 및 비디오 분석을 포함한 풍부한 API 인터페이스를 제공합니다.

소셜미디어의 인기가 높아지면서 트위터 등 소셜미디어 플랫폼을 활용해 마케팅과 홍보를 하는 사람들이 늘고 있다. 이 접근 방식은 효과적이지만 활동적인 상태를 유지하려면 많은 시간과 노력이 필요합니다. 트위터에서 브랜드나 서비스를 홍보하고 싶지만 활성 트위터 계정을 관리할 시간이나 리소스가 충분하지 않은 경우 트위터 봇 사용을 고려할 수 있습니다. 트위터 봇은 트위터에 자신만의 게시물을 작성하는 데 도움이 되는 자동화된 도구입니다.

PHPAPI 전류 제한은 고정 창 카운터, 슬라이딩 창 카운터, 누출 된 버킷 알고리즘 및 토큰 버킷 알고리즘을 통해 구현할 수 있습니다. 1. 고정 창 카운터는 시간 창을 통한 요청 수를 제한합니다. 2. 슬라이딩 윈도우 카운터는보다 정확한 전류 제한을 제공하기 위해 시간 창을 개선합니다. 3. 누출 된 버킷 알고리즘은 파열 트래픽을 방지하기 위해 일정한 속도로 요청을 처리합니다. 4. 토큰 버킷 알고리즘은 어느 정도의 버스트 트래픽을 허용하고 토큰을 소비하여 요청을 제어합니다.

PHP Kuaishou API 인터페이스 개발 가이드: 비디오 재생 및 댓글 시스템 구축 방법 소개: Kuaishou 플랫폼의 등장으로 많은 개발자들이 API 인터페이스를 통해 다양한 애플리케이션을 개발했습니다. 이 기사에서는 독자가 빠르게 시작하고 자신의 애플리케이션을 구축할 수 있도록 PHP를 사용하여 Kuaishou 비디오 재생 및 댓글 시스템의 API 인터페이스를 개발하는 방법을 소개합니다. 1. 준비 작업 시작하기 전에 다음 준비 작업을 완료했는지 확인해야 합니다. PHP 환경 설치: 로컬 개발 환경에서 PH를 설정해야 합니다.

최신 웹 애플리케이션에서 API 인터페이스는 일반적으로 서비스 인터페이스를 구현하는 방법입니다. 이러한 API 인터페이스를 PHP 언어로 구현할 때 여러 API 클라이언트를 처리하는 방법을 고려해야 합니다. 일반적인 상황에서 각 API 클라이언트 요청은 PHP가 구현한 RESTful 인터페이스를 통해 처리됩니다. 그러나 대량의 API 클라이언트 요청을 처리해야 하는 경우 어떻게 인터페이스 처리 효율성을 높이고 시스템 오버헤드를 줄일 수 있는지가 시급한 문제가 되었습니다.
