From d1338cbb59d0752155f17d94b0b9b073df95183f Mon Sep 17 00:00:00 2001 From: George Halkiadakis Date: Sat, 27 May 2023 13:06:44 +0300 Subject: content model; add petition to database --- public/app/models/Content_model.php | 101 ++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 public/app/models/Content_model.php (limited to 'public/app/models/Content_model.php') 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 @@ +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", []); + } + + +} -- cgit v1.2.3