Skip to content
Snippets Groups Projects
Commit f6227a7f authored by xamgore's avatar xamgore
Browse files

Small additions to the `Student` model

parent 0356c03e
Branches
Tags
No related merge requests found
...@@ -8,6 +8,9 @@ class Model_Student extends Model ...@@ -8,6 +8,9 @@ class Model_Student extends Model
$student = new self(); $student = new self();
$student->id = (int) $id; $student->id = (int) $id;
// todo: there should be a function to load data from db
// Student_Get(id): array
return $student; return $student;
} }
...@@ -23,11 +26,12 @@ class Model_Student extends Model ...@@ -23,11 +26,12 @@ class Model_Student extends Model
* @param $secondName * @param $secondName
* @param $gradeID * @param $gradeID
* @param $activationCode * @param $activationCode
* @return $this;
*/ */
public static function create($lastName, $firstName, $secondName, $gradeID, $activationCode) { public static function create($lastName, $firstName, $secondName, $gradeID, $activationCode) {
$sql = 'SELECT `CreateStudent`(:last, :first, :second, :grade, :code)'; $sql = 'SELECT `CreateStudent`(:last, :first, :second, :grade, :code)';
DB::query(Database::SELECT, $sql) $id = DB::query(Database::SELECT, $sql)
->parameters([ ->parameters([
'last' => $lastName, 'last' => $lastName,
'first' => $firstName, 'first' => $firstName,
...@@ -36,9 +40,12 @@ class Model_Student extends Model ...@@ -36,9 +40,12 @@ class Model_Student extends Model
'code' => $activationCode, 'code' => $activationCode,
]) ])
->execute(); ->execute();
return self::load($id);
} }
// getters and setters
function __get($name) { function __get($name) {
if ($name == 'id') if ($name == 'id')
return (int) $this->id; return (int) $this->id;
...@@ -47,6 +54,10 @@ class Model_Student extends Model ...@@ -47,6 +54,10 @@ class Model_Student extends Model
function __set($name, $value) { } function __set($name, $value) { }
// todo implementation
public function update() {
throw new BadMethodCallException('Method is not implemented yet!');
}
/** /**
* @see students_groups.IsStudyLeave * @see students_groups.IsStudyLeave
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment