本文整理汇总了PHP中sql::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP sql::insert方法的具体用法?PHP sql::insert怎么用?PHP sql::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sql
的用法示例。
在下文中一共展示了sql::insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login
function login()
{
include "config.php";
if (isset($_POST['usuario']) and isset($_POST['senha']) and $_POST['usuario'] != "" and $_POST['senha'] != "") {
$select = "SELECT * FROM " . $schema . ".cad_usuario where usuario='" . $_POST['usuario'] . "';";
$resultado = mysql_query($select, $conexao) or die(mysql_error());
while ($row = mysql_fetch_array($resultado)) {
$cod_user = $row['cod_usuario'];
$senha_usuario = $row['senha'];
}
if ($senha_usuario == $_POST['senha'] and (isset($_SESSION['loged']) == false or $_SESSION['loged'] == false)) {
$_SESSION['cod_usuario'] = $cod_user;
$_SESSION['user'] = $_POST['usuario'];
$_SESSION['loged'] = true;
$_SESSION['session'] = md5(mt_rand(1, 10000));
$sql = new sql();
$table = "session";
$campos = "username,session,ip";
$values = "'" . $_SESSION['user'] . "','" . $_SESSION['session'] . "','" . $_SERVER['REMOTE_ADDR'] . "'";
$sql->insert($table, $campos, $values, 'N');
} else {
// $login=new login;
// $login->logout();
}
}
}
示例2: rex_opf_sync
function rex_opf_sync()
{
global $REX;
// abgleich der replacevalue felder..
$s = new sql();
// $s->debugsql = 1;
$s->setQuery("select clang, replacename, name, count(replacename) from rex_opf_lang group by replacename");
for ($i = 0; $i < $s->getRows(); $i++) {
if (count($REX['CLANG']) != $s->getValue("count(replacename)")) {
reset($REX['CLANG']);
while (list($key, $val) = each($REX['CLANG'])) {
$lclang = $key;
$replacename = $s->getValue("replacename");
$name = $s->getValue("name");
$gs = new sql();
$gs->setQuery("select clang from rex_opf_lang where clang={$lclang} and replacename='{$replacename}'");
if ($gs->getRows() == 0) {
// erstelle
$us = new sql();
$us->setTable("rex_opf_lang");
$us->setValue("clang", $lclang);
$us->setValue("replacename", $replacename);
$us->setValue("name", $name);
$us->insert();
}
}
}
$s->next();
}
}
示例3: setRecord
public function setRecord($data)
{
$data[blocktype] = $this->blocktype;
$operation[$data[operation_id]] = array('date' => $data[action_date], 'comment_id' => sqltable_model::getCommentId($data[comment]));
// если в поле для нового ввели номер сопроводиловки уже существующий в журнале
// то будем править его
$sql = "SELECT * FROM {$this->maintable} WHERE lanch_id='{$data[lanch_id]}'";
$res = sql::fetchOne($sql);
if (empty($res)) {
// гадство! тут нужен уникальный, а без коментариев будет получаться один
sql::insert('coments', array(array("comment" => multibyte::Json_encode($operation))));
$data[coment_id] = sql::lastId();
} else {
$coment = multibyte::Json_decode(sqltable_model::getComment($res[coment_id]));
$coment[$data[operation_id]] = $operation[$data[operation_id]];
// заменить старый по ключу
sql::insertUpdate('coments', array(array("id" => $res[coment_id], "comment" => multibyte::Json_encode($coment))));
$data[edit] = $res[id];
// если был такой его и правим
$data[coment_id] = $res[coment_id];
}
$data[lastoperation] = $data[operation_id];
parent::setRecord($data);
return true;
}
示例4: insertOrder
function insertOrder()
{
$sql = new sql();
$sql->debugsql = 0;
$sql->setTable("rex_4_order");
$sql->setValue("overallsum", $this->_overallsum);
$sql->setValue("status", $this->_status);
$sql->setValue("date", date("Y-m-d H:i:s"));
$sql->setValue("name", $this->_name);
$sql->setValue("mailtext", $this->_mailtxt);
$sql->insert();
if ($sql->error == "") {
$order_id = $sql->last_insert_id;
$sql->flush();
$counter = 0;
if (is_array($this->_product)) {
for ($i = 0; $i < count($this->_product['pid']); $i++) {
$sql->setTable("rex_4_order_product");
$sql->setValue("order_id", $order_id);
$sql->setValue("product_id", $this->_product['pid'][$i]);
$sql->setValue("product_name", $this->_product['name'][$i]);
$sql->setValue("amount", $this->_product['amount'][$i]);
$sql->setValue("price", $this->_product['price'][$i]);
$sql->insert();
$sql->flush();
if ($sql->error == "") {
$counter++;
}
}
}
if ($counter == count($this->_product['pid'])) {
return true;
} else {
return false;
}
} else {
return false;
}
}
示例5: sql
$NFILENAME = $NFILE_NAME . "_{$cf}" . "{$NFILE_EXT}";
if (!file_exists($REX[MEDIAFOLDER] . "/{$NFILENAME}")) {
break;
}
}
}
if (!move_uploaded_file(${$FILE}, $REX[MEDIAFOLDER] . "/{$NFILENAME}")) {
$message = " - " . $I18N->msg("moving_file_error", $fi) . " | ";
} else {
$FILESQL = new sql();
$FILESQL->setTable("rex_file");
$FILESQL->setValue("filetype", ${$FILETYPE});
$FILESQL->setValue("filename", $NFILENAME);
$FILESQL->setValue("originalname", ${$FILENAME});
$FILESQL->setValue("filesize", ${$FILESIZE});
$FILESQL->insert();
$meta_sql->setValue("file", $NFILENAME);
}
} elseif (${$FILEDEL} == "on") {
$meta_sql->setValue("file", '');
}
// ----------------------------- / FILE UPLOAD
$meta_sql->update();
$article->setQuery("select * from rex_article where id='{$article_id}'");
$err_msg = $I18N->msg("metadata_updated") . $message;
generateArticle($article_id);
}
$typesel = new select();
$typesel->set_name("type_id");
$typesel->set_style("width:100%;");
$typesel->set_size(1);
示例6: write
function write()
{
global $REX, $REX_USER;
$sql = new sql();
$sql->setTable($REX['TABLE_PREFIX'] . '51_cache_article');
foreach ($this->vars as $key => $value) {
$sql->setValue($key, $value);
}
$user = $REX['REDAXO'] ? $REX_USER->getValue('login') : '';
if ($this->exists()) {
$sql->where('article_id=' . $this->article_id . ' AND clang=' . $this->clang);
$sql->setValue('updatedate', time());
$sql->setValue('updateuser', $user);
$sql->update();
} else {
$sql->setValue('article_id', $this->article_id);
$sql->setValue('clang', $this->clang);
$sql->setValue('createdate', time());
$sql->setValue('createuser', $user);
$sql->insert();
}
}
示例7: strstr
function create_file($cssFile, $cssDir, $cssCatId)
{
if ($cssFile != "") {
global $REX_USER;
$extension = strstr($cssFile, '.');
if (strlen($extension) == "4") {
// ----- neuer filename und extension holen
$NFILENAME = strtolower(preg_replace("/[^a-zA-Z0-9.]/", "_", $cssFile));
if (strrpos($NFILENAME, ".") != "") {
$NFILE_NAME = substr($NFILENAME, 0, strlen($NFILENAME) - (strlen($NFILENAME) - strrpos($NFILENAME, ".")));
$NFILE_EXT = substr($NFILENAME, strrpos($NFILENAME, "."), strlen($NFILENAME) - strrpos($NFILENAME, "."));
} else {
$NFILE_NAME = $NFILENAME;
$NFILE_EXT = "";
}
// ---- ext checken
$ERROR_EXT = array("php", "php3", "php4", "php5", "phtml", "pl", "asp", "aspx", "cfm");
if (in_array($NFILE_EXT, $ERROR_EXT)) {
$NFILE_NAME .= $NFILE_EXT;
$NFILE_EXT = ".txt";
}
$NFILENAME = $NFILE_NAME . $NFILE_EXT;
if ($NFILE_EXT == ".css") {
$FILETYPE = "text/css";
} else {
$FILETYPE = "text/plain";
return $this->errorMsg .= $this->thisFileIsNoCss;
}
// ----- datei schon vorhanden -> warnung ausgeben ->
if (!file_exists($cssDir . $NFILENAME)) {
$openFile = fopen($cssDir . $NFILENAME, "w");
fputs($openFile, "");
fclose($openFile);
$upload = true;
} else {
return $this->errorMsg .= $this->thisFileExists;
}
$FILESIZE = filesize($cssDir . $NFILENAME);
if ($upload) {
@chmod($cssDir . "/{$NFILENAME}", 0777);
$FILESQL = new sql();
//$FILESQL->debugsql=1;
$FILESQL->setTable("rex_file");
$FILESQL->setValue("filetype", $FILETYPE);
$FILESQL->setValue("title", $FILEINFOS[title]);
$FILESQL->setValue("description", $FILEINFOS[description]);
$FILESQL->setValue("copyright", $FILEINFOS[copyright]);
$FILESQL->setValue("filename", $NFILENAME);
$FILESQL->setValue("originalname", $NFILENAME);
$FILESQL->setValue("filesize", $FILESIZE);
$FILESQL->setValue("width", 0);
$FILESQL->setValue("height", 0);
$FILESQL->setValue("category_id", $cssCatId);
$FILESQL->setValue("createdate", time());
$FILESQL->setValue("createuser", $REX_USER->getValue("login"));
$FILESQL->setValue("updatedate", time());
$FILESQL->setValue("updateuser", $REX_USER->getValue("login"));
$FILESQL->insert();
$ok = 1;
}
$this->successMsg .= "Die Datei " . $NFILENAME . " wurde im Medienpool und auf dem Server erfolgeich angelegt.";
} else {
$this->errorMsg .= "Falsche Extension. Eine Extension besteht aus 3 Zeichen. <br /> Datei wurde <strong>NICHT</strong> angelegt.";
}
} else {
$this->errorMsg .= "Bitte geben Sie einen Dateinamen ein.";
}
}
示例8: rex_addCLang
/**
* Erstellt eine Clang
*
* @param $id Id der Clang
* @param $name Name der Clang
*/
function rex_addCLang($id, $name)
{
global $REX;
$REX['CLANG'][$id] = $name;
$content = "// --- DYN\n\r";
reset($REX['CLANG']);
for ($i = 0; $i < count($REX['CLANG']); $i++) {
$cur = key($REX['CLANG']);
$val = current($REX['CLANG']);
$content .= "\n\r\$REX['CLANG']['{$cur}'] = \"{$val}\";";
next($REX['CLANG']);
}
$content .= "\n\r// --- /DYN";
$file = $REX['INCLUDE_PATH'] . "/clang.inc.php";
$h = fopen($file, "r");
$fcontent = fread($h, filesize($file));
$fcontent = ereg_replace("(\\/\\/.---.DYN.*\\/\\/.---.\\/DYN)", $content, $fcontent);
fclose($h);
$h = fopen($file, "w+");
fwrite($h, $fcontent, strlen($fcontent));
fclose($h);
@chmod($file, 0777);
$add = new sql();
$add->setQuery("select * from " . $REX['TABLE_PREFIX'] . "article where clang='0'");
$fields = $add->getFieldnames();
for ($i = 0; $i < $add->getRows(); $i++) {
$adda = new sql();
// $adda->debugsql = 1;
$adda->setTable($REX['TABLE_PREFIX'] . "article");
reset($fields);
while (list($key, $value) = each($fields)) {
if ($value == "pid") {
echo "";
} else {
if ($value == "clang") {
$adda->setValue("clang", $id);
} else {
if ($value == "status") {
$adda->setValue("status", "0");
} else {
$adda->setValue($value, rex_addslashes($add->getValue("{$value}")));
}
}
}
// createuser
// updateuser
}
$adda->insert();
$add->next();
}
$add = new sql();
$add->query("insert into " . $REX['TABLE_PREFIX'] . "clang set id='{$id}',name='{$name}'");
// ----- EXTENSION POINT
rex_register_extension_point('CLANG_ADDED', '', array('id' => $id, 'name' => $name));
rex_generateAll();
}
示例9: insert
/**
* The insert method, call sql::insert().
*
* @param string $table
* @access public
* @return object the dao object self.
*/
public function insert($table)
{
$this->setMode('raw');
$this->setMethod('insert');
$this->sqlobj = sql::insert($table);
$this->setTable($table);
return $this;
}
示例10: time
}
}
// ----- linklist
$newsql->setValue("linklist{$fi}", $REX_ACTION['LINKLIST'][$fi]);
// ----- medialist
$newsql->setValue("filelist{$fi}", $REX_ACTION['MEDIALIST'][$fi]);
}
$newsql->setValue("updatedate", time());
$newsql->setValue("updateuser", $REX_USER->getValue("login"));
if ($function == "edit") {
$newsql->update();
$message .= $I18N->msg('block_updated');
} elseif ($function == "add") {
$newsql->setValue("createdate", time());
$newsql->setValue("createuser", $REX_USER->getValue("login"));
$newsql->insert();
$last_id = $newsql->last_insert_id;
$newsql->query("update " . $REX['TABLE_PREFIX'] . "article_slice set re_article_slice_id='{$last_id}' where re_article_slice_id='{$slice_id}' and id<>'{$last_id}' and article_id='{$article_id}' and clang={$clang}");
$message .= $I18N->msg('block_added');
$slice_id = $last_id;
}
} else {
// make delete
$re_id = $CM->getValue($REX['TABLE_PREFIX'] . "article_slice.re_article_slice_id");
$newsql = new sql();
$newsql->setQuery("select * from " . $REX['TABLE_PREFIX'] . "article_slice where re_article_slice_id='{$slice_id}'");
if ($newsql->getRows() > 0) {
$newsql->query("update " . $REX['TABLE_PREFIX'] . "article_slice set re_article_slice_id='{$re_id}' where id='" . $newsql->getValue("id") . "'");
}
$newsql->query("delete from " . $REX['TABLE_PREFIX'] . "article_slice where id='{$slice_id}'");
$message = $I18N->msg('block_deleted');
示例11: unset
$adduser->setValue("newsletter", $unewsletter);
if ($ushowinfo != "") {
$ushowinfo = 1;
} else {
$ushowinfo = 0;
}
$adduser->setValue("showinfo", $ushowinfo);
// unnoetig ?
/*
if ($usendmail != "") $usendmail = 1;
else $usendmail = 0;
$adduser->setValue("sendmail",$usendmail);
*/
// Markus => http://forum.redaxo.de/viewtopic.php?t=235
$adduser->setValue("sendmail", $usendmail);
$adduser->insert();
$user_id = 0;
$function = "";
$message = "User wurde hinzugefügt !";
unset($FADD);
} else {
$message = "Login existiert schon oder ist nicht korrekt!";
}
}
$SHOW = true;
if ($FADD != "") {
// ------------------------------------ USER HINZUFÜGEN
$SHOW = false;
echo "\t<table border=0 cellpadding=5 cellspacing=1 width=770>\n\t\t<form action=index.php method=post>\n\t\t<input type=hidden name=page value=community>\n\t\t<input type=hidden name=subpage value=user>\n\t\t<input type=hidden name=save value=1>\n\t\t<tr>\n\t\t\t<th align=left colspan=4 class=dgrey><b>User hinzufügen</b></th>\n\t\t</tr>";
if ($message != "") {
echo "<tr><td align=center class=warning><img src=pics/warning.gif width=16 height=16></td><td colspan=3 class=warning>{$message}</td></tr>";
示例12: copyCategory
function copyCategory($which, $to_cat)
{
## orginal selecten
$orig = new sql();
$orig->setQuery("SELECT * FROM rex_category WHERE id={$which}");
if ($to_cat != 0) {
## ziel selecten um den path zu bekomme
$ziel = new sql();
$ziel->setQuery("SELECT * FROM rex_category WHERE id={$to_cat}");
$zielpath = $ziel->getValue("path") . "-" . $to_cat;
} else {
## ziel is top also path
$zielpath = "";
}
## neue kategorie schreiben
$add = new sql();
$add->setTable("rex_category");
$add->setValue("name", $orig->getValue("name"));
$add->setValue("re_category_id", $to_cat);
$add->setValue("prior", $orig->getValue("prior"));
$add->setValue("path", $zielpath);
$add->setvalue("status", $orig->getValue("status"));
$add->insert();
## artikel kopieren order by !!! da sonst startartikel falsch
$articles = new sql();
$articles->setQuery("SELECT * FROM rex_article WHERE category_id={$which} order by startpage desc");
for ($i = 0; $i < $articles->rows; $i++, $articles->next()) {
copyArticle($articles->getValue("id"), $add->last_insert_id);
}
## suchen nach unterkategorien und diese dann natürlich mitkopieren
## "rekursier on" hier
$subcats = new sql();
$subcats->setQuery("SELECT * FROM rex_category WHERE re_category_id={$which}");
for ($i = 0; $i < $subcats->rows; $i++, $subcats->next()) {
copyCategory($subcats->getValue("id"), $add->last_insert_id);
}
}
示例13: sql
function inserir_arquivo_ofx_lancamentos($tb, $data_inicio, $data_fim, $carteira)
{
include "config.php";
$sql = new sql();
$table = "arquivo_ofx_lancamentos";
$where = "cod_carteira='" . $carteira . "' and (DTPOSTED between '" . $data_inicio . "' and '" . $data_fim . "')";
$sql->delete($table, $where);
$table = "captacao_cartas_baixas";
$campos = "cod_conciliacao=0";
$where = "cod_carteira='" . $carteira . "' and (data_baixa between '" . $data_inicio . "' and '" . $data_fim . "')";
$sql->update($table, $campos, $where);
$table = "arquivo_ofx_lancamentos";
$campos = "`cod_carteira`,`TRNTYPE`,`DTPOSTED`,`TRNAMT`,`FITID`,`CHECKNUM`,`MEMO`";
$values = $tb;
$sql->insert($table, $campos, $values);
}
示例14: sql
print "<tr><td class=grey>Datei:</td><td class=grey><input type=file name=file_new size=30></td></tr>";
print "<tr><td class=grey> </td><td class=grey><input type=submit value=\"" . $I18N->msg('pool_file_upload') . "\">";
if ($opener_input_field != "REX_MEDIA_0") {
echo "<input type=submit name=saveandexit value=\"" . $I18N->msg('pool_file_upload_get') . "\">";
}
print "</td></tr>\n";
print "</form>\n";
print "</table>\n";
#######
}
// ------------------------------------- Kategorienverwaltung
if ($media_method == 'add_file_cat') {
$db = new sql();
$db->setTable('rex_file_category');
$db->setValue('name', $cat_name);
$db->insert();
$msg = $I18N->msg('pool_kat_saved', $cat_name);
} elseif ($media_method == 'edit_file_cat') {
$db = new sql();
//$db->debugsql = true;
$db->setTable('rex_file_category');
$db->where("id='{$cat_id}'");
$db->setValue('name', $cat_name);
$db->update();
$msg = $I18N->msg('pool_kat_updated', $cat_name);
$cat_id = "";
} elseif ($media_method == 'delete_file_cat') {
$gf = new sql();
$gf->setQuery("select * from rex_file where category_id='{$cat_id}'");
if ($gf->getRows() == 0) {
$gf->setQuery("delete from rex_file_category where id='{$cat_id}'");
示例15: saveMedia
function saveMedia($FILE, $filefolder, $extensions_array, $rex_file_category)
{
global $REX;
$FILENAME = $FILE['name'];
$FILESIZE = $FILE['size'];
$FILETYPE = $FILE['type'];
$NFILENAME = "";
$message = '';
// ----- neuer filename und extension holen
$NFILENAME = strtolower(preg_replace("/[^a-zA-Z0-9.\\-\$\\+]/", "_", $FILENAME));
if (strrpos($NFILENAME, ".") != "") {
$NFILE_NAME = substr($NFILENAME, 0, strlen($NFILENAME) - (strlen($NFILENAME) - strrpos($NFILENAME, ".")));
$NFILE_EXT = substr($NFILENAME, strrpos($NFILENAME, "."), strlen($NFILENAME) - strrpos($NFILENAME, "."));
} else {
$NFILE_NAME = $NFILENAME;
$NFILE_EXT = "";
}
// ---- ext checken
$ERROR_EXT = array(".php", ".php3", ".php4", ".php5", ".phtml", ".pl", ".asp", ".aspx", ".cfm");
if (in_array($NFILE_EXT, $ERROR_EXT)) {
$NFILE_NAME .= $NFILE_EXT;
$NFILE_EXT = ".txt";
}
$standard_extensions_array = array(".rtf", ".pdf", ".doc", ".gif", ".jpg", ".jpeg");
if (count($extensions_array) == 0) {
$extensions_array = $standard_extensions_array;
}
if (!in_array($NFILE_EXT, $extensions_array)) {
$RETURN = FALSE;
$RETURN['ok'] = FALSE;
return $RETURN;
}
$NFILENAME = $NFILE_NAME . $NFILE_EXT;
// ----- datei schon vorhanden -> namen aendern -> _1 ..
if (file_exists($filefolder . "/{$NFILENAME}")) {
for ($cf = 1; $cf < 1000; $cf++) {
$NFILENAME = $NFILE_NAME . "_{$cf}" . "{$NFILE_EXT}";
if (!file_exists($filefolder . "/{$NFILENAME}")) {
break;
}
}
}
// ----- dateiupload
$upload = true;
if (!move_uploaded_file($FILE['tmp_name'], $filefolder . "/{$NFILENAME}")) {
if (!copy($FILE['tmp_name'], $filefolder . "/{$NFILENAME}")) {
$message .= "move file {$NFILENAME} failed | ";
$RETURN = FALSE;
$RETURN['ok'] = FALSE;
return $RETURN;
}
}
@chmod($filefolder . "/{$NFILENAME}", $REX['FILEPERM']);
$RETURN['type'] = $FILETYPE;
$RETURN['msg'] = $message;
$RETURN['ok'] = TRUE;
$RETURN['filename'] = $NFILENAME;
$FILESQL = new sql();
// $FILESQL->debugsql=1;
$FILESQL->setTable($REX['TABLE_PREFIX'] . "file");
$FILESQL->setValue("filetype", $FILETYPE);
$FILESQL->setValue("filename", $NFILENAME);
$FILESQL->setValue("originalname", $FILENAME);
$FILESQL->setValue("filesize", $FILESIZE);
$FILESQL->setValue("category_id", $rex_file_category);
$FILESQL->setValue("createdate", time());
$FILESQL->setValue("createuser", "system");
$FILESQL->setValue("updatedate", time());
$FILESQL->setValue("updateuser", "system");
$FILESQL->insert();
return $RETURN;
}