DB.PHP - PHP ORM

Load all from table and iterate throught the result

To load all records for table which in case of ORM means to load all objects of class use:

$result = $database->path->to->class->load ();

Example:

$products = $database->shop->product->load ();

if ($products)
{
    foreach ($products as $product)
    {
        echo $product->name;
    }
}

Result represents regular array, keys of array represents ids of objects. If we know that we have product with id 2 we can access it in load result by following code:

echo $products[2]->name;