1. Go to this page and download the library: Download aplia/query 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/ */
aplia / query example snippets
$set = new QuerySet();
foreach ($set as $node) {
echo $node->attribute('name'), "\n";
}
$set = new QuerySet();
$newSet = $set->depth(1)->sortByField('a-z');
// $set and $newSet are the same instance
$set = new QuerySet(array('useClone' => true));
$newSet = $set->depth(1)->sortByField('a-z');
// $set and $newSet are different instances
$set = new QuerySet();
$newSet = $set->copy()->depth(1)->sortByField('a-z');
// $set and $newSet are different instances
$set = new QuerySet();
foreach ($set as $node) {
echo $node->attribute('name'), "\n";
}
$set = new QuerySet();
$set = $set->classes('article');
foreach ($set as $node) {
echo $node->attribute('name'), "\n";
}
// or
$set = new QuerySet(array('classes' => array('article')));
foreach ($set as $node) {
echo $node->attribute('name'), "\n";
}
$set = new QuerySet();
$set = $set->depth(false)->parentNode(42);
foreach ($set as $node) {
echo $node->attribute('name'), "\n";
}
// or
$set = new QuerySet(array('depth' => false, 'parentNodeId' => 42));
foreach ($set as $node) {
echo $node->attribute('name'), "\n";
}
$set = new QuerySet();
$set = $set->depth(2, '>=');
foreach ($set as $node) {
echo $node->attribute('name'), "\n";
}
// or
$set = new QuerySet(array('depth' => false, 'depthOperator' => '>='));
foreach ($set as $node) {
echo $node->attribute('name'), "\n";
}
$set = new QuerySet();
$set = $set->sortByField('a-z');
foreach ($set as $node) {
echo $node->attribute('name'), "\n";
}
$set = new QuerySet();
$set = $set->sortChoices(array('age' => 'created'))->sortByField('-age');
foreach ($set as $node) {
echo $node->attribute('name'), "\n";
}
$set = new QuerySet();
$set = $set->sortByArray(array(
array('published', 1),
));
foreach ($set as $node) {
echo $node->attribute('name'), "\n";
}
$set = new QuerySet();
$set = $set->pageLimit(50)->page(5);
foreach ($set as $node) {
echo $node->attribute('name'), "\n";
}