At its simplest, dojo.data requires that you provide the name of the identifier field in each item, and a set of items (data). You can either pass these in via the constructor, or via mutators:
Example 340. Zend_Dojo_Data initialization via constructor
<?php
$data = new Zend_Dojo_Data('id', $items);
Example 341. Zend_Dojo_Data initialization via mutators
<?php
$data = new Zend_Dojo_Data();
$data->setIdentifier('id')
->addItems($items);
You can also add a single item at a time, or append items, using
addItem() and addItems().
Example 342. Appending data to Zend_Dojo_Data
<?php
$data = new Zend_Dojo_Data($identifier, $items);
$data->addItem($someItem);
$data->addItems($someMoreItems);
Always use an identifier!
Every dojo.data datastore requires that the identifier column
be provided as metadata, including Zend_Dojo_Data. In fact,
if you attempt to add items without an identifier, it will raise an exception.
Individual items may be one of the following:
Associative arrays
Objects implementing a
toArray()methodAny other objects (will serialize via
get_object_vars())
You can attach collections of the above items via
addItems() or setItems() (overwrites
all previously set items); when doing so, you may pass a single argument:
Arrays
Objects implementing the
Traversableinterface ,which includes the interfacesIteratorandArrayAccess.
If you want to specify a field that will act as a label for the
item, call setLabel():
Finally, you can also load a Zend_Dojo_Data item from a
dojo.data JSON array, using the
fromJson() method.




