1. Go to this page and download the library: Download sledgehammer/orm library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sledgehammer / orm example snippets
use Sledgehammer\Orm\Repository;
// inside your bootstrap.php
$repo = Repository::instance();
$repo->registerBackend(new DatabaseRepositoryBackend("default")); // Extract models from the "default" database connection.
// Somewhere in your application
$repo = Repository::instance();
$customer = $repo->getCustomer($_GET['id']);
$customer->name = $_POST['name'];
$repo->saveCustomer($customer);
// When the Customer class extends Sledgehammer\ActiveRecord the familiar API is also available
$customer = Customer::one($_GET['id']);
$customer->name = $_POST['name'];
$customer->save();
// Linq style filtering
$selection = $repo->allCustomers()->where(array('name' => 'James Bond'))->where(function ($c) { return $c->isSpecialAgent(); });
$list = Customer::all()->select('name', 'id'); // Results in: array($id1 => $name1, $id2 => $name2, ...)
if ($customer->orders[0]->id === $order->id) { ... } // Always works
if ($customer->orders[0] === $order) { ...} // WRONG. Doesn't work reliably
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.