本文整理汇总了PHP中rex_sql::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP rex_sql::insert方法的具体用法?PHP rex_sql::insert怎么用?PHP rex_sql::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rex_sql
的用法示例。
在下文中一共展示了rex_sql::insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: asd_news_addClang
function asd_news_addClang($params)
{
global $REX;
$id = $params['id'];
$name = $params['name'];
$now = new DateTime();
$error = false;
$sql = new rex_sql();
$sql->setQuery('SELECT * FROM `' . rex_asd_news_config::getTable() . '` WHERE `clang` = ' . $REX['START_CLANG_ID']);
for ($i = 1; $i <= $sql->getRows(); $i++) {
$save = new rex_sql();
$save->setTable(rex_asd_news_config::getTable());
$save->setValues($sql->getRow());
$save->setValue('clang', $id);
$save->setValue('createdAt', $now->format('Y-m-d H:i:s'));
$save->setValue('updatedAt', $now->format('Y-m-d H:i:s'));
$save->setValue('publishedAt', '0000-00-00 00:00:00');
$save->setValue('createdBy', $REX['USER']->getValue('user_id'));
$save->setValue('updatedBy', $REX['USER']->getValue('user_id'));
$save->setValue('publishedBy', 0);
$save->setValue('status', 0);
unset($save->values['news_id']);
if (!$save->insert()) {
$error = $save->getError();
}
}
if ($error) {
echo rex_warning('ASD News: Neuigkeiten in der Sprache "' . $name . '" konnten nicht angelegt werden<br />' . $error);
} else {
echo rex_info('ASD News: Neuigkeiten in der Sprache "' . $name . '" wurden angelegt');
}
}
示例2: elseif
function rex_copyRevisionContent($article_id, $clang, $from_revision_id, $to_revision_id, $from_re_sliceid = 0, $to_revision_delete = FALSE)
{
global $REX;
if ($to_revision_delete) {
$dc = new rex_sql();
// $dc->debugsql = 1;
$dc->setQuery('delete from ' . $REX['TABLE_PREFIX'] . 'article_slice where article_id=' . $article_id . ' and clang=' . $clang . ' and revision=' . $to_revision_id);
}
if ($from_revision_id == $to_revision_id) {
return false;
}
$gc = new rex_sql();
// $gc->debugsql = 1;
$gc->setQuery("select * from " . $REX['TABLE_PREFIX'] . "article_slice where re_article_slice_id='{$from_re_sliceid}' and article_id='{$article_id}' and clang='{$clang}' and revision='{$from_revision_id}'");
if ($gc->getRows() == 1) {
// letzt slice_id des ziels holen ..
$glid = new rex_sql();
// $glid->debugsql = 1;
$glid->setQuery("\n\t\t\t\t\tselect \n\t\t\t\t\t\tr1.id, r1.re_article_slice_id\n\t from \n\t\t\t\t\t\t" . $REX['TABLE_PREFIX'] . "article_slice as r1\n\t\t\t\t\tleft join " . $REX['TABLE_PREFIX'] . "article_slice as r2 on r1.id = r2.re_article_slice_id\n\t where \n\t\t\t\t\t\tr1.article_id = {$article_id} and r1.clang = {$clang} and \n\t\t\t\t\t\tr2.id is NULL and \n\t\t\t\t\t\tr1.revision='{$to_revision_id}';");
if ($glid->getRows() == 1) {
$to_last_slice_id = $glid->getValue("r1.id");
} else {
$to_last_slice_id = 0;
}
$ins = new rex_sql();
// $ins->debugsql = 1;
$ins->setTable($REX['TABLE_PREFIX'] . "article_slice");
$cols = new rex_sql();
$cols->setquery("SHOW COLUMNS FROM " . $REX['TABLE_PREFIX'] . "article_slice");
for ($j = 0; $j < $cols->rows; $j++, $cols->next()) {
$colname = $cols->getValue("Field");
if ($colname == "re_article_slice_id") {
$value = $to_last_slice_id;
} elseif ($colname == "revision") {
$value = $to_revision_id;
} elseif ($colname == "createdate") {
$value = time();
} elseif ($colname == "updatedate") {
$value = time();
} elseif ($colname == "createuser") {
$value = $REX["USER"]->getValue("login");
} elseif ($colname == "updateuser") {
$value = $REX["USER"]->getValue("login");
} else {
$value = $gc->getValue($colname);
}
if ($colname != "id") {
$ins->setValue($colname, $ins->escape($value));
}
}
$ins->insert();
// id holen und als re setzen und weitermachen..
rex_copyRevisionContent($article_id, $clang, $from_revision_id, $to_revision_id, $gc->getValue("id"));
return true;
}
rex_generateArticle($article_id);
return true;
}
示例3: execute
function execute()
{
$subject_key = $this->action["elements"][2];
$body_key = $this->action["elements"][3];
$user_id_key = $this->action["elements"][4];
foreach ($this->elements_sql as $key => $value) {
if ($subject_key == $key) {
$subject = $value;
}
if ($body_key == $key) {
$body = $value;
}
if ($user_id_key == $key) {
$from_user_id = $value;
}
// echo "<br /> $key => $value";
}
if ($subject == "" or $body == "" or $from_user_id == "") {
return FALSE;
}
// User auslesen
$gu = new rex_sql();
// $gu->debugsql = 1;
// $gu->setQuery('select * from rex_com_user where id<>"'.$from_user_id.'" order by id');
$gu->setQuery('select * from rex_com_user order by id');
foreach ($gu->getArray() as $user) {
$user_body = $body;
$user_subject = $subject;
$to_user_id = $user["id"];
// Empfaenger einbauen
$in = new rex_sql();
// $in->debugsql = 1;
$in->setTable("rex_com_message");
$in->setValue("user_id", $to_user_id);
$in->setValue("from_user_id", $from_user_id);
$in->setValue("to_user_id", $to_user_id);
$in->setValue("subject", $user_subject);
$in->setValue("body", $user_body);
$in->setValue("create_datetime", time());
$in->insert();
/*
$in = new rex_sql;
// $in->debugsql = 1;
$in->setTable("rex_com_message");
$in->setValue("user_id",$from_user_id);
$in->setValue("from_user_id",$from_user_id);
$in->setValue("to_user_id",$to_user_id);
$in->setValue("subject",$user_subject);
$in->setValue("body",$user_body);
$in->setValue("create_datetime",time());
$in->insert();
*/
rex_com_user::exeAction($to_user_id, "sendemail_newmessage", $user);
}
}
示例4: execute
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"];
}
}
}
示例5: array
function a724_generatePathnamesFromTable($params)
{
$debug = false;
$sql = new rex_sql();
$results = $sql->getArray('SELECT article_id, url_table, url_table_parameters FROM rex_a724_frau_schultze WHERE url_table != "" AND url_table_parameters != ""');
$URLPATH = array();
if ($sql->getRows() >= 1) {
a724_deletePathnamesFromTable();
foreach ($results as $result) {
if (is_array($result) && count($result) > 0) {
$path = rex_getUrl($result['article_id']) . '/';
$path = str_replace('.html', '', $path);
$table = $result['url_table'];
$params = unserialize($result['url_table_parameters']);
$col_name = $params[$table][$table . "_name"];
$col_id = $params[$table][$table . "_id"];
// Daten zum Aufbau der Urls holen
$sqlu = new rex_sql();
$sqlu->setDebug($debug);
$res = $sqlu->getArray('SELECT ' . $col_name . ' AS name, ' . $col_id . ' AS id FROM ' . $table);
if ($sqlu->getRows() >= 1) {
// Urls in die Datenbank schreiben
$sqli = new rex_sql();
$sqli->setDebug($debug);
foreach ($res as $re) {
$table_path = $path . strtolower(rex_parse_article_name($re['name'])) . '.html';
$table_id = $re['id'];
$URLPATH[$result['url_table']][$table_id] = $table_path;
$sqli->setTable('rex_a724_frau_schultze');
$sqli->setValue('article_id', $result['article_id']);
$sqli->setValue('status', '1');
$sqli->setValue('url_table', $result['url_table']);
$sqli->setValue('name', $table_path);
$sqli->insert();
}
}
}
}
}
rex_put_file_contents(A724_URL_TABLE_PATHLIST, "<?php\n\$URLPATH = " . var_export($URLPATH, true) . ";\n");
}
示例6: getInsertValue
function getInsertValue($value)
{
$value = (array) $value;
$section =& $this->getSection();
// Alle vorhanden Werte löschen
$sql = new rex_sql();
$sql->setTable($this->foreignTable);
$sql->setWhere($section->_getWhereString());
$sql->delete();
// und anschließend alle neu eintragen
foreach ($value as $val) {
// Parameter aus der Ursprungstabelle mit abspeichern damit später darüber verknüpft werden kann
foreach ($section->getWhere() as $whereColName => $whereColValue) {
$sql->setValue($whereColName, $whereColValue);
}
// Den zu speichernden Wert
$sql->setValue($this->foreignField, $val);
$sql->setTable($this->foreignTable);
$sql->insert();
}
// null zurückgeben, damit zu diesem Feld nichts im rexForm gespeichert wird
return null;
}
示例7: array
$AART->setValue('name', $article_name);
$AART->setValue('catname', $category_name);
// TODO Neue noch nicht verwendete Datenbankspalten
// $AART->setValue('attributes', $category_attributes);
$AART->setValue('attributes', '');
$AART->setValue('clang', $key);
$AART->setValue('re_id', $category_id);
$AART->setValue('prior', $Position_New_Article);
$AART->setValue('path', $KATPATH);
$AART->setValue('startpage', 0);
$AART->setValue('status', 0);
$AART->setValue('template_id', $template_id);
// TODO hier Update + Createfields?
$AART->addGlobalCreateFields();
$AART->addGlobalUpdateFields();
if ($AART->insert()) {
// ----- PRIOR
rex_newArtPrio($category_id, $key, 0, $Position_New_Article);
} else {
$amessage = $AART->getError();
}
}
rex_generateArticle($id);
// ----- EXTENSION POINT
$amessage = rex_register_extension_point('ART_ADDED', $amessage, array('id' => $id, 'status' => 0, 'name' => $article_name, 're_id' => $category_id, 'prior' => $Position_New_Article, 'path' => $KATPATH, 'template_id' => $template_id));
} elseif (!empty($artedit_function) && $article_id != '' && $KATPERM) {
// --------------------- ARTIKEL EDIT
$Position_Article = (int) $Position_Article;
if ($Position_Article == 0) {
$Position_Article = 1;
}
示例8: createTable
function createTable($mifix = "", $data_table, $params = array(), $debug = FALSE)
{
// Tabelle erstellen wenn noch nicht vorhanden
$c = rex_sql::factory();
$c->debugsql = $debug;
$c->setQuery('CREATE TABLE IF NOT EXISTS `' . $data_table . '` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY );');
// Tabellenset in die Basics einbauen, wenn noch nicht vorhanden
$c = new rex_sql();
$c->debugsql = $debug;
$c->setQuery('DELETE FROM rex_xform_table where table_name="' . $data_table . '"');
$c->setTable('rex_xform_table');
$params["table_name"] = $data_table;
if (!isset($params["status"])) {
$params["status"] = 1;
}
if (!isset($params["name"])) {
$params["name"] = 'Tabelle "' . $data_table . '"';
}
if (!isset($params["prio"])) {
$params["prio"] = 100;
}
if (!isset($params["search"])) {
$params["search"] = 0;
}
if (!isset($params["hidden"])) {
$params["hidden"] = 0;
}
if (!isset($params["export"])) {
$params["export"] = 0;
}
foreach ($params as $k => $v) {
$c->setValue($k, $v);
}
$c->insert();
return TRUE;
}
示例9: foreach
}
$postsavemode = 0;
foreach ($postsavestatus as $status) {
$postsavemode |= $status;
}
$faction->setTable($REX['TABLE_PREFIX'] . 'action');
$faction->setValue('name', $name);
$faction->setValue('preview', $previewaction);
$faction->setValue('presave', $presaveaction);
$faction->setValue('postsave', $postsaveaction);
$faction->setValue('previewmode', $previewmode);
$faction->setValue('presavemode', $presavemode);
$faction->setValue('postsavemode', $postsavemode);
if ($function == 'add') {
$faction->addGlobalCreateFields();
if ($faction->insert()) {
$info = $I18N->msg('action_added');
} else {
$warning = $faction->getError();
}
} else {
$faction->addGlobalUpdateFields();
$faction->setWhere('id=' . $action_id);
if ($faction->update()) {
$info = $I18N->msg('action_updated');
} else {
$warning = $faction->getError();
}
}
if (isset($goon) and $goon != '') {
$save = 'nein';
示例10:
if ($ga->getRows() > 0) {
$err_msg .= $I18N->msg('setup_042');
} else {
if ($REX['PSWFUNC'] != '') {
$redaxo_user_pass = call_user_func($REX['PSWFUNC'], $redaxo_user_pass);
}
$user = new rex_sql();
// $user->debugsql = true;
$user->setTable($REX['TABLE_PREFIX'] . 'user');
$user->setValue('name', 'Administrator');
$user->setValue('login', $redaxo_user_login);
$user->setValue('psw', $redaxo_user_pass);
$user->setValue('rights', '#admin[]#dev[]#import[]#stats[]#moveSlice[]#');
$user->addGlobalCreateFields('setup');
$user->setValue('status', '1');
if (!$user->insert()) {
$err_msg .= $I18N->msg("setup_043");
}
}
}
} else {
$gu = new rex_sql();
$gu->setQuery("select * from " . $REX['TABLE_PREFIX'] . "user LIMIT 1");
if ($gu->getRows() == 0) {
$err_msg .= $I18N->msg('setup_044');
}
}
if ($err_msg == '') {
$checkmodus = 5;
$send = '';
}
示例11: saveOverLangValues
/**
* @param rex_news_form $form
* @param $id
* @param $clang
*/
public static function saveOverLangValues(rex_news_form $form, $id, $clang)
{
global $REX;
$lang = new rex_sql();
$lang->setQuery('SELECT `id` FROM `' . $REX['TABLE_PREFIX'] . 'clang` WHERE `id` != ' . $clang);
for ($i = 1; $i <= $lang->getRows(); $i++) {
$sql = new rex_sql();
$sql->setTable($form->getTableName());
$sql->setDebug(true);
$sql->setWhere('`id` = ' . $id . ' AND `clang` = ' . $lang->getValue('id'));
$sql->select('id');
$sql->setTable($form->getTableName());
$sql->setDebug(true);
$sql->setWhere('`id` = ' . $id . ' AND `clang` = ' . $lang->getValue('id'));
if (OOAddon::isAvailable('metainfo')) {
$sql->setValues($form->getMetaValues());
}
if ($sql->getRows()) {
$sql->setValues(array_intersect_key($form->getValues(), array_flip($form->getOverSavedFields())));
$sql->setValue('clang', $lang->getValue('id'));
$sql->setValue('id', $id);
$sql->update();
} else {
$sql->setValues($form->getValues());
$sql->setValue('clang', $lang->getValue('id'));
$sql->setValue('id', $id);
$sql->insert();
}
$lang->next();
}
}
示例12: rex_medienpool_saveMedia
/**
* Holt ein upgeloadetes File und legt es in den Medienpool
* Dabei wird kontrolliert ob das File schon vorhanden ist und es
* wird eventuell angepasst, weiterhin werden die Fileinformationen übergeben
*
* @param $FILE
* @param $rex_file_category
* @param $FILEINFOS
* @param $userlogin
*/
function rex_medienpool_saveMedia($FILE, $rex_file_category, $FILEINFOS, $userlogin = null)
{
global $REX, $I18N;
$rex_file_category = (int) $rex_file_category;
$gc = new rex_sql();
$gc->setQuery('SELECT * FROM ' . $REX['TABLE_PREFIX'] . 'file_category WHERE id=' . $rex_file_category);
if ($gc->getRows() != 1) {
$rex_file_category = 0;
}
$FILENAME = $FILE['name'];
$FILESIZE = $FILE['size'];
$FILETYPE = $FILE['type'];
$NFILENAME = rex_medienpool_filename($FILENAME);
$message = '';
// ----- neuer filename
$dstFile = $REX['MEDIAFOLDER'] . '/' . $NFILENAME;
// ----- dateiupload
$upload = true;
if (!@move_uploaded_file($FILE['tmp_name'], $dstFile) && !@copy($FILE['tmp_name'], $dstFile)) {
$message .= $I18N->msg("pool_file_movefailed");
$ok = 0;
$upload = false;
}
if ($upload) {
chmod($dstFile, $REX['FILEPERM']);
// get widht height
$size = @getimagesize($dstFile);
$FILESQL = new rex_sql();
$FILESQL->setTable($REX['TABLE_PREFIX'] . 'file');
$FILESQL->setValue('filetype', $FILETYPE);
$FILESQL->setValue('title', $FILEINFOS['title']);
$FILESQL->setValue('filename', $NFILENAME);
$FILESQL->setValue('originalname', $FILENAME);
$FILESQL->setValue('filesize', $FILESIZE);
$FILESQL->setValue('width', $size[0]);
$FILESQL->setValue('height', $size[1]);
$FILESQL->setValue('category_id', $rex_file_category);
// TODO Create + Update zugleich?
$FILESQL->addGlobalCreateFields($userlogin);
$FILESQL->addGlobalUpdateFields($userlogin);
$FILESQL->insert();
$ok = 1;
$message .= $I18N->msg("pool_file_added");
}
$RETURN['title'] = $FILEINFOS['title'];
$RETURN['width'] = $size[0];
$RETURN['height'] = $size[1];
$RETURN['type'] = $FILETYPE;
$RETURN['msg'] = $message;
$RETURN['ok'] = $ok;
$RETURN['filename'] = $NFILENAME;
$RETURN['old_filename'] = $FILENAME;
return $RETURN;
}
示例13: VARCHAR
$a = new rex_sql();
$a->setTable("rex_62_params");
$a->setValue("title", "Gruppen");
$a->setValue("name", "art_com_groups");
$a->setValue("prior", "12");
$a->setValue("type", "3");
$a->setValue("attributes", "multiple=multiple");
$a->setValue("params", "select name as label,id from rex_com_group order by label");
$a->setValue("validate", NULL);
$a->addGlobalCreateFields();
$g = new rex_sql();
$g->setQuery('select * from rex_62_params where name="art_com_groups"');
if ($g->getRows() == 1) {
$a->setWhere('name="art_com_groups"');
$a->update();
} else {
$a->insert();
}
$g = new rex_sql();
$g->setQuery('show columns from rex_article Like "art_com_groups"');
if ($g->getRows() == 0) {
$a->setQuery("ALTER TABLE `rex_article` ADD `art_com_groups` VARCHAR( 255 ) NOT NULL");
}
// ************************************************************** CACHE LOESCHEN
$info = rex_generateAll();
// quasi kill cache ..
$REX['ADDON']['install']['auth'] = 1;
if ($error != "") {
$REX['ADDON']['install']['auth'] = 0;
$REX['ADDON']['installmsg']['auth'] = $error;
}
示例14: rex_medienpool_registerFile
function rex_medienpool_registerFile($physical_filename, $org_filename, $filename, $category_id, $title, $filesize, $filetype)
{
global $REX, $REX_USER;
$abs_file = $REX['MEDIAFOLDER'] . '/' . $physical_filename;
if (!file_exists($abs_file)) {
return false;
}
if (empty($filesize)) {
$filesize = filesize($abs_file);
}
if (empty($filetype) && function_exists('mime_content_type')) {
$filetype = mime_content_type($abs_file);
}
@chmod($abs_file, $REX['FILEPERM']);
$filename = rex_medienpool_filename($filename, false);
$org_filename = strtolower($org_filename);
// Ggf Alte Datei umbennen
rename($abs_file, $REX['MEDIAFOLDER'] . '/' . $filename);
$abs_file = $REX['MEDIAFOLDER'] . '/' . $filename;
// get widht height
$size = @getimagesize($abs_file);
$FILESQL = new rex_sql();
// $FILESQL->debugsql=1;
$FILESQL->setTable($REX['TABLE_PREFIX'] . "file");
$FILESQL->setValue('filename', $filename);
$FILESQL->setValue('originalname', $org_filename);
$FILESQL->setValue('category_id', $category_id);
$FILESQL->setValue('title', $title);
$FILESQL->setValue('filesize', $filesize);
$FILESQL->setValue('filetype', $filetype);
$FILESQL->setValue('width', $size[0]);
$FILESQL->setValue('height', $size[1]);
// TODO Hier Update + Create zugleich?
$FILESQL->addGlobalUpdateFields();
$FILESQL->addGlobalCreateFields();
$FILESQL->insert();
return $FILESQL->getError() == '';
}
示例15: setTableField
public static function setTableField($table_name, array $table_field)
{
unset($table_field['id']);
if ($table_name == '') {
throw new Exception('table_name must be set');
}
if (count($table_field) == 0) {
throw new Exception('field must be a filled array');
}
$fieldIdentifier = array('type_id' => $table_field['type_id'], 'type_name' => $table_field['type_name'], 'name' => $table_field['name']);
$currentFields = rex_xform_manager_table::get($table_name)->getFields($fieldIdentifier);
// validate specials
if ($table_field['type_id'] == 'validate') {
$table_field['list_hidden'] = 1;
$table_field['search'] = 0;
}
self::createMissingFieldColumns($table_field);
if (count($currentFields) > 1) {
throw new Exception('more than one field found for table: ' . $table_name . ' with Fieldidentifier: ' . implode(', ', $fieldIdentifier) . '');
} elseif (count($currentFields) == 0) {
// Insert
$field_insert = new rex_sql();
$field_insert->debugsql = self::$debug;
$field_insert->setTable(rex_xform_manager_field::table());
$field_insert->setValue('table_name', $table_name);
foreach ($table_field as $field_name => $field_value) {
$field_insert->setValue($field_name, $field_value);
}
if (!isset($table['prio'])) {
$field_insert->setValue('prio', rex_xform_manager_table::get($table_name)->getMaximumPrio() + 1);
}
$field_insert->insert();
} else {
// Update
$currentField = $currentFields[0]->toArray();
foreach ($table_field as $field_name => $field_value) {
$currentField[$field_name] = $field_value;
}
$field_update = new rex_sql();
$field_update->debugsql = self::$debug;
$field_update->setTable(rex_xform_manager_field::table());
$add_where = array();
foreach ($fieldIdentifier as $field => $value) {
$add_where[] = '`' . mysql_real_escape_string($field) . '`="' . mysql_real_escape_string($table_name) . '"';
}
$where = 'table_name="' . mysql_real_escape_string($table_name) . '"';
if (count($add_where) > 0) {
$where .= ' and (' . implode(' and ', $add_where) . ') ';
}
$field_update->setWhere($where);
foreach ($table_field as $field_name => $field_value) {
$field_update->setValue($field_name, $field_value);
}
$field_update->update();
}
}