This example shows how to get all the objects from a table. Make sure there is a model with the same layout as the table.
$orm = new Orm_Core();
$items = $orm->get('Item');
foreach($items as $item)
{
// do something
}
Results are always returned in an array(). Even when getting something by a primary-key value.
$orm = new Orm_Core();
$item = $orm->get('Item', "WHERE id = :id", array("id" => 1));
Storing an object is easy. It doesn't matter wether your object should be stored or updated. All storage works through the save() function.
$orm = new Orm_Core();
$item = new Item();
$item->foo = "bar";
$orm->save($item);
An object obtained from the orm can simply be removed by using the remove() function.
$orm->remove($item);
Transactions can be used to group database interaction and execute it at once. Transactions can be used with save() and remove().
$orm = new Orm_Core();
$item = new Item();
$item->foo = "bar";
$orm->startTransaction();
$orm->save($item);
$orm->remove($earlierObtainedItem);
$orm->commitTransaction();
In addition a transaction can be cancelled before committing.
$orm->cancelTransaction();