Changes

Jump to navigation Jump to search
136 bytes removed ,  15:28, 26 May 2012
no edit summary
=Conventions=
All functions in this module are assigned to the <code>{{Code|http://basex.org/modules/client</code> }} namespace, which is statically bound to the <code>{{Code|client</code> }} prefix.<br/>All errors are assigned to the <code>{{Code|http://basex.org/errors</code> }} namespace, which is statically bound to the <code>{{Code|bxerr</code> }} prefix.
=Functions=
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|client:connect</b>(|$host as xs:string, $port as xs:integer, $user as xs:string, $password as xs:string) as |xs:anyURI</code>}}<br/ >
|-
|'''Summary'''
|This function establishes a connection to a remote BaseX server, creates a new client session, and returns a session id. The parameter <code>{{Code|$host</code> }} is the name of the database server, <code>{{Code|$port</code> }} specifies the server port, and <code>{{Code|$user</code> }} and <code>{{Code|$password</code> }} represent the login data.
|-
|'''Errors'''
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|client:execute</b>(|$id as xs:anyURI, $command as xs:string) as |xs:string</code>}}
|-
| '''Summary'''
| This function executes a database command and returns the result as string. The parameter <code>{{Code|$id</code> }} contains the session id returned by [[Client Module#client:connect|client:connect()]]. The <code>{{Code|$command</code> }} represents the database command string, which will be executed by the server.
|-
|'''Errors'''
|-
| '''Examples'''
|The following query creates a new database <code>{{Code|TEST</code> }} on a remote BaseX server:
<pre class="brush:xquery">
let $c := client:connect('basex.server.org', 8080, 'admin', 'admin')
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|client:query</b>(|$id as xs:anyURI, $query as xs:string) as |item()*</code>}}
|-
| '''Summary'''
| This function evaluates a query and returns the result as sequence. The parameter <code>{{Code|$id</code> }} contains the session id returned by [[Client Module#client:connect|client:connect()]], and <code>{{Code|$query</code> }} represents the query string, which will be evaluated by the server.
|-
|'''Errors'''
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|client:close</b>(|$id as xs:anyURI) as |empty-sequence()</code>}}
|-
| '''Summary'''
| This function closes a client session. <code>{{Code|$id</code> }} specifies the session id.<br/>At the end of query execution, open sessions will be automatically closed.
|-
|'''Errors'''
! width="95%"|Description
|-
|<code>{{Code|BXCL0001</code>}}
| An error occurred while creating a new session (possible reasons: server not available, access denied).
|-
|<code>{{Code|BXCL0002</code>}}
| The specified session is unknown, or has already been closed.
|-
|<code>{{Code|BXCL0003</code>}}
| An I/O error occurred while transferring data from or to the server.
|-
|<code>{{Code|BXCL0004</code>}}
| An error occurred while executing a command.
|-
|<code>{{Code|BXCL0005</code>}}
| An error occurred while evaluating a query. Will only be raised if the XQuery error cannot be extracted from the returned error string.
|}
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu