コード例 #1
0
 public function testTableName()
 {
     $this->given($tablename = \website\model\TeacherModuleSubscription::tableName())->then->string($tablename)->isEqualTo('TEACHER_MODULE_SUBSCRIPTION');
 }
コード例 #2
0
ファイル: User.php プロジェクト: maxisoft/m2test6
 public static function delete($id)
 {
     $transactStarted = false;
     if (!self::db()->inTransaction()) {
         $transactStarted = true;
         self::db()->beginTransaction();
     }
     $queries = array();
     $queries[] = "DELETE FROM " . Notification::tableName() . " WHERE target_user_id = :id";
     $queries[] = "DELETE FROM " . StudentModuleSubscription::tableName() . " WHERE user_id = :id";
     $queries[] = "DELETE FROM " . TeacherModuleSubscription::tableName() . " WHERE user_id = :id";
     $queries[] = "DELETE FROM " . self::tableName() . " WHERE id = :id";
     foreach ($queries as &$query) {
         $st = self::db()->prepare($query);
         $st->execute(['id' => $id]);
     }
     if ($transactStarted && self::db()->inTransaction()) {
         self::db()->commit();
     }
 }
コード例 #3
0
ファイル: index.php プロジェクト: maxisoft/m2test6
<?php

require_once 'autoload.php';
use website\Common;
use website\model\User;
use website\utils\Password;
use website\model\Module;
use website\model\StudentModuleSubscription;
use website\model\TeacherModuleSubscription;
$common = Common::getInstance();
$common->db()->exec('DELETE FROM ' . StudentModuleSubscription::tableName());
$common->db()->exec('DELETE FROM ' . TeacherModuleSubscription::tableName());
$common->db()->exec('DELETE FROM ' . User::tableName());
$common->db()->exec('DELETE FROM ' . Module::tableName());
$bananaHashed = Password::hash('banana', false);
$admin = new User();
$admin->first_name = "super admin";
$admin->last_name = "nameless";
$admin->login = '******';
$admin->password = $bananaHashed;
$admin->role = 'admin';
$admin->address = 'nowhere';
$admin->date_of_birth = '2000-01-01';
$admin->phone = '000';
$admin->email = '*****@*****.**';
$admin->valid = true;
$admin->save();
$prof = new User();
$prof->first_name = "teneyug";
$prof->last_name = "nameless";
$prof->login = '******';