*Hi. Im trying to make my own entity - item(e-shop). So far I have this http://pastebin.com/KgrzBzAY 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 ? ** * *Ivan Jaroš* *blog: ivanjaros.com* tel: +421 948 496 678 skype: ijaros
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 http://pastebin.com/KgrzBzAY 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; $item->save(); 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. http://drupal.org/project/profile2 http://drupal.org/project/wsclient -- Klaus Purer 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
participants (2)
-
Ivan Jaroš -
Klaus Purer