1. Go to this page and download the library: Download erodriguezds/active-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/ */
erodriguezds / active-orm example snippets
$results = (new Query($myPdo))
->select('*') // not necesary
->from('users')
->where([
'name' => $submitedName, // translates to "name = ? ", where '?' will be replaced by the SQL-escaped value of $submittedPage
[ 'age', '>', $submitedAge ], // 3-elements array syntax for 'field', 'operator' and 'value'. The 3rd element will be prepared by PDO
"age < $submitedAge", //more confortable, but this way, you won't have a PDO prepared parameter
'id' => [2, 3, 6], // translates to "id IN(2, 3, 6)"
], 'OR') // OR's all the previously defined condition. Default is 'AND'
->fetchAll(); // you could also "fetchOne()"
foreach($result as $row){
// ...
}
use ActiveORM\Query;
....
$pdo = new \PDO('mysql:dbname=goldoni;host=localhost;charset=utf8', 'root', 'root');
$query = (new Query($pdo))
use ActiveORM\Query;
....
$pdo = new \PDO('mysql:dbname=goldoni;host=localhost;charset=utf8', 'root', 'root');
Query::setPdo($pdo);
....
$query = (new Query()) //will get the PDO instance from the global set
->select('*')
->from('users')
->where(...)
composer
$query = (new Query())->from('users')->select('first_name');