PHP code example of bronsted / orm

1. Go to this page and download the library: Download bronsted/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/ */

    

bronsted / orm example snippets


class Sample extends DbObject
{
    protected int $uid = 0;
    protected ?string $name = null;
    protected ?DateTime $created = null;
}

$sample = new Sample();
$uid = $sample->save();

// returns a single object
$sample = Sample::getByUid($uid);

// returns 0 or more objects
$samples = Sample::getBy(['name' => 'something%']);

$sample = Sample::getByUid($uid);
$sample->name = 'Hello';
$sample->save();

$sample = Sample::getByUid($uid);
$sample->delete();

$pdo = new PDO('sqlite::memory:');
$dbCon = new DbConnection($pdo);
Db::setConnection($dbCon);