Example #1
0
 /**
  * fetch the result from database
  *
  * @return array
  * @throws base_database_Exception
  */
 public function fetchDatabase()
 {
     $this->_validateTableNameNotEmpty();
     $dbObj = base_database_connection_Mysql::get();
     $result = $dbObj->query($this);
     return $this->transformDBResultToColumns($result);
 }
Example #2
0
    /**
     * execute the actual ajax request
     */
    protected function executeRequest()
    {
        $error = null;
        $requestHelper = $this->controller->getRequestHelper();
        $ret = BaseObject::SAVE_FAILURE;
        try {
            $class = $requestHelper->getParam('class');
            $lk = (int) $requestHelper->getParam('LK');
            $obj = Factory::loadObject($class, $lk);
            if (empty($obj)) {
                $this->msg = "Es wurde kein LK zum Löschen ausgewählt";
                return;
            } else {

            }
            $dbObj = base_database_connection_Mysql::get();
            $dbObj->beginTransaction();
            $ret = $obj->delete();
            $dbObj->endTransaction();
        } catch (Exception $e) {
            $error = $e->getMessage();
        }

        if (!is_null($error)) {
            $this->msg = $error;
            return;
        }
        $this->returnCode = self::PROCEED_TO_NEXT_PAGE;
        $this->redirectUrl = $_SERVER['HTTP_REFERER'];
        if ($ret == BaseObject::DELETE_SUCCESS) {
            $this->msg = "Der Datensatz '$lk' wurde erfolgreich gelöscht.";
            return;
        }
        $this->msg = "Der Datensatz '$lk' konnte nicht gelöscht werden";
    }
Example #3
0
    /**
     * execute the actual ajax request
     */
    protected function executeRequest()
    {
        $requestHelper = $this->controller->getRequestHelper();
        $lks = $requestHelper->getParam('LK');
        $amounts = $requestHelper->getParam('orderAmount');

        $dbObj = base_database_connection_Mysql::get();
        $dbObj->beginTransaction();

        for ($i = 0; $i < count($lks); $i++) {
            $lk = $lks[$i];
            $amount = $amounts[$i];
            $medOffer = $this->calcNewOfferAmount($lk, $amount);
            $medOrder = $this->_createMedOrder($medOffer, $amount);
            $this->mails['offer'][$medOffer['firstEditor']][] = $medOrder;
            $this->mails['order'][] = $medOrder;
        }
        $this->msg = $this->errors[0];
        if (count($this->errors) == 0) {
            $dbObj->doCommit();
            $this->_sendMails();
            $this->returnCode = self::PROCEED_TO_NEXT_PAGE;
            $this->msg = "Ihre Bestellung wurde aufgegeben. Bitte überprüfen Sie Ihre Emails.";
            return;
        }
        $dbObj->doRollback();
        $this->returnCode = self::STAY_ON_ACTUAL_PAGE;
//        $this->msg = implode('<br />', $this->errors);
    }
Example #4
0
 /**
  * insert result into database
  *
  * @return int|null
  */
 public function insertDatabase()
 {
     if (empty($this->columnValues) === true) {
         return null;
     }
     $dbObj = base_database_connection_Mysql::get();
     return $dbObj->execute($this);
 }
Example #5
0
 /**
  * insert result into database
  *
  * @return int
  */
 public function insertDatabase()
 {
     $dbObj = base_database_connection_Mysql::get();
     $dbObj->beginTransaction();
     $lastKey = $dbObj->execute($this);
     $dbObj->endTransaction();
     return $lastKey;
 }
Example #6
0
    /**
     * @return base_database_connection_Mysql
     */
    public static function get()
    {
        if (self::$_instance === null) {
            self::$_instance = new self();
        }

        return self::$_instance;
    }
