小编art*_*olk的帖子

PDO不会两次运行相同的查询?

美好的一天!

我试图用相同的参数运行相同的更新语句两次,似乎它没有在第二种情况下执行:

$update_query = $this->db->connection->prepare('UPDATE `Table SET `field` = :price WHERE (`partnum` = :partnum)');

$update_query->execute(array('price' => 123, 'partnum' => test));
var_dump($update_query->rowCount()); //returns 1

// If I insert here any statement it works as expected

$update_query->execute(array('price' => 123, 'partnum' => test));
var_dump($update_query->rowCount()); //returns 0!
Run Code Online (Sandbox Code Playgroud)

我没有启用mysql查询缓存.

谢谢!

php mysql pdo

3
推荐指数
1
解决办法
535
查看次数

jQuery Validate 1.7在jQuery 1.5上打破$ .getJSON()?

美好的一天!

我在jQuery 1.4.4上运行一个插件getJSON(),在升级到1.5之后,没有调用回调.返回的JSON有效(我已使用验证器检查过).

另外我注意到?callback=...jQuery添加到URL的其他get参数

我似乎想出了如何创建一个测试用例,似乎JQuery验证1.7(最新版本)是原因:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="ru">

<head>
    <title>

    </title>

    <meta http-equiv="content-type" content="text/html; charset=utf8" />     
    <script type="text/javascript" src="js/jquery-1.5.min.js"></script>
<!--    
    If I uncomment this - it will not work
    <script type="text/javascript" src="js/jquery.validate.js"></script>
-->
</head>
<body>
<script type="text/javascript">
$(function(){
    $.ajaxSetup({ cache: false });
    $('#clickme').click(function(){
        var params = {userid : 'some-user-id-to-choose-right-temp-FTP-folder-for-the-user'};
        $.getJSON('/ajax-page_material-edit-ftp-filelist.php', params, function(data) {
            console.log(data);
        });
    });
});
</script>

<a href="#" id="clickme">Click Me!</a>

</body>
</html>
Run Code Online (Sandbox Code Playgroud)

也许这个插件中的代码是原因:

// ajax mode: …
Run Code Online (Sandbox Code Playgroud)

jquery jquery-validate

3
推荐指数
1
解决办法
1719
查看次数

更改默认值"{0}字段是必需的"(最终解决方案?)

美好的一天!

我有以下用于登录表单的ViewModel类:

using System.ComponentModel.DataAnnotations;

...

public class UserLogin : IDataErrorInfo
{           
    [Required]
    [DisplayName("Login")]
    public string Login { get; set; }

    [Required]
    [DisplayName("Password")]
    public string Password { get; set; }

    [DisplayName("Remember Me")]
    public bool RememberMe { get; set; }

    #region IDataErrorInfo Members

    // This will be a Model-level error
    public string Error
    {
        get
        {
            if (!WebUser.CanLogin(Login, Password))
            {
                return Resources.ValidationErrors.InvalidLoginPassword;
            }
            else
            {
                return String.Empty;
            }
        }
    }

    // All is handled by DataAnnotation attributes, just a stub for interface …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc modelbinders viewmodel asp.net-mvc-2

2
推荐指数
1
解决办法
5209
查看次数

.NET 4.0上的ASP.NET MVC2:[ValidateInput(false)]足够了吗?

美好的一天!

我打算将我的ASP.NET MVC 2应用程序升级到.NET 4.0,并且有几个问题:

  1. 正在[ValidateInput(false)]采取行动足以接受HTML,或者我需要<httpRuntime requestValidationMode="2.0"/>按照此处所述进行设置:ASP.NET 4 Breaking Changes

