David Santiso
|
Wednesday 04 May 2011 2:28:28 pm
Hi, I'm developing an extension that updates an attribute of an object. I read the tutorial and explains how to insert and query data from the database, but doesn't explain how to update. I've created the module, function and class, but I'm blocked. In ezpersistentobject class ther is a function updateObjectList, but I have to pass a variable $parameters. My code is this: exempleclass.php
class ExempleClass extends eZPersistentObject {
function exempleclass( $row ) {
$this->eZPersistenObject( $row );
}
function definition() {
return array( 'fields' => array( 'id' => array( 'name' => 'id',
'datatype' => 'integer',
'default' => 0,
'required' => true ),
'user_id' => array( 'name' => 'version',
'datatype' => 'integer',
'default' => 0,
'required' => true ),
'created' => array( 'name' => 'data_int',
'datatype' => 'integer',
'default' => 0,
'required' => false ) ),
'class_name' => 'exempleclass',
'name' => 'ezcontentobject_attribute' );
}
function update( $attribute_id, $version, $value ) {
$row = array( 'definition' => array( 'name' => 'ezcontentobject_attribute',
'fields' => array( ),
'key' ),
'update_fields' => array( 'data_int' => $value ),
'conditions' => array( 'id' => $attribute_id,
'version' => $version ) );
return new exempleclass( $row );
}
} exemplefunction.php
include_once 'extension/example/classes/exempleclass.php';
$Module = $Params['Module'];
$attributeId= $Params['AttributeId'];
$version = $Params['Version'];
$ExampleClass= ExampleClass::update( $attributeId, $version, 23 ); How do I call the function to update? Thanks, David
|
David Santiso
|
Thursday 05 May 2011 6:09:58 am
Ok. I've to do this in function.php:
includes...
$Module = $Params['Module'];
$objectId = $Params['ObjectId'];
$attributeId = $Params['AttributeId'];
$version = $Params['Version'];
$contentObject= eZContentObject::fetchAttributesByIdentifier( $attributeId, $version, false, true );
... ? But, how do I change the attribute?
|
Marko Žmak
|
Thursday 05 May 2011 6:32:27 am
You can find some usefull tips about it here:
- http://share.ez.no/forums/developer/can-attribute-store-be-replaced-by-object-store
- http://share.ez.no/forums/developer/how-to-edit-store-user-attributes-within-a-extension
The last comment in the first thread is the simplest, but I think it won't clear the cache. As for the detailed docs about it I don't think there is any, you'll have to dig and try a little bit until you figure out what's the best for you.
--
Nothing is impossible. Not if you can imagine it!
Hubert Farnsworth
|