Good afternoon, I have this bbdd with 7 tables. link In the last one as we can see I have 4 PK because it is necessary to be able to have a document with the same name but with different versions.
The problem is:
How do I collect the data correctly to delete a row and not 20 rows at a time because it only recognizes a primary key?
I have this code
<?php
require_once 'alumno.entidad7.php';
require_once 'alumno.model7.php';
$alm = new Categoria();
$model = new CategoriaModel();
if (isset($_REQUEST['action'])) {
switch ($_REQUEST['action']) {
case 'eliminar':
$model->Eliminar = array(($_REQUEST['titulo_documento']['num_documento']['version']['revision']));
header('Location: index7.php');
break;
}
}
?>
This would be the php part and this the html in the same file
<?php foreach ($model->Listar() as $r): ?>
<tr>
<td><?php echo $r->__GET('titulo_documento'); ?></td>
<td><?php echo $r->__GET('proyecto'); ?></td>
<td><?php echo $r->__GET('estado'); ?></td>
<td><?php echo $r->__GET('idioma'); ?></td>
<td><?php echo $r->__GET('num_documento'); ?></td>
<td><?php echo $r->__GET('version'); ?></td>
<td><?php echo $r->__GET('revision'); ?></td>
<td><?php echo $r->__GET('descripcion'); ?></td>
<td><?php echo $r->__GET('fecha'); ?></td>
<td><?php echo $r->__GET('subcategoria'); ?></td>
<td><?php echo $r->__GET('confidencialidad'); ?></td>
<td><?php echo $r->__GET('tipo_documento'); ?></td>
<td><?php echo $r->__GET('acro_usuario'); ?></td>
<td><?php echo $r->__GET('aprobado_por'); ?></td>
<td><?php echo $r->__GET('autorizado_por'); ?></td>
<td><?php echo $r->__GET('revisor'); ?></td>
<td><?php echo $r->__GET('compania'); ?></td>
<td><?php echo $r->__GET('codigo_proyecto'); ?></td>
<td>
<a href="?action=eliminar&titulo_documento=<?php echo $r->titulo_documento; ?>&num_documento=<?php echo $r->num_documento; ?>
&version=<?php echo $r->version; ?>&revision=<?php echo $r->revision; ?>"><img src="delete.png" width="30px" height="30px"/></a>
</td>
</tr>
<?php endforeach; ?>
And in another file I would come to declare this another
public function Eliminar($categoria,$categoria1,$categoria2,$categoria3) {
try {
$stm = $this->pdo
->prepare("DELETE FROM documento WHERE titulo_documento = '?' and num_documento = ? and version = ? and revision = ?");
$stm->execute(array($categoria,$categoria1,$categoria2,$categoria3));
} catch (Exception $e) {
die($e->getMessage());
}
}
I also have problems updating, but first I want to be able to delete records and once someone can help me try to fix the part of the UPDATE. Many thanks to all who can help me