1. Go to this page and download the library: Download faslatam/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/ */
faslatam / orm example snippets
class User extends \Forestry\Orm\BaseModel {
public static $database = 'example';
public static $table = 'users';
}
$user = new User;
$user->setName('Bob');
$user->save();
$user = new User;
$user->name = 'Bob';
$user->save();
\Forestry\Orm\Storage::set('default', [
'dsn' => 'mysql:host=localhost',
'user' => 'root',
'password' => '',
'option' => [/* any PDO options can be defined here */]
]);
use \Forestry\Orm\Storage;
use \Forestry\Orm\BaseModel;
Storage::set('myOtherConnection', [
'dsn' => 'mysql:host=127.0.0.1',
'user' => 'root',
'password' => ''
]);
class Acme extends BaseModel {
public static $storage = 'myOtherConnection';
public static $table = 'acme_table';
}
Storage::get('myOtherConnection')->exec('SELECT * FROM example.users');
Storage::delete('myOtherConnection');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.