You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/10. Miscellaneous.md
+3
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,8 @@
1
1
# PHPFUI\ORM Miscellaneous
2
2
3
+
## SQLite Support
4
+
While this library is tested against SQLite, there are differences between MySQL/MariaDB syntax and SQLite syntax. Most notabliy is insertOrUpdate() and insertOrIgnore() which are not supported for SQLite. Use the custom SQL query support below instead.
5
+
3
6
## Custom SQL Queries
4
7
**PHFUI\ORM** supports raw string queries for special cases or complex queries. The following static methods of [\PHPFUI\ORM](http://phpfui.com/?n=PHPFUI&c=ORM) are supported:
Copy file name to clipboardexpand all lines: docs/5. Virtual Fields.md
+30-5
Original file line number
Diff line number
Diff line change
@@ -3,9 +3,13 @@
3
3
4
4
You can define virtual fields with get and set semantics for any **\App\Record** class. Virtual fields are evaluated before any database field, so you can override the database defaults if needed, or create new functionality.
5
5
6
-
Every **\App\Record** class has a static $virtualFields array defined. The key of the array is the name of the virtual key. The value for each virtual field is an array of strings. The first string is the virtual field class name. Subsequent parameters are are passed the the **getValue** and **setValue** methods.
6
+
Every **\App\Record** class has a static $virtualFields array defined. The key of the array is the name of the virtual key. The value for each virtual field is an array of strings. The first string is the virtual field class name. Subsequent parameters are are passed the the **getValue** and **setValue** methods.
7
7
8
-
## One To One and Parent Relationships
8
+
The **VirtualField** class has two properties that will always be defined for use by the derived class:
9
+
* $currentRecord is the current record that the virtual field should be based on.
10
+
* $fieldName the field name that the VirtualField object was created from. This is the key of the $virtualFields array in the Record class.
11
+
12
+
## One To One and Parent Related Record Relationships
9
13
If a field is named the same way as a corresponding table and suffixed with the proper ID, **PHPFUI\ORM** will automatically generate a One To One or parent relationship for you.
10
14
11
15
A child record with an ID field of the parent record automatically has a parent relationship via the build in related record functionality.
@@ -20,6 +24,29 @@ Likewise, the Invoice record has a relationship to its Order record, and from th
20
24
$invoice = new \App\Record\Invoice(7);
21
25
echo $invoice->order->shipper->company;
22
26
```
27
+
## Custom Related Record Relationships
28
+
Sometimes you can't name a related record with the name of the table. For example you might have an Employee table, but yet need to have several references to different employees in the same table. You might have the following fields which are all Employee Ids:
29
+
* salesPerson_id
30
+
* packedBy_id
31
+
* inspectedBy_id
32
+
33
+
You can make them all return employees with the following virtual field definitions:
34
+
```php
35
+
class Order extends \Tests\App\Record\Definition\Order
0 commit comments