本文整理汇总了PHP中DataBase::update方法的典型用法代码示例。如果您正苦于以下问题:PHP DataBase::update方法的具体用法?PHP DataBase::update怎么用?PHP DataBase::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataBase
的用法示例。
在下文中一共展示了DataBase::update方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* 修改联系人信息
* @todo 未完成
* @param Group_Contact $group_contact 联系人信息
*/
public function update($group_id, $contact, $mode = 'default')
{
$id = $contact->get_id();
switch ($mode) {
case 'overwrite':
$setters = array();
$setters['gid'] = $group_id;
foreach ($this->map as $field) {
$name = (string) $field->name;
$getprop = (string) $field->accessor;
if (in_array($name, array('uid', 'fid', 'formatted_name', 'phonetic', 'given_name', 'middle_name', 'family_name', 'prefix', 'suffix', 'organization', 'department', 'note', 'birthday', 'title', 'nickname', 'sort', 'modified'))) {
$setters[$name] = call_user_func(array($contact, $getprop));
}
}
$sqls = $this->_edit_avatar($group_id, $id, $contact->get_avatar());
foreach (array('emails', 'tels', 'addresses', 'ims', 'urls', 'events', 'relations') as $type) {
$sqls = array_merge($sqls, $this->_edit_info($group_id, $id, $type, call_user_func(array($contact, 'get_' . $type))));
}
//更新数据库
$query = $this->db->update('gcp_contacts', $setters, array('gcid' => $id));
foreach ($sqls as $sql) {
$this->db->query($sql);
}
$contact->set_modified_at($setters['modified']);
return SUCCESS;
break;
}
return FAIL;
}
示例2: update_history
/**
* 更新快照信息
* @param int $user_id 用户ID
* @param int $history_id 快照ID
* @param array $setters 更新内容
* @return bool
*/
public function update_history($user_id, $history_id, $setters)
{
$this->db->begin();
$query = $this->db->update($this->get_table($user_id, 'contact_history'), $setters, array('id' => $history_id));
if (!$query) {
$this->db->rollback();
}
return $this->db->commit();
}
示例3: while
}
//end of for loop
$sql = "SELECT img_loc FROM doc_imgs where doc_imgs.doc_id='" . $get_decument_id . "' ";
$data = mysql_query($sql);
$con->disconnect();
}
//end of if statment if(isset($_POST['pleace']))
if (isset($_POST['change'])) {
$sql = "SELECT c_id FROM documentation where c_num='" . $course_id . "' ";
echo $sql;
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result)) {
$get_decument_id = $row['c_id'];
echo $get_decument_id;
}
$con->update('documentation', array('course' => $course, 'event' => $event, 'c_name' => $course_name, 'c_num' => $course_id, 'c_location' => $pleace, 'c_collage_index' => $collage, 'c_dept' => $dept, 'c_price' => $price, 'c_gender' => $type, 'c_target_group' => $target, 'c_duration' => $how_long, 'c_req_num' => $at_least, 'c_reg_time' => $start_date, 'c_max_num' => $at_most, 'c_time_from' => $start_time, 'c_time_to' => $end_time, 'c_major' => $course_about, 'c_languate' => $language, 'c_goals' => $goals, 'c_doc_desc' => $description, 'c_notes' => $notes), array('c_id', $get_decument_id));
}
if (isset($_POST['delete_course_id'])) {
//echo "it is set <br/>";
$course_id = $_POST['delete_course_id'];
$sql = "SELECT c_id FROM documentation where c_num='" . $course_id . "' ";
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result)) {
$get_decument_id = $row['c_id'];
}
$con->delete('comunity_service', 'documentation', 'c_id="' . $get_decument_id . '"');
}
//else{echo "not set";}
}
if (isset($_POST['delete_course_id'])) {
//echo "it is set <br/>";
示例4: json_encode
$aDatos['entreCalles'] = filter_input(INPUT_POST, "entreCalles");
$aDatos['colonia'] = filter_input(INPUT_POST, "colonia");
$aDatos['ciudad'] = filter_input(INPUT_POST, "ciudad");
$aDatos['estado'] = filter_input(INPUT_POST, "estado");
$aDatos['codigoPostal'] = filter_input(INPUT_POST, "codigoPost");
// Pestaña de Localizacion
$aDatos['telefono'] = filter_input(INPUT_POST, "telefono");
$aDatos['fax'] = filter_input(INPUT_POST, "fax");
$aDatos['movil'] = filter_input(INPUT_POST, "movil");
$aDatos['email'] = filter_input(INPUT_POST, "email");
// Pestaña de Contacto
$aDatos['contactoNombre'] = filter_input(INPUT_POST, "contactoNombre");
$aDatos['contactoTelefono'] = filter_input(INPUT_POST, "contactoTelefono");
$aDatos['contactoMail'] = filter_input(INPUT_POST, "contactoMail");
// Pestaña Extras
$aDatos['direccionEntrega'] = filter_input(INPUT_POST, "direccionEntrega");
$aDatos['direccionCobro'] = filter_input(INPUT_POST, "direccionCobro");
$aDatos['comentario'] = filter_input(INPUT_POST, "comentarios");
$cDb = new DataBase();
if ($cIdCliente != "") {
$sWhere = "idCliente = {$cIdCliente}";
$actualizado = $cDb->update("cliente", $aDatos, $sWhere);
} else {
$actualizado = $cDb->insert("cliente", $aDatos);
}
$Mensaje = "Datos del Cliente Guardados Correctamente";
if (!$actualizado) {
$Mensaje = $cDb->LastError;
}
$return = array("correcto" => $actualizado, "mensaje" => $Mensaje);
echo json_encode($return);
示例5:
ob_end_clean();
echo '{"success":false,"message":"error: no columns given to query"}';
exit;
}
if ($objParseColumns->success == false) {
ob_end_clean();
echo '{"success":false,"message":"error: no columns given to query"}';
exit;
}
$dataBase->parseJoin($strJoin);
$dataBase->parseRestrictions($strRestrictions);
$dataBase->parseOrderBy($strOrder);
$dataBase->parseGroupBy($strGroupBy);
$dataBase->parseLimit($strLimit);
$dataBase->parseValues($strValues);
ob_end_clean();
switch ($strQuery) {
case 'SELECT':
echo $dataBase->select();
break;
case 'INSERT':
echo $dataBase->insert();
break;
case 'DELETE':
echo $dataBase->delete();
break;
case 'UPDATE':
echo $dataBase->update();
break;
}
exit;
示例6: json_encode
<?php
session_start();
include '../dataBaseClass/connection.php';
$aDatos = array();
$idAgente = filter_input(INPUT_POST, "idAgente");
$aDatos['nombre'] = filter_input(INPUT_POST, "nombre");
$aDatos['clave'] = filter_input(INPUT_POST, "clave");
$aDatos['direccion'] = filter_input(INPUT_POST, "direccion");
$aDatos['email'] = filter_input(INPUT_POST, "email");
$aDatos['telefono'] = filter_input(INPUT_POST, "telefono");
$aDatos['movil'] = filter_input(INPUT_POST, "movil");
$cDb = new DataBase();
if ($idAgente != '') {
$lCorrecto = $cDb->update("agente", $aDatos, "idAgente = '{$idAgente}'");
} else {
$lCorrecto = $cDb->insert("agente", $aDatos, false);
}
$mensaje = "Datos del agente guardados correctamente";
if (!$lCorrecto) {
$mensaje = "Error al tratar de guardar la informacion del agente: " . $cDb->LastError;
}
echo json_encode(array('correcto' => $lCorrecto, 'mensaje' => $mensaje));
示例7: die
$dbConfig = "";
die(json_encode(array('code' => 'error', 'comment' => 'no database type specified')));
}
include $dbConnector;
if (!hash_equals($authKey, crypt($auth, $authKey))) {
header("HTTP/1.1 403 Forbidden");
die(json_encode(array('code' => 'error', 'comment' => 'auth failed with authkey: ' . $auth)));
}
$db = new DataBase($dbConfig);
switch ($function) {
case 'listall':
echo $db->listall();
break;
case 'save':
if ($db->exists($itemName)) {
echo $db->update($itemName, $itemCount);
} else {
echo $db->save($itemName, $itemCount);
}
break;
case 'update':
echo $db->update($itemName, $itemCount);
break;
case 'delete':
echo $db->delete($itemName);
break;
case 'clear':
echo $db->clear();
break;
default:
die(json_encode(array('code' => 'error', 'comment' => 'function not specified')));
示例8: count
echo json_encode($newArr);
}
// Список отзывов
if ($_m == 'reviewList') {
$limit = $_GET['limit'];
$page = $_GET['page'];
$from = $page * $limit - $limit;
$array['result'] = $Db->select('SELECT * FROM reviews ORDER BY id DESC LIMIT ' . $from . ', ' . $limit);
$array['total'] = $Db->count('SELECT count(*) FROM reviews');
$array['unread'] = $Db->count('SELECT count(*) FROM reviews WHERE visible = ' . $Db->quote(0));
echo json_encode($array);
}
// Список отзывов
if ($_m == 'reviewListSetVisible') {
$ids = json_decode($_GET['ids']);
$Db->update('UPDATE reviews SET visible = ' . $Db->quote($_GET['visible']) . ' WHERE id IN (' . implode(',', array_map('intval', $ids)) . ')');
}
if ($_m == 'userList') {
$limit = $_GET['limit'];
$page = $_GET['page'];
$from = $page * $limit - $limit;
$search = '';
if (strlen($_GET['search']) > 0) {
$search = $_GET['search'];
}
$array['result'] = $Db->select('
SELECT id, login, f, i, o, date, type, email,
(SELECT count(id) FROM reviews WHERE reviews.user = user.id) as reviewsCount
FROM user
WHERE user.login like "%' . $search . '%"
ORDER BY id DESC
示例9: update
static function update($name, $array = array(), $nid)
{
$master = self::table_master($name);
DataBase::update($master, $array, array('id=:id', array(':id' => $nid)));
}
示例10: sendMail
$user = $user[0];
sendMail($user['email'], Config::get('SITE_TITLE'), Config::get('SITE_TITLE'), 'Password reset', 'Dear ' . $user['firstname'] . ' ' . $user['lastname'] . ",<br /><br />Next to your request, your password will be reset. Click the link below to reset it.<br />If you didn't request us to reset your password, simply ignore this mail.<br /><br /><a href=\"http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}?action=reset&token=" . $user['token'] . "\">Reset your password</a><br /><br /><small>Sent from Skyer</small>");
$showForgotSubmitted = true;
} else {
die('<h3>User not found</h3>');
}
} else {
$showForgot = true;
}
break;
case 'reset':
if (isset($_GET['token'])) {
$user = DataBase::get('users', array(), array('token' => $_GET['token']));
if (count($user) && $user !== false) {
$pass = md5(uniqid(rand(), true));
DataBase::update('users', array('password' => hash('sha384', $pass)), array('token' => $_GET['token']));
$showReset = true;
} else {
die('<h3>User not found</h3>');
}
} else {
die('<h3>Bad request</h3>');
}
break;
}
}
if (!User::isGuest() && (!isset($_GET['action']) || $_GET['action'] !== 'logout')) {
header('Location: index.php');
}
if (isset($_POST['submit']) && isset($_POST['pseudo']) && isset($_POST['password'])) {
$displayForm = false;
示例11: array
session_start();
include './dataBaseClass/connection.php';
$aDatos = array();
$idCompania = filter_input(INPUT_POST, "IdCompania");
$aDatos['nombre'] = filter_input(INPUT_POST, "nombre");
$aDatos['direccion'] = filter_input(INPUT_POST, "direccion");
$aDatos['telefono'] = filter_input(INPUT_POST, "telefono");
$aDatos['portal'] = filter_input(INPUT_POST, "portal");
$aTipos = array();
if (isset($_POST['chkTipoPoliza'])) {
$aTipos = $_POST['chkTipoPoliza'];
}
$cDb = new DataBase();
if ($idCompania != "") {
$sWhere = "idCompania = {$idCompania}";
$lCorrecto = $cDb->update("Companias", $aDatos, $sWhere);
} else {
$lCorrecto = $cDb->insert("Companias", $aDatos);
$idCompania = strval($cDb->LastInsertedId);
}
$mensaje = "Datos de la compañia guardados correctamente";
if (!$lCorrecto) {
$mensaje = "Error al tratar de guardar la informacion de la compañia: " . mysqli_stmt_error($stmt);
}
if ($lCorrecto) {
// Borramos los datos de los tipos de polizas y agregamos las nuevas seleccionadas
$cDb->delete("TipoPolizaCompania", "idCompania = {$idCompania}");
foreach ($aTipos as $value) {
$aData = array();
$aData['idCompania'] = $idCompania;
$aData['idTipo'] = $value;
示例12: json_encode
<?php
session_start();
include '../dataBaseClass/connection.php';
$aDatos = array();
$id = filter_input(INPUT_POST, "idPaquete");
$tipoPoliza = filter_input(INPUT_POST, "tipoPoliza");
$cobertura = filter_input(INPUT_POST, "coberturaOrg");
$aDatos['idPaquete'] = filter_input(INPUT_POST, "idPaquete");
$aDatos['tipoPoliza'] = filter_input(INPUT_POST, "tipoPoliza");
$aDatos['cobertura'] = filter_input(INPUT_POST, "cobertura");
$cDb = new DataBase();
$lCorrecto = $cDb->update("Paquete", $aDatos, "idPaquete = '{$id}' AND tipoPoliza = '{$tipoPoliza}' AND cobertura = '{$cobertura}'");
$mensaje = "Datos del tipo de poliza guardados correctamente";
if (!$lCorrecto) {
$mensaje = "Error al tratar de guardar la informacion del tipo de poliza: " . $cDb->LastError;
}
echo json_encode(array('correcto' => $lCorrecto, 'mensaje' => $mensaje));
示例13: die
$mail['sender_ID'] = $mail['sender'];
$mail['sender'] = $sender['fullname'];
$recipient = User::getUserFromID($mail['recipient']);
$mail['recipient_ID'] = $mail['recipient'];
$mail['recipient'] = $recipient['fullname'];
die(json_encode($mail));
break;
case 'move':
$mail = DataBase::get('messages', array('sender', 'recipient'), array('ID' => $_GET['ID']));
if (count($mail) && $mail !== false) {
$mail = $mail[0];
if ($mail['sender'] == User::getID()) {
$r = DataBase::update('messages', array('sender_dir' => $_GET['dir']), array('ID' => $_GET['ID'], 'sender' => User::getID()))->fetch();
} else {
if ($mail['recipient'] == User::getID()) {
$r = DataBase::update('messages', array('recipient_dir' => $_GET['dir']), array('ID' => $_GET['ID'], 'recipient' => User::getID()))->fetch();
} else {
die('<h3>Mail not found</h3>');
}
}
} else {
die('<h3>That\'s not your mail !</h3>');
}
die('true');
break;
case 'unread':
$unread = DataBase::query('SELECT COUNT(*) FROM messages WHERE opened = 0 AND recipient_dir = ' . DataBase::_secure($_GET['folder']) . ' AND recipient = ' . User::getID())->fetch()[0];
if (strval($unread)) {
die($unread);
} else {
die;
示例14: array
$allowGuest = true;
$hideDefaultView = true;
require 'framework/inc.php';
Page::setTitle('Register');
Page::css('inspinia/plugins/iCheck/custom');
Page::css('register');
Page::js('inspinia/plugins/iCheck/icheck.min');
Page::js('register');
$registered = $activated = false;
$err = '';
if (isset($_GET['activate'])) {
$user = DataBase::get('users', array(), array('token' => $_GET['activate']));
if (count($user) && $user !== false) {
$pass = md5(uniqid(rand(), true));
DataBase::update('users', array('activated' => 1), array('token' => $_GET['activate']));
$activated = true;
} else {
die('<h3>User not found</h3>');
}
} elseif (isset($_POST['submit'])) {
$required = array('pseudo', 'firstname', 'lastname', 'fullname', 'email', 'email-confirm', 'password', 'password-confirm');
foreach ($required as $i => $name) {
if (!isset($_POST[$name])) {
$err = 'All fields are required';
} else {
$_POST[$name] = htmlspecialchars($_POST[$name]);
}
}
if (strlen($_POST['pseudo']) < 5) {
$err = 'Pseudo must be at least 5 characters';