diff options
| author | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-05-27 13:06:44 +0300 |
|---|---|---|
| committer | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-05-27 13:06:44 +0300 |
| commit | d1338cbb59d0752155f17d94b0b9b073df95183f (patch) | |
| tree | 75b7fe87a47ee6961dc38263582117bb920fa1d4 /public/app/models/Content_model.php | |
| parent | 38cc5c0c3abed6cfe4fbe0cbabec60a8ed64784d (diff) | |
| download | gyraf1gov-d1338cbb59d0752155f17d94b0b9b073df95183f.tar.gz gyraf1gov-d1338cbb59d0752155f17d94b0b9b073df95183f.tar.bz2 gyraf1gov-d1338cbb59d0752155f17d94b0b9b073df95183f.zip | |
content model; add petition to database
Diffstat (limited to 'public/app/models/Content_model.php')
| -rw-r--r-- | public/app/models/Content_model.php | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/public/app/models/Content_model.php b/public/app/models/Content_model.php new file mode 100644 index 0000000..ea19165 --- /dev/null +++ b/public/app/models/Content_model.php @@ -0,0 +1,101 @@ +<?php +namespace app\models; + +use \Registry; + + +class Content_model { + + ## P E T I T I O N S + ## ------------------------------------------------------------------------- + + /** add petition + * + * add petition record to the database + * + * @param array $data + * @return int new petition-ID + */ + public static function add_petition($data) + { + return Registry::use('database')->query( + "INSERT INTO petition + (user_id, `type_id`, `subject`, `signature`, `form_structure`) + VALUES (:user_id, :type_id, :subject, :signature, :form_structure)", + [ + ':user_id' => $data['user_id'], + ':type_id' => $data['type_id'], + ':subject' => $data['subject'], + ':signature' => $data['signature'], + ':form_structure' => $data['form_structure'] + ] + )->lastInsertID(); + } + + + /** set protocol + * + * @param int $pid: petition ID + * @param string $protocol: official pritocol number (full string) + */ + public static function set_protocol($pid, $protocol) + { + Registry::use('database')->runQuery( + "UPDATE petition SET protocol = :protocol WHERE id = :pid", + [ + ':protocol' => $protocol, + ':pid' => $pid + ] + ); + return true; + } + + + /** user petitions + * + * get all petitions of a user + * + * @param int $uid: user id + * @return array petition records + */ + public static function user_petitions($uid) + { + return Registry::use('database')->runQuery( + "SELECT * FROM petition WHERE user_id = :uid", + [ ':uid' => $uid ] + ); + } + + + /** all petitions + * + * get all petitions of a user + * + * @param void + * @return array petition records + */ + public static function all_petitions() + { + return Registry::use('database')->runQuery( + "SELECT * FROM petition", + [] + ); + } + + + + ## F I L E S + ## ------------------------------------------------------------------------- + + /** files + * return all files + * @param void + * @return array + */ + public static function files() + { + return Registry::use('database')->runQuery("SELECT * from media", []); + } + + +} |
