第一个文件(被引用的部分)publicfunctionexecute_dql2($sql){$arr=array();$res=mysql_query($sql,$this->conn);$i=0;while($row=mysql_fetch_assoc($res)){$arr[$i++]=$row;}//释放...
第一个文件(被引用的部分)
public function execute_dql2($sql){
$arr=array();
$res=mysql_query($sql,$this->conn);
$i=0;
while($row=mysql_fetch_assoc($res)){
$arr[$i++]=$row;
}
//释放资源
mysql_free_result($res);
return $arr;
}
第二个文件
require_once 'SqlHelper.class.php';
class EmpService{
function getPageCount($pageSize){
//需要查询$rowCount,总记录数
$sql="select count(id) from person";
$sqlHelper=new SqlHelper();
$res=$sqlHelper->execute_dql2($sql);
print_r($res);//表中是14个数据,这里也确实打印了一个14的数据。Array ( [0] => Array ( [count(id)] => 14 ) )
//这样就可以计算$pageCount
if($row=mysql_fetch_row($res)){ //这里出错,$row得不到值。正确的应该是得到14这个值
$pageCount=ceil($row[0]/$pageSize);//计算页数
}
//释放资源关闭连接
//mysql_free_result($res);
$sqlHelper->close_connect();
return $pageCount;
上面出错部分 如何得到值啊,急等
展开