简体   繁体   English

PHP脚本执行

[英]PHP script execution

I'm stuck on a this special problem: 我陷入了一个特殊的问题:

I have a php application which manage a request process; 我有一个管理请求过程的php应用程序; when the request is sent an email is also sent to the several validators. 发送请求时,还将向多个验证者发送电子邮件。 What i want is when one of the validators does not validate the request, a reminder email should be sent to him 3 times every 30 minutes. 我想要的是,当验证者之一未验证请求时,应每30分钟向他发送一封提醒电子邮件3次。

For that i create the function bellow which is related to other classes but it does not work. 为此,我创建了与其他类相关的波纹管功能,但是它不起作用。 This function will be executed as a planned task but before i tried to execute it as a line command : 'php -f C:\\wamp\\www\\test_2006\\job.php' . 该功能将作为计划任务执行,但是在我尝试将其作为行命令执行之前: 'php -f C:\\ wamp \\ www \\ test_2006 \\ job.php'

This job.php contains that: 此job.php包含以下内容:

My function is 我的功能是

public static function autoThread()
{
    parent::connection()->open();
    foreach( Greeter::getAllRequests() As $request )
    {
        if( in_array( $stage=$request->stage(),array( "threader","requester","CLOSED" ) ) ) continue;
        $currentIdUser = $request->requester()->chef( $stage );
        $r = parent::connection()->executeQuery( " SELECT id FROM notification WHERE matriculeUser = '$currentIdUser' AND requestId = {$request->id()} " );
        if( $r->rowCount()>2 )
        {
          ( new User( $currentIdUser ) )->judgeRequest( array( $request->id()=>"BYPASS" ) );
        }
        else
        {
            parent::connection()->executeQuery( " INSERT INTO notification ( matriculeUser,requestId ) VALUES ( '$currentIdUser',$request->id() )" );
            Greeter::validationMail( $request );
        }
    }
}

The error that i get is : 我得到的错误是:

Warning: include(php/Classes/FrameworkDb.php): failed to open stream: No such file or directory in C:\wamp\www\test_2006\php\include\head.php on line 3
Call Stack:
    0.0000     229496   1. {main}() C:\wamp\www\test_2006\job.php:0
    0.0000     236808   2. include('C:\wamp\www\test_2006\php\include\head.php')
C:\wamp\www\test_2006\job.php:3
Warning: include(): Failed opening 'php/Classes/FrameworkDb.php' for inclusion (include_path='.;C:\php\pear') in C:\wamp\www\test_2006\php\include\head.php on li
ne 3
Call Stack:
    0.0000     229496   1. {main}() C:\wamp\www\test_2006\job.php:0
    0.0000     236808   2. include('C:\wamp\www\test_2006\php\include\head.php')
C:\wamp\www\test_2006\job.php:3


Fatal error: Class 'User' not found in C:\wamp\www\test_2006\php\include\head.php
 on line 12

Call Stack:
    0.0000     229496   1. {main}() C:\wamp\www\test_2006\job.php:0
    0.0000     236808   2. include('C:\wamp\www\test_2006\php\include\head.php')
C:\wamp\www\test_2006\job.php:3

First of all; 首先; please add any errors in the question itself in a code block (you can edit your question). 请在问题本身的代码块中添加任何错误(您可以编辑问题)。 Errors in comments are really hard to read... 注释中的错误真的很难阅读...

Furthermore; 此外; the error says no such file or directory , meaning you are including the file from a non-existent place. 该错误表明no such file or directory ,表示您正在从不存在的位置包含该文件。 Please checkout paths etc. When you are using CLI, relative paths are most of the time different then from normal execution (from the browser). 请检出路径等。使用CLI时,相对路径通常与正常执行(从浏览器)不同。 You can tackle this by defining a root path: 您可以通过定义根路径来解决此问题:

define('ROOT', '/home/users/ssa/');
include ROOT . 'some_dir/my_file.php';

As the ROOT constant you fill in the path of your document root (the directory where you can find your index.php). 作为ROOT常数,您填写文档根目录的路径(可以在其中找到index.php的目录)。 Then every time you include a file, you prepend the constant to the relative path from the doc root. 然后,每次包含文件时,都将常量添加到doc根目录的相对路径之前

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM