/** * Основной метод, выполняющий обновление пользователя * * @param type $userId * @param array $whatAssoc * @param array $whereAssoc * @return type */ private function updateUser($userId, array $whatAssoc, array $whereAssoc = array()) { //Сразу валидируем код пользователя $userId = AuthManager::validateUserId($userId); //В апдейте можно использовать только ассоциативные параметры Query::assertOnlyAssocParams($whatAssoc); //Получим список обновляемых колонок $columns = check_condition(array_keys($whatAssoc), 'Не переданы параметры обновления пользователя'); //Проверим на наличие запрещённых полей $denyColumns = array_intersect(self::$UPDATE_DENY_FIELDS, $columns); if ($denyColumns) { raise_error('Cледующие параметры пользователя не могут быть обновлены: ' . array_to_string(array_values($denyColumns))); } //Проверим на наличие неизвестных полей $unknownColumns = array_diff($columns, self::getColumns()); if ($unknownColumns) { raise_error('Попытка обновить недопустимые параметры пользователя: ' . array_to_string(array_values($unknownColumns))); } //Загружаем текущее состояние, на всякий случай предварительно сбросив кеш $OLD = $this->getUserDataById($this->reset($userId)); //Сбрасываем кеш и выполняем обновление $whereAssoc[self::FIELD_ID] = $this->reset($userId); $updated = $this->update(Query::update('users', $whatAssoc, $whereAssoc)); if ($updated <= 0) { return; //--- } //Загружаем новое состояние $NEW = $this->getUserDataById($this->reset($userId)); //Сравним и запишем аудит $DIF = array(); foreach ($OLD as $column => $oldValue) { if (in_array($column, self::$SKIP_AUDIT_ON_UPDATE_FIELDS)) { continue; //--- } $newValue = $NEW[$column]; if (strcmp(trim($oldValue), trim($newValue)) != 0) { $DIF[$column] = $newValue; } } if (empty($DIF)) { return; //--- } UserAudit::inst()->onUpdate($userId, $DIF); }
function update($table) { $instance = new Query($this); $instance->update($table); return $instance; }
public function changeStatus($ids, $status) { Query::update('pages')->set('status', $status, 'updated', time())->where('id', 'in', $ids)->act(); }
$tab->addClickableIconColumn('Replay', 'trackid', 'media-playback-start', 'play'); // We register the table. $c->register($tab); break; /* --------------------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------------------- */ case 'process': if (count($chunks) > 0) { foreach ($chunks as $chunk) { // We split the chunk into triplets. $triplets = explode('#', $chunk['content']); // We parse the first triplet (it's special) $fields = parseTriplet(array_shift($triplets)); $q->insertList(array('track_id' => $chunk['id'], 't' => 0, 'action' => 'resize', 'xc' => $fields['vpw'], 'yc' => $fields['vph']))->into('event')->run(); // We put the offset into the track table. $q->update('offset', $fields['offset'])->into('track')->where("id=" . $chunk['id'])->run(); // We process each triplet. foreach ($triplets as $triplet) { $fields = parseTriplet($triplet); $fields['track_id'] = $chunk['id']; switch ($fields['action']) { case 'mv': // No further processing is necessary in this case. break; case 'm-clk': replaceKey($fields, 'id', 'xtra1'); replaceKey($fields, 'which', 'xtra2'); break; case 'm-ent': case 'm-lev': replaceKey($fields, 'id', 'xtra1');
function insertaRegistro() { $nombre = __($_POST["nombre"]); $ap_pat = __($_POST["ap_pat"]); $ap_mat = __($_POST["ap_mat"]); $edad = $_POST["edad"]; $telefono_casa = $_POST["telefono"]; $idMunicipio = $_POST["municipio"]; $sexo = $_POST["sexo"]; $email = limpiaEmail($_POST["email"]); $idKoinonia = $_POST["koinonia"]; if (empty($nombre)) { exit("<p>UPSS!!!. El campo <code><b>Nombre</b></code> está vacio. Verifícalo</p>\n\t\t\t<br/>\n\t\t\t<b><a href='inscribir.php'>Regresar</a></b>"); } else { if (empty($ap_pat)) { exit("<p>UPSS!!!. El campo <code><b>Apellido Paterno</b></code> está vacio. Verifícalo</p>\n\t\t\t<br/>\n\t\t\t<b><a href='inscribir.php'>Regresar</a></b>"); } else { if (empty($ap_mat)) { exit("<p>UPSS!!!. El campo <code><b>Apellido Materno</b></code> está vacio. Verifícalo</p>\n\t\t\t<br/>\n\t\t\t<b><a href='inscribir.php'>Regresar</a></b>"); } else { if (!esEmail($email)) { exit("<p>UPSS!!!. El campo <code><b>E-Mail</b></code> debe ser válido. Verifícalo</p>\n\t\t\t<br/>\n\t\t\t<b><a href='inscribir.php'>Regresar</a></b>"); } else { if (empty($telefono_casa)) { exit("<p>UPSS!!!. El campo <code><b>Teléfono</b></code> está vacio. Verifícalo</p>\n\t\t\t<br/>\n\t\t\t<b><a href='inscribir.php'>Regresar</a></b>"); } else { if (empty($edad)) { exit("<p>UPSS!!!. El campo <code><b>Edad</b></code> está vacio. Verifícalo</p>\n\t\t\t<br/>\n\t\t\t<b><a href='inscribir.php'>Regresar</a></b>"); } else { if (siExiste("email", "asistente", "email='{$email}'")) { exit("<p>UPSS!!!. El campo <code><b>Email</b></code> ya está registrado. Verifícalo</p>\n\t\t\t<br/>\n\t\t\t<b><a href='inscribir.php'>Regresar</a></b>"); } else { if (empty($idKoinonia)) { exit("<p>UPSS!!!. El campo <code><b>Koinonia</b></code> está vacio. Verifícalo</p>\n\t\t\t<br/>\n\t\t\t<b><a href='inscribir.php'>Regresar</a></b>"); } else { if (empty($idMunicipio)) { exit("<p>UPSS!!!. El campo <code><b>Municipio</b></code> está vacio. Verifícalo</p>\n\t\t\t<br/>\n\t\t\t<b><a href='inscribir.php'>Regresar</a></b>"); } else { //require ("Query.inc"); //Ya no lo necesita se agrego en la funcion siExiste|| $query = new Query(); if ($query->insert("asistente", "nombre, ap_pat, ap_mat, telefono_casa, idMunicipio, edad, email, sexo, idKoinonia", "'{$nombre}','{$ap_pat}','{$ap_mat}','{$telefono_casa}','{$idMunicipio}','{$edad}','{$email}','{$sexo}','{$idKoinonia}'")) { if (!$query->update("koinonia", "lugares_disponibles=(lugares_disponibles-1)", "id={$idKoinonia}")) { echo "<p>Error al asignar Koinon�a</p>"; } echo "<h2>Datos insertados correctamente</h2>\n\t\t\t\t<br/>\n\t\t\t\t<br/>\n\t\t\t\t<h2>Gracias por inscribirte {$nombre}!</h2>\n\t\t\t\t<br/>\n\t\t\t\t<br/>\n\t\t\t\t<p><a href='paginaInscritos.php'>Ver todos los Inscritos</a></p>\n\t\t\t\t<br/>\n\t\t\t\t<h2><a href='inscribir.php'>Seguir Inscribiendo</a></h2>"; } } } } } } } } } } }
<p style="text-align: center; font-weight: bold;"> <font style="font-size: larger;">Coordinación General de Atención Ciudadana</font><br> Delegación SEP Estado de México </p>'; $nom = "respuesta"; $query2 = new Query(); if ($mailOpcional != '') { $_FILES["imagen"]["name"]; $archivoAdjunto = guardaArchivo("Respuestas", $nom); if ($query2->insert("respuesta", "fecha, asunto, redaccion, archivoAdjunto, oficio_idOficio", "now(), '{$v_asunto}', '{$v_redaccion}','{$archivoAdjunto}', {$vR_id}")) { require_once 'sources/AttachMailer.php'; $mailer = new AttachMailer("*****@*****.**", "{$mail},{$mailOpcional}", "{$v_asunto}", "{$cuerpoMail}"); $mailer->attachFile($archivoAdjunto); $res = $mailer->send() ? "OK" : "error"; if ($res == "OK") { $query->update("oficio", "status=3", "idOficio={$vR_id}"); $respuesta = ' <img src="images/ok.png" width="100"> <h4> Respuesta enviada correctamente </h4> '; } else { $respuesta = ' <img src="images/error.png" width="100"> <h4> Ha ocurrido un error </h4> '; } } else {
public function adjustPositionAfterRemoval($pageColumnId, $removedPosition) { Query::update($this->getDomain()->getTableName(), array("position" => "position - 1"), "position > :position AND pageColumnId = :pageColumnId", array("position" => $removedPosition, "pageColumnId" => $pageColumnId)); }
<?php include "sources/funciones.php"; if ($_SESSION["Activa"] and $_SESSION["Tipo_usuario"] == "administrador" and $_POST) { $propietario = __($_POST["propietario"]); $texto = __($_POST["texto"]); $id = $_POST['id']; require "sources/Query.inc"; $query = new Query(); if ($query->update("redaccion", "propietario='{$propietario}', texto='{$texto}'", "idRedaccion={$id}")) { $respuesta = ' <img src="images/ok.png" width="100"> <h4> Datos actualizados correctamente. </h4> '; } else { $respuesta = ' <img src="images/error.png" width="100"> <h4> Ha ocurrido un error. </h4> '; } ?> <!DOCTYPE html> <html> <head> <?php include 'sources/template/head.php'; ?>
$miArray = array("error" => "La transacción no ha podido ser modificada."); echo json_encode($miArray); } } else { $miArray = array("error" => "La transacción o el empleado no existen."); echo json_encode($miArray); } } else { if ($_POST["receiveShoe"]) { $transactionid = $_POST["transactionid"]; $employeeid_sender = $_POST["employeeid_sender"]; $query = new Query(); $em = $query->select("employeeid", "employee", "employeeid = {$employeeid_sender}", "", "arr"); $tr = $query->select("transitionid, branch_destination_id, stockid", "transition_shoe_log", "transitionid = {$transactionid}", "", "arr"); if ($em != null && $tr != null) { if ($query->update("transition_shoe_log", "employeeid_receiber = {$employeeid_sender}", "transitionid = {$transactionid}", "") && $query->update("detail_stock", "branchid = {$tr['1']}, date_stock_up = NOW()", "stockid = {$tr['2']}", "")) { $miArray = array("error" => null); echo json_encode($miArray); } else { $miArray = array("error" => "La transacción no ha podido ser modificada."); echo json_encode($miArray); } } else { $miArray = array("error" => "La transacción o el empleado no existen."); echo json_encode($miArray); } } } } } }
$ccpRn1col3 = __($_POST["ccpRn1col3"]); $ccpRn2col1 = __($_POST["ccpRn2col1"]); $ccpRn2col2 = __($_POST["ccpRn2col2"]); $ccpRn3col1 = __($_POST["ccpRn3col1"]); $ccpRn3col2 = __($_POST["ccpRn3col2"]); $rnFolio = __($_POST["rnFolio"]); $ciudadanoCol1 = __($_POST["ciudadanoCol1"]); $ciudadanoCol2 = __($_POST["ciudadanoCol2"]); $ccpRn6 = __($_POST["ccpRn6"]); $piePagRn1 = __($_POST["piePagRn1"]); $piePagRn2 = __($_POST["piePagRn2"]); $id = $_POST['id']; require "sources/Query.inc"; $query = new Query(); if ($conFirma and $conLogo) { if ($query->update("plantilla", "fechaMod=now(), logo='{$logo}', encabezadoRn1='{$encabezadoRn1}', encabezadoRn2='{$encabezadoRn2}', encabezadoRn3='{$encabezadoRn3}', encabezadoRn4='{$encabezadoRn4}', encabezadoRn5='{$encabezadoRn5}', encabezadoRn6='{$encabezadoRn6}', oficioNumero='{$oficioNumero}', lugar='{$lugar}', encabezadoCol1='{$encabezadoCol1}', encabezadoCol2='{$encabezadoCol2}', despedidaRn1='{$despedidaRn1}', despedidaRn2='{$despedidaRn2}', att='{$att}', sloganAtt='{$sloganAtt}', firma='{$firma}', encargadoAtt='{$encargadoAtt}', puestoAtt='{$puestoAtt}', ccpRn1col1='{$ccpRn1col1}', ccpRn1col2='{$ccpRn1col2}', ccpRn1col3='{$ccpRn1col3}', ccpRn2col1='{$ccpRn2col1}', ccpRn2col2='{$ccpRn2col2}', ccpRn3col1='{$ccpRn3col1}', ccpRn3col2='{$ccpRn3col2}', rnFolio='{$rnFolio}', ciudadanoCol1='{$ciudadanoCol1}', ciudadanoCol2='{$ciudadanoCol2}', ccpRn6='{$ccpRn6}', piePagRn1='{$piePagRn1}', piePagRn2='{$piePagRn2}'", "idPlantilla={$id}")) { $respuesta = ' <img src="images/ok.png" width="100"> <h4> Datos actualizados correctamente. </h4> '; } else { $respuesta = ' <img src="images/error.png" width="100"> <h4> Ha ocurrido un error. </h4> '; } } elseif ($conFirma and $conLogo == FALSE) {
/** * Updates meta info for this query * */ protected function update() { parent::update(); // Copy all keys from all children $this->keys = new \StdClass(); foreach ($this->children as $child) { foreach ($child->keys as $key => $field) { $this->keys->{$key} = $field; } } // Copy default param only if every child has the same default param $defaultParam = $this->children[0]->defaultParam; $diff = false; foreach ($this->children as $child) { if ($child->defaultParam != $defaultParam) { $diff = true; } } if (!$diff) { $this->defaultParam = $defaultParam; } }
$fecha = __($_POST["fecha"]); $ciudadano = __($_POST["ciudadano"]); $asunto = __($_POST["asunto"]); $referencia = __($_POST["referencia"]); $folio = __($_POST["folio"]); $mailCiudadano = strtolower(__($_POST["mailCiudadano"])); $telCiudadano = __($_POST["telCiudadano"]); $conFirma = __($_POST["conFirma"]); $destinatario = __($_POST["destinatario"]); $redaccion = __($_POST["redaccion"]); $datosDestinatario = getDatosDestinatario($destinatario); $datosRedaccion = getDatosRedaccion($redaccion); $meses = array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"); require_once "sources/Query.inc"; $query = new Query(); if ($query->update("oficio", " anio='{$anio}', fecha='{$fecha}', ciudadano='{$ciudadano}', asunto='{$asunto}', referencia='{$referencia}', folio='{$folio}', mailCiudadano='{$mailCiudadano}', telCiudadano='{$telCiudadano}'", "noOficio={$noOficio}")) { $respuesta = "<center><h1><span>Agregado correctamente</span></h1></center>"; $html = ' <style> td { vertical-align: top; } .tabla { font-family: Arial, Helvetica, sans-serif; font-size: 15px; text-align: justify; } .tabla td { border-left: 0.1mm solid #000000; border-right: 0.1mm solid #000000; margin: 5px;
<?php include "sources/funciones.php"; if ($_SESSION["Activa"] and $_SESSION["Tipo_usuario"] == "administrador" and $_POST) { $id = $_POST['id']; $usu = __(strtolower($_POST["usu"])); $cambiarPass = $_POST['cambiarPass']; if ($cambiarPass == "si") { $pass = __($_POST["pass"]); $passEncriptado = sha1($pass); } require "sources/Query.inc"; $query = new Query(); if ($cambiarPass == "si") { if ($query->update("login", "usuario='{$usu}', password='******'", "idLogin={$id}")) { $respuesta = ' <img src="images/ok.png" width="100"> <h4> Datos actualizados correctamente. </h4> '; } else { $respuesta = ' <img src="images/error.png" width="100"> <h4> Ha ocurrido un error. </h4> '; } } else { if ($query->update("login", "usuario='{$usu}'", "idLogin={$id}")) {
<?php include "sources/funciones.php"; if ($_SESSION["Activa"] and $_SESSION["Tipo_usuario"] == "administrador" and $_POST) { $Rn1 = __($_POST["Rn1"]); $Rn2 = __($_POST["Rn2"]); $Rn3 = __($_POST["Rn3"]); $Rn4 = __($_POST["Rn4"]); $Rn5 = __($_POST["Rn5"]); $mail = __($_POST["mail"]); $id = $_POST['id']; require "sources/Query.inc"; $query = new Query(); if ($query->update("dependencia", "titulo='{$Rn1}', nombre='{$Rn2}', puestoRn1='{$Rn3}', puestoRn2='{$Rn4}', rnPresente='{$Rn5}', correo='{$mail}'", "idDependencia={$id}")) { $respuesta = ' <img src="images/ok.png" width="100"> <h4> Datos actualizados correctamente. </h4> '; } else { $respuesta = ' <img src="images/error.png" width="100"> <h4> Ha ocurrido un error. </h4> '; } ?> <!DOCTYPE html> <html>
public function updSoporte($data, $id) { return $this->_query->update($data, $this->primary, $id); }
public static function delete($name) { list($id, $keys) = self::parseName($name); // deleting (locally) if (empty($keys)) { unset(self::$fields[$id]); } else { self::deleteSubKey(self::$fields[$id], $keys); } // pushing changes to database if (!array_key_exists($id, self::$fields)) { // deleting field completely Query::delete('config')->where('name', $id)->act(); self::$noSuchField[$id] = true; } else { // or only updating Query::update('config')->where('name', $id)->set('value', serialize(self::$fields[$id]))->act(); } }
public function reject(array $ids) { foreach ($ids as $id) { $comment = DB::select('comments', $id); // can't reject admin's comment if ($comment->authorID !== null) { continue; } // updating counters $tableName = $comment->type . 's'; $recordID = $comment->record; if ($comment->approved) { DB::query('UPDATE __? SET approvedCommentsCount = approvedCommentsCount - 1 WHERE id = ?', $tableName, $recordID); } // rejecting Query::update('comments')->set('approved', false)->where('id', $id)->act(); } }
function save($sync = true) { // insert if new if ($this->isNew()) { return $this->insert($sync); } $query = new Query($this->tableName); $query->update($this->tableName, $this->toArray())->where($this->primaryKeyName . ' = ?', [$this->primaryKey])->limit(1); $result = static::query($query, $query->params); if ($sync) { $this->sync(); } return (bool) $result; }
<?php include "sources/funciones.php"; if ($_SESSION["Activa"] and $_SESSION["Tipo_usuario"] == "administrador" and $_POST) { $texto = __($_POST["texto"]); $id = $_POST['id']; require "sources/Query.inc"; $query = new Query(); if ($query->update("redNotificacion", "redaccionOficios='{$texto}'", "idRedNotificacion={$id}")) { $respuesta = ' <img src="images/ok.png" width="100"> <h4> Datos actualizados correctamente. </h4> '; } else { $respuesta = ' <img src="images/error.png" width="100"> <h4> Ha ocurrido un error. </h4> '; } ?> <!DOCTYPE html> <html> <head> <?php include 'sources/template/head.php'; ?> <meta http-equiv="Refresh" content="2;url=consultarNotOficios.php" />
addButton('btn btn-success', 'Submit', 'col-sm-offset-2 col-sm-4', 'Sign Up'); ?> </fieldset> </form> <?php require_once 'Status.php'; require_once 'database.php'; $q = new Status($db); $q->viewStatus('dvd', 'available', 'Return'); ?> <?php require_once "Query.php"; $crud_book = new Query(7, 'dvd', 'item_no,title,genre,description,price,rental_period,status'); $crud_book->mysqlConnect('localhost', 'root', '', 'video_rental'); $crud_book->create(); echo "<hr/>"; $crud_book->read(); echo "<hr/>"; $crud_book->update(); echo "<hr/>"; $crud_book->delete(); echo "<hr/>"; ?> </div> </div> </div> </body> </html>
public function changeStatus($ids, $status) { Query::update('blogposts')->set('status', $status, 'updated', time())->where('id', 'in', $ids)->act(); self::updateFeed(); }
/** * Create an update * * @param string $table * @param array $values * @param string $handler * @return DB\Query */ public static function update($table, $data = null, $handler = null) { return Query::update($table, $data, $handler); }
public function adjustPositionAfterRemoval($removedPosition) { Query::update($this->getDomain()->getTableName(), array("position" => "position - 1"), "position > :position", array("position" => $removedPosition)); }
<?php include "sources/funciones.php"; if ($_SESSION["Activa"] and $_SESSION["Tipo_usuario"] == "administrador" and $_POST) { $texto = __($_POST["texto"]); $id = $_POST['id']; require "sources/Query.inc"; $query = new Query(); if ($query->update("redNotificacion", "redaccionRespuestas='{$texto}'", "idRedNotificacion={$id}")) { $respuesta = ' <img src="images/ok.png" width="100"> <h4> Datos actualizados correctamente. </h4> '; } else { $respuesta = ' <img src="images/error.png" width="100"> <h4> Ha ocurrido un error. </h4> '; } ?> <!DOCTYPE html> <html> <head> <?php include 'sources/template/head.php'; ?> <meta http-equiv="Refresh" content="2;url=consultarNotRespuestas.php" />
function update($objectname, $data) { $query = new Query(); return $query->update($objectname, $data); }
<?php include "sources/funciones.php"; if ($_SESSION["Activa"] and $_SESSION["Tipo_usuario"] == "administrador" and $_POST) { $nombre = __($_POST["nombre"]); $mail = __($_POST['mail']); $id = $_POST['id']; require "sources/Query.inc"; $query = new Query(); if ($query->update("revisor", "nombre='{$nombre}', correo='{$mail}'", "idRevisor={$id}")) { $respuesta = ' <img src="images/ok.png" width="100"> <h4> Datos actualizados correctamente. </h4> '; } else { $respuesta = ' <img src="images/error.png" width="100"> <h4> Ha ocurrido un error. </h4> '; } ?> <!DOCTYPE html> <html> <head> <?php include 'sources/template/head.php'; ?>
/** * Executes an UPDATE statement on $tableName using $values as new values. * If present, $where contains a list of filters for the target set. * * @param array $values An associative array containing [fieldName => value] pairs. * @param A3gZ\Database\Interfaces\CamlInterface[] $where List of Caml conditions. * @param string $tableName Optional: the target table's name. If not given $this->tableName is used instead. * * @return A3gZ\Database\Interfaces\AbstractTableDataGateway Self */ public function update(array $values, array $where = null, $tableName = null) { if (!isset($tableName) && !isset($this->tableName)) { throw new \Exception("Table name is required."); } elseif (!isset($tableName)) { $tableName = $this->tableName; } $qry = Query::update($tableName); // Try to use the module's metadata whenever available $fields = null; if (isset($this->metadata) && isset($this->metadata['fields']) && count($this->metadata['fields'])) { $fields = $this->metadata['fields']; } // Set values foreach ($values as $key => $value) { // Only pass fields that exist in the metadata. if (!isset($fields) || isset($fields) && isset($fields[$key])) { $qry->set($key, ":{$key}"); } } // Inject conditions if (isset($where) && is_array($where)) { foreach ($where as $caml) { $qry->where($caml); } } $qst = $qry->toSql(); if ($this->execute($qst, $values) === false) { return false; } return $this; }