hi,
i’ve been getting the following error when I try to update an existing record:
No primary key value found for pk definition:
I’m pretty stumped. I think I’ve left something out of the schema, but can’t see what it is. The schema for this table is:
<object class="PriceOverride" table="price_override" extends="xPDOSimpleObject">
<field key="property" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="" index="index" />
<field key="item" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="true" />
<field key="num_months" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="true" />
<field key="let_full_let" dbtype="enum" precision="'L','FL'" phptype="string" null="true" />
<field key="price" dbtype="decimal" precision="8,2" phptype="integer" null="false" default="" />
<aggregate class="Property" key="id" local="property" foreign="id" cardinality="one" />
<aggregate class="Items" key="id" local="item" foreign="id" cardinality="one" />
<aggregate class="NumMonths" key="id" local="num_months" foreign="id" cardinality="one" />
</object>
and the SQL for the table structure is:
CREATE TABLE `pfp_price_override` (
`id` int(10) unsigned NOT NULL auto_increment,
`property` int(10) unsigned NOT NULL,
`item` int(10) unsigned default NULL,
`num_months` int(10) unsigned default NULL,
`let_full_let` enum('L','FL') default NULL,
`price` decimal(8,2) NOT NULL,
PRIMARY KEY (`id`),
KEY `property` (`property`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Stores details of prices that have been overridden.' AUTO_INCREMENT=9 ;
I’m still not entirely sure where to define primary keys. This is bizarre since I’ve got other tables working fine. I can retrieve objects and update values, but I just can’t save the changes back to the db.
**edit**
I can retrieve values using a composite key such as:
$xpdo->getObject(’PriceOverride’, array(’property’ => intval($_POST[’id’]), ’num_months’ => intval($monthID[1])))
but not on the primary key with:
$po = $xpdo->getObject(’PriceOverride’, $id);
Thanks for any help
ps - i’m using xpdo alpha 16 (and don’t really want to upgrade)