getLastId() 공개 메소드

Gibt die letzte InsertId zurueck.
public getLastId ( )
 function execute()
 {
     // echo "DB EXECUTE";
     // return;
     $sql = new rex_sql();
     if ($this->params["debug"]) {
         $sql->debugsql = TRUE;
     }
     $main_table = "";
     if (isset($this->action["elements"][2]) && $this->action["elements"][2] != "") {
         $main_table = $this->action["elements"][2];
     } else {
         $main_table = $this->params["main_table"];
     }
     if ($main_table == "") {
         $this->params["form_show"] = TRUE;
         $this->params["hasWarnings"] = TRUE;
         $this->params["warning_messages"][] = $this->params["Error-Code-InsertQueryError"];
         return FALSE;
     }
     $sql->setTable($main_table);
     $where = "";
     if (isset($this->action["elements"][3]) && trim($this->action["elements"][3]) != "") {
         $where = trim($this->action["elements"][3]);
     }
     // SQL Objekt mit Werten füllen
     foreach ($this->elements_sql as $key => $value) {
         $sql->setValue($key, $value);
         if ($where != "") {
             $where = str_replace('###' . $key . '###', addslashes($value), $where);
         }
     }
     if ($where != "") {
         $sql->setWhere($where);
         $sql->update();
         $flag = "update";
     } else {
         $sql->insert();
         $flag = "insert";
         $id = $sql->getLastId();
         $this->elements_email["ID"] = $id;
         // $this->elements_sql["ID"] = $id;
         if ($id == 0) {
             $this->params["form_show"] = TRUE;
             $this->params["hasWarnings"] = TRUE;
             $this->params["warning_messages"][] = $this->params["Error-Code-InsertQueryError"];
         }
     }
 }
