// 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";
Exemple #2
0
<?php

/**
 * @package Rdo
 */
require_once './Clotho.php';
$im = new ItemMapper($conf['adapter']);
$dm = new DependencyMapper($conf['adapter']);
$cm = new CalendarMapper($conf['adapter']);
$rm = new ResourceMapper($conf['adapter']);
$ram = new ResourceAvailabilityMapper($conf['adapter']);
$item = $im->create(array('item_name' => 'Test Item', 'item_parent' => 0));
echo get_class($item) . "\n";
$item = $im->create(array('item_name' => 'Test Item 2', 'item_parent' => 0));
echo get_class($item) . "\n";
$item = $im->create(array('item_name' => 'Child Item', 'item_parent' => 1));
echo get_class($item) . "\n";
$dep = $dm->create(array('dependency_type' => 'S', 'dependency_lhs_item' => 1, 'dependency_rhs_item' => 2));
echo get_class($dep) . "\n";
$cal = $cm->create(array('calendar_name' => 'Test Calendar', 'calendar_hoursinday' => 8, 'calendar_hoursinweek' => 40, 'calendar_type' => 'weekly', 'calendar_data' => ''));
echo get_class($cal) . "\n";
$res = $rm->create(array('resource_type' => 'M', 'resource_name' => 'Test Resource', 'resource_base_calendar' => 1));
echo get_class($res) . "\n";
$resavail = $ram->create(array('resource_id' => 1, 'availability_date' => 1121404095, 'availability_hours' => 2));
echo get_class($resavail) . "\n";