/usr/share/doc/php-horde-rdo/examples/RelationshipTest.php is in php-horde-rdo 2.0.2-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | <?php
/**
* @package Rdo
* @subpackage UnitTests
*/
// class definitions.
require './Clotho.php';
// one-to-one
$im = new ItemMapper($conf['adapter']);
$i = $im->findOne(3);
echo "({$i->item_id}) {$i->item_name} has parent:\n";
echo " ({$i->parent->item_id}) {$i->parent->item_name}\n";
// one-to-many
$rm = new ResourceMapper($conf['adapter']);
$r = $rm->findOne(1);
echo "Resource ({$r->resource_id}) {$r->resource_name} has " . count($r->availabilities) . " availabilities:\n";
foreach ($r->availabilities as $ra) {
echo ' (' . $ra->availability_id . ') ' . $ra->resource->resource_name . " on " . strftime('%x %X', $ra->availability_date) . " (" . $ra->availability_hours . " hours)\n";
}
// many-to-one
$ram = new ResourceAvailabilityMapper($conf['adapter']);
$ra = $ram->findOne(1);
echo "Resource Availability ({$ra->availability_id}) " . strftime('%x %X', $ra->availability_date) . " has resource:\n";
echo " ({$ra->resource->resource_id}) {$ra->resource->resource_name}\n";
// many-to-many
echo "Listing all Items and their Resources:\n\n";
$im = new ItemMapper($conf['adapter']);
foreach ($im->find() as $i) {
if (count($i->resources)) {
echo " (" . $i->item_id . ") " . $i->item_name . " has resources:\n";
foreach ($i->resources as $r) {
echo ' (' . $r->resource_id . ') ' . $r->resource_name . "\n";
}
}
}
echo "\n\nListing all Resources and their Items:\n\n";
$rm = new ResourceMapper($conf['adapter']);
foreach ($rm->find() as $r) {
if (count($r->items)) {
echo " (" . $r->resource_id . ") " . $r->resource_name . " has items:\n";
foreach ($r->items as $i) {
echo ' (' . $i->item_id . ') ' . $i->item_name . "\n";
}
}
}
|