<object class="harbourEvent" table="harbour_events" extends="xPDOSimpleObject">
<field key="name" dbtype="varchar" precision="100" phptype="string" null="false" default=""/>
<field key="location" dbtype="text" phptype="string" null="false" default=""/>
<field key="type" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false"/>
<field key="start_date" dbtype="datetime" phptype="datetime" null="true"/>
<field key="end_date" dbtype="datetime" phptype="datetime" null="true"/>
<field key="price_member" dbtype="decimal" precision="8,2" phptype="float" null="false" default="0"/>
<field key="price_others" dbtype="decimal" precision="8,2" phptype="float" null="false" default="0"/>
<field key="max_attendees" dbtype="int" precision="8" phptype="integer" null="true"/>
<aggregate alias="EventType" class="harbourEventType" local="type" foreign="id" cardinality="one" owner="foreign"/>
<composite alias="Attendees" class="harbourEventAttendee" local="id" foreign="event_id" cardinality="many" owner="local"/>
<composite alias="Contestants" class="harbourContestAttendee" local="id" foreign="event_id" cardinality="many" owner="local"/>
</object>
<object class="harbourEventType" table="harbour_event_types" extends="xPDOSimpleObject">
<field key="name" dbtype="varchar" precision="100" phptype="string" null="false"/>
<field key="controller" dbtype="varchar" precision="25" phptype="string" null="false"/>
<composite alias="Events" class="harbourEvent" local="id" foreign="type" cardinality="many" owner="local"/>
</object>
<object class="harbourEventAttendee" table="harbour_event_attendees" extends="xPDOSimpleObject">
<field key="user_id" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="true"/>
<field key="event_id" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false"/>
<field key="boat_id" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="true"/>
<field key="additional" dbtype="text" phptype="string" null="true"/>
<aggregate alias="User" class="modUser" local="user_id" foreign="id" cardinality="one" owner="foreign"/>
<aggregate alias="Event" class="harbourEvent" local="event_id" foreign="id" cardinality="one" owner="foreign"/>
</object>
<object class="harbourContestAttendee" table="harbour_contest_attendees" extends="harbourEventAttendee">
<field key="spinnaker" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0"/>
<field key="skipper_name" dbtype="varchar" precision="50" phptype="string" null="false"/>
<field key="skipper_phone" dbtype="varchar" precision="24" phptype="string" null="false"/>
<field key="skipper_email" dbtype="varchar" precision="50" phptype="string" null="false"/>
<field key="association" dbtype="varchar" precision="100" phptype="string" null="false" default=""/>
<field key="deckhands" dbtype="text" phptype="string" null="true"/>
</object><?php
/**
* @package harbour
* @subpackage model.mysql
*/
require_once (strtr(realpath(dirname(__FILE__)), '\\', '/') . '/harboureventattendee.class.php');
class harbourContestAttendee extends harbourEventAttendee {}<?php
$attendee = $modx->newObject('harbourContestAttendee');
$attendee->set('user_id', $hook->getValue('user_id'));
$attendee->set('event_id', $hook->getValue('event'));
$attendee->set('boat_id', $boat->get('id'));
$attendee->fromArray(array(
'additional' => $hook->getValue('additional'),
'spinnaker' => $hook->getValue('spinnaker'),
'skipper_name' => $hook->getValue('skipper_name'),
'skipper_phone' => $hook->getValue('skipper_phone'),
'skipper_email' => $hook->getValue('skipper_email'),
'association' => $hook->getValue('association'),
'deckhands' => $hook->getValue('deckhands')
));
$attendee->save();This question has been answered by opengeek. See the first response.
$modx->loadClass('harbour.harbourEventAttendee', $harbour->config['modelPath'], true, true);
$attendee = $modx->newObject('harbourContestAttendee');
$attendee->set('user_id', $hook->getValue('user_id'));
$attendee->set('event_id', intval($hook->getValue('event')));
$attendee->set('boat_id', $boat->get('id'));
$attendee->fromArray(array(
'additional' => $hook->getValue('additional'),
'spinnaker' => $hook->getValue('spinnaker'),
'skipper_name' => $hook->getValue('skipper_name'),
'skipper_phone' => $hook->getValue('skipper_phone'),
'skipper_email' => $hook->getValue('skipper_email'),
'association' => $hook->getValue('association'),
'deckhands' => $hook->getValue('deckhands')
));
$attendee->save();[2013-07-09 16:13:15] (DEBUG @ /index.php) Returning table name: `modx_harbour_contest_attendees` for class: harbourContestAttendee
[2013-07-09 16:13:15] (DEBUG @ /index.php) Returning ancestry for harbourContestAttendee: Array
(
[0] => harbourContestAttendee
[1] => harbourEventAttendee
[2] => xPDOSimpleObject
[3] => xPDOObject
)
[2013-07-09 16:13:15] (DEBUG @ /index.php) No primary key value found for pk definition: id
[2013-07-09 16:13:15] (DEBUG @ /index.php) Returning ancestry for harbourContestAttendee: Array
(
[0] => harbourEventAttendee
[1] => xPDOSimpleObject
[2] => xPDOObject
)
[2013-07-09 16:13:15] (DEBUG @ /index.php) Returning validation rules: Array
(
)
[2013-07-09 16:13:15] (DEBUG @ /index.php) Validation called but no rules were found.
[2013-07-09 16:13:15] (DEBUG @ /index.php) Validator class executed, result = 1
[2013-07-09 16:13:15] (DEBUG @ /index.php) Executing SQL:
INSERT INTO `modx_harbour_contest_attendees` (`spinnaker`, `skipper_name`, `skipper_phone`, `skipper_email`, `association`, `deckhands`) VALUES (:spinnaker, :skipper_name, :skipper_phone, :skipper_email, :association, :deckhands)
with bindings:
Array
(
[:spinnaker] => Array
(
[value] => 0
[type] => 1
)
[:skipper_name] => Array
(
[value] => John Doe
[type] => 2
)
[:skipper_phone] => Array
(
[value] => 012-3456789
[type] => 2
)
[:skipper_email] => Array
(
[value] => [email protected]
[type] => 2
)
[:association] => Array
(
[value] => WSF
[type] => 2
)
[:deckhands] => Array
(
[value] => Jane Doe
Carl Test
Ren Test
[type] => 2
)
)
[2013-07-09 16:13:15] (DEBUG @ /index.php) Returning table class: harbourContestAttendee for class: harbourContestAttendee
[2013-07-09 16:13:15] (DEBUG @ /index.php) Returning table name: `modx_harbour_contest_attendees` for class: harbourContestAttendee
[2013-07-09 16:13:15] (DEBUG @ /index.php) xPDOObject::_getDataType() -- No data type specified for field (user_id), using `text`.
[2013-07-09 16:13:15] (DEBUG @ /index.php) xPDOObject::_getPHPType() -- No PHP type specified for field (user_id), using `string`.
[2013-07-09 16:13:15] (DEBUG @ /index.php) xPDOObject::_getDataType() -- No data type specified for field (event_id), using `text`.
[2013-07-09 16:13:15] (DEBUG @ /index.php) xPDOObject::_getPHPType() -- No PHP type specified for field (event_id), using `string`.
[2013-07-09 16:13:15] (DEBUG @ /index.php) xPDOObject::_getDataType() -- No data type specified for field (boat_id), using `text`.
[2013-07-09 16:13:15] (DEBUG @ /index.php) xPDOObject::_getPHPType() -- No PHP type specified for field (boat_id), using `string`.
[2013-07-09 16:13:15] (DEBUG @ /index.php) xPDOObject::_getDataType() -- No data type specified for field (additional), using `text`.
[2013-07-09 16:13:15] (DEBUG @ /index.php) xPDOObject::_getPHPType() -- No PHP type specified for field (additional), using `string`.$modx->loadClass('harbour.harbourEventAttendee', $harbour->config['modelPath'], true, false);I just realized my error, obviously the class is related an xPDOObject. Switched $transient to false and it's now working perfectly.You don't actually need to include anything but the first parameter if your package is loaded, and likely don't need the "harbour." prefix, though that is harmless, e.g.
$modx->loadClass('harbour.harbourEventAttendee', $harbour->config['modelPath'], true, false);
Thanks for your help!
$modx->loadClass('harbourEventAttendee');