This repository was archived by the owner on May 12, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -12,3 +12,29 @@ $ composer require brokencube\automatorm
12
12
13
13
### Requirements
14
14
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 )
You can’t perform that action at this time.
0 commit comments