@@ -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 | } |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | { |
47 | 47 | foreach ($array as $value) |
48 | 48 | { |
49 | - if(empty($value)) |
|
49 | + if (empty($value)) |
|
50 | 50 | { |
51 | 51 | throw new Exception("Error Processing Request"); |
52 | 52 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | private function columnasSonString($array): void |
57 | 57 | { |
58 | - if(!is_string($array[0]) || !is_string($array[3])) |
|
58 | + if (!is_string($array[0]) || !is_string($array[3])) |
|
59 | 59 | { |
60 | 60 | throw new Exception("Error Processing Request"); |
61 | 61 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | |
64 | 64 | private function numeroDeElementosValido($array): void |
65 | 65 | { |
66 | - if(count($array) !== 6) |
|
66 | + if (count($array) !== 6) |
|
67 | 67 | { |
68 | 68 | throw new Exception("Error Processing Request"); |
69 | 69 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | |
72 | 72 | private function operadorValido($array): void |
73 | 73 | { |
74 | - if(!in_array($array[1], $this->_operadoresValidos) || !in_array($array[4], $this->_operadoresValidos)) |
|
74 | + if (!in_array($array[1], $this->_operadoresValidos) || !in_array($array[4], $this->_operadoresValidos)) |
|
75 | 75 | { |
76 | 76 | throw new Exception("Error Processing Request"); |
77 | 77 | } |
@@ -18,14 +18,14 @@ |
||
18 | 18 | ) |
19 | 19 | { |
20 | 20 | try |
21 | - { |
|
22 | - $this->_pdo = new PDO('mysql:host='.$HostBaseDeDatos->hostBaseDeDatos().';dbname='.$BaseDeDatos->baseDeDatos().';chartset=utf8mb4',$UsuarioBaseDeDatos->usuarioBaseDeDatos(),$ContrasenaBaseDeDatos->contrasenaBaseDeDatos()); |
|
23 | - $this->_pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
|
24 | - } |
|
25 | - catch(PDOException) |
|
26 | - { |
|
27 | - throw new ConexionABaseDeDatosException("Error al conectar con base de datos"); |
|
28 | - } |
|
21 | + { |
|
22 | + $this->_pdo = new PDO('mysql:host='.$HostBaseDeDatos->hostBaseDeDatos().';dbname='.$BaseDeDatos->baseDeDatos().';chartset=utf8mb4',$UsuarioBaseDeDatos->usuarioBaseDeDatos(),$ContrasenaBaseDeDatos->contrasenaBaseDeDatos()); |
|
23 | + $this->_pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
|
24 | + } |
|
25 | + catch(PDOException) |
|
26 | + { |
|
27 | + throw new ConexionABaseDeDatosException("Error al conectar con base de datos"); |
|
28 | + } |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | public function conectar(): PDO |
@@ -9,8 +9,7 @@ discard block |
||
9 | 9 | { |
10 | 10 | private $_pdo; |
11 | 11 | |
12 | - public function __construct |
|
13 | - ( |
|
12 | + public function __construct( |
|
14 | 13 | HostBaseDeDatos $HostBaseDeDatos, |
15 | 14 | BaseDeDatos $BaseDeDatos, |
16 | 15 | UsuarioBaseDeDatos $UsuarioBaseDeDatos, |
@@ -19,10 +18,10 @@ discard block |
||
19 | 18 | { |
20 | 19 | try |
21 | 20 | { |
22 | - $this->_pdo = new PDO('mysql:host='.$HostBaseDeDatos->hostBaseDeDatos().';dbname='.$BaseDeDatos->baseDeDatos().';chartset=utf8mb4',$UsuarioBaseDeDatos->usuarioBaseDeDatos(),$ContrasenaBaseDeDatos->contrasenaBaseDeDatos()); |
|
21 | + $this->_pdo = new PDO('mysql:host='.$HostBaseDeDatos->hostBaseDeDatos().';dbname='.$BaseDeDatos->baseDeDatos().';chartset=utf8mb4', $UsuarioBaseDeDatos->usuarioBaseDeDatos(), $ContrasenaBaseDeDatos->contrasenaBaseDeDatos()); |
|
23 | 22 | $this->_pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
24 | 23 | } |
25 | - catch(PDOException) |
|
24 | + catch (PDOException) |
|
26 | 25 | { |
27 | 26 | throw new ConexionABaseDeDatosException("Error al conectar con base de datos"); |
28 | 27 | } |
@@ -21,8 +21,7 @@ |
||
21 | 21 | { |
22 | 22 | $this->_pdo = new PDO('mysql:host='.$HostBaseDeDatos->hostBaseDeDatos().';dbname='.$BaseDeDatos->baseDeDatos().';chartset=utf8mb4',$UsuarioBaseDeDatos->usuarioBaseDeDatos(),$ContrasenaBaseDeDatos->contrasenaBaseDeDatos()); |
23 | 23 | $this->_pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
24 | - } |
|
25 | - catch(PDOException) |
|
24 | + } catch(PDOException) |
|
26 | 25 | { |
27 | 26 | throw new ConexionABaseDeDatosException("Error al conectar con base de datos"); |
28 | 27 | } |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace src\pdodatabase\sentencias\insert; |
3 | 3 | |
4 | -use src\pdodatabase\elementos\{Tabla,Insert}; |
|
4 | +use src\pdodatabase\elementos\{Tabla, Insert}; |
|
5 | 5 | |
6 | 6 | class SentenciaInsert |
7 | 7 | { |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | { |
44 | 44 | foreach ($array as $key => $value) |
45 | 45 | { |
46 | - if(empty($key)) |
|
46 | + if (empty($key)) |
|
47 | 47 | { |
48 | 48 | throw new Exception("Error Processing Request"); |
49 | 49 | } |
@@ -54,20 +54,20 @@ discard block |
||
54 | 54 | { |
55 | 55 | $keys = array_keys($array); |
56 | 56 | $values = ''; |
57 | - $x=1; |
|
57 | + $x = 1; |
|
58 | 58 | |
59 | - foreach($array as $field) |
|
59 | + foreach ($array as $field) |
|
60 | 60 | { |
61 | - $values.= "?"; |
|
61 | + $values .= "?"; |
|
62 | 62 | |
63 | - if($x < count($array)) |
|
63 | + if ($x < count($array)) |
|
64 | 64 | { |
65 | - $values.= ', '; |
|
65 | + $values .= ', '; |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | $x++; |
69 | 69 | } |
70 | 70 | |
71 | - return "(`". implode('`, `', $keys) ."`) VALUES ({$values})"; |
|
71 | + return "(`".implode('`, `', $keys)."`) VALUES ({$values})"; |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | \ No newline at end of file |
@@ -63,13 +63,13 @@ |
||
63 | 63 | { |
64 | 64 | $set = ""; |
65 | 65 | |
66 | - $values = []; |
|
66 | + $values = []; |
|
67 | 67 | |
68 | - foreach ($array as $key => $value) |
|
69 | - { |
|
70 | - $set = $set.$key. ' = ?,'; |
|
71 | - } |
|
68 | + foreach ($array as $key => $value) |
|
69 | + { |
|
70 | + $set = $set.$key. ' = ?,'; |
|
71 | + } |
|
72 | 72 | |
73 | - return trim($set, ','); |
|
73 | + return trim($set, ','); |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 | \ No newline at end of file |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | { |
53 | 53 | foreach ($array as $key => $value) |
54 | 54 | { |
55 | - if(empty($key)) |
|
55 | + if (empty($key)) |
|
56 | 56 | { |
57 | 57 | throw new Exception("Error Processing Request"); |
58 | 58 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | |
68 | 68 | foreach ($array as $key => $value) |
69 | 69 | { |
70 | - $set = $set.$key. ' = ?,'; |
|
70 | + $set = $set.$key.' = ?,'; |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | return trim($set, ','); |
@@ -35,7 +35,7 @@ |
||
35 | 35 | |
36 | 36 | private function setCampos(string $campos): string |
37 | 37 | { |
38 | - $campos = str_replace(',',','.$this->_tabla->sql().'.',$campos); |
|
38 | + $campos = str_replace(',', ','.$this->_tabla->sql().'.', $campos); |
|
39 | 39 | |
40 | 40 | return $this->_tabla->sql().'.'.$campos; |
41 | 41 | } |