1. Go to this page and download the library: Download windwalker/datamapper 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/ */
php
use Windwalker\DataMapper\DataMapper;
$fooMapper = new DataMapper('#__foo');
$fooSet = $fooMapper->find(array('id' => 1));
php
// $db is Windwalker DatabaseDriver
$mapper = new DataMapper('table', null, $db);
php
// If keep keys NULL, the default `id` will auto set.
$mapper = new DataMapper('table'); // Keys: array('id')
// Set custom key
$mapper = new DataMapper('table', 'table_id'); // Keys: array('table_id')
// Set multiple keys
$mapper = new DataMapper('table', array('table_id', 'uuid')); // Keys: array('table_id', 'uuid')
php
$fooSet = $fooMapper->find(
array(
new GteCompare('id', 5),
new NeqCompare('name', 'bar')
new LtCompare('published', 1),
new NinCompare('catid', array(1,2,3,4,5))
)
);
php
echo (string) new Compare('title', '%flower%', 'LIKE');
php
class FooListener
{
public function onAfterCreate(Event $event)
{
$result = $event['result'];
// Do something
}
}
$mapper = new DataMapper('table');
// Add object as listener
$mapper->getDispatcher()->addListener(new FooListener);
// Use listen() to add a callback as listener
$mapper->getDispatcher()->listen('onAfterUpdate', function () { ... });
$mapper->create($dataset);
php
class SakuraMapper extends DataMapper
{
protected $table = 'saluras';
public function onAfterFind(Event $event)
{
$result = $event['result'];
// Find some relations
}
}
$mapper = new DataMapper('table');
$mapper->find(array('id' => 5));
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.