PHP code example of crocodile2u / tinyorm

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

    

crocodile2u / tinyorm example snippets


$select = (new Select("my_table"))
    ->join("LEFT JOIN another_table USING (join_column)")
    ->where("filter_column = ?", $filterColumnValue)
    ->setConnection($db);
$count = $select->count("DISTINCT id");
$rows = $select->execute()->fetchAll(\PDO::FETCH_ASSOC);

$select->setFetchMode(\PDO::FETCH_ASSOC);
$select->setFetchClass(MyTableEntity::class);
$select->setFetchInto(new MyTableEntity());

$txManager = new \tinyorm\TxManager();
$txManager->registerConnection($this->connection)
    ->registerConnection($this->connection2);

$result = $txManager->atomic(function () {
    $this->connection->exec("INSERT INTO test (c_unique) VALUES ('val1')");
    $this->connection2->exec("INSERT INTO test (c_unique) VALUES ('val2')");
    return true;
});