Skip to content
This repository was archived by the owner on May 12, 2022. It is now read-only.

Commit c13bc99

Browse files
author
Nik Barham
committed
2 parents a3403cb + 6423a0c commit c13bc99

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,29 @@ $ composer require brokencube\automatorm
1212

1313
### Requirements
1414
PHP 7.0 + PDO (Currently only MySQL supported - expect to support other engines in the future)
15+
16+
### Basic Example
17+
```php
18+
<?php
19+
use Automatorm\Orm\{Model,Schema};
20+
use Automatorm\DataLayer\Database\Connection;
21+
22+
// Class that is linked to the table "blog" - namespace is linked to a particular schema + connection
23+
namespace models {
24+
class Blog extends Model {}
25+
}
26+
27+
// Get db connection
28+
$connection = Connection::register($pdo);
29+
30+
// Get db schema for the ORM and assign to 'models' namespace as above
31+
Schema::generate($connection, 'models');
32+
33+
// Find a table row based on a simple where clause
34+
$blog = Blog::find(['title' => 'My Blog']); // Select * from blog where title = 'My Blog';
35+
36+
echo $blog->id; // Prints "1"
37+
echo $blog->title; // Prints "My First Entry"
38+
```
39+
40+
A more detailed layout of how to use the ORM can be found in the [Wiki](https://github.com/brokencube/automatorm/wiki)

0 commit comments

Comments
 (0)