PHP code example of dealnews / data-mapper
1. Go to this page and download the library: Download dealnews/data-mapper 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/ */
dealnews / data-mapper example snippets
$db_mapper = new \DB\Widget\Mapper();
// Load a Widget from a database
$widget = $db_mapper->load(1);
// Save the Widget to some external storage
// like a 3rd party API
$external_mapper = new \ExternalAPI\Widget\Mapper();
$widget = $external_mapper->save($widget);
# Application\Repository.php
$repo = new \DealNews\DataMapper\Repository();
$repo->add_mapper("Widget", new \DB\Widget\Mapper());
# Application\SomeFile.php
get");
$widget = $repo->save("Widget", $widget);