Changes

Jump to navigation Jump to search
616 bytes added ,  14:21, 27 February 2020
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==
<pre class="brushTaken from our [https:java">// Create a session objectgithub.com/BaseXdb/basex-api/blob/master/src/main/php/Example.php repository]:Session session = new Session("localhost", 1984, "admin", "admin");
<syntaxhighlight lang="php"><?php/* * This example shows how database commands can be executed. * Documentation: http://basex.org/api * * (C) BaseX Team 2005-15, BSD License */Run the command in question and print the textual result:print session.executeinclude("info databaseBaseXClient.php");
try { // initialize timer $start = microtime(true);  // create session $session = new Session("localhost", 1984, "admin", "admin"); // perform command and print returned string print $session->execute("xquery 1 to 10");  //Close the close session: $session.->close();  // print time needed $time = (microtime(true) - $start) * 1000; print "\n$time ms\n"; } catch (Exception $e) { // print exception print $e->getMessage();}?></presyntaxhighlight>
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu