dquv73115 2013-05-12 07:19
浏览 31
已采纳

用exec()执行方法

Is it efficient and/or possible to use exec(); with a method of the same class? Instead of executing a file with an $argv array, I'd like to pass variables to a method and execute it within another method:

class Foo{

    private function bar($table, $column, $id){
        //SQL 
    }

    public function bar_exec($table, $column, $id){
        exec($this->bar($table, $column, $id)); //this is most likely wrong
    }
}

The reasoning behind this is I have a method that chews through my database and takes quite a few arguments which in turn takes about a minute to finish, so I need to run it in the background whenever a form is submitted. What's the best way to handle this?

  • 写回答

1条回答 默认 最新

  • dqef7931 2013-05-12 07:23
    关注

    When you spin up another PHP process, you also get a clean environment which has no knowledge of your current objects, call stack, or anything. You have to treat it entirely separately. The answer to your question is no. You cannot spin up another process for just some method call. You need to write a script that instantiates a new object and calls that method.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM