小编Mar*_*lln的帖子

什么mysql引擎的大量数据(日志记录)?

什么mysql引擎最适合处理大量(多行)的(小)数据?我在谈论伐木.

每当我在页面上做事情时,我都在考虑记录,比如调用函数,调用文件等等.

我还应该了解如何构建表格.

mysql logging structure

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

x未定义,setTimeout问题

使用以下代码我得到一个clock is not defined错误,为什么?

$(function(){   
    function clock() {
        var nd = new Date();
        var h, m, s;
        h = nd.getHours();
        m = nd.getMinutes();
        s = nd.getSeconds();
        if (h <= 9) h = "0" + h;
        if (m <= 9) m = "0" + m;
        if (s <= 9) s = "0" + s;
        $('#digital-clock .hour').text(h+':');
        $('#digital-clock .min').text(m+':');
        $('#digital-clock .sec').text(s);
    }
    setTimeout('clock()', 1000);
});
Run Code Online (Sandbox Code Playgroud)

javascript settimeout

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

将时区int解析为字符串(时区名称)(facebook api)

你如何将时区转换intstring(等:Europe/Stockholm)

我正在使用Facebook的PHP api并返回["timezone"] => int(2).我怎么想解析那个?

php timezone facebook-graph-api

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

当我在url中使用已知的文件扩展名时,nginx 404

每当我在url nginx中返回一个已知的文件扩展名404 Not Found.

domain.com/myroute.foodomain.com/foo/myroute.foo是好的,但domain.com/myroute.phpdomain.com/foo/myroute.php(或例如的CSS,.js文件)返回404 Not Found.

我的nginx服务器配置:

server {
        listen          80;
        server_name     domain.com;
        root            /var/www/path/public;

        charset utf-8;
        gzip on;

        #access_log  logs/host.access.log  main;

        location / {
                index index.html index.php index.htm;
                try_files $uri $uri/ /index.php?q=$uri&$args;
        }

        location ~ \.php$ {
                try_files                       $uri = 404;
                fastcgi_pass    unix:/var/run/php5-fpm.sock;
                fastcgi_index   index.php;
                fastcgi_param   SCRIPT_FILENAME  $request_filename;
                include         fastcgi_params;
        }

        location ~* \.(jpg|jpeg|gif|png|bmp|ico|pdf|flv|swf|exe|html|htm|txt|css|js) {
                add_header        Cache-Control public;
                add_header        Cache-Control must-revalidate;
                expires           7d;
                access_log off;
        }
} …
Run Code Online (Sandbox Code Playgroud)

nginx

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

回调函数中带有变量的PHP错误

我在php(laravel)中有这个功能:

    public static function isUserParticipatesInTournament($tourId, $userId)
    {
        var_dump($userId); //dumped
        $user = User::find($userId);

        if(!$user)
        {
            return null;
        }

        $obj = $user->whereHas('tournaments', function($query)
        {
            var_dump($tourId); //error
            $query->where('id', '=', $tourId); //error
        })->get();

        return $obj;
    }
Run Code Online (Sandbox Code Playgroud)

问题是在闭包$obj = $user->whereHas('tournaments', function($query){...}$tourId变量是未定义的.我收到这个错误: Undefined variable: userId.

为什么会这样?变量在内部函数的范围内声明.我唯一的想法是,它是一个回调函数.

当我尝试执行此函数时:$obj = $user->whereHas('tournaments', function($query, $tourId){...}然后我收到此异常:

Missing argument 2 for User::{closure}()
Run Code Online (Sandbox Code Playgroud)

php scope laravel

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

OOP不能在变量中使用define

为什么defines在类中创建变量时不能使用?我该怎么做才能超越这个?(define是表前缀(db))

像这样:

class foo {
    public $bar = FOO."bar";
}
Run Code Online (Sandbox Code Playgroud)

这给了我以下错误:

解析错误:语法错误,意外'.',期待','或';'

php oop variables class

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

为什么我在window.location中保存的变量会发生变化?

我保存window.location到变量但是当window.location更改时(History.js)我的变量也被更改,为什么?我没有在第一页请求之外的任何地方设置我的变量.

(function(){
    var myvar = window.location;

    History.Adapter.bind(window, 'statechange', function(){
        console.log(window.location.pathname);
        console.log(myvar.pathname); // same as window.location.pathname but should be saved data from line 2

        var state = History.getState(),
            options = {
                url: state.url,
                type: 'get',
                success: function(resp, status, xhr) { 
                    $('#wrapper').html(resp); 
                }
            };

        $.extend(options, callbackOptions);
        $.ajax(options);
    });

    $(document).on('click', 'a[data-pjax]', function(e){
        e.preventDefault();

        var self = $(this),
            callback = self.attr('data-pjax');

        History.pushState({ "callback" : callback }, 'Loading page...', self.attr('href'));
    });
})();
Run Code Online (Sandbox Code Playgroud)

我加载页面,我的当前location.pathname/foo,我点击一个pjax链接,我的新网址是/bar.myvar当我这样做时为什么会改变?我没有更改变量的代码.

javascript history.js

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

Laravel 函数调用和返回在同一个控制器中

我是 Laravel 的新手。我不确定如何在同一控制器内调用其他函数并将处理后的值返回到调用它的函数。我尝试过类似C语言的代码,但代码不起作用

class AgreementsApiController extends Controller
    {

      public function store($th_id,$mv_id,$wk1_terms,$wk2_terms,$wk3_terms)

        {
        //make a function call here to add function similar to
        $result=add($th_id,$mv_id);
        }

    public function add($th_id,$mv_id)

        { //process the parameters and return to store function

          $r=$th_id+$mv_id;
          return $r;

        }
    }
Run Code Online (Sandbox Code Playgroud)

php

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