根目录下一个单独目录的php,想调用controller内的一个方法
发布于:2022-01-17 09:50:54
#1 tidiar
我的工具根目录下,建立了一个单独的其它目录。 想在里面的一个php内,调用controller内的一个方法,请问怎样可以?
代码:include_once('../controller/_store.php');
//$yuuumiJudge = new _store();
//$yuuumiJudge->
tradeJudge();
错误:SAE_Fatal_error: Class 'spController' not found in
controller/_store.php on line
3
2012-02-09 11:50:10
#2 tidiar
哦,是我自己不小心加入 extends ....
已解决
2012-02-09 12:03:18
#3 tidiar
但好像,没办法调用 spClass()
2012-02-09 14:22:03
#4 jake
tidiar 发表于 2012-2-9 14:22 
但好像,没办法调用 spClass()
引入SpeedPHP.php文件就可以
2012-02-09 14:47:48
#5 tidiar
include speedphp.php 是么?
2012-02-09 14:51:18
#6 tidiar
include ../SpeedPHP/SpeedPHP.php
SAE_Warning: require(/data1/www/htdocs/614/yuuumi/2/SpeedPHP/SpeedPHP/spFunctions.php) [function.require]: failed to open stream: No such file or directory in SpeedPHP/SpeedPHP.php on line 19
include ../SpeedPHP.php
SAE_Warning: require_once(../SpeedPHP.php) [function.require-once]: failed to open stream: No such file or directory in alipay/alipayto.php on line 22
2012-02-09 15:37:12
#7 tidiar
修改了SPeedPHP.php 中
if(!defined('SP_PATH')) define('SP_PATH', dirname(__FILE__));
外部调用改成
include_once("../SpeedPHP/SpeedPHP.php");
include_once('../include/_utl_yumi_main.php');
$yuuumiJudge = new _utl_yumi_main();
$yuuumiJudge->tradeJudge();
报错:
SAE_Fatal_error: Call to a member function findSql() on a non-object in include/_utl_yumi_main.php on line 92
2012-02-09 16:05:21
#8 tidiar
$sql = "SELECT * from t_fast LIMIT 0,8";
$store_fast = spClass('t_fast', null, '../model/t_fast.PHP', TRUE ); //TRUE 和 FALSE 都试过
$result_list = $store_fast->findSql($sql); // LINE 92
2012-02-09 16:14:44
#9 jake
tidiar 发表于 2012-2-9 16:05 
修改了SPeedPHP.php 中
if(!defined('SP_PATH')) define('SP_PATH', dirname(__FILE__));
应该是这个类_utl_yumi_main的model类没有extends spModel
2012-02-09 19:35:31
#10 tidiar
是指这个么? 好像有的耶
class t_591_store_fast extends spModel
{
var $pk = "store_id";
var $table = "t_591_store_fast";
}
2012-02-09 21:48:13
#11 jake
SAE_Fatal_error: Call to a member function findSql() on a non-object in include/_utl_yumi_main.php on line 92
这个92行,是什么?
这里的提示是调用findSql的变量,并非一个实例,要看你的变量是否已经实例化了。
2012-02-09 21:51:15
#12 tidiar
91行 $store_fast = spClass('t_591_store_fast', null, '../model/t_591_store_fast.PHP', false );
92行 $result_list = $store_fast->findSql($sql);
2012-02-09 21:58:06
#13 tidiar
我试用直接用$store_fast = spClass('t_591_store_fast'); 这个如果不是在外部的php中调用,是可以的。但在外部php调用,说找不到,所以查了框架内的代码,写成91行那样。
2012-02-09 21:59:58
#14 jake
spClass('t_591_store_fast', null, '../model/t_591_store_fast.PHP', false );
../model/t_591_store_fast.PHP
用绝对路径,或者注意大小写。你试试echo file_exists( '../model/t_591_store_fast.PHP')看看是否能找到这个文件?
2012-02-09 22:34:55
#15 jake
tidiar 发表于 2012-2-9 21:59 
我试用直接用$store_fast = spClass('t_591_store_fast'); 这个如果不是在外部的php中调用,是可以的。但 ...
对了,看看有没有同名的类存在。
t_591_store_fast
$store_fast = spClass('t_591_store_fast', null, '../model/t_591_store_fast.PHP', false );
dump($store_fast);
2012-02-09 22:37:09
#16 tidiar
呀! 谢谢jake,是大小写的问题。
t_591_store_fast.PHP 改成 t_591_store_fast.php 后调用正常。
2012-02-09 22:41:25
#17 tidiar
看来还是自己急了,应该再仔细看看的。
2012-02-09 22:42:15