private function _insertNewSequence() { $table = DB::table('sequence'); $statement = new base_database_statement_Insert(); $statement->setTable($table); $statement->setColumnValue($table->getColumn('class'), DB::term($this->class)); $statement->setColumnValue($table->getColumn('num'), DB::term($this->nextSeq)); $statement->insertDatabase(); }
/** * insert a new revision of the given Object * * @param base_database_Table * @throws base_database_Exception */ private function _insertNewData(base_database_Table $table) { $statement = new base_database_statement_Insert(); $statement->setTable($table); foreach ($this->_fields as $fieldName => $value) { if (empty($value) || $fieldName == 'PK') { continue; } if (in_array($fieldName, $this->mnFields)) { continue; } $fi = $this->getFieldinfo($fieldName); $dtObj = $fi->getDatatypeObject(); $value = $dtObj->toDB($value); $statement->setColumnValue($table->getColumn($fieldName), DB::term($value)); } $statement->insertDatabase(); foreach ($this->mnFields as $fieldName) { $fi = $this->getFieldinfo($fieldName); $this->_saveMNField($fi); } }
/** * saves the given Connection * * @throws base_exception_BaseConnectionObject */ public function save() { if ($this->_validateNeededInformation() != self::SAVE_VALIDATION_SUCCESSFULL) { return self::SAVE_OBJECT_ALREADY_EXISTS; } $insert = new base_database_statement_Insert(); $table = DB::table($this->table); $insert->setTable($table); $properties = ['classLeft', 'classRight', 'lkLeft', 'lkRight']; foreach ($properties as $property) { $insert->setColumnValue($table->getColumn($property), DB::term($this->$property)); } $insert->insertDatabase(); return self::SAVE_SUCCESSFULL; }
/** * 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); }