summaryrefslogtreecommitdiff
path: root/html/app/models/Jorge.php
diff options
context:
space:
mode:
authorGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-03-12 18:00:00 +0200
committerGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-03-12 18:00:00 +0200
commit221af3a2e035bd6689294509feb52f286d3bd5be (patch)
tree811188225d6edc9f303c777f86aa8604c6f21743 /html/app/models/Jorge.php
parent8b1a9cca9ca949d431f6ef5cf2b1fba0f27b4209 (diff)
downloadclassroom-221af3a2e035bd6689294509feb52f286d3bd5be.tar.gz
classroom-221af3a2e035bd6689294509feb52f286d3bd5be.tar.bz2
classroom-221af3a2e035bd6689294509feb52f286d3bd5be.zip
database connection and documentation API
Diffstat (limited to 'html/app/models/Jorge.php')
-rw-r--r--html/app/models/Jorge.php33
1 files changed, 18 insertions, 15 deletions
diff --git a/html/app/models/Jorge.php b/html/app/models/Jorge.php
index 011b8c0..5d79007 100644
--- a/html/app/models/Jorge.php
+++ b/html/app/models/Jorge.php
@@ -43,21 +43,23 @@ class Jorge
// define relations
$this->tables['relate'] = [
- 'products' => [
- 'brands' => 'products.BrandID = brands.ID',
- 'products_to_product_categories' => 'products.ID = products_to_product_categories.SimpleProductID',
- 'products_to_images' => 'products.ID = products_to_images.SimpleProductID',
- 'prices' => 'products.SKU = prices.SKU'
+ 'lesson' => [
+ 'course' => 'course.id = lesson.course_id',
+ 'lesson_media' => 'lesson_media.lesson_id = lesson.id',
+ 'lesson_privilege' => 'lesson_privilege.lesson_id = lesson.id'
],
- 'products_to_product_categories' => [
- 'product_categories' => 'product_categories.ID = products_to_product_categories.ProductCategoryID'
+ 'page' => [
+ 'page_media' => 'page_media.page_id = page.id'
],
- 'products_to_images' => [
- 'products' => 'products_to_images.SimpleProductID = products.ID',
- 'assets' => 'products_to_images.ImageID = assets.ID'
- ]
+ 'user' => [
+ 'user_privilege' => 'user_privilege.user_id = user.id'
+ ],
+
+ 'privilege' => [
+ 'user_privilege' => 'user_privilege.privilege_id = privilege.id'
+ ],
];
@@ -113,7 +115,7 @@ class Jorge
private function extractTableFields()
{
// words used by SQL that can not be field names
- $nonFields = ['PRIMARY', 'KEY', '(', ')']; // reduced list (used on CREATE)
+ $nonFields = ['PRIMARY', 'KEY', '(', ')', 'CONSTRAINT', 'UNIQUE']; // reduced list (used on CREATE)
foreach( $this->tables['create'] as $table => $sqlCreate ) {
@@ -130,10 +132,11 @@ class Jorge
// remove 1st+last parentesis
$mainDefinitions = substr($match[0][0], 1, -1);
- // replace comma (,) on decimal definitions
- // example: 'decimal(18, 2)' turns to 'decimal(18: 2)'
+ // replace comma (,) on sub-parenthesis
+ // ex: 'decimal(18, 2)' turns to 'decimal(18: 2)'
+ // or: 'PRIMARY KEY (id1, id2)' turns to 'PRIMARY KEY (id1: id2)'
$sentences = preg_replace(
- '/\\(([0-9]*)[ ,]([0-9 ]*)\\)/',
+ '/\\(([0-9a-zA-Z_`]*)[ ,]([0-9a-zA-Z_` ]*)\\)/',
'($1:$2)',
$mainDefinitions,
-1