From f6227a7fab9a717345ecce50babecc51e4be69ae Mon Sep 17 00:00:00 2001
From: xamgore <xamgore@ya.ru>
Date: Sat, 16 May 2015 22:09:20 +0300
Subject: [PATCH] Small additions to the `Student` model

---
 ~dev_rating/application/classes/Model/Student.php | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/~dev_rating/application/classes/Model/Student.php b/~dev_rating/application/classes/Model/Student.php
index 47d3cab6d..6018f805c 100644
--- a/~dev_rating/application/classes/Model/Student.php
+++ b/~dev_rating/application/classes/Model/Student.php
@@ -8,6 +8,9 @@ class Model_Student extends Model
         $student = new self();
         $student->id = (int) $id;
 
+        // todo: there should be a function to load data from db
+        //    Student_Get(id): array
+
         return $student;
     }
 
@@ -23,11 +26,12 @@ class Model_Student extends Model
      * @param $secondName
      * @param $gradeID
      * @param $activationCode
+     * @return $this;
      */
     public static function create($lastName, $firstName, $secondName, $gradeID, $activationCode) {
         $sql = 'SELECT `CreateStudent`(:last, :first, :second, :grade, :code)';
 
-        DB::query(Database::SELECT, $sql)
+        $id = DB::query(Database::SELECT, $sql)
             ->parameters([
                 'last' => $lastName,
                 'first' => $firstName,
@@ -36,9 +40,12 @@ class Model_Student extends Model
                 'code' => $activationCode,
             ])
             ->execute();
+
+        return self::load($id);
     }
 
 
+    // getters and setters
     function __get($name) {
         if ($name == 'id')
             return (int) $this->id;
@@ -47,6 +54,10 @@ class Model_Student extends Model
 
     function __set($name, $value) { }
 
+    // todo implementation
+    public function update() {
+        throw new BadMethodCallException('Method is not implemented yet!');
+    }
 
     /**
      * @see students_groups.IsStudyLeave
-- 
GitLab