[2012-02-12 18:53:37] (ERROR @ /index.php) No foreign key definition for parentClass: RunnerEntrant using relation alias: TimeLive
<?xml version="1.0" encoding="UTF-8"?> <model package="athletes" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1"> <object class="RunnerEntrant" table="runnerEntrant" extends="xPDOObject"> <field key="AutoId" dbtype="int" precision="10" phptype="integer" null="false" index="pk" generated="native" /> <field key="RegId" dbtype="int" precision="10" phptype="integer" null="true" /> <field key="EventId" dbtype="int" precision="10" phptype="integer" null="true" /> <field key="EventTitle" dbtype="varchar" precision="100" phptype="string" null="true" /> <field key="ClientEventId" dbtype="int" precision="10" phptype="integer" null="true" /> <field key="GroupId" dbtype="int" precision="10" phptype="integer" null="true" /> <field key="StatusDescription" dbtype="varchar" precision="30" phptype="string" null="true" /> <field key="RegTypeDescription" dbtype="varchar" precision="60" phptype="string" null="true" /> <field key="first_Name" dbtype="varchar" precision="30" phptype="string" null="true" /> <field key="last_Name" dbtype="varchar" precision="30" phptype="string" null="true" /> <field key="FirstLastName" dbtype="varchar" precision="60" phptype="string" null="true" /> <field key="City" dbtype="varchar" precision="30" phptype="string" null="true" /> <field key="Country" dbtype="varchar" precision="30" phptype="string" null="true" /> <field key="HomePhone" dbtype="varchar" precision="20" phptype="string" null="true" /> <field key="CellPhone" dbtype="varchar" precision="20" phptype="string" null="true" /> <field key="Email_Address" dbtype="varchar" precision="100" phptype="string" null="true" /> <field key="DateOfBirth" dbtype="varchar" precision="9" phptype="string" null="true" /> <field key="Gender" dbtype="varchar" precision="1" phptype="string" null="true" /> <field key="Nationality" dbtype="varchar" precision="30" phptype="string" null="true" /> <field key="BibNumber" dbtype="int" precision="4" phptype="integer" null="true" /> <field key="EmergencyContactName" dbtype="varchar" precision="40" phptype="string" null="true" /> <field key="EmergencyContactPhone" dbtype="varchar" precision="20" phptype="string" null="true" /> <field key="Shuttle" dbtype="varchar" precision="8" phptype="string" null="true" /> <field key="Shuttle50" dbtype="varchar" precision="8" phptype="string" null="true" /> <field key="Shuttle100" dbtype="varchar" precision="8" phptype="string" null="true" /> <field key="alphaCountryCode" dbtype="varchar" precision="2" phptype="string" null="true" /> <field key="timeAdded" dbtype="timestamp" phptype="timestamp" null="false" default="CURRENT_TIMESTAMP" /> <index alias="PRIMARY" name="PRIMARY" primary="true" unique="true" type="BTREE" > <column key="AutoId" length="" collation="A" null="false" /> </index> <composite alias="TimeLive" class="TimeLive" local="RegId" foreign="runnerId" cardinality="many" owner="local" /> </object> <object class="TimeLive" table="timeLive" extends="xPDOObject"> <field key="autoId" dbtype="int" precision="10" phptype="integer" null="false" index="pk" generated="native" /> <field key="runnerId" dbtype="int" precision="20" phptype="integer" null="true" /> <field key="stationId" dbtype="int" precision="6" phptype="integer" null="true" /> <field key="raceId" dbtype="int" precision="4" phptype="integer" null="true" /> <field key="timeUnix" dbtype="timestamp" phptype="timestamp" null="true" /> <field key="createdon" dbtype="timestamp" phptype="timestamp" null="false" default="CURRENT_TIMESTAMP" /> <index alias="PRIMARY" name="PRIMARY" primary="true" unique="true" type="BTREE" > <column key="autoId" length="" collation="A" null="false" /> </index> <aggregate alias="RunnerEntrant" class="RunnerEntrant" local="runnerId" foreign="RegId" cardinality="one" owner="foreign" /> </object> </model>
foreach ($athletes as $athlete){
echo ($athlete->get('FirstLastName'). '<br />');
// get all related times
$runnerTimes = $athlete->getMany('TimeLive');
print_r($runnerTimes);
// Loop over times and do stuff
if (!empty ($runnerTimes)) {
foreach ($runnerTimes as $runnerTime){
echo ('Unixtime: '. $runnerTime->get('timeUnix') . '<br/>');
}
}
echo ('<hr />');
}
[[!CreateXpdoClasses? &myPackage=`athletes` &myPrefix=`cr_` &createSchema=`0`]]
<?xml version="1.0" encoding="UTF-8"?> <model package="athletes" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1"> </model>
$createSchema = $modx->getOption('createSchema',$scriptProperties,true);$createSchema = false;
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 11482154 bytes) in /home/centurio/public_html/core/model/modx/modparser.class.php on line 120
Fatal error: Maximum execution time of 60 seconds exceeded in /home/centurio/public_html/core/xpdo/om/xpdoobject.class.php on line 628
foreach ($athletes as $athlete){
echo ($athlete->get('FirstLastName'). '<br />');
// get all related times
$runnerTimes = $athlete->getMany('TimeLive');
}
$runnerTimes = $athlete->getMany('TimeLive');
<?php
$xpdo_meta_map['TimeLive']= array (
'package' => 'athletes',
'version' => '1.1',
'table' => 'timeLive',
'fields' =>
array (
'autoId' => NULL,
'runnerId' => NULL,
'stationId' => NULL,
'raceId' => NULL,
'timeUnix' => NULL,
'createdon' => 'CURRENT_TIMESTAMP',
),
'fieldMeta' =>
array (
'autoId' =>
array (
'dbtype' => 'int',
'precision' => '10',
'phptype' => 'integer',
'null' => false,
'index' => 'pk',
'generated' => 'native',
),
'runnerId' =>
array (
'dbtype' => 'int',
'precision' => '20',
'phptype' => 'integer',
'null' => true,
),
'stationId' =>
array (
'dbtype' => 'int',
'precision' => '6',
'phptype' => 'integer',
'null' => true,
),
'raceId' =>
array (
'dbtype' => 'int',
'precision' => '4',
'phptype' => 'integer',
'null' => true,
),
'timeUnix' =>
array (
'dbtype' => 'timestamp',
'phptype' => 'timestamp',
'null' => true,
),
'createdon' =>
array (
'dbtype' => 'timestamp',
'phptype' => 'timestamp',
'null' => false,
'default' => 'CURRENT_TIMESTAMP',
),
),
'indexes' =>
array (
'PRIMARY' =>
array (
'alias' => 'PRIMARY',
'primary' => true,
'unique' => true,
'type' => 'BTREE',
'columns' =>
array (
'autoId' =>
array (
'length' => '',
'collation' => 'A',
'null' => false,
),
),
),
),
'aggregates' =>
array (
'RunnerEntrant' =>
array (
'class' => 'RunnerEntrant',
'local' => 'runnerId',
'foreign' => 'RegId',
'cardinality' => 'one',
'owner' => 'foreign',
),
),
);
set_time_limit(0);
<?php
set_time_limit(0);
$path = MODX_CORE_PATH . 'components/athletes/';
$result = $modx->addPackage('athletes', $path . 'model/','cr_');
if (! $result) {
echo 'failed to add package';
} else {
echo '<p>Connected to live DB!</p>';
}
//Get all the Entrants for TP100 only
$query = $modx->newQuery('RunnerEntrant');
$query->select(array(
'AutoId',
'RegId',
'FirstLastName',
'BibNumber'
));
// just get one runner for now
$query->where(array(
'RegTypeDescription' => $race,
'StatusDescription' => 'Confirmed',
'RegId' => '31519946'
));
$query->sortby('BibNumber','ASC');
$athletes = $modx->getCollection('RunnerEntrant', $query);
//Get all the Aid stations for TP100 only
$query2 = $modx->newQuery('Station');
$query2->where(array(
'stationRaceId' => $raceId
));
$aidStations = $modx->getCollection('Station', $query2);
// Get all the times for TP100 only
$query3 = $modx->newQuery('TimeLive');
$query3->where(array(
'raceId' => $raceId
));
$times = $modx->getCollection('TimeLive', $query3);
//count how many entrants
$athletesCount = count($athletes);
echo ("<h2>no of athletes competing</h2>" . $athletesCount);
//count how many times have been recorded
$timesCount = count($times);
echo ("<h2>no of times recorded in the db</h2>" . $timesCount);
//count how many aidstaions there are
$aidStationsCount = count($aidStations);
echo ("<h2>no of aidstations</h2>" . $aidStationsCount);
echo("<h1>runnerEntrants </h1>");
foreach ($athletes as $athlete){
echo ($athlete->get('FirstLastName'). '<br />');
// get all related times
$runnerTimes = $athlete->getMany('TimeLive');
print_r($runnerTimes);
// Loop over times and do stuff
/*
if (!empty ($runnerTimes)) {
foreach ($runnerTimes as $runnerTime){
echo ('Unixtime: '. $runnerTime->get('timeUnix') . '<br/>');
}
}
echo ('<hr />');
*/
}
echo("<h1>StationName</h1>");
foreach ($aidStations as $aidStation){
echo ("<br />");
echo ($aidStation->get('stationName'));
}
echo("<h1>runnerEntrants </h1>");
foreach ($athletes as $athlete){
echo ($athlete->get('FirstLastName'). '<br />');
// get all related times
// $runnerTimes = $athlete->getMany('TimeLive');
// print_r($runnerTimes);
// Loop over times and do stuff
/*
if (!empty ($runnerTimes)) {
foreach ($runnerTimes as $runnerTime){
echo ('Unixtime: '. $runnerTime->get('timeUnix') . '<br/>');
}
}
echo ('<hr />');
*/
}