[development] Managing own entity
klaus.purer at gmail.com
Fri Nov 19 17:58:41 UTC 2010
On 11/19/2010 06:33 PM, Ivan Jaroš wrote:
> *Hi. Im trying to make my own entity - item(e-shop). So far I have this
> Lets say I have an array/object with data(name, price..), how do I save it
> and load it? How do I make Drupal insert, lets say, price into my price
> column in my item table ?
I recommend the Entity API module: http://drupal.org/project/entity
It comes with useful tools to handle entities. In your case you would
create a class that extends EntityDB for your needs.
If you want to create an item entity:
$item = new Item(); // Item is your newly created class
If you want to set a price for an item and save it:
$item->price = 50;
If you want to load an entity:
$item = entity_load('item', array('your_entity_id'));
or you define a custom loading function.
Have a look at entity.api.php that comes with the entity module. Further
examples that make use of entities are profile2 and wsclient.
This E-Mail contains a digital signature and can be verified with this
PGP|GPG Public Key: http://web.student.tuwien.ac.at/~e0426223/key/kp.asc
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 262 bytes
Desc: OpenPGP digital signature
Url : http://lists.drupal.org/pipermail/development/attachments/20101119/74e2149f/attachment.bin
More information about the development