phpDataMapper bunu yapmak için özel olarak tasarlanmıştır. Orada onunla birlikte gelen hiçbir dağıtılan kabuk veya cli komut vardır, ancak kod temeli bu yapabilirsiniz:
Kurulum adaptörü:
try {
$adapter = new phpDataMapper_Adapter_Mysql('localhost', 'db', 'root', '');
} catch(Exception $e) {
echo $e->getMessage();
exit();
}
Lütfen mapper / tablo alanlarını tanımlayın:
class PostMapper extends phpDataMapper_Base
{
// Specify the data source (table for SQL adapters)
protected $_datasource = "blog_posts";
// Define your fields as public class properties
public $id = array('type' => 'int', 'primary' => true, 'serial' => true);
public $title = array('type' => 'string', 'required' => true);
public $body = array('type' => 'text', 'required' => true);
public $status = array('type' => 'string', 'default' => 'draft');
public $date_created = array('type' => 'datetime');
}
Adaptörü (ler), ve kurulum tablolar ile eşleştiricisini örneğini:
$postMapper = new PostMapper($adapter [, $adapterSlave]);
$postMapper->migrate();
http://phpdatamapper.com/documentation/getting-started/