diff options
| author | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-03-12 18:00:00 +0200 |
|---|---|---|
| committer | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-03-12 18:00:00 +0200 |
| commit | 221af3a2e035bd6689294509feb52f286d3bd5be (patch) | |
| tree | 811188225d6edc9f303c777f86aa8604c6f21743 /html/app/models | |
| parent | 8b1a9cca9ca949d431f6ef5cf2b1fba0f27b4209 (diff) | |
| download | classroom-221af3a2e035bd6689294509feb52f286d3bd5be.tar.gz classroom-221af3a2e035bd6689294509feb52f286d3bd5be.tar.bz2 classroom-221af3a2e035bd6689294509feb52f286d3bd5be.zip | |
database connection and documentation API
Diffstat (limited to 'html/app/models')
| -rw-r--r-- | html/app/models/Jorge.php | 33 | ||||
| -rw-r--r-- | html/app/models/cms/Media_model.php | 36 | ||||
| -rw-r--r-- | html/app/models/user/Validate_model.php (renamed from html/app/models/Validate_model.php) | 0 |
3 files changed, 54 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 diff --git a/html/app/models/cms/Media_model.php b/html/app/models/cms/Media_model.php index e69de29..6a4a681 100644 --- a/html/app/models/cms/Media_model.php +++ b/html/app/models/cms/Media_model.php @@ -0,0 +1,36 @@ +<?php + +namespace app\models\cms; + +use \Registry; + + +class Media_model +{ + public static function serve($type, $id, $ticket) + { + + // get media data + // [ type =>, rights =>, path => ] + + // validate ticket + // ValidateAccess::for($ticket) + + // serve + // header("Content-type: type"); + // passthru('cat $media_path'); + + + return Registry::use('database')->query( + "SELECT * FROM pages + WHERE FullFriendlyUrl = :url AND IsActive = 1", + [ ':url' => $url ] + )->getFirst(); + } + +} + + + +// check: +// https://stackoverflow.com/questions/1353850/serve-image-with-php-script-vs-direct-loading-an-image
\ No newline at end of file diff --git a/html/app/models/Validate_model.php b/html/app/models/user/Validate_model.php index ec60d72..ec60d72 100644 --- a/html/app/models/Validate_model.php +++ b/html/app/models/user/Validate_model.php |
