两次调用一个类的函数有问题! [英] Problem with call a function of a class twice!
本文介绍了两次调用一个类的函数有问题!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好!
我建立了2个班级:
1,数据库
hi every one!
I have built 2 classes:
1, DB
class DB extends MySQLi{
function getRecordSet($sql){
...
//Return record set
}
}
2,部门
2, Department
class Department{
var $db;
function getDepartment(){
return $this->db->getRecordSet('...');
}
}
问题:
Problem:
$dept=new Department();
$db=new DB();
$dept->db=$db;
//Problem
$department=$dept->getDepartment();
$department2=$dept->getDepartment();
我的问题是变量$ department具有记录集,但是$ department2是bool(false).我用这个是因为我需要两次使用部门.
注意:我已经测试了存储部门第一次使用另一个属性,但是无法获取的另一种方法.
请帮帮我!
谢谢!
My problem is that variable $department has record set, but $department2 is bool(false). I use this because I need to use departments twice.
Note: I already test another way that store departments getting the first time in another attribute, but cannot fetch.
Please help me!
Thanks!
推荐答案
sql){ ... // 返回记录集 } }
sql){ ... //Return record set } }
2,部门
2, Department
class Department{
var
db ; 函数getDepartment(){ 返回
db; function getDepartment(){ return
this-> db-> getRecordSet(' ...'); } }
this->db->getRecordSet('...'); } }
问题:
Problem:
这篇关于两次调用一个类的函数有问题!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文