Example #7
0
    public function importCMD()
    {
        if (empty($this->data)) {
            return self::NO_DATA;
        }
        $i = 0;
        echo '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++';
        echo '----- Import der Klasse ' . get_class($this->obj) . ' -----';
        $microStart = time();
        $dbObj = base_database_connection_Mysql::get();
        $dbObj->beginTransaction();
        foreach ($this->data as $data) {
            if ($i % 50 == 0) {
                echo PHP_EOL . "$i/" . count($this->data);
            }
            if ($this->isIrrelevantData($data)) {
                echo 'S';
                $i++;
                continue;
            }
            $result = null;
            $obj = clone $this->obj;
            $where = $this->getWhereForFindExistingData($data);
            if ($where instanceof base_database_Where) {
                $result = $this->getExistingObjects($where);
            }

            if (!is_null($result)) {
                $obj->load($result, BaseObject::LOAD_PK);
            }
            foreach ($data as $colName => $value) {
                $mapper = base_mapper_Factory::createObject(get_class($obj), $colName);
                if (!is_null($mapper)) {
                    $mapper->setCurrentDataSet($data);
                    $value = $mapper->mapFieldValue($value);
                }
                $obj[$colName] = $value;
            }
            if ($obj->save() == BaseObject::SAVE_NOCHANGES) {
                echo 'S';
            } else {
                echo '.';
            }
            $i++;
        }
        $microEnd = time();
        $diff = $microEnd - $microStart;
        echo PHP_EOL . "----- Dauer: " . $diff . " Sekunden" . PHP_EOL . PHP_EOL;
        echo '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++' . PHP_EOL;
        $dbObj->endTransaction();
        return self::SUCCESS;
    }
Example #8
0
File: DB.php Project: kafruhs/fws
 /**
  * end a database transaction
  */
 public static function endTransaction()
 {
     base_database_connection_Mysql::get()->endTransaction();
 }
Example #9
0
 /**
  * insert result into database
  *
  * @return int|null
  */
 public function insertDatabase()
 {
     $dbObj = base_database_connection_Mysql::get();
     return $dbObj->execute($this);
 }
Example #10
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);
 }
Example #11
0
 /**
  * fetch the result from database
  *
  * @return array
  * @throws base_database_Exception
  */
 public function fetchDatabase()
 {
     $dbObj = base_database_connection_Mysql::get();
     return $dbObj->query($this);
 }
Example #12
0
    /**
     * execute the actual ajax request
     */
    protected function executeRequest()
    {
        $error = '';
        $requestHelper = $this->controller->getRequestHelper();
        try {
            $class = $requestHelper->getParam('class');
            $lk = (int) $requestHelper->getParam('LK');
            if (!empty($lk)) {
                $obj = Factory::loadObject($class, $lk);
            } else {
                $obj = Factory::createObject($class);
            }

            foreach ($requestHelper->getAllParams() as $fieldName => $value) {

                try {
                    $fi = $obj->getFieldinfo($fieldName);
                    if ($fi->isMandatory() && empty($value) && $fieldName != 'LK') {
                        $error .= TMS(base_exception_Fieldinfo::FIELD_IS_MANDATORY, array('field' => $fi->getFieldLabel())) . "<br />";
                    }
                    $obj[$fieldName] = $value;
                } catch (Exception $e) {

                }
            }
            if (empty($error)) {
                $dbObj = base_database_connection_Mysql::get();
                $dbObj->beginTransaction();
                $ret = $obj->save();
                $dbObj->endTransaction();
            }
        } catch (Exception $e) {
            $error = $e->getMessage();
        }

        if (!empty($error)) {
            $this->msg = $error;
            return;
        }

        if ($this->controller->getCallerSection() == base_ajax_Controller::CALLER_SECTION_ACP) {
            $url = 'de/acp';
        } else {
            $url = 'de/';
        }
        switch ($requestHelper->getParam('referer')) {
            case base_form_View::SAVE_AND_EDIT:
                $this->returnCode = self::STAY_ON_ACTUAL_PAGE;
                break;
            case base_form_View::SAVE_AND_NEW:
                $this->returnCode = self::PROCEED_TO_NEXT_PAGE;
                $this->setRedirectUrl($url . '/frontend.php?controller=base_pages_input_controller_BaseObject&class=' . $class . '&mode=edit');
                break;
            case base_form_View::SAVE_AND_SEARCH:
                $this->returnCode = self::PROCEED_TO_NEXT_PAGE;
                $this->setRedirectUrl($url . '/frontend.php?controller=base_pages_search_controller_TableList&class=' . $class . '&mode=edit');
                break;
        }

        if ($ret == BaseObject::SAVE_SUCCESS) {
            $this->msg = "Der Datensatz wurde erfolgreich gespeichert.";
            return;
        }
        $this->returnCode = self::STAY_ON_ACTUAL_PAGE;
        if ($ret == BaseObject::SAVE_FAILURE) {
            $this->msg = "Der Datensatz konnte nicht gespeichert werden";
            return;
        }
        $this->msg = "Es wurden keine Veränderungen am Datensatz vorgenommen";
    }