sp框架开发中的问题

#1 peter

是不是不能在 spModel子类 里面用 spClass() 其他的 spModel 类?我调用后,说findAll等函数不存在没声明.
 
class user_group extends spModel {
var $pk = "id"; // 每个留言唯一的标志,可以称为主键  
var $table = "user_group"; // 数据表的名称

/**
  * 根据ID删除分组信息
  *
  * @param int $id
  */
function deleteGroupById($id){
  //获得组信息
  $group = $this->getGroupMsgById($id);
  if(!$group) Tips('抱歉,此用户组不存在!',0);
  
  //查询这个组下面有多少人
  $userNum = spClass('user');
  $condistions = array('group'=>$id);
  $num = $userNum -> findCount($condistions);//---------------------报错,说这个方法不存在
  if($num >0 ) Tips('警告,此组下还有['.$num.']位用户,不能删除',0);  
  return $this -> deleteByPk ($id);
}
}
?>

看看报错:
QQ截图未命名.png

2010-08-08 21:32:01

#2 jake

类的调用是不区分在那里的,只要定义能载入。

楼主的问题,我看应该是user这个类,没有extends spModel吧?

2010-08-08 21:39:51

#3 peter

回复 2 jake


    定义了,而且我还dump()出了对象。

2010-08-08 21:41:34

#4 jake

$userNum = spClass('user');
dump($userNum);

如果能dump出对象,那么有没有看到该对象的方法函数呢?

2010-08-08 21:44:47

#5 peter

回复 4 jake
dump()以下代码
user Object
(
[v] => spView Object
(
[smarty:private] => Smarty Object
(
[template_dir] => G:\xampp\htdocs/smarty/template
[compile_dir] => G:\xampp\htdocs/smarty/compile
[config_dir] => configs
[plugins_dir] => Array
(
[0] => plugins
)

[debugging] =>
[error_reporting] =>
[debug_tpl] =>
[debugging_ctrl] => NONE
[compile_check] => 1
[force_compile] =>
[caching] => 0
[cache_dir] => G:\xampp\htdocs/smarty/cache
[cache_lifetime] => 3600
[cache_modified_check] =>
[php_handling] => 0
[security] =>
[secure_dir] => Array
(
)

[security_settings] => Array
(
[PHP_HANDLING] =>
[IF_FUNCS] => Array
(
[0] => array
[1] => list
[2] => isset
[3] => empty
[4] => count
[5] => sizeof
[6] => in_array
[7] => is_array
[8] => true
[9] => false
[10] => null
)

[INCLUDE_ANY] =>
[PHP_TAGS] =>
[MODIFIER_FUNCS] => Array
(
[0] => count
)

[ALLOW_CONSTANTS] =>
[ALLOW_SUPER_GLOBALS] => 1
)

[trusted_dir] => Array
(
)

[left_delimiter] => <{
[right_delimiter] => }>
[request_vars_order] => EGPCS
[request_use_auto_globals] => 1
[compile_id] =>
[use_sub_dirs] =>
[default_modifiers] => Array
(
)

[default_resource_type] => file
[cache_handler_func] =>
[autoload_filters] => Array
(
)

[config_overwrite] => 1
[config_booleanize] => 1
[config_read_hidden] =>
[config_fix_newlines] => 1
[default_template_handler_func] =>
[compiler_file] => Smarty_Compiler.class.php
[compiler_class] => Smarty_Compiler
[config_class] => Config_File
[_tpl_vars] => Array
(
[SCRIPT_NAME] => /admin/index.php
)

[_smarty_vars] =>
[_sections] => Array
(
)

[_foreach] => Array
(
)

[_tag_stack] => Array
(
)

[_conf_obj] =>
[_config] => Array
(
[0] => Array
(
[vars] => Array
(
)

[files] => Array
(
)

)

)

[_smarty_md5] => f8d698aea36fcbead2b9d5359ffca76f
[_version] => 2.6.26
[_inclusion_depth] => 0
[_compile_id] =>
[_smarty_debug_id] => SMARTY_DEBUG
[_smarty_debug_info] => Array
(
)

[_cache_info] => Array
(
)

[_file_perms] => 420
[_dir_perms] => 505
[_reg_objects] => Array
(
)

[_plugins] => Array
(
[modifier] => Array
(
)

[function] => Array
(
)

[block] => Array
(
)

[compiler] => Array
(
)

[prefilter] => Array
(
)

[postfilter] => Array
(
)

[outputfilter] => Array
(
)

[resource] => Array
(
)

[insert] => Array
(
)

)

[_cache_serials] => Array
(
)

[_cache_include] =>
[_cache_including] =>
)

[displayed:private] =>
)

[__template_vals:private] => Array
(
)

)


2010-08-08 21:49:47

#6 peter

我正常调用好像也不行。。。。。

2010-08-08 21:50:27

#7 peter

其他的表都好好的

2010-08-08 21:50:38

#8 peter

知道问题了,
文件名和类名改下 就行了。好像不能用user

谢谢 jake

2010-08-08 21:53:32

#9 jake

是控制器有个user类,这里建议一下model类都给个前缀就好。

PS:此贴将转移到求助问答区,谢谢支持:handshake

2010-08-08 21:59:50