  2. 如果我将ASP.NET MVC升级到版本3(除了升级到.NET 4.0)之外它将如何工作?

提前致谢!

asp.net request-validation asp.net-mvc-3 asp.net-mvc-2

2
推荐指数
1
解决办法
763
查看次数

PHP CURL 和 SSL 证书(或证书链)

再会!

我有 REST API,可以通过 SSL (https://) 访问。我想将正确的证书(或证书链)与我编写的 PHP 和 CURL 脚本一起发出请求。

以下是来自我的目标 ( http://api.vkontakte.ru ) 的证书在 Firefox 中的样子:

http://speedcap.net/img/bc687485819715c65d6fe1e4ca1fdc40/1a2be.png

以下是从 Firefox 保存的“PEM 格式的证书链 X.509”的片段(此处描述:http ://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access- https-ssltls-protected-sites/ ):

-----BEGIN CERTIFICATE-----
MIIFVzCCBD+gAwIBAgIHKx5Ov2FOejANBgkqhkiG9w0BAQUFADCByjELMAkGA1UE
[..skip...]
0npsf5fkvT8E13NgVY0PK6V/baMTlTgWXKQZ
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIE3jCCA8agAwIBAgICAwEwDQYJKoZIhvcNAQEFBQAwYzELMAkGA1UEBhMCVVMx
[..skip...]
qDTMBqLdElrRhjZkAzVvb3du6/KFUJheqwNTrZEjYx8WnM25sgVjOuH0aBsXBTWV
U+4=
-----END CERTIFICATE-----
Run Code Online (Sandbox Code Playgroud)

以下是 CURL 初始化的代码示例:

$this->ch = curl_init();
    curl_setopt_array($this->ch, array(

        CURLOPT_TIMEOUT => 30,
        CURLOPT_RETURNTRANSFER => TRUE,
        CURLOPT_AUTOREFERER => TRUE,
        CURLOPT_FOLLOWLOCATION => TRUE,

        CURLOPT_SSL_VERIFYPEER => TRUE,
        CURLOPT_SSL_VERIFYHOST => 2,
        CURLOPT_CAINFO => <path to my cert>,        
    )); 
Run Code Online (Sandbox Code Playgroud)

我收到 CURL 错误 60 …

php ssl https curl

2
推荐指数
1
解决办法
3万
查看次数

如何掌握所有C#功能特性?

我在C#中使用lambdas很多(LINQ中有很多种类,ASP.NET MVC中的强类型助手,AutoMapper API等),但是我不能在我自己的代码中开始使用C#功能,因为我不能弄清楚我能用他们做些什么很酷的事情.我大部分时间都直观地使用它们.

有关于此的任何参考或快速(但完整)指南.我不是在寻找MSDN参考,而是为了快速解释C#的所有功能特性.如果可以缩小列表以及一些指向博客文章的链接 - 这也是可以接受的.

问题结束后更新:似乎我的长解释并不清楚,所以我会尝试将其缩小:我需要一个可用于编写自己的代码的概念列表(不使用其他API).接受的答案是我需要的,谢谢.

c# linq lambda

2
推荐指数
1
解决办法
244
查看次数

express.compress()和express.responseTime()不适用于控制器的输出

我有以下脚手架快递申请:

var 
    express = require('express')
  , routes = require('./routes')
  , user = require('./routes/user')
  , http = require('http')
  , path = require('path')
  , _ = require('underscore');

var app = express();

app.configure(function(){
  app.set('port', process.env.PORT || 5000);
  app.set('views', __dirname + '/views');
  app.set('view engine', 'ejs');
  app.use(express.favicon());
  app.use(express.logger('dev'));
  app.use(express.bodyParser());
  app.use(express.methodOverride());
  app.use(app.router);
  app.use(express.compress());
  app.use(express.responseTime());
  app.use(require('less-middleware')({ src: __dirname + '/public' }));
  app.use(express.static(path.join(__dirname, 'public')));
});

app.configure('development', function(){
  app.use(express.errorHandler());
});

app.get('/', routes.index);
app.get('/users', user.list);

http.createServer(app).listen(app.get('port'), function(){
    console.log("Express server listening on port " + app.get('port'));
});
Run Code Online (Sandbox Code Playgroud)

我对快速生成器生成的代码所做的唯一修改:

  app.use(express.compress());
  app.use(express.responseTime());
Run Code Online (Sandbox Code Playgroud)

问题:处理到LESS文件是gzip并具有响应时间的X-HTTP标头,但是我的控制器(HTML页面)的输出不是gzippped并且没有标头. …

connect node.js express

2
推荐指数
1
解决办法
2800
查看次数