我正在使用搜索引擎进行mvc crud,但是当我运行项目时显示致命错误:在C:\ xampp \ htdocs \ mvc \ view \ client \ client中调用未定义的方法client :: buscame()第56行的.php
这是/view/cliente/cliente.php
<h1 class="page-header">CRUD con el patrón MVC en PHP POO y PDO </h1>
<a class="btn btn-primary pull-right" href="?c=cliente&a=agregar">Agregar</a>
<a class="btn btn-primary pull-right" href="?c=cliente&a=ardila">Ardila</a>
<a class="btn btn-primary pull-right" href="?c=cliente&a=mateus">Mateus</a>
<table class="table table-striped table-hover" id="tabla">
<thead>
<tr>
<th style="width:180px; background-color: #5DACCD; color:#fff">ID</th>
<th style="width:120px; background-color: #5DACCD; color:#fff">DNI</th>
<th style="width:180px; background-color: #5DACCD; color:#fff">Nombre</th>
<th style=" background-color: #5DACCD; color:#fff">Apellido</th>
<th style=" background-color: #5DACCD; color:#fff">Correo</th>
<th style="width:120px; background-color: #5DACCD; color:#fff">Telefono</th>
<th style="width:60px; background-color: #5DACCD; color:#fff"></th>
<th style="width:60px; background-color: #5DACCD; color:#fff"></th>
</tr>
</thead>
<tbody>
<?php foreach($this->model->Listar() as $r): ?>
<tr>
<td><?php echo $r->id; ?></td>
<td><?php echo $r->dni; ?></td>
<td><?php echo $r->Nombre; ?></td>
<td><?php echo $r->Apellido; ?></td>
<td><?php echo $r->Correo; ?></td>
<td><?php echo $r->Telefono; ?></td>
<td>
<a class="btn btn-warning" href="?c=cliente&a=agregar&id=<?php echo $r->id; ?>">Editar</a>
</td>
<td>
<a class="btn btn-danger" onclick="javascript:return confirm('¿Seguro de eliminar este registro?');" href="?c=cliente&a=Eliminar&id=<?php echo $r->id; ?>">Eliminar</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
<form action="?c=cliente&a=buscame" method="get" enctype="multipart/form-data">
<input type="text" name="dni" id="dni"/>
<input type="submit" name="boton" id="boton"/>
</form>
<?php while($f= $this->model->buscame()){
echo '<tr>';
echo '<td width="19">'.$f['id'].'</td>';
echo '<td width="61">'.$f['dni'].'</td>';
echo '<td width="157">'.$f['Nombre'].'</td>';
echo '<td width="221">'.$f['Apellido'].'</td>';
echo '<td width="176">'.$f['Correo'].'</td>';
echo '<td width="118">'.$f['Telefono'].'</td>';
echo '</tr>';
}
?>
</tbody>
这是cliente.controller.php
class clienteController {
private $model;
public function __CONSTRUCT(){
$this->model = new cliente();
}
public function Paginar(){
require_once 'view/header.php';
require_once 'view/cliente/cliente.php';
}
public function agregar(){
$cliente = new cliente();
if(isset($_REQUEST['id'])){
$cliente = $this->model->Obtener($_REQUEST['id']);
}
require_once 'view/header.php';
require_once 'view/cliente/cliente-editar.php';
}
public function buscame(){
$cliente = new cliente();
$dni=$_GET('dni');
if(isset($dni)){
$stm = $pdo->query('SELECT * FROM cliente WHERE id= :id');
$stm -> bindParam(':id', $id, PDO::PARAM_INT);
$stm -> execute();
$res = $stm->fetchAll(PDO::FETCH_ASSOC);
if(empty($res) or $res == false){
return array();}
else{
return $res;}
}
require_once 'view/header.php';
require_once 'view/cliente/cliente.php';
}
public function ardila(){
$cliente = new cliente();
if(isset($_REQUEST['id'])){
$cliente = $this->model->ListarApellido($_REQUEST['id']);
}
require_once 'view/header.php';
require_once 'view/cliente/Lista.php';
}
public function mateus(){
$cliente = new cliente();
if(isset($_REQUEST['id'])){
$cliente = $this->model->ListarApellidoM($_REQUEST['id']);
}
require_once 'view/header.php';
require_once 'view/cliente/Lista.php';
}
public function Guardar(){
$cliente = new cliente();
$cliente->id = $_REQUEST['id'];
$cliente->dni = $_REQUEST['dni'];
$cliente->Nombre = $_REQUEST['Nombre'];
$cliente->Apellido = $_REQUEST['Apellido'];
$cliente->Correo = $_REQUEST['Correo'];
$cliente->telefono = $_REQUEST['telefono'];
if($cliente->id > 0){
$this->model->Actualizar($cliente);
}
else{
$this->model->Registrar($cliente);
}
header('Location: index.php');
}
public function Eliminar(){
$this->model->Eliminar($_REQUEST['id']);
header('Location: index.php');
}
}
当我进行搜索时,会出现致命错误:
在C:\ xampp \ htdocs \中调用未定义的方法client :: buscame() 第56行的mvc \ view \ client \ client.php
答案 0 :(得分:0)
您还没有提供所有代码,但看起来您在视图中调用的模型上没有方法buscame()
。
$this->model->buscame()
你是否有可能做某些事情,比如
$this->client->buscame()