@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | { |
| 22 | 22 | public function crear(array $array): Consulta |
| 23 | 23 | { |
| 24 | - $donde = new Donde( |
|
| 24 | + $donde = new Donde( |
|
| 25 | 25 | new MasDonde($this->masDonde($array)), |
| 26 | 26 | $this->donde($array) |
| 27 | 27 | ); |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | private function campos(array $array): array |
| 49 | 49 | { |
| 50 | - if(isset($array['campos'])) |
|
| 50 | + if (isset($array['campos'])) |
|
| 51 | 51 | { |
| 52 | 52 | return $array['campos']; |
| 53 | 53 | } |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | private function donde($array): array |
| 59 | 59 | { |
| 60 | - if(isset($array['donde'])) |
|
| 60 | + if (isset($array['donde'])) |
|
| 61 | 61 | { |
| 62 | 62 | return $array['donde']; |
| 63 | 63 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | |
| 68 | 68 | private function masDonde($array): array |
| 69 | 69 | { |
| 70 | - if( is_array($this->donde($array)) && isset($array['masDonde']) ) |
|
| 70 | + if (is_array($this->donde($array)) && isset($array['masDonde'])) |
|
| 71 | 71 | { |
| 72 | 72 | return $array['masDonde']; |
| 73 | 73 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | |
| 78 | 78 | private function entre(array $array): array |
| 79 | 79 | { |
| 80 | - if(isset($array['entre'])) |
|
| 80 | + if (isset($array['entre'])) |
|
| 81 | 81 | { |
| 82 | 82 | return $array['entre']; |
| 83 | 83 | } |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | private function limite(array $array) |
| 89 | 89 | { |
| 90 | - if(isset($array['limite'])) |
|
| 90 | + if (isset($array['limite'])) |
|
| 91 | 91 | { |
| 92 | 92 | return $array['limite']; |
| 93 | 93 | } |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | |
| 96 | 96 | private function orden(array $array) |
| 97 | 97 | { |
| 98 | - if(isset($array['orden'])) |
|
| 98 | + if (isset($array['orden'])) |
|
| 99 | 99 | { |
| 100 | 100 | return $array['orden']; |
| 101 | 101 | } |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | |
| 19 | 19 | private function setTabla(string $tabla): string |
| 20 | 20 | { |
| 21 | - if(strlen($tabla) < 1) |
|
| 21 | + if (strlen($tabla) < 1) |
|
| 22 | 22 | { |
| 23 | 23 | throw new Exception("La tabla no puede estar vacia"); |
| 24 | 24 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | public function insert(): string |
| 22 | - { |
|
| 22 | + { |
|
| 23 | 23 | $keys = array_keys($this->_valoresAInsertar->valoresAInsertar()); |
| 24 | 24 | $values = ''; |
| 25 | 25 | |
@@ -37,5 +37,5 @@ discard block |
||
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | return "INSERT INTO ". $this->_tabla->tabla()." (`". implode('`, `', $keys) ."`) VALUES ({$values})"; |
| 40 | - } |
|
| 40 | + } |
|
| 41 | 41 | } |
| 42 | 42 | \ No newline at end of file |
@@ -8,8 +8,7 @@ discard block |
||
| 8 | 8 | private $_tabla; |
| 9 | 9 | private $_valoresAInsertar; |
| 10 | 10 | |
| 11 | - public function __construct |
|
| 12 | - ( |
|
| 11 | + public function __construct( |
|
| 13 | 12 | Tabla $Tabla, |
| 14 | 13 | ValoresAInsertar $ValoresAInsertar |
| 15 | 14 | ) |
@@ -23,19 +22,19 @@ discard block |
||
| 23 | 22 | $keys = array_keys($this->_valoresAInsertar->valoresAInsertar()); |
| 24 | 23 | $values = ''; |
| 25 | 24 | |
| 26 | - $x=1; |
|
| 27 | - foreach($this->_valoresAInsertar->valoresAInsertar() as $field) |
|
| 25 | + $x = 1; |
|
| 26 | + foreach ($this->_valoresAInsertar->valoresAInsertar() as $field) |
|
| 28 | 27 | { |
| 29 | - $values.= "?"; |
|
| 28 | + $values .= "?"; |
|
| 30 | 29 | |
| 31 | - if($x < count($this->_valoresAInsertar->valoresAInsertar())) |
|
| 30 | + if ($x < count($this->_valoresAInsertar->valoresAInsertar())) |
|
| 32 | 31 | { |
| 33 | - $values.= ', '; |
|
| 32 | + $values .= ', '; |
|
| 34 | 33 | } |
| 35 | 34 | |
| 36 | 35 | $x++; |
| 37 | 36 | } |
| 38 | 37 | |
| 39 | - return "INSERT INTO ". $this->_tabla->tabla()." (`". implode('`, `', $keys) ."`) VALUES ({$values})"; |
|
| 38 | + return "INSERT INTO ".$this->_tabla->tabla()." (`".implode('`, `', $keys)."`) VALUES ({$values})"; |
|
| 40 | 39 | } |
| 41 | 40 | } |
| 42 | 41 | \ No newline at end of file |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | |
| 20 | 20 | private function setValoresAInsertar(array $array): array |
| 21 | 21 | { |
| 22 | - if(count($array) < 1) |
|
| 22 | + if (count($array) < 1) |
|
| 23 | 23 | { |
| 24 | 24 | throw new Exception("Error, no hay valores para insertar"); |
| 25 | 25 | } |
@@ -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 | ); |