@@ -13,8 +13,7 @@ discard block |
||
| 13 | 13 | private $_query; |
| 14 | 14 | public $_ultimaIdInsertada = null; |
| 15 | 15 | |
| 16 | - public function __construct |
|
| 17 | - ( |
|
| 16 | + public function __construct( |
|
| 18 | 17 | ConexionBaseDeDatos $ConexionBaseDeDatos, |
| 19 | 18 | Query $Query |
| 20 | 19 | ) |
@@ -27,12 +26,12 @@ discard block |
||
| 27 | 26 | { |
| 28 | 27 | $consulta = $this->_conexionBaseDeDatos->prepare($this->_query->query()); |
| 29 | 28 | |
| 30 | - if(!empty($this->_query->valores())) |
|
| 29 | + if (!empty($this->_query->valores())) |
|
| 31 | 30 | { |
| 32 | - $x=1; |
|
| 31 | + $x = 1; |
|
| 33 | 32 | foreach ($this->_query->valores() as $value) |
| 34 | 33 | { |
| 35 | - $consulta->bindValue($x,$value); |
|
| 34 | + $consulta->bindValue($x, $value); |
|
| 36 | 35 | $x++; |
| 37 | 36 | } |
| 38 | 37 | } |
@@ -43,7 +42,7 @@ discard block |
||
| 43 | 42 | $this->_ultimaIdInsertada = $this->_conexionBaseDeDatos->lastInsertId(); |
| 44 | 43 | |
| 45 | 44 | } |
| 46 | - catch(PDOException $e) |
|
| 45 | + catch (PDOException $e) |
|
| 47 | 46 | { |
| 48 | 47 | throw new ConsultaException("Error al procesar la consulta"); |
| 49 | 48 | } |
@@ -42,8 +42,7 @@ |
||
| 42 | 42 | $consulta->execute(); |
| 43 | 43 | $this->_ultimaIdInsertada = $this->_conexionBaseDeDatos->lastInsertId(); |
| 44 | 44 | |
| 45 | - } |
|
| 46 | - catch(PDOException $e) |
|
| 45 | + } catch(PDOException $e) |
|
| 47 | 46 | { |
| 48 | 47 | throw new ConsultaException("Error al procesar la consulta"); |
| 49 | 48 | } |
@@ -43,7 +43,7 @@ |
||
| 43 | 43 | return $consulta->crear(array( |
| 44 | 44 | 'conexion' => $conexion->crear(array()), |
| 45 | 45 | 'sql' => $update->update(), |
| 46 | - 'valores' => $this->juntarValores($array['valores'],$donde->datos()) |
|
| 46 | + 'valores' => $this->juntarValores($array['valores'], $donde->datos()) |
|
| 47 | 47 | )); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -29,13 +29,13 @@ |
||
| 29 | 29 | public function update(): string |
| 30 | 30 | { |
| 31 | 31 | $set = ""; |
| 32 | - $values = []; |
|
| 32 | + $values = []; |
|
| 33 | 33 | |
| 34 | - foreach ($this->_valoresAInsertar->valoresAInsertar() as $key => $value) |
|
| 35 | - { |
|
| 36 | - $set = $set. ' ' .$key. ' = ?,'; |
|
| 37 | - array_push($values, $value); |
|
| 38 | - } |
|
| 34 | + foreach ($this->_valoresAInsertar->valoresAInsertar() as $key => $value) |
|
| 35 | + { |
|
| 36 | + $set = $set. ' ' .$key. ' = ?,'; |
|
| 37 | + array_push($values, $value); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | 40 | $valores = trim($set, ','); |
| 41 | 41 | |
@@ -14,8 +14,7 @@ discard block |
||
| 14 | 14 | private $_donde; |
| 15 | 15 | private $_valoresAInsertar; |
| 16 | 16 | |
| 17 | - public function __construct |
|
| 18 | - ( |
|
| 17 | + public function __construct( |
|
| 19 | 18 | Tabla $Tabla, |
| 20 | 19 | Donde $Donde, |
| 21 | 20 | ValoresAInsertar $ValoresAInsertar |
@@ -33,12 +32,12 @@ discard block |
||
| 33 | 32 | |
| 34 | 33 | foreach ($this->_valoresAInsertar->valoresAInsertar() as $key => $value) |
| 35 | 34 | { |
| 36 | - $set = $set. ' ' .$key. ' = ?,'; |
|
| 35 | + $set = $set.' '.$key.' = ?,'; |
|
| 37 | 36 | array_push($values, $value); |
| 38 | 37 | } |
| 39 | 38 | |
| 40 | 39 | $valores = trim($set, ','); |
| 41 | 40 | |
| 42 | - return "UPDATE " . $this->_tabla->tabla(). " SET ".$valores.$this->_donde->donde(); |
|
| 41 | + return "UPDATE ".$this->_tabla->tabla()." SET ".$valores.$this->_donde->donde(); |
|
| 43 | 42 | } |
| 44 | 43 | } |
| 45 | 44 | \ No newline at end of file |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | |
| 7 | 7 | declare(strict_types=1); |
| 8 | 8 | |
| 9 | -require_once __DIR__ . '/vendor/autoload.php'; |
|
| 9 | +require_once __DIR__.'/vendor/autoload.php'; |
|
| 10 | 10 | |
| 11 | 11 | use src\pdoDataBase\conexion\{ |
| 12 | 12 | BaseDeDatos, |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | $prueba = new Consulta( |
| 98 | 98 | $conexion, |
| 99 | - new Query($sql->select(),$donde->datos()) |
|
| 99 | + new Query($sql->select(), $donde->datos()) |
|
| 100 | 100 | ); |
| 101 | 101 | echo '<h1>Obteniendo la consulta de un select</h1>'; |
| 102 | 102 | var_dump( |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | new Donde( |
| 166 | 166 | new MasDonde(array()), |
| 167 | 167 | array( |
| 168 | - 'id','=',1 |
|
| 168 | + 'id', '=', 1 |
|
| 169 | 169 | ) |
| 170 | 170 | ), |
| 171 | 171 | new ValoresAInsertar( |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | 'dos' => 102331 |
| 189 | 189 | ), |
| 190 | 190 | 'donde' => array( |
| 191 | - 'id','=',1 |
|
| 191 | + 'id', '=', 1 |
|
| 192 | 192 | ) |
| 193 | 193 | ) |
| 194 | 194 | ); |