我困在一个特殊的问题上:
我有一个php应用程序来管理请求进程;当请求被发送时,电子邮件也被发送到几个验证器。我想要的是,当其中一个验证者不验证请求时,每30分钟向他发送一封提醒邮件3次。
为此,我创建了下面的函数,它与其他类相关,但不起作用。这个函数将作为一个计划的任务执行,但在我尝试将其作为行命令执行之前:'php -f -f。
此job.php包含以下内容:
我的职责是
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 );
}
}
}我得到的错误是:
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发布于 2015-07-13 13:31:01
首先,请在代码块中添加问题本身中的任何错误(您可以编辑您的问题)。评论中的错误很难读懂.
此外,错误表示为no such file or directory,意味着您正在从一个不存在的地方包含该文件。当您使用CLI时,相对路径在大多数情况下都不同于正常执行(从浏览器)。您可以通过定义根路径来解决这个问题:
define('ROOT', '/home/users/ssa/');
include ROOT . 'some_dir/my_file.php';作为ROOT常量,您可以填充文档根目录(可以找到index.php的目录)的路径。然后,每次包含文件时,都会将常量放在文档根的相对路径的前面。
https://stackoverflow.com/questions/31383545
复制相似问题