Monday 23 January 2006 2:26:51 am
Hi, I want to insert an object in a node. But it's doesn't work, but I have no error report and no process error.
$class =& eZContentClass::fetch(21);
$customer =& $class->instantiate(15);
$nodeAssignment =& eZNodeAssignment::create(
array(
'contentobject_id' => $customer->attribute( 'id' ),
'contentobject_version' => 1,
'parent_node' => $parent_node_id,
'is_main' => 1
)
);
$nodeAssignment->store();
$version =& $customer->version( 1 );
$version->setAttribute( 'modified', eZDateTime::currentTimeStamp() );
$version->setAttribute( 'status', EZ_VERSION_STATUS_PUBLISHED );
$version->store();
$db = & eZDB::instance();
$customers = $db->arrayQuery("SELECT * FROM customer WHERE code='$custNumber'");
if( $customers ) {
$contentObjectAttributes =& $version->contentObjectAttributes();
$contentObjectAttributes[0]->setAttribute('data_text', $customers[0]['name']);
$contentObjectAttributes[0]->store();
$contentObjectAttributes[1]->setAttribute('data_text', $customers[0]['code']);
$contentObjectAttributes[1]->store();
$customer->store();
}
This is the whole proccess with $customer object. This part doesn't work but I don't know why ?...The $customer object is not null and contains the required value. The query result is right too. Is there an error in eZNodeAssignment::create ? Do I forget parameters ? Or is the second parameter section for $class->instantiate required ?
Thanks for your help Julien
|