mirror of
https://github.com/rmontanana/inventario2.git
synced 2025-08-16 16:05:58 +00:00
Compare commits
2 Commits
analysis-Q
...
master
Author | SHA1 | Date | |
---|---|---|---|
67a7080e59
|
|||
e1151343bd
|
14
Ajax.php
14
Ajax.php
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Inventario
|
||||
* @copyright Copyright (c) 2008, Ricardo Montañana Gómez
|
||||
@@ -25,7 +26,8 @@ require_once 'Sql.php';
|
||||
$ajax = new Ajax();
|
||||
echo $ajax->procesa();
|
||||
|
||||
class Ajax {
|
||||
class Ajax
|
||||
{
|
||||
private $sql;
|
||||
private $tabla;
|
||||
|
||||
@@ -46,8 +48,10 @@ class Ajax {
|
||||
{
|
||||
$opc = $_GET['opc'];
|
||||
switch ($opc) {
|
||||
case "get": return $this->obtiene();
|
||||
case "put": return $this->actualiza();
|
||||
case "get":
|
||||
return $this->obtiene();
|
||||
case "put":
|
||||
return $this->actualiza();
|
||||
}
|
||||
}
|
||||
private function mensaje($exito, $texto)
|
||||
@@ -57,7 +61,7 @@ class Ajax {
|
||||
private function actualiza()
|
||||
{
|
||||
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
|
||||
$comando = "update " . mysql_escape_string($this->tabla) . " set " . mysql_escape_string($_POST['name']) . " = '" . mysql_escape_string($_POST['value']) . "' where id = '" . mysql_escape_string($_POST['pk']). "';";
|
||||
$comando = "update " . $this->sql->filtra($this->tabla) . " set " . $this->sql->filtra($_POST['name']) . " = '" . $this->sql->filtra($_POST['value']) . "' where id = '" . $this->sql->filtra($_POST['pk']) . "';";
|
||||
$this->sql->ejecuta($comando);
|
||||
$exito = !$this->sql->error();
|
||||
$mensaje = $this->sql->mensajeError();
|
||||
@@ -84,5 +88,3 @@ class Ajax {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
16
Sql.php
16
Sql.php
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Gestión de una base de datos MySQL
|
||||
* @author Ricardo Montañana <rmontanana@gmail.com>
|
||||
@@ -21,7 +22,8 @@
|
||||
* along with Inventario. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
class Sql {
|
||||
class Sql
|
||||
{
|
||||
/**
|
||||
* @var mixed Manejador de la base de datos.
|
||||
*/
|
||||
@@ -75,6 +77,7 @@ class Sql {
|
||||
$this->estado = true;
|
||||
}
|
||||
$this->peticion = NULL;
|
||||
$this->bdd->set_charset("latin1");
|
||||
return $this;
|
||||
}
|
||||
public function __destruct()
|
||||
@@ -149,7 +152,8 @@ class Sql {
|
||||
* Devuelve el número de tuplas afectadas en la última petición.
|
||||
* @return integer Número de tuplas.
|
||||
*/
|
||||
public function numeroTuplas() {
|
||||
public function numeroTuplas()
|
||||
{
|
||||
return $this->numero;
|
||||
}
|
||||
/**
|
||||
@@ -172,14 +176,16 @@ class Sql {
|
||||
* Devuelve la condición de error de la última petición
|
||||
* @return boolean condición de error.
|
||||
*/
|
||||
public function error() {
|
||||
public function error()
|
||||
{
|
||||
return $this->error;
|
||||
}
|
||||
/**
|
||||
* Devuelve el mensaje de error de la última petición
|
||||
* @return <type>
|
||||
*/
|
||||
public function mensajeError() {
|
||||
public function mensajeError()
|
||||
{
|
||||
return $this->mensajeError . $this->bdd->error;
|
||||
}
|
||||
/**
|
||||
@@ -227,5 +233,3 @@ class Sql {
|
||||
return $codigo;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
Reference in New Issue
Block a user