Example #1
0
 /**
  * if the object is inserted into the db for the first time some fields e.g. LK, firstEditor must be set
  */
 private function _setFirstEditorData()
 {
     $this['firstEditor'] = Flat::user()->getLogicalKey();
     $this['firstEditTime'] = new base_date_model_DateTime();
     $seq = new Sequence(get_class($this));
     $this['LK'] = $seq->getNextSequence();
     $seq->save();
 }
Example #2
0
 /**
  * creates the admin user
  *
  * @param OutputDevice $od
  * @throws base_database_Exception
  */
 public function createAdminUser(OutputDevice $od)
 {
     $user = new User();
     if (!is_null($user->load(1))) {
         return;
     }
     $seq = new Sequence('User');
     $adminData['LK'] = $seq->getNextSequence();
     $adminData['firstEditor'] = 1;
     $dateTime = new base_date_model_DateTime();
     $adminData['firstEditTime'] = $dateTime->toDB();
     $adminData['editor'] = 1;
     $adminData['editTime'] = $dateTime->toDB();
     $adminData['userid'] = 'admin';
     $adminData['password'] = '******';
     $adminData['firstName'] = 'Admin';
     $adminData['lastName'] = 'Admin';
     $adminData['email'] = '*****@*****.**';
     $statement = new base_database_statement_Insert();
     $table = DB::table('user');
     $statement->setTable($table);
     foreach ($adminData as $fieldName => $value) {
         $statement->setColumnValue($table->getColumn($fieldName), DB::term($value));
     }
     $dbObj = base_database_connection_Mysql::get();
     $dbObj->beginTransaction();
     $seq->save();
     $statement->insertDatabase();
     $dbObj->endTransaction();
     base_install_Message::printOut('----- Admin User created -----', $od);
 }