Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

alxarch/basex-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BaseX client for PHP (>=5.3)

Session

use BaseX\Session;

// Open session

$session = new Session('localhost', 1984, 'username', 'password');

// Execute commands

$session->execute('INFO');

// Database creation

$session->execute('CREATE new_db');

$session->execute('OPEN new_db');

// Simple document add.

$session->add('file.xml', '<root><node/></root>');

// Adding via file handler

$fh = fopen('another_test.xml', 'r');

$session->add('another_test.xml', $fh);

// Get/Set options

$session->getOption('chop');
$session->getOption('parser');

$session->setOption('chop', true)
		->setOption('parser', 'json');

// Session information.

$session->getInfo()->dbpath;


// End session.

$session->close();

Queries

use BaseX\Session;
use BaseX\Query\Writer as QueryWriter;

$session = new Session('localhost', 1984, 'username', 'password');

$xql = "db:open('new_db', 'test.xml')";

$query = $session->query($xql);

$xml = $query->execute();

QueryWriter

$xql = "db:open(\$db, \$doc)"

$qw = QueryWriter::begin($xql)
	->setVariable('db', 'new_db')
	->setVariable('doc', 'another_test.xml');

$query = $qw->getQuery($session);

$result = $query->execute();

Database Object

TODO

Resource Object

TODO

StreamWrapper

use BaseX\Session;
use BaseX\StreamWrapper;

$session = new Session('localhost', 1984, 'username', 'password');

StreamWrapper::register($session);

$stream = fopen('basex://database/path/to/resource.xml', 'r');

$contents = stream_get_contents($stream);

fclose($stream);

$stream = fopen('basex://database/path/to/resource.xml', 'w');

$local = fopen('somefile.xml');

stream_copy_to_stream($local, $stream);

fclose($stream);
fclose($local);

About

BaseX client for PHP 5.3

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages