-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdemo1.php
73 lines (55 loc) · 1.29 KB
/
demo1.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
<?php
require 'Clases/config.php';
require 'Clases/database.php';
use Clases\Database;
use Clases\Config;
/**
* Estas lineas es para el autocompletado en PHPStorm 5.x o Netbeans 7.x
*
* @var \PDOStatement $stmt
*/
?>
<!DOCTYPE HTML>
<html lang="es-PE">
<head>
<meta charset="UTF-8">
<title>Uso - Database </title>
<link href="css/markdown.css" rel="stylesheet"></link>
<link href="css/table.css" rel="stylesheet"></link>
</head>
<body>
<h2> Uso de la Clase Database directamente</h2>
<code>
<pre>
$stmt = Database::prepare('SELECT * FROM usuario;');
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
echo $row['id'];
echo $row['nombre'];
echo $row['email'];
echo $row['password'];
}
</pre>
</code>
<?php
$stmt = Database::prepare('SELECT * FROM usuario;');
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
?>
<h3>Resultado:</h3>
<?php
foreach ($result as $row) {
echo $row['id'] . '<br>';
echo $row['nombre'] . '<br>';
echo $row['email'] . '<br>';
echo $row['password'] . '<br>';
}
?>
<hr>
<h3>Contenido del Array ($result):</h3>
<pre>
<?php var_dump($result); ?>
</pre>
</body>
</html>