1. Go to this page and download the library: Download dynamonet/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/ */
dynamonet / orm example snippets
use Dynamo\ORM\Query;
....
$pdo = new \PDO('mysql:dbname=goldoni;host=localhost;charset=utf8', 'root', 'root');
$query = (new Query($pdo))
Query::setPdo($pdo);
....
$query = (new Query()) // this will use the static PDO instance.
$users = (new Query)
->select('*') // This is the default select
->from('users')
->where([
'role' => 'ADMIN', // translates to "role = ?", where "?" will be securely replaced by the PDO layer
'age > $minAge', // insecure! $minAge is not verified! However, we allow this form for convenience
[ 'age', '<=', $maxAge ], // better
], false) // false "OR's" all the previous conditions. Default is true, which will "AND" all the conditions.
->all(); // Fetches all the results
composer
namespace MyApp;
use Dynamo\ORM\ActiveModel;
class User extends ActiveModel
{
//
}
namespace MyApp;
use Dynamo\ORM\ActiveModel;
class User extends ActiveModel
{
public static function getTableName()
{
return 'my_users_table';
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.