-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathejemplo17PDO.php
83 lines (63 loc) · 3.57 KB
/
ejemplo17PDO.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<!DOCTYPE html>
<html>
<head>
<title> Ejempos PHP</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="estilo.css">
</head>
<body>
<div class="container">
<div class="page-header">
<h1>Ejemplos de PHP</h1>
</div>
<div class="jumbotron">
<h3 class="text-info">Método de instancia para Modificar.</h3>
<div class="well well-sm text-info">
class cd
{<br>
public function BorrarCd()
{<br>
$objetoAccesoDato = AccesoDatos::dameUnObjetoAcceso(); <br>
$consulta =$objetoAccesoDato->RetornarConsulta("<br>
delete <br>
from cds <br>
WHERE id=:id"); <br>
$consulta->bindValue(':id',$this->id, PDO::PARAM_INT); <br>
return $consulta->execute();<br>
}
}<br>
//utilización del método estático<br>
$unCd =cd::TraerUnCd(4);<br>
$unCd->titulo="titulo cambiado";<br>
$unCd->año=date("his");<br>
$unCd->cantante="cantante cambiado";<br>
$cantidadDeAfectadas=$unCd->BorrarCd();<br>
print("filas afectadas :$cantidadDeAfectadas<br>");
</div>
</div>
<h3 > Método de la clase </h3>
<?php
include_once ("clases/AccesoDatos.php");
include_once ("clases/cd.php");
$unCd =cd::TraerUnCd(4);
//verifico si existe
if(isset($unCd->cantante))
{
$cantidadDeAfectadas=$unCd->BorrarCd();
print("filas afectadas :$cantidadDeAfectadas<br>");
}
else
{
print("no existe la instancia<br>");
}
?>
<a class="btn btn-info" href="indexPDO.html">Menu principal</a>
</div>
</body>
</html>