@@ -20,6 +20,6 @@ |
||
20 | 20 | |
21 | 21 | public function datos(): array |
22 | 22 | { |
23 | - return [ $this->_where[2], $this->_where[5] ]; |
|
23 | + return [$this->_where[2], $this->_where[5]]; |
|
24 | 24 | } |
25 | 25 | } |
26 | 26 | \ No newline at end of file |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | |
47 | 47 | public function testCamposSoloRetornaTexto() |
48 | 48 | { |
49 | - $campos = new Campos(['*','78']); |
|
49 | + $campos = new Campos(['*', '78']); |
|
50 | 50 | $this->assertIsString($campos->sql()); |
51 | 51 | } |
52 | 52 | |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | $tabla = new Tabla('prueba'); |
58 | 58 | $campos = new Campos(['a,b,c,d']); |
59 | 59 | |
60 | - $camposytabla = new CamposYTabla($campos,$tabla); |
|
60 | + $camposytabla = new CamposYTabla($campos, $tabla); |
|
61 | 61 | |
62 | - $this->assertSame('a,b,c,d FROM prueba',$camposytabla->sql()); |
|
62 | + $this->assertSame('a,b,c,d FROM prueba', $camposytabla->sql()); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | //Clase ValidadorDeParametrosWhere |
@@ -73,13 +73,13 @@ discard block |
||
73 | 73 | public function testValidadorDeParametrosWhereLaColumnaSoloPuedeSerString() |
74 | 74 | { |
75 | 75 | $this->expectException(Exception::class); |
76 | - new ValidadorDeParametrosWhere([1,'1','2']); |
|
76 | + new ValidadorDeParametrosWhere([1, '1', '2']); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | public function testValidadorDeParametrosWhereNingunCampoPuedeEstarVacio() |
80 | 80 | { |
81 | 81 | $this->expectException(Exception::class); |
82 | - new ValidadorDeParametrosWhere(['','1','2']); |
|
82 | + new ValidadorDeParametrosWhere(['', '1', '2']); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | //Clase ValidadorDeParametrosWhereBetween |
@@ -93,19 +93,19 @@ discard block |
||
93 | 93 | public function testValidadorDeParametrosWhereBetweenNoPuedeTenerValoresIguales() |
94 | 94 | { |
95 | 95 | $this->expectException(Exception::class); |
96 | - new ValidadorDeParametrosWhereBetween(['id','1','1']); |
|
96 | + new ValidadorDeParametrosWhereBetween(['id', '1', '1']); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | public function testValidadorDeParametrosWhereBetweenLaColumnaSoloPuedeSerString() |
100 | 100 | { |
101 | 101 | $this->expectException(Exception::class); |
102 | - new ValidadorDeParametrosWhereBetween([1,'1','2']); |
|
102 | + new ValidadorDeParametrosWhereBetween([1, '1', '2']); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | public function testValidadorDeParametrosWhereBetweenNingunCampoPuedeEstarVacio() |
106 | 106 | { |
107 | 107 | $this->expectException(Exception::class); |
108 | - new ValidadorDeParametrosWhereBetween(['','1','2']); |
|
108 | + new ValidadorDeParametrosWhereBetween(['', '1', '2']); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | //Clase Where |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | { |
115 | 115 | $where = new Where( |
116 | 116 | new ValidadorDeParametrosWhere( |
117 | - ['id','=','21'] |
|
117 | + ['id', '=', '21'] |
|
118 | 118 | ) |
119 | 119 | ); |
120 | 120 | |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | { |
126 | 126 | $where = new Where( |
127 | 127 | new ValidadorDeParametrosWhere( |
128 | - ['id','=','21'] |
|
128 | + ['id', '=', '21'] |
|
129 | 129 | ) |
130 | 130 | ); |
131 | 131 | |
@@ -143,19 +143,19 @@ discard block |
||
143 | 143 | public function testValidadorDeParametrosWhereAndOthersNoPuedeTenerValoresIguales() |
144 | 144 | { |
145 | 145 | $this->expectException(Exception::class); |
146 | - new ValidadorDeParametrosWhereAndOthers(['id','=','1','id','=','1']); |
|
146 | + new ValidadorDeParametrosWhereAndOthers(['id', '=', '1', 'id', '=', '1']); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | public function testValidadorDeParametrosWhereAndOthersLaColumnaSoloPuedeSerString() |
150 | 150 | { |
151 | 151 | $this->expectException(Exception::class); |
152 | - new ValidadorDeParametrosWhereAndOthers([1,'=','2','1','=','2']); |
|
152 | + new ValidadorDeParametrosWhereAndOthers([1, '=', '2', '1', '=', '2']); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | public function testValidadorDeParametrosWhereAndOthersNingunCampoPuedeEstarVacio() |
156 | 156 | { |
157 | 157 | $this->expectException(Exception::class); |
158 | - new ValidadorDeParametrosWhereAndOthers(['','1','2','','','']); |
|
158 | + new ValidadorDeParametrosWhereAndOthers(['', '1', '2', '', '', '']); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | //Clase Where And |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | { |
165 | 165 | $where = new WhereAnd( |
166 | 166 | new ValidadorDeParametrosWhereAndOthers( |
167 | - ['id','=','21','uno','=','1'] |
|
167 | + ['id', '=', '21', 'uno', '=', '1'] |
|
168 | 168 | ) |
169 | 169 | ); |
170 | 170 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | { |
178 | 178 | $where = new WhereOr( |
179 | 179 | new ValidadorDeParametrosWhereAndOthers( |
180 | - ['id','=','21','uno','=','1'] |
|
180 | + ['id', '=', '21', 'uno', '=', '1'] |
|
181 | 181 | ) |
182 | 182 | ); |
183 | 183 | |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | { |
191 | 191 | $where = new WhereBetween( |
192 | 192 | new ValidadorDeParametrosWhereBetween( |
193 | - ['id','1','21'] |
|
193 | + ['id', '1', '21'] |
|
194 | 194 | ) |
195 | 195 | ); |
196 | 196 | |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | { |
204 | 204 | $where = new WhereNotBetween( |
205 | 205 | new ValidadorDeParametrosWhereBetween( |
206 | - ['id','1','21'] |
|
206 | + ['id', '1', '21'] |
|
207 | 207 | ) |
208 | 208 | ); |
209 | 209 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | { |
217 | 217 | $where = new WhereNotBetween( |
218 | 218 | new ValidadorDeParametrosWhereBetween( |
219 | - ['id','1','21'] |
|
219 | + ['id', '1', '21'] |
|
220 | 220 | ) |
221 | 221 | ); |
222 | 222 | |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | { |
234 | 234 | $where = new WhereNotBetween( |
235 | 235 | new ValidadorDeParametrosWhereBetween( |
236 | - ['id','1','21'] |
|
236 | + ['id', '1', '21'] |
|
237 | 237 | ) |
238 | 238 | ); |
239 | 239 | |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | new CamposYTabla( |
246 | 246 | new Campos(['*']), |
247 | 247 | new Tabla('prueba') |
248 | - ),$como |
|
248 | + ), $como |
|
249 | 249 | ); |
250 | 250 | |
251 | 251 | $this->assertSame('SELECT * FROM prueba WHERE NOT BETWEEN id ? AND ?', $sentencia->sql()); |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | declare(strict_types=1); |
3 | 3 | |
4 | -require_once __DIR__ . '/vendor/autoload.php'; |
|
4 | +require_once __DIR__.'/vendor/autoload.php'; |
|
5 | 5 | |
6 | 6 | use src\Factory; |
7 | 7 | use src\pdodatabase\resultados\ContarResultados; |
@@ -15,10 +15,10 @@ discard block |
||
15 | 15 | |
16 | 16 | // SELECT * FROM prueba |
17 | 17 | |
18 | -$select = $factory->crear('src\factory\SelectWhere',[ |
|
18 | +$select = $factory->crear('src\factory\SelectWhere', [ |
|
19 | 19 | 'tabla' => 'prueba', |
20 | 20 | 'campos' => ['*'], |
21 | - 'where' => ['id','=','42'] |
|
21 | + 'where' => ['id', '=', '42'] |
|
22 | 22 | ]); |
23 | 23 | |
24 | 24 | $select = $select->obtener(); |
@@ -20,6 +20,6 @@ |
||
20 | 20 | |
21 | 21 | public function datos(): array |
22 | 22 | { |
23 | - return [ $this->_where[1], $this->_where[2] ]; |
|
23 | + return [$this->_where[1], $this->_where[2]]; |
|
24 | 24 | } |
25 | 25 | } |
26 | 26 | \ No newline at end of file |
@@ -20,6 +20,6 @@ |
||
20 | 20 | |
21 | 21 | public function datos(): array |
22 | 22 | { |
23 | - return [ $this->_where[2], $this->_where[5] ]; |
|
23 | + return [$this->_where[2], $this->_where[5]]; |
|
24 | 24 | } |
25 | 25 | } |
26 | 26 | \ No newline at end of file |
@@ -19,10 +19,10 @@ discard block |
||
19 | 19 | { |
20 | 20 | $query = $this->_conexion->prepare($sentencia->sql()); |
21 | 21 | |
22 | - $x=1; |
|
22 | + $x = 1; |
|
23 | 23 | foreach ($sentencia->datos() as $value) |
24 | 24 | { |
25 | - $query->bindValue($x,$value); |
|
25 | + $query->bindValue($x, $value); |
|
26 | 26 | $x++; |
27 | 27 | } |
28 | 28 | |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | { |
31 | 31 | $query->execute(); |
32 | 32 | } |
33 | - catch(PDOException $e) |
|
33 | + catch (PDOException $e) |
|
34 | 34 | { |
35 | 35 | throw new Exception("Error en la consulta"); |
36 | 36 | } |
@@ -29,8 +29,7 @@ |
||
29 | 29 | try |
30 | 30 | { |
31 | 31 | $query->execute(); |
32 | - } |
|
33 | - catch(PDOException $e) |
|
32 | + } catch(PDOException $e) |
|
34 | 33 | { |
35 | 34 | throw new Exception("Error en la consulta"); |
36 | 35 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | { |
24 | 24 | $query->execute(); |
25 | 25 | } |
26 | - catch(PDOException $e) |
|
26 | + catch (PDOException $e) |
|
27 | 27 | { |
28 | 28 | throw new Exception("Error en la consulta"); |
29 | 29 | } |
@@ -29,8 +29,7 @@ |
||
29 | 29 | try |
30 | 30 | { |
31 | 31 | $query->execute(); |
32 | - } |
|
33 | - catch(PDOException $e) |
|
32 | + } catch(PDOException $e) |
|
34 | 33 | { |
35 | 34 | throw new Exception("Error en la consulta"); |
36 | 35 | } |
@@ -61,7 +61,7 @@ |
||
61 | 61 | new Como( |
62 | 62 | new Where( |
63 | 63 | new ValidadorDeParametrosWhere( |
64 | - ['id','=',12] |
|
64 | + ['id', '=', 12] |
|
65 | 65 | ) |
66 | 66 | ) |
67 | 67 | ) |
@@ -26,34 +26,34 @@ |
||
26 | 26 | public function testFactorySelectWhereDevuelveClaseAdecuada() |
27 | 27 | { |
28 | 28 | $select = new SelectWhere; |
29 | - $this->assertInstanceOf(ConsultaSelectWhere::class, $select->crear(['tabla' => 'prueba', 'campos' => ['*'],'where' => ['id','=',2]])); |
|
29 | + $this->assertInstanceOf(ConsultaSelectWhere::class, $select->crear(['tabla' => 'prueba', 'campos' => ['*'], 'where' => ['id', '=', 2]])); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | // SelectWhereAnd |
33 | 33 | public function testFactorySelectWhereAndDevuelveClaseAdecuada() |
34 | 34 | { |
35 | 35 | $select = new SelectWhereAnd; |
36 | - $this->assertInstanceOf(ConsultaSelectWhere::class, $select->crear(['tabla' => 'prueba', 'campos' => ['*'],'where' => ['id','=',2,'uno','=',9]])); |
|
36 | + $this->assertInstanceOf(ConsultaSelectWhere::class, $select->crear(['tabla' => 'prueba', 'campos' => ['*'], 'where' => ['id', '=', 2, 'uno', '=', 9]])); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | // SelectWhereOr |
40 | 40 | public function testFactorySelectWhereOrDevuelveClaseAdecuada() |
41 | 41 | { |
42 | 42 | $select = new SelectWhereOr; |
43 | - $this->assertInstanceOf(ConsultaSelectWhere::class, $select->crear(['tabla' => 'prueba', 'campos' => ['*'],'where' => ['id','=',2,'uno','=',9]])); |
|
43 | + $this->assertInstanceOf(ConsultaSelectWhere::class, $select->crear(['tabla' => 'prueba', 'campos' => ['*'], 'where' => ['id', '=', 2, 'uno', '=', 9]])); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | // SelectWhereBetween |
47 | 47 | public function testFactorySelectWhereBetweenDevuelveClaseAdecuada() |
48 | 48 | { |
49 | 49 | $select = new SelectWhereBetween; |
50 | - $this->assertInstanceOf(ConsultaSelectWhere::class, $select->crear(['tabla' => 'prueba', 'campos' => ['*'],'where' => ['id','1',2]])); |
|
50 | + $this->assertInstanceOf(ConsultaSelectWhere::class, $select->crear(['tabla' => 'prueba', 'campos' => ['*'], 'where' => ['id', '1', 2]])); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | // SelectWhereBetween |
54 | 54 | public function testFactorySelectWhereNotBetweenDevuelveClaseAdecuada() |
55 | 55 | { |
56 | 56 | $select = new SelectWhereNotBetween; |
57 | - $this->assertInstanceOf(ConsultaSelectWhere::class, $select->crear(['tabla' => 'prueba', 'campos' => ['*'],'where' => ['id','1',2]])); |
|
57 | + $this->assertInstanceOf(ConsultaSelectWhere::class, $select->crear(['tabla' => 'prueba', 'campos' => ['*'], 'where' => ['id', '1', 2]])); |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | \ No newline at end of file |