Changes

Jump to navigation Jump to search
533 bytes added ,  15:53, 17 January 2016
no edit summary
<p>In the standard modeof the [[Clients]], a database command can be
sent to the server using the <code>execute()</code> function
of the <code>Session</code>. This functions returns the whole
<p>The standard execution works as follows:</p>
#Create a new session instance with hostname, port, username and password. #Call the <code>execute()</code> function of the session with the [[Commands|database commands]] as argument. #Receive the result of a successfully executed command. As If an error occurs , an exception is thrown. # Optionally, call <code>info()</code> to get some process information#Continue using the client (back to 2.), or close the session.
==Examplein PHP==
#Create a session objectTaken from our [https:<br/>/github.com/BaseXdb/basex-api/blob/master/src/main/php/Example.php repository]: <pre class="brush:javaphp">Session <?php/* * This example shows how database commands can be executed. * Documentation: http://basex.org/api * * (C) BaseX Team 2005-15, BSD License */include("BaseXClient.php"); try { // initialize timer $start = microtime(true);  // create session $session = new Session("localhost", 1984, "admin", "admin");< //pre> #Run the perform command in question and print the textual result:<br/><pre class="brush:java">returned string print $session.->execute("info databasexquery 1 to 10");<  //preclose session $session-> close(); #Close the session:<br //><pre classprint time needed $time =(microtime(true) - $start) * 1000; print "brush:java\n$time ms\n"; } catch (Exception $e) { // print exception print $e->session.closegetMessage();}?></pre>
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu