PDO를 사용하여 데이터베이스의 테이블 값을 표시하려고하는데이 작업을 수행하는 동안 오류가 표시됩니다.
"치명적인 오류 : 정의되지 않은 메서드 ManageUsers :: fetchAll () 호출"
이 문제를 해결하기위한 솔루션을 제공 하시겠습니까?
list-seller.php
<?php
include "C:/wamp/www/Super_Admin_MangoAir/classes/class.ManageUsers.php";
$sellers = new ManageUsers();
//$sellers->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
while ($row = $sellers->fetchAll(PDO::FETCH_ASSOC)) {
?>
<tr>
<td><?php echo $row['company_name']; ?>
<span class="pull-right-container">
<small class="label pull-center bg-green">Premium Member</small>
</span>
</td>
<td><?php echo $row['email']; ?></td>
<td><?php echo $row['mobile']; ?></td>
<td><?php echo $row['count_free']; ?></td>
<td><?php echo $row['count_travel']; ?>
<span class="pull-right-container">
<small class="label pull-center bg-green">Paid</small>
</span>
</td>
<td><a href=""><button type="button" class="btn btn-flat btn-default btn-sm disabled">Already Paid</button></a></td>
</tr>
<?php } ?>
class.ManageUsers.php
<?php
class ManageUsers{
include "C:/wamp/www/Super_Admin_MangoAir/classes/class.database.php";
public $link;
function __construct(){
$db_connection = new dbConnection();
$this->link = $db_connection->connect();
return $this->link;
}
function seller_list($result){
$result = $this->link->prepare("SELECT company_name,email,phone,count_free,count_travel FROM login");
$result->execute();
}
}
?>
class.database.php
<?php
class dbConnection{
protected $db_conn;
public $db_name='company';
public $db_user='root';
public $db_pass='';
public $db_host='localhost';
function connect (){
try{
$this->db_conn=new PDO("mysql:host=$this->db_host;dbname=$this->db_name",$this->db_user,
$this->db_pass);
return $this->db_conn;
}
catch(PDOException $e){
return $e->getMessage();
echo 'errorrrrrrrr';
}
}
}
?>
변화
1)include "C:/wamp/www/Super_Admin_MangoAir/classes/class.database.php";
ManageUsers (내부) 클래스에서 제거 하고 위에 배치합니다.
2) 앞에 공개를 추가하십시오 seller_list()
.
3) list-seller.php 페이지 seller_list()
에서 호출 합니다.
4)return
함수에서 누락 된 키워드 seller_list()
. 그것을 추가하십시오.
5) 제거 $result
에서 seller_list()
의 기능 Class ManageUsers
은 아무 소용이 때문이다.
업데이트 된 코드
list-seller.php
<?php
include "C:/wamp/www/Super_Admin_MangoAir/classes/class.ManageUsers.php";
$sellers = new ManageUsers();
$query = $sellers->seller_list();
foreach($query as $row){
?>
<tr>
<td><?php echo $row['company_name']; ?>
<span class="pull-right-container">
<small class="label pull-center bg-green">Premium Member</small>
</span>
</td>
<td><?php echo $row['email']; ?></td>
<td><?php echo $row['mobile']; ?></td>
<td><?php echo $row['count_free']; ?></td>
<td><?php echo $row['count_travel']; ?>
<span class="pull-right-container">
<small class="label pull-center bg-green">Paid</small>
</span>
</td>
<td><a href=""><button type="button" class="btn btn-flat btn-default btn-sm disabled">Already Paid</button></a></td>
</tr>
<?php } ?>
class.ManageUsers.php
<?php
include "C:/wamp/www/Super_Admin_MangoAir/classes/class.database.php";
class ManageUsers{
public $link;
function __construct(){
$db_connection = new dbConnection();
$this->link = $db_connection->connect();
}
public function getDB(){
return $this->link;
}
public function seller_list(){
$result = $this->getDB()->prepare("SELECT company_name,email,phone,count_free,count_travel FROM login");
$result->execute();
return $result->fetchAll();
}
}
?>
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다