diff --git a/~dev_rating/application/classes/Model/Student.php b/~dev_rating/application/classes/Model/Student.php index 47d3cab6dabf14f597ad4dccea324f683734f70c..6018f805c775193c25b22dec1dd3c1b23eb36198 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