@@ -19,6 +19,9 @@ discard block |
||
| 19 | 19 | $this->connection = $connector->setConnection(); |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | + /** |
|
| 23 | + * @param string $table |
|
| 24 | + */ |
|
| 22 | 25 | public function getFrom($table, $columns = '*') |
| 23 | 26 | { |
| 24 | 27 | $sql = "SELECT $columns FROM $table"; |
@@ -35,6 +38,10 @@ discard block |
||
| 35 | 38 | return $result; |
| 36 | 39 | } |
| 37 | 40 | |
| 41 | + /** |
|
| 42 | + * @param string $table |
|
| 43 | + * @param integer $id |
|
| 44 | + */ |
|
| 38 | 45 | public function getOne($table, $id) |
| 39 | 46 | { |
| 40 | 47 | $sql = "SELECT * FROM $table WHERE id = :id "; |
@@ -69,6 +76,9 @@ discard block |
||
| 69 | 76 | // return $this->getOne($table, self::$connection->lastInsertId()); |
| 70 | 77 | } |
| 71 | 78 | |
| 79 | + /** |
|
| 80 | + * @param \PDOStatement $statement |
|
| 81 | + */ |
|
| 72 | 82 | public function tryExecuting($statement) |
| 73 | 83 | { |
| 74 | 84 | try { |
@@ -81,6 +91,9 @@ discard block |
||
| 81 | 91 | return $execution; |
| 82 | 92 | } |
| 83 | 93 | |
| 94 | + /** |
|
| 95 | + * @param string $message |
|
| 96 | + */ |
|
| 84 | 97 | public function throwFaultyExecutionException($message) |
| 85 | 98 | { |
| 86 | 99 | throw new FaultyExecutionException($message); |
@@ -91,6 +104,9 @@ discard block |
||
| 91 | 104 | return '('.implode(', ', array_keys($data)).')'; |
| 92 | 105 | } |
| 93 | 106 | |
| 107 | + /** |
|
| 108 | + * @param \PDOStatement $statement |
|
| 109 | + */ |
|
| 94 | 110 | public function setBindForInsert($statement, $values) |
| 95 | 111 | { |
| 96 | 112 | $count = count($values); |
@@ -99,6 +115,10 @@ discard block |
||
| 99 | 115 | } |
| 100 | 116 | } |
| 101 | 117 | |
| 118 | + /** |
|
| 119 | + * @param string $table |
|
| 120 | + * @param integer $id |
|
| 121 | + */ |
|
| 102 | 122 | public function deleteFrom($table, $id) |
| 103 | 123 | { |
| 104 | 124 | $sql = "DELETE FROM $table WHERE id = :id "; |
@@ -129,6 +149,9 @@ discard block |
||
| 129 | 149 | return $execution; |
| 130 | 150 | } |
| 131 | 151 | |
| 152 | + /** |
|
| 153 | + * @param \PDOStatement $statement |
|
| 154 | + */ |
|
| 132 | 155 | public function setBindForUpdate($statement, array $data) |
| 133 | 156 | { |
| 134 | 157 | $count = count($data); |
@@ -149,6 +172,9 @@ discard block |
||
| 149 | 172 | return $upd = trim($upd, ', '); |
| 150 | 173 | } |
| 151 | 174 | |
| 175 | + /** |
|
| 176 | + * @param integer $count |
|
| 177 | + */ |
|
| 152 | 178 | public function putQuesMarks($count) |
| 153 | 179 | { |
| 154 | 180 | $str = ''; |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | { |
| 58 | 58 | $columnsString = $this->getColumns($data); |
| 59 | 59 | $count = (int) count($data); |
| 60 | - $sql = "INSERT INTO $table $columnsString VALUES (".$this->putQuesMarks($count).')'; |
|
| 60 | + $sql = "INSERT INTO $table $columnsString VALUES (" . $this->putQuesMarks($count) . ')'; |
|
| 61 | 61 | $statement = $this->connection->prepare($sql); |
| 62 | 62 | if ($statement == false) { |
| 63 | 63 | $this->throwFaultyOrNoTableException($table); |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | |
| 89 | 89 | public function getColumns(array $data) |
| 90 | 90 | { |
| 91 | - return '('.implode(', ', array_keys($data)).')'; |
|
| 91 | + return '(' . implode(', ', array_keys($data)) . ')'; |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | public function setBindForInsert($statement, $values) |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | $id = (int) $data['id']; // store the id in a variable. |
| 118 | 118 | unset($data['id']); |
| 119 | 119 | $upd = (string) $this->makeModify(array_keys($data)); // genertate the columns for the update statement. |
| 120 | - $sql = "UPDATE {$table} SET ".$upd.' WHERE id = :id_val'; |
|
| 120 | + $sql = "UPDATE {$table} SET " . $upd . ' WHERE id = :id_val'; |
|
| 121 | 121 | $statement = $this->connection->prepare($sql); |
| 122 | 122 | if ($statement == false) { |
| 123 | 123 | $this->throwFaultyOrNoTableException($table); |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | { |
| 134 | 134 | $count = count($data); |
| 135 | 135 | foreach ($data as $key => $value) { |
| 136 | - $statement->bindValue(":$key".'_val', $value); |
|
| 136 | + $statement->bindValue(":$key" . '_val', $value); |
|
| 137 | 137 | } |
| 138 | 138 | } |
| 139 | 139 | |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | $count = count($columns); |
| 144 | 144 | $upd = ''; |
| 145 | 145 | foreach ($columns as $key) { |
| 146 | - $upd .= $key.' = '.':'.$key.'_val, '; |
|
| 146 | + $upd .= $key . ' = ' . ':' . $key . '_val, '; |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | return $upd = trim($upd, ', '); |
@@ -101,7 +101,7 @@ |
||
| 101 | 101 | 'adaptar = sqlite', |
| 102 | 102 | ]; |
| 103 | 103 | foreach ($configData as $cfg) { |
| 104 | - fwrite($file, $cfg."\n"); |
|
| 104 | + fwrite($file, $cfg . "\n"); |
|
| 105 | 105 | } |
| 106 | 106 | fclose($file); |
| 107 | 107 | $result = $this->connector->getConfigurations($this->configFile); |
@@ -60,7 +60,7 @@ |
||
| 60 | 60 | |
| 61 | 61 | public function getConfigFilePath() |
| 62 | 62 | { |
| 63 | - return __DIR__.'/../config.ini'; |
|
| 63 | + return __DIR__ . '/../config.ini'; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | public function getAdaptar() |