我的代码中有错误:
致命错误:在第 47 行对 ... 中的非对象调用成员函数 query()
第 47 行:
$query = $this->link->query("SELECT * FROM links ORDER BY DESC");
完整代码:
<?php
class Manage{
public $link;
function __construct() {
include_once 'class_database.php';
$conn = new database;
$this->link = $conn->connect();
return $this->link;
}
function getData($table_name, $id=null){
if(isset($id)){
$query = $this->link->query("SELECT * FROM $table_name");
}else{
$query = $this->link->query("SELECT * FROM $table_name ORDER BY id ASC");
}
$rowCount = $query->rowCount();
if($rowCount >=1)
{
$query->setFetchMode(PDO::FETCH_ASSOC);
$result = $query->fetchAll();
}
else{
$result = 0;
}
return $result;
}
function insertData($table_name, $fields_name, $bind_param, $field_values){
$query = $this->link->prepare("INSERT INTO $table_name ($fields_name) VALUES ($bind_param)");
$query->execute($field_values);
$rowCount = $query->rowCount();
return $rowCount();
}
function deleteData($table_name, $id){
$query = $this->link->query("DELETE FROM $table_name WHERE id = '$id'");
$rowCount = $query->rowCount();
return $rowCount;
}
function selectLinks(){
$query = $this->link->query("SELECT * FROM links ORDER BY DESC");
$rowCount = $query->rowCount();
if($rowCount >=1)
{
$query->setFetchMode(PDO::FETCH_ASSOC);
$result = $query->fetchAll();
}
else{
$result = 0;
}
return $result;
}
}
怎么修?