-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsistema.class.php
82 lines (64 loc) · 1.42 KB
/
sistema.class.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
81
82
<?php
session_start();
define('palabrassaltarinas', true);
require_once('C:\xampp\htdocs\palabrassaltarinas\lib\smarty\libs\Smarty.class.php');
class Sistema
{
var $servidordb="localhost";
var $usuariodb="root";
var $contrasenadb="";
var $con=null;
var $nombredb="juego";
var $smarty=null;
var $mensaje="";
function construct()
{
}
//conexion a la base de datos
public function Conectar()
{
$this->con = new PDO('mysql:host='.$this->servidordb.';dbname='.$this->nombredb, $this->usuariodb, $this->contrasenadb);
}
//funcion para consulta
public function Query($sql)
{
return $this->con->query($sql);
}
public function Exec($sql)
{
return $this->con->exec($sql);
}
//funcion para crear variable smarty
public function Smarty()
{
$smarty=new Smarty();
}
public function fetchAll($sql)
{
$stmt=$this->con->prepare($sql);
$stmt->execute();
$datos=$stmt->fetchAll(PDO::FETCH_ASSOC);
return $datos;
}
}
class Juegopalabras extends Sistema
{
public function Crearmenu()
{
$this->Crearsmarty();
$menu=$this->smarty->fetch("index.html");
}
public function Crearsmarty()
{
$this->smarty = new Smarty();
$this->smarty->setTemplateDir('templates/');
$this->smarty->setCompileDir('templates_c/');
$this->smarty->setConfigDir('configs/');
$this->smarty->setCacheDir('cache/');
}
}
$web=new Juegopalabras;
$web->Conectar();
$web->Crearsmarty();
$smarty=$web->smarty;
?>