是否可以在sql中执行更新语句,但只有在更新不同时才更新?
例如
如果在数据库中, col1 = "hello"
update table1 set col1 = 'hello'
Run Code Online (Sandbox Code Playgroud)
不应该执行任何类型的更新
但是,如果
update table1 set col1 = "bye"
Run Code Online (Sandbox Code Playgroud)
这应该执行更新.
在开发Web应用程序时,在客户端级别,我使用console.log和console.error来帮助我查看正在发生的事情.我正在寻找服务器端级别的类似功能,以帮助我了解正在发生的事情.我见过error_log,它将错误写入服务器的日志文件,并想知道是否有类似的函数写入服务器访问日志?
或者我是以错误的方式解决这个问题,我是否应该使用完全不同的东西来查看后台服务器开发的情况?
目前,我正在构建json数据如下:
<%@ Page Language="VB" Debug="True" EnableViewState="false" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.IO" %>
<script runat="server">
Dim objSQLConnection As SqlConnection
Dim objSQLCommand As SqlCommand
Dim objSQLDataReader As SqlDataReader
Dim objJSONStringBuilder As StringBuilder
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Response.Clear()
Response.ContentType = "application/json"
Response.Write(get_json())
Response.End()
End Sub
Function get_json() As String
objJSONStringBuilder = New StringBuilder()
objSQLConnection = New SqlConnection(System.Configuration.ConfigurationManager.AppSettings("connString"))
objSQLCommand = New SqlCommand("sql query goes here", objSQLConnection)
objJSONStringBuilder.Append("[")
objSQLCommand.Connection.Open()
objSQLDataReader = objSQLCommand.ExecuteReader() …Run Code Online (Sandbox Code Playgroud) 这是脚本:
$("#some_button").click(function() {
var changed = [];
$( 'input[id$="_1"]' ).each(function() {
var new_id = this.id.replace( '_1', '_0' );
if ( $(this).val() !== $( 'input#' + new_id ).val() ) {
changed.push({id:new_id, new_val:$('input#' + new_id).val(), old_val:$(this).val()});
}
});
alert(changed);
});
Run Code Online (Sandbox Code Playgroud)
它给了我[object Object],[object Object].
我究竟做错了什么?
如果用户发布表单然后单击浏览器刷新按钮,以下内容是否会阻止数据库中的意外重复条目?
<?php
if( $_SERVER['REQUEST_METHOD']=='POST' ) {
try {
// write to database
} catch($e) {
// error reporting
}
}
?>
Run Code Online (Sandbox Code Playgroud) 我知道您可以使用连接从多个表中选择多个列.是否可以使用连接更新多个表中的多个列?
这是C#中的示例
using System.Web.Script.Serialization;
var jss = new JavaScriptSerializer();
var dict = jss.Deserialize<Dictionary<string,string>>(jsonText);
Console.WriteLine(dict["some_number"]); //outputs 108.541
Run Code Online (Sandbox Code Playgroud)
因为当我尝试使用在线转换器将其转换为vb.net时,我不断收到错误.有谁知道如何在vb.net中重写这个?
我从http://www.developerfusion.com/tools/convert/csharp-to-vb/得到的错误是:
-- line 3 col 1: EOF expected
Run Code Online (Sandbox Code Playgroud) 可能重复:
使用javascript格式化货币
我从服务器端返回数据作为数值,即
value[0] = 1
value[1] = 100
value[2] = 10000
value[3] = 1000000
value[4] = 100000000
Run Code Online (Sandbox Code Playgroud)
等等.
如何在客户端格式化它,使它们看起来像这样:
£1
£100
£10,000
£1,000,000
£100,000,000
Run Code Online (Sandbox Code Playgroud) 我有以下代码,允许我向当前登录的用户Facebook墙发布消息:
<?php
error_reporting( E_ALL | E_STRICT );
ini_set('display_errors', 1);
session_start();
require("facebook.php");
$facebook = new Facebook(array(
'appId' => 'app_id_here',
'secret' => 'secret_here',
'cookie' => true
));
$session = $facebook->getSession();
if( !empty( $session ) ) {
try {
$uid = $facebook->getUser();
$user = $facebook->api('/me');
$api_call = array(
'method' => 'users.hasAppPermission',
'uid' => $uid,
'ext_perm' => 'publish_stream'
);
$can_post = $facebook->api($api_call);
if( $can_post ) {
$facebook->api('/'.$uid.'/feed', 'post', array('message' => 'post some message here'));
echo 'Posted! Then redirect to an appropriate page.';
} else …Run Code Online (Sandbox Code Playgroud)