|
34 | 34 | $db_add_and_subtract_b_variable = ":b";
|
35 | 35 | $db_add_and_subtract_b_value = 5;
|
36 | 36 |
|
37 |
| -$db_add_and_subtract_x_env_variable = "@x"; |
38 |
| -$db_add_and_subtract_y_env_variable = "@y"; |
| 37 | +$db_add_and_subtract_x_env_variable = "@env_var_x"; |
| 38 | +$db_add_and_subtract_y_env_variable = "@env_var_y"; |
39 | 39 |
|
40 | 40 | $availableDrivers = PDO::getAvailableDrivers();
|
41 | 41 |
|
|
65 | 65 | // UPDATE statement
|
66 | 66 | $new_comment = "PHP ".date("j.n.Y H:i:s");
|
67 | 67 |
|
68 |
| - $stm0 = $conn->prepare("update ".$db_table." set ".$db_update_column."=".$db_update_column_variable." where ".$db_column."!=".$db_column_variable); |
| 68 | + $stm0query = "update ".$db_table." set ".$db_update_column."=".$db_update_column_variable." where ".$db_column."!=".$db_column_variable; |
| 69 | + echo $stm0query.PHP_EOL; |
| 70 | + |
| 71 | + $stm0 = $conn->prepare($stm0query); |
69 | 72 | $stm0->bindParam($db_update_column_variable, $new_comment, PDO::PARAM_STR);
|
70 | 73 | $stm0->bindParam($db_column_variable, $db_column_value, PDO::PARAM_INT);
|
71 | 74 | $stm0->execute();
|
|
75 | 78 | $stm0 = null;
|
76 | 79 |
|
77 | 80 | // Full SELECT statement
|
78 |
| - $stm1 = $conn->prepare("select * from ".$db_table); |
| 81 | + $stm1query = "select * from ".$db_table; |
| 82 | + echo $stm1query.PHP_EOL; |
| 83 | + |
| 84 | + $stm1 = $conn->prepare($stm1query); |
79 | 85 | $stm1->execute();
|
80 | 86 | echo "Total columns x rows: ".$stm1->columnCount()." x ".$stm1->rowCount().PHP_EOL;
|
81 | 87 |
|
|
90 | 96 | $stm1 = null;
|
91 | 97 |
|
92 | 98 | // SELECT WHERE statement
|
93 |
| - $stm2 = $conn->prepare("select count(*) from ".$db_table." where ".$db_column."!=".$db_column_variable); |
| 99 | + $stm2query = "select count(*) from ".$db_table." where ".$db_column."!=".$db_column_variable; |
| 100 | + echo $stm2query.PHP_EOL; |
| 101 | + |
| 102 | + $stm2 = $conn->prepare($stm2query); |
94 | 103 | $stm2->bindParam($db_column_variable, $db_column_value, PDO::PARAM_INT);
|
95 | 104 | $stm2->execute();
|
96 | 105 | echo "Total columns x rows: ".$stm2->columnCount()." x ".$stm2->rowCount().PHP_EOL;
|
|
106 | 115 | $stm2 = null;
|
107 | 116 |
|
108 | 117 | // SELECT function statement
|
109 |
| - $stm3 = $conn->prepare("select factorial(".$db_factorial_variable.")"); |
| 118 | + $stm3query = "select factorial(".$db_factorial_variable.")"; |
| 119 | + echo $stm3query.PHP_EOL; |
| 120 | + |
| 121 | + $stm3 = $conn->prepare($stm3query); |
110 | 122 | $stm3->bindParam($db_factorial_variable, $db_factorial_value, PDO::PARAM_INT);
|
111 | 123 | $stm3->execute();
|
112 | 124 | echo "Total columns: ".$stm3->columnCount().PHP_EOL;
|
|
122 | 134 | $stm3 = null;
|
123 | 135 |
|
124 | 136 | // CALL procedure statement
|
125 |
| - $stm4 = $conn->prepare("call add_and_subtract(".$db_add_and_subtract_a_variable.", ".$db_add_and_subtract_b_variable.", ".$db_add_and_subtract_x_env_variable.", ".$db_add_and_subtract_y_env_variable.")"); |
| 137 | + $stm4query = "call add_and_subtract(".$db_add_and_subtract_a_variable.", ".$db_add_and_subtract_b_variable.", ".$db_add_and_subtract_x_env_variable.", ".$db_add_and_subtract_y_env_variable.")"; |
| 138 | + echo $stm4query.PHP_EOL; |
| 139 | + |
| 140 | + $stm4 = $conn->prepare($stm4query); |
126 | 141 | $stm4->bindParam($db_add_and_subtract_a_variable, $db_add_and_subtract_a_value, PDO::PARAM_INT);
|
127 | 142 | $stm4->bindParam($db_add_and_subtract_b_variable, $db_add_and_subtract_b_value, PDO::PARAM_INT);
|
128 | 143 | $stm4->execute();
|
129 | 144 |
|
130 | 145 | $stm4error = $stm4->errorInfo();
|
131 | 146 | if ((isset($stm4error[0])) and ($stm4error[0] === "00000"))
|
132 | 147 | {
|
133 |
| - $stm4b = $conn->prepare("select ".$db_add_and_subtract_x_env_variable.", ".$db_add_and_subtract_y_env_variable); |
| 148 | + $stm4bQuery = "select ".$db_add_and_subtract_x_env_variable.", ".$db_add_and_subtract_y_env_variable; |
| 149 | + echo $stm4bQuery.PHP_EOL; |
| 150 | + |
| 151 | + $stm4b = $conn->prepare($stm4bQuery); |
134 | 152 | $stm4b->execute();
|
135 | 153 | echo "Total columns: ".$stm4b->columnCount().PHP_EOL;
|
136 | 154 |
|
|
0 commit comments