PHP code example of brokencube / automatorm

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

    

brokencube / automatorm example snippets



use Automatorm\Orm\{Model,Schema};
use Automatorm\DataLayer\Database\Connection;

// Class that is linked to the table "blog" - namespace is linked to a particular schema + connection
namespace models {
  class Blog extends Model {}
}

// Get db connection
$connection = Connection::register($pdo); 

// Get db schema for the ORM and assign to 'models' namespace as above
Schema::generate($connection, 'models');  

// Find a table row based on a simple where clause
$blog = Blog::find(['title' => 'My Blog']); // Select * from blog where title = 'My Blog';

echo $blog->id;     // Prints "1"
echo $blog->title;  // Prints "My First Entry"