PHP code example of bcdh / laravel-exist-db-client

1. Go to this page and download the library: Download bcdh/laravel-exist-db-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bcdh / laravel-exist-db-client example snippets


use BCDH\ExistDbClient\ExistDbClient;

$connection = new ExistDbClient();

$stmt = $connection->prepareQuery('for $someNode in collection("/SomeCollection")/someNodeName[./somePredicateAttribute=$someValueToBeBound] return $someNode');
$stmt->setSimpleXMLReturnType();
$stmt->bindVariable('someValueToBeBound', '5');

$resultPool = $stmt->execute();
$result = $resultPool->getAllResults();

foreach($result as $xml) {    
    var_dump($xml->somePredicateAttribute);
}

$document = $result->getDocument();
$title = $doc->getElementsByTagName('TITLE')->item(0)->nodeValue;

$document = $result->getDocument();
$title = $doc->TITLE;

$document = $result->getDocument();
$isFavorite = $doc->hasAttribute('favourite');

$document = $result->getDocument();
$attributes = $document->attributes();
$isFavorite = isset($attributes['favourite']);

$resultPool = $stmt->execute();
$results = $resultPool->getAllResults();
$res = $results[0];

$html = $res->transform(__DIR__.'/xml/cd_catalog_simplified.xsl');

$resultPool = $stmt->execute();
$results = $resultPool->getAllResults();
$rootTagName = 'catalog';

$html = $resultPool->transform($rootTagName, $results, __DIR__.'/xml/cd_catalog_simplified.xsl');
bash
sudo apt-get install php-pear
sudo pear channel-update pear.php.net