PHP db类的使用

来源:百度知道 编辑:UC知道 时间:2024/06/05 17:54:23
例:DB类的方法
function query($sql, $type = '') {
if(!($query = mysql_query($sql))) $this->show('Say:', $sql);
return $query;
}

function fn_select($tabl){
$this->query("select * from $tabl order by id desc");

}

function num_rows($query) {
return @mysql_num_rows($query);
}

function fetch_array($query, $result_type = MYSQL_ASSOC) {
return @mysql_fetch_array($query, $result_type);
}

我用$db->fn_select('message');查询到数据库
但不不知道怎么用$db->num_rows();取得里面的结果集的数据
或是用$db->fetch_array()读取到里面数据,
输入db->num_rows($this->query);也不行

知道怎么使用的请指教下,感谢................
$a=$db->fn_select('message');
db->num_rows($a);
也不可以

你的query()有返回值,你可以把代码改成这样再试试
function fn_select($tabl){
return $this->query("select * from $tabl order by id desc");

}

你没有用到自己定义的
function fetch_array($query, $result_type = MYSQL_ASSOC) {
return @mysql_fetch_array($query, $result_type);
}

你试着在后面加上
$row=$db->fetch_array($a,MYSQL_NUM);
print_r($row);
应该就看到结果了

www.365php.net 365PHP培训与交流平台 欢迎光临