예제 #2
0
 /** 
  * Stores a search result in the cache.
  * 
  * @param string $_result
  * @param array $_indexIds
  * 
  * @return bool
  */
 function cacheSearch($_result, $_indexIds)
 {
     $sql = new rex_sql();
     $sql->setTable($this->tablePrefix . '587_searchcache');
     $sql->setValues(array('hash' => $this->cacheHash($this->searchString), 'returnarray' => $sql->escape($_result)));
     $sql->insert();
     $lastId = $sql->getLastId();
     $Ainsert = array();
     foreach ($_indexIds as $id) {
         $Ainsert[] = sprintf('(%d,%d)', $id, $lastId);
     }
     $sql2 = new rex_sql();
     return $sql2->setQuery(sprintf('INSERT INTO `%s` (index_id,cache_id) VALUES
     %s;', $this->tablePrefix . '587_searchcacheindex_ids', implode(',', $Ainsert)));
 }
예제 #3
0
<?php

$error = '';
$sql = new rex_sql();
//$sql->debugsql = true;
// add single image imagetype
$sql->setQuery("SELECT * FROM `" . $REX['TABLE_PREFIX'] . "679_types` WHERE name LIKE 'magnific_popup_image_thumb'");
if ($sql->getRows() == 0) {
    // imagetype
    $sql->setQuery("INSERT INTO `" . $REX['TABLE_PREFIX'] . "679_types` (status, name, description) VALUES (0, 'magnific_popup_image_thumb', 'Magnific Popup Einzelbild Vorschaubild')");
    $lastId = $sql->getLastId();
    // effects
    $sql->setQuery("INSERT INTO `" . $REX['TABLE_PREFIX'] . "679_type_effects` (type_id, effect, parameters, prior, updatedate, updateuser, createdate, createuser) VALUES (" . $lastId . ", 'resize','a:8:{s:15:\"rex_effect_crop\";a:6:{s:21:\"rex_effect_crop_width\";s:0:\"\";s:22:\"rex_effect_crop_height\";s:0:\"\";s:28:\"rex_effect_crop_offset_width\";s:0:\"\";s:29:\"rex_effect_crop_offset_height\";s:0:\"\";s:20:\"rex_effect_crop_hpos\";s:6:\"center\";s:20:\"rex_effect_crop_vpos\";s:6:\"middle\";}s:22:\"rex_effect_filter_blur\";a:3:{s:29:\"rex_effect_filter_blur_amount\";s:2:\"80\";s:29:\"rex_effect_filter_blur_radius\";s:1:\"8\";s:32:\"rex_effect_filter_blur_threshold\";s:1:\"3\";}s:25:\"rex_effect_filter_sharpen\";a:3:{s:32:\"rex_effect_filter_sharpen_amount\";s:2:\"80\";s:32:\"rex_effect_filter_sharpen_radius\";s:3:\"0.5\";s:35:\"rex_effect_filter_sharpen_threshold\";s:1:\"3\";}s:15:\"rex_effect_flip\";a:1:{s:20:\"rex_effect_flip_flip\";s:1:\"X\";}s:23:\"rex_effect_insert_image\";a:5:{s:34:\"rex_effect_insert_image_brandimage\";s:0:\"\";s:28:\"rex_effect_insert_image_hpos\";s:4:\"left\";s:28:\"rex_effect_insert_image_vpos\";s:3:\"top\";s:33:\"rex_effect_insert_image_padding_x\";s:3:\"-10\";s:33:\"rex_effect_insert_image_padding_y\";s:3:\"-10\";}s:17:\"rex_effect_mirror\";a:5:{s:24:\"rex_effect_mirror_height\";s:0:\"\";s:33:\"rex_effect_mirror_set_transparent\";s:7:\"colored\";s:22:\"rex_effect_mirror_bg_r\";s:0:\"\";s:22:\"rex_effect_mirror_bg_g\";s:0:\"\";s:22:\"rex_effect_mirror_bg_b\";s:0:\"\";}s:17:\"rex_effect_resize\";a:4:{s:23:\"rex_effect_resize_width\";s:3:\"500\";s:24:\"rex_effect_resize_height\";s:0:\"\";s:23:\"rex_effect_resize_style\";s:7:\"maximum\";s:31:\"rex_effect_resize_allow_enlarge\";s:7:\"enlarge\";}s:20:\"rex_effect_workspace\";a:8:{s:26:\"rex_effect_workspace_width\";s:0:\"\";s:27:\"rex_effect_workspace_height\";s:0:\"\";s:25:\"rex_effect_workspace_hpos\";s:4:\"left\";s:25:\"rex_effect_workspace_vpos\";s:3:\"top\";s:36:\"rex_effect_workspace_set_transparent\";s:7:\"colored\";s:25:\"rex_effect_workspace_bg_r\";s:0:\"\";s:25:\"rex_effect_workspace_bg_g\";s:0:\"\";s:25:\"rex_effect_workspace_bg_b\";s:0:\"\";}}',1," . time() . ",'admin'," . time() . ",'admin')");
}
// add gallery image imagetype
$sql->setQuery("SELECT * FROM `" . $REX['TABLE_PREFIX'] . "679_types` WHERE name LIKE 'magnific_popup_gallery_thumb'");
if ($sql->getRows() == 0) {
    // imagetype
    $sql->setQuery("INSERT INTO `" . $REX['TABLE_PREFIX'] . "679_types` (status, name, description) VALUES (0, 'magnific_popup_gallery_thumb', 'Magnific Popup Galerie Vorschaubild')");
    $lastId = $sql->getLastId();
    // effects
    $sql->setQuery("INSERT INTO `" . $REX['TABLE_PREFIX'] . "679_type_effects` (type_id, effect, parameters, prior, updatedate, updateuser, createdate, createuser) VALUES (" . $lastId . ", 'resize','a:8:{s:15:\"rex_effect_crop\";a:6:{s:21:\"rex_effect_crop_width\";s:0:\"\";s:22:\"rex_effect_crop_height\";s:0:\"\";s:28:\"rex_effect_crop_offset_width\";s:0:\"\";s:29:\"rex_effect_crop_offset_height\";s:0:\"\";s:20:\"rex_effect_crop_hpos\";s:6:\"center\";s:20:\"rex_effect_crop_vpos\";s:6:\"middle\";}s:22:\"rex_effect_filter_blur\";a:3:{s:29:\"rex_effect_filter_blur_amount\";s:2:\"80\";s:29:\"rex_effect_filter_blur_radius\";s:1:\"8\";s:32:\"rex_effect_filter_blur_threshold\";s:1:\"3\";}s:25:\"rex_effect_filter_sharpen\";a:3:{s:32:\"rex_effect_filter_sharpen_amount\";s:2:\"80\";s:32:\"rex_effect_filter_sharpen_radius\";s:3:\"0.5\";s:35:\"rex_effect_filter_sharpen_threshold\";s:1:\"3\";}s:15:\"rex_effect_flip\";a:1:{s:20:\"rex_effect_flip_flip\";s:1:\"X\";}s:23:\"rex_effect_insert_image\";a:5:{s:34:\"rex_effect_insert_image_brandimage\";s:0:\"\";s:28:\"rex_effect_insert_image_hpos\";s:4:\"left\";s:28:\"rex_effect_insert_image_vpos\";s:3:\"top\";s:33:\"rex_effect_insert_image_padding_x\";s:3:\"-10\";s:33:\"rex_effect_insert_image_padding_y\";s:3:\"-10\";}s:17:\"rex_effect_mirror\";a:5:{s:24:\"rex_effect_mirror_height\";s:0:\"\";s:33:\"rex_effect_mirror_set_transparent\";s:7:\"colored\";s:22:\"rex_effect_mirror_bg_r\";s:0:\"\";s:22:\"rex_effect_mirror_bg_g\";s:0:\"\";s:22:\"rex_effect_mirror_bg_b\";s:0:\"\";}s:17:\"rex_effect_resize\";a:4:{s:23:\"rex_effect_resize_width\";s:3:\"200\";s:24:\"rex_effect_resize_height\";s:3:\"133\";s:23:\"rex_effect_resize_style\";s:7:\"minimum\";s:31:\"rex_effect_resize_allow_enlarge\";s:7:\"enlarge\";}s:20:\"rex_effect_workspace\";a:8:{s:26:\"rex_effect_workspace_width\";s:0:\"\";s:27:\"rex_effect_workspace_height\";s:0:\"\";s:25:\"rex_effect_workspace_hpos\";s:4:\"left\";s:25:\"rex_effect_workspace_vpos\";s:3:\"top\";s:36:\"rex_effect_workspace_set_transparent\";s:7:\"colored\";s:25:\"rex_effect_workspace_bg_r\";s:0:\"\";s:25:\"rex_effect_workspace_bg_g\";s:0:\"\";s:25:\"rex_effect_workspace_bg_b\";s:0:\"\";}}',1," . time() . ",'admin'," . time() . ",'admin')");
    $sql->setQuery("INSERT INTO `" . $REX['TABLE_PREFIX'] . "679_type_effects` (type_id, effect, parameters, prior, updatedate, updateuser, createdate, createuser) VALUES (" . $lastId . ", 'crop','a:8:{s:15:\"rex_effect_crop\";a:6:{s:21:\"rex_effect_crop_width\";s:3:\"200\";s:22:\"rex_effect_crop_height\";s:3:\"133\";s:28:\"rex_effect_crop_offset_width\";s:0:\"\";s:29:\"rex_effect_crop_offset_height\";s:0:\"\";s:20:\"rex_effect_crop_hpos\";s:6:\"center\";s:20:\"rex_effect_crop_vpos\";s:6:\"middle\";}s:22:\"rex_effect_filter_blur\";a:3:{s:29:\"rex_effect_filter_blur_amount\";s:2:\"80\";s:29:\"rex_effect_filter_blur_radius\";s:1:\"8\";s:32:\"rex_effect_filter_blur_threshold\";s:1:\"3\";}s:25:\"rex_effect_filter_sharpen\";a:3:{s:32:\"rex_effect_filter_sharpen_amount\";s:2:\"80\";s:32:\"rex_effect_filter_sharpen_radius\";s:3:\"0.5\";s:35:\"rex_effect_filter_sharpen_threshold\";s:1:\"3\";}s:15:\"rex_effect_flip\";a:1:{s:20:\"rex_effect_flip_flip\";s:1:\"X\";}s:23:\"rex_effect_insert_image\";a:5:{s:34:\"rex_effect_insert_image_brandimage\";s:0:\"\";s:28:\"rex_effect_insert_image_hpos\";s:4:\"left\";s:28:\"rex_effect_insert_image_vpos\";s:3:\"top\";s:33:\"rex_effect_insert_image_padding_x\";s:3:\"-10\";s:33:\"rex_effect_insert_image_padding_y\";s:3:\"-10\";}s:17:\"rex_effect_mirror\";a:5:{s:24:\"rex_effect_mirror_height\";s:0:\"\";s:33:\"rex_effect_mirror_set_transparent\";s:7:\"colored\";s:22:\"rex_effect_mirror_bg_r\";s:0:\"\";s:22:\"rex_effect_mirror_bg_g\";s:0:\"\";s:22:\"rex_effect_mirror_bg_b\";s:0:\"\";}s:17:\"rex_effect_resize\";a:4:{s:23:\"rex_effect_resize_width\";s:0:\"\";s:24:\"rex_effect_resize_height\";s:0:\"\";s:23:\"rex_effect_resize_style\";s:7:\"maximum\";s:31:\"rex_effect_resize_allow_enlarge\";s:7:\"enlarge\";}s:20:\"rex_effect_workspace\";a:8:{s:26:\"rex_effect_workspace_width\";s:0:\"\";s:27:\"rex_effect_workspace_height\";s:0:\"\";s:25:\"rex_effect_workspace_hpos\";s:4:\"left\";s:25:\"rex_effect_workspace_vpos\";s:3:\"top\";s:36:\"rex_effect_workspace_set_transparent\";s:7:\"colored\";s:25:\"rex_effect_workspace_bg_r\";s:0:\"\";s:25:\"rex_effect_workspace_bg_g\";s:0:\"\";s:25:\"rex_effect_workspace_bg_b\";s:0:\"\";}}',2," . time() . ",'admin'," . time() . ",'admin')");
}
if ($error == '') {
    $REX['ADDON']['install']['magnific_popup'] = true;
} else {
    $REX['ADDON']['installmsg']['magnific_popup'] = $error;
}
예제 #4
0
 // Daten wieder in den Rohzustand versetzen, da für serialize()/unserialize()
 // keine Zeichen escaped werden dürfen
 for ($i = 1; $i < count($ctypes) + 1; $i++) {
     $ctypes[$i] = stripslashes($ctypes[$i]);
 }
 $TPL = new rex_sql();
 $TPL->setTable($REX['TABLE_PREFIX'] . "template");
 $TPL->setValue("name", $templatename);
 $TPL->setValue("active", $active);
 $TPL->setValue("content", $content);
 if ($function == "add") {
     $attributes = rex_setAttributes("ctype", $ctypes, "");
     $TPL->setValue("attributes", addslashes($attributes));
     $TPL->addGlobalCreateFields();
     if ($TPL->insert()) {
         $template_id = $TPL->getLastId();
         $message = $I18N->msg("template_added");
     } else {
         $message = $TPL->getError();
     }
 } else {
     $attributes = rex_setAttributes("ctype", $ctypes, $attributes);
     $TPL->setWhere("id='{$template_id}'");
     $TPL->setValue("attributes", addslashes($attributes));
     $TPL->addGlobalUpdateFields();
     $message = $TPL->update($I18N->msg("template_updated"));
 }
 // werte werden direkt wieder ausgegeben
 $templatename = stripslashes($templatename);
 $content = stripslashes($content);
 rex_deleteDir($REX['INCLUDE_PATH'] . "/generated/templates", 0);
예제 #5
0
 /**
  * Speichert den Kurs in die Datenbank.
  * @return String Statusmeldung.
  */
 public function save()
 {
     $query = "INSERT INTO ";
     if ($this->kurs_id > 0) {
         $query = "UPDATE ";
     }
     $query .= $this->table_prefix . 'd2u_kurse_kurse SET ' . 'titel = "' . addslashes($this->titel) . '", ' . 'teaser = "' . addslashes($this->teaser) . '", ' . 'beschreibung = "' . addslashes($this->beschreibung) . '", ' . '`alter` = "' . $this->alter . '", ' . 'bild = "' . $this->bild . '", ' . 'kosten = ' . number_format($this->kosten, 2) . ', ' . 'kosten_erm = ' . number_format($this->kosten_erm, 2) . ', ' . 'datum_von = "' . $this->datum_von . '", ' . 'datum_bis = "' . $this->datum_bis . '", ' . 'uhrzeit = "' . $this->uhrzeit . '", ' . 'zielgruppen_ids = "|' . implode("|", $this->zielgruppen_ids) . '|", ' . 'kurskategorie_id = "' . $this->kurskategorie->kurskategorie_id . '", ' . 'sekundaere_kurskategorie_ids = "|' . implode("|", $this->sekundaere_kurskategorie_ids) . '|", ' . 'ort_id = "' . $this->ort->ort_id . '", ' . 'raum = "' . $this->raum . '", ' . 'terminkategorie_ids = "|' . implode("|", $this->terminkategorie_ids) . '|", ' . 'teilnehmer_max = "' . $this->teilnehmer_max . '", ' . 'teilnehmer_min = "' . $this->teilnehmer_min . '", ' . 'teilnehmer_angemeldet = "' . $this->teilnehmer_angemeldet . '", ' . 'teilnehmer_warteliste = "' . $this->teilnehmer_warteliste . '", ' . 'anmeldung_moeglich = "' . $this->anmeldung_moeglich . '", ' . 'status = "' . $this->status . '", ' . 'url_extern = "' . $this->url_extern . '", ' . 'redaxo_artikel = "' . $this->redaxo_artikel . '", ' . 'kursleiter = "' . $this->kursleiter . '", ' . 'kursnummer = "' . $this->kursnummer . '", ' . 'dokumente = "' . implode(",", $this->dokumente) . '", ' . 'import = "' . $this->import . '", ' . 'updatedate = "' . time() . '"';
     if ($this->kurs_id > 0) {
         $query .= " WHERE kurs_id = " . $this->kurs_id;
     }
     $result = new rex_sql();
     $result->setQuery($query);
     if ($this->kurs_id == 0) {
         $this->kurs_id = $result->getLastId();
     }
     if ($result->hasError()) {
         return "Fehler beim Speichern: " . $result->getError() . PHP_EOL . "Query war: " . $query;
     } else {
         return "Gespeichert: " . $query;
     }
 }